]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_transform/lib/SecEncryptTransform.cpp
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / libsecurity_transform / lib / SecEncryptTransform.cpp
1 /*
2 * Copyright (c) 2010-2011 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #include "SecEncryptTransform.h"
25 #include "EncryptTransform.h"
26
27 /* --------------------------------------------------------------------------
28 Create the declared CFStringRefs
29 -------------------------------------------------------------------------- */
30
31 const CFStringRef __nonnull kSecPaddingNoneKey = CFSTR("SecPaddingNoneKey");
32 const CFStringRef __nonnull kSecPaddingPKCS1Key = CFSTR("SecPaddingPKCS1Key");
33 const CFStringRef __nonnull kSecPaddingPKCS5Key = CFSTR("SecPaddingPKCS5Key");
34 const CFStringRef __nonnull kSecPaddingPKCS7Key = CFSTR("SecPaddingPKCS7Key");
35 const CFStringRef __nonnull kSecPaddingOAEPKey = CFSTR("OAEPPadding");
36 const CFStringRef __nonnull kSecOAEPMGF1DigestAlgorithmAttributeName = CFSTR("OAEPMGF1DigestAlgo");
37
38 const CFStringRef __nonnull kSecModeNoneKey = CFSTR("SecModeNoneKey");
39 const CFStringRef __nonnull kSecModeECBKey = CFSTR("SecModeECBKey");
40 const CFStringRef __nonnull kSecModeCBCKey = CFSTR("SecModeCBCKey");
41 const CFStringRef __nonnull kSecModeCFBKey = CFSTR("SecModeCFBKey");
42 const CFStringRef __nonnull kSecModeOFBKey = CFSTR("SecModeOFBKey");
43
44 const CFStringRef __nonnull kSecOAEPMessageLengthAttributeName = CFSTR("OAEPMessageLength");
45 const CFStringRef __nonnull kSecOAEPEncodingParametersAttributeName = CFSTR("OAEPEncodingParameters");
46
47 const CFStringRef __nonnull kSecEncryptKey = CFSTR("SecEncryptKey");
48 const CFStringRef __nonnull kSecPaddingKey = CFSTR("SecPaddingKey");
49 const CFStringRef __nonnull kSecIVKey = CFSTR("SecIVKey");
50 const CFStringRef __nonnull kSecEncryptionMode = CFSTR("SecEncryptionMode");
51
52
53 SecTransformRef SecEncryptTransformCreate(SecKeyRef keyRef, CFErrorRef* error)
54 {
55 SecTransformRef etRef = EncryptTransform::Make();
56 EncryptTransform* et = (EncryptTransform*) CoreFoundationHolder::ObjectFromCFType(etRef);
57 if (et->InitializeObject(keyRef, error))
58 {
59 return etRef;
60 }
61 else
62 {
63
64 CFRelease(etRef);
65 return NULL;
66 }
67 }
68
69
70 CFTypeID SecEncryptTransformGetTypeID()
71 {
72 return Transform::GetCFTypeID();
73 }
74
75 SecTransformRef SecDecryptTransformCreate(SecKeyRef keyRef, CFErrorRef* error)
76 {
77
78 SecTransformRef dtRef = DecryptTransform::Make();
79 DecryptTransform* dt = (DecryptTransform*) CoreFoundationHolder::ObjectFromCFType(dtRef);
80 if (dt->InitializeObject(keyRef, error))
81 {
82 return dtRef;
83 }
84 else
85 {
86 CFRelease(dtRef);
87 return NULL;
88 }
89 }
90
91 CFTypeID SecDecryptTransformGetTypeID()
92 {
93 return Transform::GetCFTypeID();
94 }