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, based on Netscape SSLRef 3.0
26 Copyright: (c) 1999 by Apple Computer, Inc., all rights reserved.
29 /* *********************************************************************
32 SSLRef 3.0 Final -- 11/19/96
34 Copyright (c)1996 by Netscape Communications Corp.
36 By retrieving this software you are bound by the licensing terms
37 disclosed in the file "LICENSE.txt". Please read it, and if you don't
38 accept the terms, delete this software.
40 SSLRef 3.0 was developed by Netscape Communications Corp. of Mountain
41 View, California <http://home.netscape.com/> and Consensus Development
42 Corporation of Berkeley, California <http://www.consensus.com/>.
44 *********************************************************************
46 File: cryptype.h Crypto structures and routines
48 Types associated with cryptographic functionality, including hashes,
49 symmetric ciphers, and cipher specs.
51 ****************************************************************** */
54 #define _CRYPTTYPE_H_ 1
57 #include <Security/CipherSuite.h>
67 { SSL2_RC4_128_WITH_MD5
= 0x010080,
68 SSL2_RC4_128_EXPORT_40_WITH_MD5
= 0x020080,
69 SSL2_RC2_128_CBC_WITH_MD5
= 0x030080,
70 SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
= 0x040080,
71 SSL2_IDEA_128_CBC_WITH_MD5
= 0x050080,
72 SSL2_DES_64_CBC_WITH_MD5
= 0x060040,
73 SSL2_DES_192_EDE3_CBC_WITH_MD5
= 0x0700C0
77 { SSL2CipherKind cipherKind
;
78 SSLCipherSuite cipherSuite
;
81 typedef SSLErr (*HashInit
)(SSLBuffer digestCtx
, SSLContext
*sslCtx
);
82 typedef SSLErr (*HashUpdate
)(SSLBuffer digestCtx
, SSLBuffer data
);
83 /* HashFinal also does HashClose */
84 typedef SSLErr (*HashFinal
)(SSLBuffer digestCtx
, SSLBuffer digest
);
85 typedef SSLErr (*HashClose
)(SSLBuffer digestCtx
, SSLContext
*sslCtx
);
86 typedef SSLErr (*HashClone
)(SSLBuffer src
, SSLBuffer dest
);
100 * -- new struct HashHmacReference
101 * -- structs which used to use HashReference now use HashHmacReference
102 * -- new union HashHmacContext, used in CipherContext.
105 const HashReference
*hash
;
106 const HMACReference
*hmac
;
111 HMACContextRef hmacCtx
;
114 /* these are declared in tls_hmac.c */
115 extern const HashHmacReference HashHmacNull
;
116 extern const HashHmacReference HashHmacMD5
;
117 extern const HashHmacReference HashHmacSHA1
;
120 * Hack to avoid circular dependency with tls_ssl.h.
122 struct _SslTlsCallouts
;
125 * All symmetric ciphers go thru CDSA, but we'll keep these callouts for
126 * now. The major change here from SSLRef3 is the inclusion of the CipherContext
127 * arg, for alg/mode and key storage.
129 struct CipherContext
;
130 typedef struct CipherContext CipherContext
;
132 typedef SSLErr (*SSLKeyFunc
)(
135 CipherContext
*cipherCtx
,
137 typedef SSLErr (*SSLCryptFunc
)(
140 CipherContext
*cipherCtx
,
142 typedef SSLErr (*SSLFinishFunc
)(
143 CipherContext
*cipherCtx
,
152 * Statically defined description of a symmetric sipher.
155 UInt8 keySize
; /* Sizes are in bytes */
159 CSSM_ALGORITHMS keyAlg
; /* CSSM_ALGID_DES, etc. */
160 CSSM_ALGORITHMS encrAlg
; /* ditto */
161 CSSM_ENCRYPT_MODE encrMode
; /* CSSM_ALGMODE_CBCPadIV8, etc. */
162 CSSM_PADDING encrPad
;
163 SSLKeyFunc initialize
;
164 SSLCryptFunc encrypt
;
165 SSLCryptFunc decrypt
;
166 SSLFinishFunc finish
;
167 } SSLSymmetricCipher
;
169 #define MAX_DIGEST_SIZE 20 /* SHA digest size = 160 bits */
170 #define MAX_MAC_PADDING 48 /* MD5 MAC padding size = 48 bytes */
171 #define MASTER_SECRET_LEN 48 /* master secret = 3 x MD5 hashes concatenated */
173 /* SSL V2 - mac secret is the size of symmetric key, not digest */
174 #define MAX_SYMKEY_SIZE 24
179 * FIXME: I have no idea what the difference is between
180 * e.g. SSL_RSA and SS_RSA_EXPORT. These don't go over the
182 * The few times the SSLRef code behaves differently between
183 * these two look wrong. See SSLDecodeRSAKeyExchange(),
184 * SSLAdvanceHandshake().
186 * UPDATE: see comments for SSL_SERVER_KEYEXCH_HACK hack.
204 SSLCipherSuite cipherSpec
;
205 Exportability isExportable
;
206 KeyExchangeMethod keyExchangeMethod
;
207 const HashHmacReference
*macAlgorithm
;
208 const SSLSymmetricCipher
*cipher
;
211 extern const SSLCipherMapping SSL2CipherMap
[];
212 extern const int SSL2CipherMapCount
;
213 extern UInt8 SSLMACPad1
[], SSLMACPad2
[];
219 #endif /* _CRYPTTYPE_H_ */