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 <Security/SecTransform.h>
45 CF_ASSUME_NONNULL_BEGIN
46 CF_IMPLICIT_BRIDGING_ENABLED
48 /*! @abstract Indicates that no padding will be used when encrypting or decrypting. */
49 extern const CFStringRef kSecPaddingNoneKey
;
50 /*! Indicates that PKCS1 padding will be used when encrypting or decrypting. */
51 extern const CFStringRef kSecPaddingPKCS1Key
;
52 /*! Indicates that PKCS5 padding will be used when encrypting or decrypting. */
53 extern const CFStringRef kSecPaddingPKCS5Key
;
54 /*! Indicates that PKCS7 padding will be used when encrypting or decrypting. */
55 extern const CFStringRef kSecPaddingPKCS7Key
;
56 /*! Indicates that PKCS7 padding will be used when encrypting or decrypting. */
57 extern const CFStringRef kSecPaddingOAEPKey
58 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
59 /*! Indicates that no mode will be used when encrypting or decrypting. */
60 extern const CFStringRef kSecModeNoneKey
;
61 /*! Indicates that ECB mode will be used when encrypting or decrypting. */
62 extern const CFStringRef kSecModeECBKey
;
63 /*! Indicates that CBC mode will be used when encrypting or decrypting. */
64 extern const CFStringRef kSecModeCBCKey
;
65 /*! Indicates that CFB mode will be used when encrypting or decrypting. */
66 extern const CFStringRef kSecModeCFBKey
;
67 /*! Indicates that OFB mode will be used when encrypting or decrypting. */
68 extern const CFStringRef kSecModeOFBKey
;
72 This attribute holds the encryption key for the transform. (ReadOnly)
74 extern const CFStringRef kSecEncryptKey
;
78 Key for setting padding.
80 This key is optional. If you do not supply a value for this key,
81 an appropriate value will be supplied for you.
83 extern const CFStringRef kSecPaddingKey
;
87 Key for setting an initialization vector.
89 This key is optional. If you do not supply a
90 value for this key, an appropriate value will be supplied for you.
92 extern const CFStringRef kSecIVKey
;
96 Specifies the encryption mode.
98 This key is optional. If you do not supply this key,
99 an appropriate value will be supplied for you.
101 extern const CFStringRef kSecEncryptionMode
;
105 Specifies the OAEP message length.
107 This should be set to a CFNumberRef when the padding is set to OAEP,
108 and a specific messages size is desired. If unset the minimum padding
109 will be added. It is ignored when the padding mode is not OAEP.
111 extern const CFStringRef kSecOAEPMessageLengthAttributeName
112 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
115 Specifies the OAEP encoding paramaters
117 This should be set to a CFDataRef when the padding is set to OAEP.
118 If unset a zero length CFDataRef is used. It is ignored by non
121 extern const CFStringRef kSecOAEPEncodingParametersAttributeName
122 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
125 Specifies the OAEP MGF1 digest algorithm.
127 This should be set to a digest algorithm when the padding is set to OAEP.
128 If unset SHA1 is used. It is ifnored by non OAEP padding modes.
130 extern const CFStringRef kSecOAEPMGF1DigestAlgorithmAttributeName
131 __OSX_AVAILABLE_STARTING(__MAC_10_8
,__IPHONE_NA
);
134 @function SecEncryptTransformCreate
135 @abstract Creates an encryption SecTransform object.
136 @param keyRef The key for the encryption operation
137 @param error A pointer to a CFErrorRef. This pointer will be set
138 if an error occurred. This value may be NULL if you
139 do not want an error returned.
140 @result A pointer to a SecTransformRef object. This object must
141 be released with CFRelease when you are done with
142 it. This function will return NULL if an error
144 @discussion This function creates a transform which encrypts data.
147 SecTransformRef
SecEncryptTransformCreate(SecKeyRef keyRef
,
149 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
152 @function SecDecryptTransformCreate
153 @abstract Creates an encryption SecTransform object.
154 @param keyRef The key for the operation
155 @param error A pointer to a CFErrorRef. This pointer will be set
156 if an error occurred. This value may be NULL if you
157 do not want an error returned.
158 @result A pointer to a SecTransformRef object. This object must
159 be released with CFRelease when you are done with
160 it. This function will return NULL if an error
162 @discussion This function creates a transform which encrypts data.
165 SecTransformRef
SecDecryptTransformCreate(SecKeyRef keyRef
,
167 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
170 @function SecDecryptTransformGetTypeID
171 @abstract Returns the CFTypeID for a decrypt transform.
175 CFTypeID
SecDecryptTransformGetTypeID(void)
176 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
179 @function SecEncryptTransformGetTypeID
180 @abstract Returns the CFTypeID for a decrypt transform.
184 CFTypeID
SecEncryptTransformGetTypeID(void)
185 __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
);
187 CF_IMPLICIT_BRIDGING_DISABLED
188 CF_ASSUME_NONNULL_END
194 #endif /* ! __SEC_ENCRYPT_TRANSFORM__ */