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>
66 { SSL2_RC4_128_WITH_MD5
= 0x010080,
67 SSL2_RC4_128_EXPORT_40_WITH_MD5
= 0x020080,
68 SSL2_RC2_128_CBC_WITH_MD5
= 0x030080,
69 SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
= 0x040080,
70 SSL2_IDEA_128_CBC_WITH_MD5
= 0x050080,
71 SSL2_DES_64_CBC_WITH_MD5
= 0x060040,
72 SSL2_DES_192_EDE3_CBC_WITH_MD5
= 0x0700C0
76 { SSL2CipherKind cipherKind
;
77 SSLCipherSuite cipherSuite
;
81 * Note: we're not changing the digest mechanisms for now; BSAFE
82 * doesn't provide the necessary "digest clone" op.
84 typedef SSLErr (*HashInit
)(SSLBuffer digestCtx
);
85 typedef SSLErr (*HashUpdate
)(SSLBuffer digestCtx
, SSLBuffer data
);
86 typedef SSLErr (*HashFinal
)(SSLBuffer digestCtx
, SSLBuffer digest
);
87 typedef SSLErr (*HashClone
)(SSLBuffer src
, SSLBuffer dest
);
99 extern const HashReference SSLHashNull
;
100 extern const HashReference SSLHashMD5
;
101 extern const HashReference SSLHashSHA1
;
105 * All symmetric ciphers go thru CDSA, but we'll keep these callouts for
106 * now. The major change here is the inclusion of the CipherContext
107 * arg, for alg/mode and key storage.
109 struct CipherContext
;
110 typedef struct CipherContext CipherContext
;
112 typedef SSLErr (*SSLKeyFunc
)(
115 CipherContext
*cipherCtx
,
117 typedef SSLErr (*SSLCryptFunc
)(
120 CipherContext
*cipherCtx
,
122 typedef SSLErr (*SSLFinishFunc
)(
123 CipherContext
*cipherCtx
,
127 typedef SSLErr (*SSLKeyFunc
)(UInt8
*key
, UInt8
*iv
, void **cipherRef
, SSLContext
*ctx
);
128 typedef SSLErr (*SSLCryptFunc
)(SSLBuffer src
, SSLBuffer dest
, void *cipherRef
, SSLContext
*ctx
);
129 typedef SSLErr (*SSLFinishFunc
)(void *cipherRef
, SSLContext
*ctx
);
130 #endif /* _APPLE_CDSA */
138 * Statically defined description of a symmetric sipher.
141 UInt8 keySize
; /* Sizes are in bytes */
146 CSSM_ALGORITHMS keyAlg
; /* CSSM_ALGID_DES, etc. */
147 CSSM_ALGORITHMS encrAlg
; /* ditto */
148 CSSM_ENCRYPT_MODE encrMode
; /* CSSM_ALGMODE_CBCPadIV8, etc. */
149 CSSM_PADDING encrPad
;
150 #endif /* _APPLE_CDSA */
151 SSLKeyFunc initialize
;
152 SSLCryptFunc encrypt
;
153 SSLCryptFunc decrypt
;
154 SSLFinishFunc finish
;
155 } SSLSymmetricCipher
;
157 #define MAX_DIGEST_SIZE 20 /* SHA digest size = 160 bits */
158 #define MAX_MAC_PADDING 48 /* MD5 MAC padding size = 48 bytes */
159 #define MASTER_SECRET_LEN 48 /* master secret = 3 x MD5 hashes concatenated */
161 /* SSL V2 - mac secret is the size of symmetric key, not digest */
162 #define MAX_SYMKEY_SIZE 24
163 #endif /* __APPLE__ */
168 * FIXME: I have no idea what the difference is between
169 * e.g. SSL_RSA and SS_RSA_EXPORT. These don't go over the
171 * The few times the SSLRef code behaves differently between
172 * these two look wrong. See SSLDecodeRSAKeyExchange(),
173 * SSLAdvanceHandshake().
175 * UPDATE: see comments for SSL_SERVER_KEYEXCH_HACK hack.
193 SSLCipherSuite cipherSpec
;
194 Exportability isExportable
;
195 KeyExchangeMethod keyExchangeMethod
;
196 const HashReference
*macAlgorithm
;
197 const SSLSymmetricCipher
*cipher
;
200 extern const SSLCipherMapping SSL2CipherMap
[];
201 extern const int SSL2CipherMapCount
;
202 extern UInt8 SSLMACPad1
[], SSLMACPad2
[];
208 #endif /* _CRYPTTYPE_H_ */