2 * Copyright (c) 1999-2001,2005-2008,2010-2012 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 * symCipher.h - symmetric cipher module
28 #ifndef _SYM_CIPHER_H_
29 #define _SYM_CIPHER_H_
31 #include <sys/types.h>
33 #include "cipherSpecs.h"
39 #define MASTER_SECRET_LEN 48 /* master secret = 3 x MD5 hashes concatenated */
41 /* SSL V2 - mac secret is the size of symmetric key, not digest */
42 #define MAX_SYMKEY_SIZE 24
52 SSL_CipherAlgorithm keyAlg
;
53 CipherType cipherType
;
54 uint8_t keySize
; /* Sizes are in bytes */
57 } SSLSymmetricCipherParams
;
60 /* All symmetric ciphers go thru these callouts. */
61 struct SymCipherContext
;
62 typedef struct SymCipherContext
*SymCipherContext
;
64 typedef int (*SSLKeyFunc
)(
65 const SSLSymmetricCipherParams
*params
,
69 SymCipherContext
*cipherCtx
);
70 typedef int (*SSLSetIVFunc
)(
73 SymCipherContext cipherCtx
);
74 typedef int (*SSLAddADD
)(
77 SymCipherContext cipherCtx
);
78 typedef int (*SSLCryptFunc
)(
82 SymCipherContext cipherCtx
);
83 typedef int (*SSLFinishFunc
)(
84 SymCipherContext cipherCtx
);
85 typedef int (*SSLAEADDoneFunc
)(
88 SymCipherContext cipherCtx
);
90 /* Statically defined description of a symmetric cipher. */
92 SSLKeyFunc initialize
;
98 SSLKeyFunc initialize
;
101 SSLCryptFunc encrypt
;
102 SSLCryptFunc decrypt
;
103 SSLAEADDoneFunc done
;
108 typedef struct SSLSymmetricCipher
{
109 const SSLSymmetricCipherParams
*params
;
110 SSLFinishFunc finish
;
112 const Cipher cipher
; /* stream or block cipher type */
113 const AEADCipher aead
; /* aeadCipherType */
115 } SSLSymmetricCipher
;
117 extern const SSLSymmetricCipher SSLCipherNull
;
118 extern const SSLSymmetricCipher SSLCipherRC2_40
;
119 extern const SSLSymmetricCipher SSLCipherRC2_128
;
120 extern const SSLSymmetricCipher SSLCipherRC4_40
;
121 extern const SSLSymmetricCipher SSLCipherRC4_128
;
122 extern const SSLSymmetricCipher SSLCipherDES40_CBC
;
123 extern const SSLSymmetricCipher SSLCipherDES_CBC
;
124 extern const SSLSymmetricCipher SSLCipher3DES_CBC
;
125 extern const SSLSymmetricCipher SSLCipherAES_128_CBC
;
126 extern const SSLSymmetricCipher SSLCipherAES_256_CBC
;
127 extern const SSLSymmetricCipher SSLCipherAES_128_GCM
;
128 extern const SSLSymmetricCipher SSLCipherAES_256_GCM
;
130 /* Those are defined in symCipherParams.c */
131 extern const SSLSymmetricCipherParams SSLCipherNullParams
;
132 extern const SSLSymmetricCipherParams SSLCipherRC2_40Params
;
133 extern const SSLSymmetricCipherParams SSLCipherRC2_128Params
;
134 extern const SSLSymmetricCipherParams SSLCipherRC4_40Params
;
135 extern const SSLSymmetricCipherParams SSLCipherRC4_128Params
;
136 extern const SSLSymmetricCipherParams SSLCipherDES40_CBCParams
;
137 extern const SSLSymmetricCipherParams SSLCipherDES_CBCParams
;
138 extern const SSLSymmetricCipherParams SSLCipher3DES_CBCParams
;
139 extern const SSLSymmetricCipherParams SSLCipherAES_128_CBCParams
;
140 extern const SSLSymmetricCipherParams SSLCipherAES_256_CBCParams
;
141 extern const SSLSymmetricCipherParams SSLCipherAES_128_GCMParams
;
142 extern const SSLSymmetricCipherParams SSLCipherAES_256_GCMParams
;
148 #endif /* _SYM_CIPHER_H_ */