]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_transform/lib/SecEncryptTransform.cpp
Security-58286.1.32.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 "SecTransformInternal.h"
26 #include "EncryptTransform.h"
27
28 /* --------------------------------------------------------------------------
29 Create the declared CFStringRefs
30 -------------------------------------------------------------------------- */
31
32 const CFStringRef __nonnull kSecPaddingNoneKey = CFSTR("SecPaddingNoneKey");
33 const CFStringRef __nonnull kSecPaddingPKCS1Key = CFSTR("SecPaddingPKCS1Key");
34 const CFStringRef __nonnull kSecPaddingPKCS5Key = CFSTR("SecPaddingPKCS5Key");
35 const CFStringRef __nonnull kSecPaddingPKCS7Key = CFSTR("SecPaddingPKCS7Key");
36 const CFStringRef __nonnull kSecPaddingOAEPKey = CFSTR("OAEPPadding");
37 const CFStringRef __nonnull kSecOAEPMGF1DigestAlgorithmAttributeName = CFSTR("OAEPMGF1DigestAlgo");
38
39 const CFStringRef __nonnull kSecModeNoneKey = CFSTR("SecModeNoneKey");
40 const CFStringRef __nonnull kSecModeECBKey = CFSTR("SecModeECBKey");
41 const CFStringRef __nonnull kSecModeCBCKey = CFSTR("SecModeCBCKey");
42 const CFStringRef __nonnull kSecModeCFBKey = CFSTR("SecModeCFBKey");
43 const CFStringRef __nonnull kSecModeOFBKey = CFSTR("SecModeOFBKey");
44
45 const CFStringRef __nonnull kSecOAEPMessageLengthAttributeName = CFSTR("OAEPMessageLength");
46 const CFStringRef __nonnull kSecOAEPEncodingParametersAttributeName = CFSTR("OAEPEncodingParameters");
47
48 const CFStringRef __nonnull kSecEncryptKey = CFSTR("SecEncryptKey");
49 const CFStringRef __nonnull kSecPaddingKey = CFSTR("SecPaddingKey");
50 const CFStringRef __nonnull kSecIVKey = CFSTR("SecIVKey");
51 const CFStringRef __nonnull kSecEncryptionMode = CFSTR("SecEncryptionMode");
52
53
54 SecTransformRef SecEncryptTransformCreate(SecKeyRef keyRef, CFErrorRef* error)
55 {
56 SecTransformRef etRef = EncryptTransform::Make();
57 EncryptTransform* et = (EncryptTransform*) CoreFoundationHolder::ObjectFromCFType(etRef);
58 if (et->InitializeObject(keyRef, error))
59 {
60 return etRef;
61 }
62 else
63 {
64
65 CFReleaseNull(etRef);
66 return NULL;
67 }
68 }
69
70
71 CFTypeID SecEncryptTransformGetTypeID()
72 {
73 return Transform::GetCFTypeID();
74 }
75
76 SecTransformRef SecDecryptTransformCreate(SecKeyRef keyRef, CFErrorRef* error)
77 {
78
79 SecTransformRef dtRef = DecryptTransform::Make();
80 DecryptTransform* dt = (DecryptTransform*) CoreFoundationHolder::ObjectFromCFType(dtRef);
81 if (dt->InitializeObject(keyRef, error))
82 {
83 return dtRef;
84 }
85 else
86 {
87 CFReleaseNull(dtRef);
88 return NULL;
89 }
90 }
91
92 CFTypeID SecDecryptTransformGetTypeID()
93 {
94 return Transform::GetCFTypeID();
95 }