]>
Commit | Line | Data |
---|---|---|
427c49bc A |
1 | /* |
2 | * Copyright (c) 2011 Apple Inc. All Rights Reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | /* | |
25 | * sslTypes.h - internal ssl types | |
26 | */ | |
27 | ||
28 | /* This header should be kernel compatible */ | |
29 | ||
30 | #ifndef _SSLTYPES_H_ | |
31 | #define _SSLTYPES_H_ 1 | |
32 | ||
33 | #include <stdbool.h> | |
34 | #include <stdint.h> | |
35 | #include <sys/types.h> | |
36 | ||
37 | enum { | |
38 | errSSLRecordInternal = -10000, | |
39 | errSSLRecordWouldBlock = -10001, | |
40 | errSSLRecordProtocol = -10002, | |
41 | errSSLRecordNegotiation = -10003, | |
42 | errSSLRecordClosedAbort = -10004, | |
43 | errSSLRecordConnectionRefused = -10005, /* peer dropped connection before responding */ | |
44 | errSSLRecordDecryptionFail = -10006, /* decryption failure */ | |
45 | errSSLRecordBadRecordMac = -10007, /* bad MAC */ | |
46 | errSSLRecordRecordOverflow = -10008, /* record overflow */ | |
47 | errSSLRecordUnexpectedRecord = -10009, /* unexpected (skipped) record in DTLS */ | |
48 | }; | |
49 | ||
50 | typedef enum | |
51 | { | |
52 | /* This value never appears in the actual protocol */ | |
53 | SSL_Version_Undetermined = 0, | |
54 | /* actual protocol values */ | |
55 | SSL_Version_2_0 = 0x0002, | |
56 | SSL_Version_3_0 = 0x0300, | |
57 | TLS_Version_1_0 = 0x0301, /* TLS 1.0 == SSL 3.1 */ | |
58 | TLS_Version_1_1 = 0x0302, | |
59 | TLS_Version_1_2 = 0x0303, | |
60 | DTLS_Version_1_0 = 0xfeff, | |
61 | } SSLProtocolVersion; | |
62 | ||
63 | /* FIXME: This enum and the SSLRecord are exposed because they | |
64 | are used at the interface between the Record and Handshake layer. | |
65 | This might not be the best idea */ | |
66 | ||
67 | enum | |
68 | { SSL_RecordTypeV2_0, | |
69 | SSL_RecordTypeV3_Smallest = 20, | |
70 | SSL_RecordTypeChangeCipher = 20, | |
71 | SSL_RecordTypeAlert = 21, | |
72 | SSL_RecordTypeHandshake = 22, | |
73 | SSL_RecordTypeAppData = 23, | |
74 | SSL_RecordTypeV3_Largest = 23 | |
75 | }; | |
76 | ||
77 | ||
78 | /* | |
79 | * This is the buffer type used internally. | |
80 | */ | |
81 | typedef struct | |
82 | { size_t length; | |
83 | uint8_t *data; | |
84 | } SSLBuffer; | |
85 | ||
86 | ||
87 | typedef struct | |
88 | { | |
89 | uint8_t contentType; | |
90 | SSLProtocolVersion protocolVersion; | |
91 | SSLBuffer contents; | |
92 | } SSLRecord; | |
93 | ||
94 | ||
95 | /* | |
96 | * We should remove this and use uint64_t all over. | |
97 | */ | |
98 | typedef uint64_t sslUint64; | |
99 | ||
100 | ||
101 | /* Opaque reference to a Record Context */ | |
102 | typedef void * SSLRecordContextRef; | |
103 | ||
104 | ||
105 | typedef int | |
106 | (*SSLRecordReadFunc) (SSLRecordContextRef ref, | |
107 | SSLRecord *rec); | |
108 | ||
109 | typedef int | |
110 | (*SSLRecordWriteFunc) (SSLRecordContextRef ref, | |
111 | SSLRecord rec); | |
112 | ||
113 | typedef int | |
114 | (*SSLRecordInitPendingCiphersFunc) (SSLRecordContextRef ref, | |
115 | uint16_t selectedCipher, | |
116 | bool server, | |
117 | SSLBuffer key); | |
118 | ||
119 | typedef int | |
120 | (*SSLRecordAdvanceWriteCipherFunc) (SSLRecordContextRef ref); | |
121 | ||
122 | typedef int | |
123 | (*SSLRecordRollbackWriteCipherFunc) (SSLRecordContextRef ref); | |
124 | ||
125 | typedef int | |
126 | (*SSLRecordAdvanceReadCipherFunc) (SSLRecordContextRef ref); | |
127 | ||
128 | typedef int | |
129 | (*SSLRecordSetProtocolVersionFunc) (SSLRecordContextRef ref, | |
130 | SSLProtocolVersion protocolVersion); | |
131 | ||
132 | typedef int | |
133 | (*SSLRecordFreeFunc) (SSLRecordContextRef ref, | |
134 | SSLRecord rec); | |
135 | ||
136 | typedef int | |
137 | (*SSLRecordServiceWriteQueueFunc) (SSLRecordContextRef ref); | |
138 | ||
139 | ||
140 | struct SSLRecordFuncs | |
141 | { SSLRecordReadFunc read; | |
142 | SSLRecordWriteFunc write; | |
143 | SSLRecordInitPendingCiphersFunc initPendingCiphers; | |
144 | SSLRecordAdvanceWriteCipherFunc advanceWriteCipher; | |
145 | SSLRecordRollbackWriteCipherFunc rollbackWriteCipher; | |
146 | SSLRecordAdvanceReadCipherFunc advanceReadCipher; | |
147 | SSLRecordSetProtocolVersionFunc setProtocolVersion; | |
148 | SSLRecordFreeFunc free; | |
149 | SSLRecordServiceWriteQueueFunc serviceWriteQueue; | |
150 | }; | |
151 | ||
152 | #endif /* _SSLTYPES_H_ */ |