2 * Copyright (c) 2010-2011 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #include "SecEncryptTransform.h"
25 #include "EncryptTransform.h"
27 /* --------------------------------------------------------------------------
28 Create the declared CFStringRefs
29 -------------------------------------------------------------------------- */
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");
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");
44 const CFStringRef __nonnull kSecOAEPMessageLengthAttributeName
= CFSTR("OAEPMessageLength");
45 const CFStringRef __nonnull kSecOAEPEncodingParametersAttributeName
= CFSTR("OAEPEncodingParameters");
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");
53 SecTransformRef
SecEncryptTransformCreate(SecKeyRef keyRef
, CFErrorRef
* error
)
55 SecTransformRef etRef
= EncryptTransform::Make();
56 EncryptTransform
* et
= (EncryptTransform
*) CoreFoundationHolder::ObjectFromCFType(etRef
);
57 if (et
->InitializeObject(keyRef
, error
))
70 CFTypeID
SecEncryptTransformGetTypeID()
72 return Transform::GetCFTypeID();
75 SecTransformRef
SecDecryptTransformCreate(SecKeyRef keyRef
, CFErrorRef
* error
)
78 SecTransformRef dtRef
= DecryptTransform::Make();
79 DecryptTransform
* dt
= (DecryptTransform
*) CoreFoundationHolder::ObjectFromCFType(dtRef
);
80 if (dt
->InitializeObject(keyRef
, error
))
91 CFTypeID
SecDecryptTransformGetTypeID()
93 return Transform::GetCFTypeID();