]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_transform/lib/SecDigestTransform.cpp
Security-57031.40.6.tar.gz
[apple/security.git] / Security / libsecurity_transform / lib / SecDigestTransform.cpp
1 #include "SecDigestTransform.h"
2 #include "Digest.h"
3
4
5
6 const CFStringRef kSecDigestMD2 = CFSTR("MD2 Digest"),
7 kSecDigestMD4 = CFSTR("MD4 Digest"),
8 kSecDigestMD5 = CFSTR("MD5 Digest"),
9 kSecDigestSHA1 = CFSTR("SHA1 Digest"),
10 kSecDigestSHA2 = CFSTR("SHA2 Digest Family"),
11 kSecDigestHMACMD5 = CFSTR("HMAC-MD5"),
12 kSecDigestHMACSHA1 = CFSTR("HMAC-SHA1"),
13 kSecDigestHMACSHA2 = CFSTR("HMAC-SHA2 Digest Family");
14
15 const CFStringRef kSecDigestTypeAttribute = CFSTR("Digest Type"),
16 kSecDigestLengthAttribute = CFSTR("Digest Length"),
17 kSecDigestHMACKeyAttribute = CFSTR("HMAC Key");
18
19 SecTransformRef SecDigestTransformCreate(CFTypeRef digestType,
20 CFIndex digestLength,
21 CFErrorRef* error
22 )
23 {
24 SecTransformRef tr = DigestTransform::Make();
25 DigestTransform* dt = (DigestTransform*) CoreFoundationHolder::ObjectFromCFType(tr);
26
27 CFErrorRef result = dt->Setup(digestType, digestLength);
28 if (result != NULL)
29 {
30 // an error occurred
31 CFRelease(tr);
32
33 if (error)
34 {
35 *error = result;
36 }
37
38 return NULL;
39 }
40
41 return tr;
42 }
43
44
45
46 CFTypeID SecDigestTransformGetTypeID()
47 {
48 return DigestTransform::GetCFTypeID();
49 }