]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/ckMD5.h
Security-57740.1.18.tar.gz
[apple/security.git] / OSX / libsecurity_cryptkit / lib / ckMD5.h
1 /*
2 File: MD5.h
3
4 Written by: Colin Plumb
5
6 Copyright: Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
7
8 Change History (most recent first):
9
10 <8> 10/06/98 ap Changed to compile with C++.
11
12 To Do:
13 */
14
15 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
16 *
17 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
18 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
19 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
20 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
21 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
22 * EXPOSE YOU TO LIABILITY.
23 ***************************************************************************
24 *
25 * MD5.h
26 * derived and used without need for permission from public domain source
27 */
28
29 #ifndef _CK_MD5_H_
30 #define _CK_MD5_H_
31
32 #include "ckconfig.h"
33
34 #if CRYPTKIT_MD5_ENABLE
35 #if CRYPTKIT_LIBMD_DIGEST
36
37 /*
38 * In this case we use the MD5 implementation in libSystem.
39 */
40 #include <CommonCrypto/CommonDigest.h>
41
42 typedef CC_MD5_CTX MD5Context;
43
44 #define MD5Init(c) CC_MD5_Init(c)
45 #define MD5Update(c, d, l) CC_MD5_Update(c, d, l)
46 #define MD5Final(c, d) CC_MD5_Final(d, c)
47
48 #define MD5_DIGEST_SIZE CC_MD5_DIGEST_LENGTH
49
50 #else /* ! CRYPTKIT_LIBMD_DIGEST */
51
52 /* Our own private implementation */
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 #ifdef __alpha
59 typedef unsigned int UINT32;
60 #elif defined (macintosh) || defined (__ppc__)
61 typedef unsigned int UINT32;
62 #else
63 typedef unsigned long UINT32;
64 #endif
65
66 typedef struct {
67 UINT32 buf[4];
68 UINT32 bits[2]; // bits[0] is low 32 bits of bit count
69 unsigned char in[64];
70 } MD5Context;
71
72 #define MD5_DIGEST_SIZE 16 /* in bytes */
73
74 void MD5Init(MD5Context *context);
75 void MD5Update(MD5Context *context, unsigned char const *buf,
76 unsigned len);
77 void MD5Final(MD5Context *context, unsigned char *digest);
78
79 /*
80 * This is needed to make RSAREF happy on some MS-DOS compilers.
81 */
82 typedef MD5Context MD5_CTX;
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif /* CRYPTKIT_LIBMD_DIGEST */
89 #endif /* CRYPTKIT_MD5_ENABLE */
90 #endif /*_CK_MD5_H_*/