]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/feeHash.c
1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
11 * FeeHash.c - generic, portable MD5 hash object
16 * Changed to compile with C++.
23 #if CRYPTKIT_MD5_ENABLE
32 * Private data for this object. A feeHash handle is cast to aa pointer
38 unsigned char digest
[MD5_DIGEST_SIZE
];
42 * Alloc and init an empty hash object.
44 feeHash
feeHashAlloc(void)
48 hinst
= (hashInst
*) fmalloc(sizeof(hashInst
));
49 MD5Init(&hinst
->context
);
54 void feeHashReinit(feeHash hash
)
56 hashInst
*hinst
= (hashInst
*) hash
;
58 MD5Init(&hinst
->context
);
65 void feeHashFree(feeHash hash
)
67 hashInst
*hinst
= (hashInst
*) hash
;
69 memset(hinst
, 0, sizeof(hashInst
));
74 * Add some data to the hash object.
76 void feeHashAddData(feeHash hash
,
77 const unsigned char *data
,
80 hashInst
*hinst
= (hashInst
*) hash
;
84 * Log some kind of error here...
88 MD5Update(&hinst
->context
, data
, dataLen
);
92 * Obtain a pointer to completed message digest, and the length of the digest.
94 unsigned char *feeHashDigest(feeHash hash
)
96 hashInst
*hinst
= (hashInst
*) hash
;
99 MD5Final(&hinst
->context
, hinst
->digest
);
102 return hinst
->digest
;
105 unsigned feeHashDigestLen(void)
107 return MD5_DIGEST_SIZE
;
110 #endif /* CRYPTKIT_MD5_ENABLE*/