2 * Copyright (c) 1999-2001,2005-2008,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 * cryptType.h - Crypto structures and routines
29 #define _CRYPTTYPE_H_ 1
31 #include <Security/CipherSuite.h>
33 #include "sslContext.h"
35 #include <CommonCrypto/CommonCryptor.h>
42 { SSL2_RC4_128_WITH_MD5
= 0x010080,
43 SSL2_RC4_128_EXPORT_40_WITH_MD5
= 0x020080,
44 SSL2_RC2_128_CBC_WITH_MD5
= 0x030080,
45 SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
= 0x040080,
46 SSL2_IDEA_128_CBC_WITH_MD5
= 0x050080,
47 SSL2_DES_64_CBC_WITH_MD5
= 0x060040,
48 SSL2_DES_192_EDE3_CBC_WITH_MD5
= 0x0700C0
52 { SSL2CipherKind cipherKind
;
53 SSLCipherSuite cipherSuite
;
56 typedef OSStatus (*HashInit
)(SSLBuffer
*digestCtx
, SSLContext
*sslCtx
);
57 typedef OSStatus (*HashUpdate
)(SSLBuffer
*digestCtx
, const SSLBuffer
*data
);
58 /* HashFinal also does HashClose */
59 typedef OSStatus (*HashFinal
)(SSLBuffer
*digestCtx
, SSLBuffer
*digest
);
60 typedef OSStatus (*HashClose
)(SSLBuffer
*digestCtx
, SSLContext
*sslCtx
);
61 typedef OSStatus (*HashClone
)(const SSLBuffer
*src
, SSLBuffer
*dest
);
75 * -- new struct HashHmacReference
76 * -- structs which used to use HashReference now use HashHmacReference
77 * -- new union HashHmacContext, used in CipherContext.
80 const HashReference
*hash
;
81 const HMACReference
*hmac
;
86 HMACContextRef hmacCtx
;
89 /* these are declared in tls_hmac.c */
90 extern const HashHmacReference HashHmacNull
;
91 extern const HashHmacReference HashHmacMD5
;
92 extern const HashHmacReference HashHmacSHA1
;
93 extern const HashHmacReference HashHmacSHA256
;
94 extern const HashHmacReference HashHmacSHA384
;
97 * Hack to avoid circular dependency with tls_ssl.h.
99 struct _SslTlsCallouts
;
102 * All symmetric ciphers go thru CDSA, via these callouts.
104 struct CipherContext
;
105 typedef struct CipherContext CipherContext
;
107 typedef OSStatus (*SSLKeyFunc
)(
110 CipherContext
*cipherCtx
,
112 typedef OSStatus (*SSLCryptFunc
)(
116 CipherContext
*cipherCtx
,
118 typedef OSStatus (*SSLFinishFunc
)(
119 CipherContext
*cipherCtx
,
128 * Statically defined description of a symmetric sipher.
131 uint8_t keySize
; /* Sizes are in bytes */
132 uint8_t secretKeySize
;
136 SSLKeyFunc initialize
;
137 SSLCryptFunc encrypt
;
138 SSLCryptFunc decrypt
;
139 SSLFinishFunc finish
;
140 } SSLSymmetricCipher
;
142 #define MAX_MAC_PADDING 48 /* MD5 MAC padding size = 48 bytes */
143 #define MASTER_SECRET_LEN 48 /* master secret = 3 x MD5 hashes concatenated */
145 /* SSL V2 - mac secret is the size of symmetric key, not digest */
146 #define MAX_SYMKEY_SIZE 24
164 /* ECDSA addenda, RFC 4492 */
173 SSLCipherSuite cipherSpec
;
174 Exportability isExportable
;
175 KeyExchangeMethod keyExchangeMethod
;
176 const HashHmacReference
*macAlgorithm
;
177 const SSLSymmetricCipher
*cipher
;
180 extern const SSLCipherMapping SSL2CipherMap
[];
181 extern const unsigned SSL2CipherMapCount
;
183 /* Default size of server-generated Diffie-Hellman parameters and keys */
185 #define SSL_DH_DEFAULT_PRIME_SIZE 1024 /* in bits */
187 #define SSL_DH_DEFAULT_PRIME_SIZE 512 /* in bits */
189 #define SSL_DH_DEFAULT_GENERATOR 2 /* only embedded uses this */
194 #endif /* _CRYPTTYPE_H_ */