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