|
Packit Service |
623930 |
/*
|
|
Packit Service |
623930 |
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
**********************************************************************
|
|
Packit Service |
623930 |
* Copyright (C) Miroslav Lichvar 2012
|
|
Packit Service |
623930 |
*
|
|
Packit Service |
623930 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
623930 |
* it under the terms of version 2 of the GNU General Public License as
|
|
Packit Service |
623930 |
* published by the Free Software Foundation.
|
|
Packit Service |
623930 |
*
|
|
Packit Service |
623930 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit Service |
623930 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
623930 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
623930 |
* General Public License for more details.
|
|
Packit Service |
623930 |
*
|
|
Packit Service |
623930 |
* You should have received a copy of the GNU General Public License along
|
|
Packit Service |
623930 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit Service |
623930 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
Packit Service |
623930 |
*
|
|
Packit Service |
623930 |
**********************************************************************
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
=======================================================================
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
Routines implementing crypto hashing using internal MD5 implementation.
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
*/
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
#include "config.h"
|
|
Packit Service |
623930 |
#include "sysincl.h"
|
|
Packit Service |
623930 |
#include "hash.h"
|
|
Packit Service |
623930 |
#include "memory.h"
|
|
Packit Service |
623930 |
#include "util.h"
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
#include "md5.c"
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
static MD5_CTX ctx;
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
int
|
|
Packit Service |
623930 |
HSH_GetHashId(const char *name)
|
|
Packit Service |
623930 |
{
|
|
Packit Service |
623930 |
/* only MD5 is supported */
|
|
Packit Service |
623930 |
if (strcmp(name, "MD5"))
|
|
Packit Service |
623930 |
return -1;
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
return 0;
|
|
Packit Service |
623930 |
}
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
unsigned int
|
|
Packit Service |
623930 |
HSH_Hash(int id, const unsigned char *in1, unsigned int in1_len,
|
|
Packit Service |
623930 |
const unsigned char *in2, unsigned int in2_len,
|
|
Packit Service |
623930 |
unsigned char *out, unsigned int out_len)
|
|
Packit Service |
623930 |
{
|
|
Packit Service |
623930 |
MD5Init(&ctx;;
|
|
Packit Service |
623930 |
MD5Update(&ctx, in1, in1_len);
|
|
Packit Service |
623930 |
if (in2)
|
|
Packit Service |
623930 |
MD5Update(&ctx, in2, in2_len);
|
|
Packit Service |
623930 |
MD5Final(&ctx;;
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
out_len = MIN(out_len, 16);
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
memcpy(out, ctx.digest, out_len);
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
return out_len;
|
|
Packit Service |
623930 |
}
|
|
Packit Service |
623930 |
|
|
Packit Service |
623930 |
void
|
|
Packit Service |
623930 |
HSH_Finalise(void)
|
|
Packit Service |
623930 |
{
|
|
Packit Service |
623930 |
}
|