Switch to unified view

a/src/utils/md5.h b/src/utils/md5.h
1
/*    $OpenBSD: md5.h,v 1.15 2004/05/03 17:30:14 millert Exp $    */
2
3
/*
4
 * This code implements the MD5 message-digest algorithm.
5
 * The algorithm is due to Ron Rivest.  This code was
6
 * written by Colin Plumb in 1993, no copyright is claimed.
7
 * This code is in the public domain; do with it what you wish.
8
 *
9
 * Equivalent code is available from RSA Data Security, Inc.
10
 * This code has been tested against that, and is equivalent,
11
 * except that you don't need to include two pages of legalese
12
 * with every copy.
13
 */
14
1
#ifndef _MD5_H_
15
#ifndef _MD5_H_
2
#define _MD5_H_
16
#define _MD5_H_
3
/* MD5.H - header file for MD5C.C
4
 * Id: md5.h,v 1.6.2.1 1998/02/18 02:28:14 jkh Exp $
5
 */
6
17
7
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
18
#define   MD5_BLOCK_LENGTH        64
8
rights reserved.
19
#define   MD5_DIGEST_LENGTH       16
20
#define   MD5_DIGEST_STRING_LENGTH    (MD5_DIGEST_LENGTH * 2 + 1)
9
21
10
License to copy and use this software is granted provided that it
11
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
12
Algorithm" in all material mentioning or referencing this software
13
or this function.
14
15
License is also granted to make and use derivative works provided
16
that such works are identified as "derived from the RSA Data
17
Security, Inc. MD5 Message-Digest Algorithm" in all material
18
mentioning or referencing the derived work.
19
20
RSA Data Security, Inc. makes no representations concerning either
21
the merchantability of this software or the suitability of this
22
software for any particular purpose. It is provided "as is"
23
without express or implied warranty of any kind.
24
25
These notices must be retained in any copies of any part of this
26
documentation and/or software.
27
 */
28
29
/* Base functions from original file */
30
/* MD5 context. */
31
typedef struct MD5Context {
22
typedef struct MD5Context {
32
  unsigned int state[4];  /* state (ABCD) */
23
  u_int32_t state[4];         /* state */
33
  unsigned int count[2];  /* number of bits, modulo 2^64 (lsb first) */
24
  u_int64_t count;            /* number of bits, mod 2^64 */
34
  unsigned char buffer[64];   /* input buffer */
25
  u_int8_t buffer[MD5_BLOCK_LENGTH];  /* input buffer */
35
} MD5_CTX;
26
} MD5_CTX;
36
27
37
extern void   MD5Init (MD5_CTX *);
28
void   MD5Init(MD5_CTX *);
38
extern void   MD5Update (MD5_CTX *, const unsigned char *, unsigned int);
29
void   MD5Update(MD5_CTX *, const u_int8_t *, size_t);
39
extern void   MD5Final (unsigned char [16], MD5_CTX *);
30
void   MD5Pad(MD5_CTX *);
31
void   MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
32
void   MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]);
40
33
41
/* Convenience / utilities */
42
#include <string>
43
using std::string;
44
extern void MD5Final(string& digest, MD5_CTX *);
45
extern bool MD5File(const string& filename, string& digest, string *reason);
46
extern string& MD5String(const string& data, string& digest);
47
extern string& MD5HexPrint(const string& digest, string& xdigest);
48
extern string& MD5HexScan(const string& xdigest, string& digest);
49
#endif /* _MD5_H_ */
34
#endif /* _MD5_H_ */