1/*
2 * Copyright (c) 2010 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
31CFStringRef kSecPaddingNoneKey = CFSTR("SecPaddingNoneKey");
32CFStringRef kSecPaddingPKCS1Key = CFSTR("SecPaddingPKCS1Key");
33CFStringRef kSecPaddingPKCS5Key = CFSTR("SecPaddingPKCS5Key");
34CFStringRef kSecPaddingPKCS7Key = CFSTR("SecPaddingPKCS7Key");
35CFStringRef kSecPaddingOAEPKey = CFSTR("OAEPPadding");
36CFStringRef kSecOAEPMGF1DigestAlgorithmAttributeName = CFSTR("OAEPMGF1DigestAlgo");
37
38CFStringRef kSecModeNoneKey = CFSTR("SecModeNoneKey");
39CFStringRef kSecModeECBKey = CFSTR("SecModeECBKey");
40CFStringRef kSecModeCBCKey = CFSTR("SecModeCBCKey");
41CFStringRef kSecModeCFBKey = CFSTR("SecModeCFBKey");
42CFStringRef kSecModeOFBKey = CFSTR("SecModeOFBKey");
43
44CFStringRef kSecOAEPMessageLengthAttributeName = CFSTR("OAEPMessageLength");
45CFStringRef kSecOAEPEncodingParametersAttributeName = CFSTR("OAEPEncodingParameters");
46
47CFStringRef kSecEncryptKey = CFSTR("SecEncryptKey");
48CFStringRef kSecPaddingKey = CFSTR("SecPaddingKey");
49CFStringRef kSecIVKey = CFSTR("SecIVKey");
50CFStringRef kSecEncryptionMode = CFSTR("SecEncryptionMode");
51
52
53SecTransformRef 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
70CFTypeID SecEncryptTransformGetTypeID()
71{
72	return Transform::GetCFTypeID();
73}
74
75SecTransformRef 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
91CFTypeID SecDecryptTransformGetTypeID()
92{
93	return Transform::GetCFTypeID();
94}
95