2 * Copyright (c) 2010-2011,2013 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@
25 @header SecEncryptTransform
27 This file defines a SecTransform that will do both asynchronous and synchronous
30 The key that is supplied to the SecTransform determines the type of encryption
34 #if !defined(__SEC_ENCRYPT_TRANSFORM__)
35 #define __SEC_ENCRYPT_TRANSFORM__ 1
37 #include <CoreFoundation/CoreFoundation.h>
38 #include <Security/SecKey.h>
39 #include "SecTransform.h"
45 /*! @abstract Indicates that no padding will be used when encrypting or decrypting. */
46 extern CFStringRef kSecPaddingNoneKey
;
47 /*! Indicates that PKCS1 padding will be used when encrypting or decrypting. */
48 extern CFStringRef kSecPaddingPKCS1Key
;
49 /*! Indicates that PKCS5 padding will be used when encrypting or decrypting. */
50 extern CFStringRef kSecPaddingPKCS5Key
;
51 /*! Indicates that PKCS7 padding will be used when encrypting or decrypting. */
52 extern CFStringRef kSecPaddingPKCS7Key
;
53 /*! Indicates that PKCS7 padding will be used when encrypting or decrypting. */
54 extern CFStringRef kSecPaddingOAEPKey
55 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
56 /*! Indicates that no mode will be used when encrypting or decrypting. */
57 extern CFStringRef kSecModeNoneKey
;
58 /*! Indicates that ECB mode will be used when encrypting or decrypting. */
59 extern CFStringRef kSecModeECBKey
;
60 /*! Indicates that CBC mode will be used when encrypting or decrypting. */
61 extern CFStringRef kSecModeCBCKey
;
62 /*! Indicates that CFB mode will be used when encrypting or decrypting. */
63 extern CFStringRef kSecModeCFBKey
;
64 /*! Indicates that OFB mode will be used when encrypting or decrypting. */
65 extern CFStringRef kSecModeOFBKey
;
69 This attribute holds the encryption key for the transform. (ReadOnly)
71 extern CFStringRef kSecEncryptKey
;
75 Key for setting padding.
77 This key is optional. If you do not supply a value for this key,
78 an appropriate value will be supplied for you.
80 extern CFStringRef kSecPaddingKey
;
84 Key for setting an initialization vector.
86 This key is optional. If you do not supply a
87 value for this key, an appropriate value will be supplied for you.
89 extern CFStringRef kSecIVKey
;
93 Specifies the encryption mode.
95 This key is optional. If you do not supply this key,
96 an appropriate value will be supplied for you.
98 extern CFStringRef kSecEncryptionMode
;
102 Specifies the OAEP message length.
104 This should be set to a CFNumberRef when the padding is set to OAEP,
105 and a specific messages size is desired. If unset the minimum padding
106 will be added. It is ignored when the padding mode is not OAEP.
108 extern CFStringRef kSecOAEPMessageLengthAttributeName
109 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
112 Specifies the OAEP encoding paramaters
114 This should be set to a CFDataRef when the padding is set to OAEP.
115 If unset a zero length CFDataRef is used. It is ignored by non
118 extern CFStringRef kSecOAEPEncodingParametersAttributeName
119 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
122 Specifies the OAEP MGF1 digest algorithm.
124 This should be set to a digest algorithm when the padding is set to OAEP.
125 If unset SHA1 is used. It is ifnored by non OAEP padding modes.
127 extern CFStringRef kSecOAEPMGF1DigestAlgorithmAttributeName
128 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
132 @function SecEncryptTransformCreate
133 @abstract Creates an encryption SecTransform object.
134 @param keyRef The key for the encryption operation
135 @param error A pointer to a CFErrorRef. This pointer will be set
136 if an error occurred. This value may be NULL if you
137 do not want an error returned.
138 @result A pointer to a SecTransformRef object. This object must
139 be released with CFRelease when you are done with
140 it. This function will return NULL if an error
142 @discussion This function creates a transform which encrypts data.
145 SecTransformRef
SecEncryptTransformCreate(SecKeyRef keyRef
,
147 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
150 @function SecDecryptTransformCreate
151 @abstract Creates an encryption SecTransform object.
152 @param keyRef The key for the operation
153 @param error A pointer to a CFErrorRef. This pointer will be set
154 if an error occurred. This value may be NULL if you
155 do not want an error returned.
156 @result A pointer to a SecTransformRef object. This object must
157 be released with CFRelease when you are done with
158 it. This function will return NULL if an error
160 @discussion This function creates a transform which encrypts data.
163 SecTransformRef
SecDecryptTransformCreate(SecKeyRef keyRef
,
165 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
168 @function SecDecryptTransformGetTypeID
169 @abstract Returns the CFTypeID for a decrypt transform.
173 CFTypeID
SecDecryptTransformGetTypeID()
174 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
177 @function SecEncryptTransformGetTypeID
178 @abstract Returns the CFTypeID for a decrypt transform.
182 CFTypeID
SecEncryptTransformGetTypeID()
183 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
189 #endif /* ! __SEC_ENCRYPT_TRANSFORM__ */