]> git.saurik.com Git - apple/security.git/blob - SecureTransport/privateInc/sslhdshk.h
Security-28.tar.gz
[apple/security.git] / SecureTransport / privateInc / sslhdshk.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 /* *********************************************************************
20 File: sslhdshk.h
21
22 SSLRef 3.0 Final -- 11/19/96
23
24 Copyright (c)1996 by Netscape Communications Corp.
25
26 By retrieving this software you are bound by the licensing terms
27 disclosed in the file "LICENSE.txt". Please read it, and if you don't
28 accept the terms, delete this software.
29
30 SSLRef 3.0 was developed by Netscape Communications Corp. of Mountain
31 View, California <http://home.netscape.com/> and Consensus Development
32 Corporation of Berkeley, California <http://www.consensus.com/>.
33
34 *********************************************************************
35
36 File: sslhdshk.h SSL Handshake Layer
37
38 Prototypes, values, and types for the SSL handshake state machine and
39 handshake decoding routines.
40
41 ****************************************************************** */
42
43 #ifndef _SSLHDSHK_H_
44 #define _SSLHDSHK_H_ 72
45
46 #ifndef _SSL_H_
47 //#include "ssl.h"
48 #endif
49
50 #ifndef _CRYPTYPE_H_
51 #include "cryptType.h"
52 #endif
53
54 #ifndef _SSLREC_H_
55 #include "sslrec.h"
56 #endif
57
58 typedef enum
59 { SSL_hello_request = 0,
60 SSL_client_hello = 1,
61 SSL_server_hello = 2,
62 SSL_certificate = 11,
63 SSL_server_key_exchange = 12,
64 SSL_certificate_request = 13,
65 SSL_server_hello_done = 14,
66 SSL_certificate_verify = 15,
67 SSL_client_key_exchange = 16,
68 SSL_finished = 20,
69 SSL_MAGIC_no_certificate_alert = 100
70 } SSLHandshakeType;
71
72 typedef enum
73 { SSL_read,
74 SSL_write
75 } CipherSide;
76
77 typedef enum
78 {
79 SSLUninitialized = 0, /* only valid within SSLContextAlloc */
80 HandshakeServerUninit, /* no handshake yet */
81 HandshakeClientUninit, /* no handshake yet */
82 SSLGracefulClose,
83 SSLErrorClose,
84 SSLNoNotifyClose, /* server disconnected with no
85 * notify msg */
86 /* remainder must be consecutive */
87 HandshakeServerHello, /* must get server hello; client hello sent */
88 HandshakeServerHelloUnknownVersion, /* Could get SSL 2 or SSL 3 server hello back */
89 HandshakeKeyExchange, /* must get key exchange; cipher spec requires it */
90 HandshakeCertificate, /* may get certificate or certificate request (if no cert request received yet) */
91 HandshakeHelloDone, /* must get server hello done; after key exchange or fixed DH parameters */
92 HandshakeClientCertificate, /* must get certificate or no cert alert from client */
93 HandshakeClientKeyExchange, /* must get client key exchange */
94 HandshakeClientCertVerify, /* must get certificate verify from client */
95 HandshakeChangeCipherSpec, /* time to change the cipher spec */
96 HandshakeFinished, /* must get a finished message in the new cipher spec */
97 HandshakeSSL2ClientMasterKey,
98 HandshakeSSL2ClientFinished,
99 HandshakeSSL2ServerHello,
100 HandshakeSSL2ServerVerify,
101 HandshakeSSL2ServerFinished,
102 HandshakeServerReady, /* ready for I/O; server side */
103 HandshakeClientReady /* ready for I/O; client side */
104 } SSLHandshakeState;
105
106 typedef struct
107 { SSLHandshakeType type;
108 SSLBuffer contents;
109 } SSLHandshakeMsg;
110
111 #define SSL_Finished_Sender_Server 0x53525652
112 #define SSL_Finished_Sender_Client 0x434C4E54
113
114 /** sslhdshk.c **/
115 typedef SSLErr (*EncodeMessageFunc)(SSLRecord *rec, SSLContext *ctx);
116 SSLErr SSLProcessHandshakeRecord(SSLRecord rec, SSLContext *ctx);
117 SSLErr SSLPrepareAndQueueMessage(EncodeMessageFunc msgFunc, SSLContext *ctx);
118 SSLErr SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx);
119 SSLErr SSL3ReceiveSSL2ClientHello(SSLRecord rec, SSLContext *ctx);
120
121 /** hdskchgc.c **/
122 SSLErr SSLEncodeChangeCipherSpec(SSLRecord *rec, SSLContext *ctx);
123 SSLErr SSLProcessChangeCipherSpec(SSLRecord rec, SSLContext *ctx);
124 SSLErr SSLDisposeCipherSuite(CipherContext *cipher, SSLContext *ctx);
125
126 /** hdskcert.c **/
127 SSLErr SSLEncodeCertificate(SSLRecord *certificate, SSLContext *ctx);
128 SSLErr SSLProcessCertificate(SSLBuffer message, SSLContext *ctx);
129 SSLErr SSLEncodeCertificateRequest(SSLRecord *request, SSLContext *ctx);
130 SSLErr SSLProcessCertificateRequest(SSLBuffer message, SSLContext *ctx);
131 SSLErr SSLEncodeCertificateVerify(SSLRecord *verify, SSLContext *ctx);
132 SSLErr SSLProcessCertificateVerify(SSLBuffer message, SSLContext *ctx);
133
134 /** hdskhelo.c **/
135 SSLErr SSLEncodeServerHello(SSLRecord *serverHello, SSLContext *ctx);
136 SSLErr SSLProcessServerHello(SSLBuffer message, SSLContext *ctx);
137 SSLErr SSLEncodeClientHello(SSLRecord *clientHello, SSLContext *ctx);
138 SSLErr SSLProcessClientHello(SSLBuffer message, SSLContext *ctx);
139 SSLErr SSLInitMessageHashes(SSLContext *ctx);
140
141 /** hdskkyex.c **/
142 SSLErr SSLEncodeServerKeyExchange(SSLRecord *keyExch, SSLContext *ctx);
143 SSLErr SSLProcessServerKeyExchange(SSLBuffer message, SSLContext *ctx);
144 SSLErr SSLEncodeKeyExchange(SSLRecord *keyExchange, SSLContext *ctx);
145 SSLErr SSLProcessKeyExchange(SSLBuffer keyExchange, SSLContext *ctx);
146
147 /** hdskfini.c **/
148 SSLErr SSLEncodeFinishedMessage(SSLRecord *finished, SSLContext *ctx);
149 SSLErr SSLProcessFinished(SSLBuffer message, SSLContext *ctx);
150 SSLErr SSLEncodeServerHelloDone(SSLRecord *helloDone, SSLContext *ctx);
151 SSLErr SSLProcessServerHelloDone(SSLBuffer message, SSLContext *ctx);
152 SSLErr SSLCalculateFinishedMessage(SSLBuffer finished, SSLBuffer shaMsgState, SSLBuffer md5MsgState, UInt32 senderID, SSLContext *ctx);
153
154 /** hdskkeys.c **/
155 SSLErr SSLEncodeRSAPremasterSecret(SSLContext *ctx);
156 SSLErr SSLEncodeDHPremasterSecret(SSLContext *ctx);
157 SSLErr SSLCalculateMasterSecret(SSLContext *ctx);
158 SSLErr SSLInitPendingCiphers(SSLContext *ctx);
159 #ifdef _APPLE_CDSA_
160 /* FIXME - TBD */
161 SSLErr ReadyRandom(void *randCtx, SSLContext *ctx);
162 #else
163 SSLErr ReadyRandom(SSLRandomCtx *rsaRandom, SSLContext *ctx);
164 #endif
165
166 #endif /* _SSLHDSHK_H_ */