-
Notifications
You must be signed in to change notification settings - Fork 1
/
md5utils.c
63 lines (47 loc) · 1.21 KB
/
md5utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* MDDRIVER.C - test driver for MD2, MD4 and MD5
*
*/
/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
rights reserved.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/*
jku: added support to deal with vectors
*/
#define MD 5
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "md5global.h"
#include "md5.h"
#include "md5utils.h"
#include "dprint.h"
#include "ut.h"
#define MD_CTX MD5_CTX
#define MDInit MD5Init
#define MDUpdate MD5Update
#define MDFinal MD5Final
/* Digests a string array and store the result in dst; assumes
32 bytes in dst
*/
void MDStringArray (char *dst, str src[], int size)
{
MD_CTX context;
unsigned char digest[16];
int i;
int len;
char *s;
MDInit (&context);
for (i=0; i<size; i++) {
trim_len( len, s, src[i] );
MDUpdate (&context, s, len);
}
MDFinal (digest, &context);
string2hex(digest, 16, dst );
LM_DBG("MD5 calculated: %.*s\n", MD5_LEN, dst );
}