]>
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++.
30 * Private data for this object. A feeHash handle is cast to aa pointer
36 unsigned char digest
[MD5_DIGEST_SIZE
];
40 * Alloc and init an empty hash object.
42 feeHash
feeHashAlloc(void)
46 hinst
= (hashInst
*) fmalloc(sizeof(hashInst
));
47 MD5Init(&hinst
->context
);
52 void feeHashReinit(feeHash hash
)
54 hashInst
*hinst
= (hashInst
*) hash
;
56 MD5Init(&hinst
->context
);
63 void feeHashFree(feeHash hash
)
65 hashInst
*hinst
= (hashInst
*) hash
;
67 memset(hinst
, 0, sizeof(hashInst
));
72 * Add some data to the hash object.
74 void feeHashAddData(feeHash hash
,
75 const unsigned char *data
,
78 hashInst
*hinst
= (hashInst
*) hash
;
82 * Log some kind of error here...
86 MD5Update(&hinst
->context
, data
, dataLen
);
90 * Obtain a pointer to completed message digest, and the length of the digest.
92 unsigned char *feeHashDigest(feeHash hash
)
94 hashInst
*hinst
= (hashInst
*) hash
;
97 MD5Final(&hinst
->context
, hinst
->digest
);
100 return hinst
->digest
;
103 unsigned feeHashDigestLen(void)
105 return MD5_DIGEST_SIZE
;