]> git.saurik.com Git - apple/security.git/blob - SecureTransport/privateInc/sslHandshake.h
Security-163.tar.gz
[apple/security.git] / SecureTransport / privateInc / sslHandshake.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: sslHandshake.h - SSL Handshake Layer
21 ****************************************************************** */
22
23 #ifndef _SSLHANDSHAKE_H_
24 #define _SSLHANDSHAKE_H_
25
26 #include "cryptType.h"
27 #include "sslRecord.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 typedef enum
34 { SSL_HdskHelloRequest = 0,
35 SSL_HdskClientHello = 1,
36 SSL_HdskServerHello = 2,
37 SSL_HdskCert = 11,
38 SSL_HdskServerKeyExchange = 12,
39 SSL_HdskCertRequest = 13,
40 SSL_HdskServerHelloDone = 14,
41 SSL_HdskCertVerify = 15,
42 SSL_HdskClientKeyExchange = 16,
43 SSL_HdskFinished = 20,
44 SSL_HdskNoCertAlert = 100
45 } SSLHandshakeType;
46
47 typedef enum
48 { SSL_read,
49 SSL_write
50 } CipherSide;
51
52 typedef enum
53 {
54 SSL_HdskStateUninit = 0, /* only valid within SSLContextAlloc */
55 SSL_HdskStateServerUninit, /* no handshake yet */
56 SSL_HdskStateClientUninit, /* no handshake yet */
57 SSL_HdskStateGracefulClose,
58 SSL_HdskStateErrorClose,
59 SSL_HdskStateNoNotifyClose, /* server disconnected with no
60 * notify msg */
61 /* remainder must be consecutive */
62 SSL_HdskStateServerHello, /* must get server hello; client hello sent */
63 SSL_HdskStateServerHelloUnknownVersion,
64 /* Could get SSL 2 or SSL 3 server hello back */
65 SSL_HdskStateKeyExchange, /* must get key exchange; cipher spec
66 * requires it */
67 SSL_HdskStateCert, /* may get certificate or certificate
68 * request (if no cert request received yet) */
69 SSL_HdskStateHelloDone, /* must get server hello done; after key
70 * exchange or fixed DH parameters */
71 SSL_HdskStateClientCert, /* must get certificate or no cert alert
72 * from client */
73 SSL_HdskStateClientKeyExchange, /* must get client key exchange */
74 SSL_HdskStateClientCertVerify, /* must get certificate verify from client */
75 SSL_HdskStateChangeCipherSpec, /* time to change the cipher spec */
76 SSL_HdskStateFinished, /* must get a finished message in the
77 * new cipher spec */
78 SSL2_HdskStateClientMasterKey,
79 SSL2_HdskStateClientFinished,
80 SSL2_HdskStateServerHello,
81 SSL2_HdskStateServerVerify,
82 SSL2_HdskStateServerFinished,
83 SSL_HdskStateServerReady, /* ready for I/O; server side */
84 SSL_HdskStateClientReady /* ready for I/O; client side */
85 } SSLHandshakeState;
86
87 typedef struct
88 { SSLHandshakeType type;
89 SSLBuffer contents;
90 } SSLHandshakeMsg;
91
92 #define SSL_Finished_Sender_Server 0x53525652
93 #define SSL_Finished_Sender_Client 0x434C4E54
94
95 /** sslHandshake.c **/
96 typedef OSStatus (*EncodeMessageFunc)(SSLRecord &rec, SSLContext *ctx);
97 OSStatus SSLProcessHandshakeRecord(SSLRecord rec, SSLContext *ctx);
98 OSStatus SSLPrepareAndQueueMessage(EncodeMessageFunc msgFunc, SSLContext *ctx);
99 OSStatus SSLAdvanceHandshake(SSLHandshakeType processed, SSLContext *ctx);
100 OSStatus SSL3ReceiveSSL2ClientHello(SSLRecord rec, SSLContext *ctx);
101
102 /** sslChangeCipher.c **/
103 OSStatus SSLEncodeChangeCipherSpec(SSLRecord &rec, SSLContext *ctx);
104 OSStatus SSLProcessChangeCipherSpec(SSLRecord rec, SSLContext *ctx);
105 OSStatus SSLDisposeCipherSuite(CipherContext *cipher, SSLContext *ctx);
106
107 /** sslCert.c **/
108 OSStatus SSLEncodeCertificate(SSLRecord &certificate, SSLContext *ctx);
109 OSStatus SSLProcessCertificate(SSLBuffer message, SSLContext *ctx);
110 OSStatus SSLEncodeCertificateRequest(SSLRecord &request, SSLContext *ctx);
111 OSStatus SSLProcessCertificateRequest(SSLBuffer message, SSLContext *ctx);
112 OSStatus SSLEncodeCertificateVerify(SSLRecord &verify, SSLContext *ctx);
113 OSStatus SSLProcessCertificateVerify(SSLBuffer message, SSLContext *ctx);
114
115 /** sslHandshakeHello.c **/
116 OSStatus SSLEncodeServerHello(SSLRecord &serverHello, SSLContext *ctx);
117 OSStatus SSLProcessServerHello(SSLBuffer message, SSLContext *ctx);
118 OSStatus SSLEncodeClientHello(SSLRecord &clientHello, SSLContext *ctx);
119 OSStatus SSLProcessClientHello(SSLBuffer message, SSLContext *ctx);
120 OSStatus SSLInitMessageHashes(SSLContext *ctx);
121
122 /** sslKeyExchange.c **/
123 OSStatus SSLEncodeServerKeyExchange(SSLRecord &keyExch, SSLContext *ctx);
124 OSStatus SSLProcessServerKeyExchange(SSLBuffer message, SSLContext *ctx);
125 OSStatus SSLEncodeKeyExchange(SSLRecord &keyExchange, SSLContext *ctx);
126 OSStatus SSLProcessKeyExchange(SSLBuffer keyExchange, SSLContext *ctx);
127 OSStatus SSLInitPendingCiphers(SSLContext *ctx);
128
129 /** sslHandshakeFinish.c **/
130 OSStatus SSLEncodeFinishedMessage(SSLRecord &finished, SSLContext *ctx);
131 OSStatus SSLProcessFinished(SSLBuffer message, SSLContext *ctx);
132 OSStatus SSLEncodeServerHelloDone(SSLRecord &helloDone, SSLContext *ctx);
133 OSStatus SSLProcessServerHelloDone(SSLBuffer message, SSLContext *ctx);
134 OSStatus SSLCalculateFinishedMessage(SSLBuffer finished, SSLBuffer shaMsgState, SSLBuffer md5MsgState, UInt32 senderID, SSLContext *ctx);
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif /* _SSLHANDSHAKE_H_ */