2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
22 Contains: Crypto structures and routines
24 Written by: Doug Mitchell
26 Copyright: (c) 1999 by Apple Computer, Inc., all rights reserved.
31 #define _CRYPTTYPE_H_ 1
33 #include <Security/CipherSuite.h>
35 #include "sslContext.h"
43 { SSL2_RC4_128_WITH_MD5
= 0x010080,
44 SSL2_RC4_128_EXPORT_40_WITH_MD5
= 0x020080,
45 SSL2_RC2_128_CBC_WITH_MD5
= 0x030080,
46 SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
= 0x040080,
47 SSL2_IDEA_128_CBC_WITH_MD5
= 0x050080,
48 SSL2_DES_64_CBC_WITH_MD5
= 0x060040,
49 SSL2_DES_192_EDE3_CBC_WITH_MD5
= 0x0700C0
53 { SSL2CipherKind cipherKind
;
54 SSLCipherSuite cipherSuite
;
57 typedef OSStatus (*HashInit
)(SSLBuffer
&digestCtx
, SSLContext
*sslCtx
);
58 typedef OSStatus (*HashUpdate
)(SSLBuffer
&digestCtx
, const SSLBuffer
&data
);
59 /* HashFinal also does HashClose */
60 typedef OSStatus (*HashFinal
)(SSLBuffer
&digestCtx
, SSLBuffer
&digest
);
61 typedef OSStatus (*HashClose
)(SSLBuffer
&digestCtx
, SSLContext
*sslCtx
);
62 typedef OSStatus (*HashClone
)(const SSLBuffer
&src
, SSLBuffer
&dest
);
76 * -- new struct HashHmacReference
77 * -- structs which used to use HashReference now use HashHmacReference
78 * -- new union HashHmacContext, used in CipherContext.
81 const HashReference
*hash
;
82 const HMACReference
*hmac
;
87 HMACContextRef hmacCtx
;
90 /* these are declared in tls_hmac.c */
91 extern const HashHmacReference HashHmacNull
;
92 extern const HashHmacReference HashHmacMD5
;
93 extern const HashHmacReference HashHmacSHA1
;
96 * Hack to avoid circular dependency with tls_ssl.h.
98 struct _SslTlsCallouts
;
101 * All symmetric ciphers go thru CDSA, via these callouts.
103 struct CipherContext
;
104 typedef struct CipherContext CipherContext
;
106 typedef OSStatus (*SSLKeyFunc
)(
109 CipherContext
*cipherCtx
,
111 typedef OSStatus (*SSLCryptFunc
)(
114 CipherContext
*cipherCtx
,
116 typedef OSStatus (*SSLFinishFunc
)(
117 CipherContext
*cipherCtx
,
126 * Statically defined description of a symmetric sipher.
129 UInt8 keySize
; /* Sizes are in bytes */
133 CSSM_ALGORITHMS keyAlg
; /* CSSM_ALGID_DES, etc. */
134 CSSM_ALGORITHMS encrAlg
; /* ditto */
135 CSSM_ENCRYPT_MODE encrMode
; /* CSSM_ALGMODE_CBCPadIV8, etc. */
136 CSSM_PADDING encrPad
;
137 SSLKeyFunc initialize
;
138 SSLCryptFunc encrypt
;
139 SSLCryptFunc decrypt
;
140 SSLFinishFunc finish
;
141 } SSLSymmetricCipher
;
143 #define MAX_MAC_PADDING 48 /* MD5 MAC padding size = 48 bytes */
144 #define MASTER_SECRET_LEN 48 /* master secret = 3 x MD5 hashes concatenated */
146 /* SSL V2 - mac secret is the size of symmetric key, not digest */
147 #define MAX_SYMKEY_SIZE 24
167 SSLCipherSuite cipherSpec
;
168 Exportability isExportable
;
169 KeyExchangeMethod keyExchangeMethod
;
170 const HashHmacReference
*macAlgorithm
;
171 const SSLSymmetricCipher
*cipher
;
174 extern const SSLCipherMapping SSL2CipherMap
[];
175 extern const unsigned SSL2CipherMapCount
;
177 /* Default size of server-generated Diffie-Hellman parameters and keys */
179 #define SSL_DH_DEFAULT_PRIME_SIZE 1024 /* in bits */
181 #define SSL_DH_DEFAULT_PRIME_SIZE 512 /* in bits */
188 #endif /* _CRYPTTYPE_H_ */