-
Notifications
You must be signed in to change notification settings - Fork 71
/
SqueakSSL.h
156 lines (133 loc) · 4.99 KB
/
SqueakSSL.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef SqueakSSL_H
#define SqueakSSL_H
/**********************************************************/
/* SqueakSSL Version Information */
/* Version 1: Inital version */
/* Version 2: SNI support by Levente Uzonyi and help by */
/* Marcel Taeumel and Tobias Pape */
/* Version 3: Verification support in macOS */
/**********************************************************/
#define SQSSL_VERSION 3
/*************************/
/* SSL connection states */
/*************************/
#define SQSSL_UNUSED 0
#define SQSSL_ACCEPTING 1
#define SQSSL_CONNECTING 2
#define SQSSL_CONNECTED 3
/********************************************/
/* Return codes from the core SSL functions */
/********************************************/
#define SQSSL_OK 0
#define SQSSL_NEED_MORE_DATA -1
#define SQSSL_INVALID_STATE -2
#define SQSSL_BUFFER_TOO_SMALL -3
#define SQSSL_INPUT_TOO_LARGE -4
#define SQSSL_GENERIC_ERROR -5
#define SQSSL_OUT_OF_MEMORY -6
/**************************************/
/* SqueakSSL certificate status bits. */
/**************************************/
#define SQSSL_NO_CERTIFICATE -1
#define SQSSL_OTHER_ISSUE 0x0001
#define SQSSL_UNTRUSTED_ROOT 0x0002
#define SQSSL_CERT_EXPIRED 0x0004
#define SQSSL_WRONG_USAGE 0x0008
#define SQSSL_INVALID_CN 0x0010
#define SQSSL_CERT_REVOKED 0x0020
/****************************************/
/* SqueakSSL getInt/setInt property IDs */
/****************************************/
#define SQSSL_PROP_VERSION 0
#define SQSSL_PROP_LOGLEVEL 1
#define SQSSL_PROP_SSLSTATE 2
#define SQSSL_PROP_CERTSTATE 3
/**********************************************/
/* SqueakSSL getString/setString property IDs */
/**********************************************/
#define SQSSL_PROP_PEERNAME 0
#define SQSSL_PROP_CERTNAME 1
#define SQSSL_PROP_SERVERNAME 2
/* sqCreateSSL: Creates a new SSL instance.
Arguments: None.
Returns: SSL handle.
*/
sqInt sqCreateSSL(void);
/* sqDestroySSL: Destroys an SSL instance.
Arguments:
handle - the SSL handle
Returns: Non-zero if successful.
*/
sqInt sqDestroySSL(sqInt handle);
/* sqAcceptSSL: Start/continue an SSL server handshake.
Arguments:
handle - the SSL handle
srcBuf - the input token sent by the remote peer
srcLen - the size of the input token
dstBuf - the output buffer for a new token
dstLen - the size of the output buffer
Returns: The size of the output token or an error code.
*/
sqInt sqAcceptSSL(sqInt handle, char* srcBuf, sqInt srcLen, char *dstBuf, sqInt dstLen);
/* sqConnectSSL: Start/continue an SSL client handshake.
Arguments:
handle - the SSL handle
srcBuf - the input token sent by the remote peer
srcLen - the size of the input token
dstBuf - the output buffer for a new token
dstLen - the size of the output buffer
Returns: The size of the output token or an error code.
*/
sqInt sqConnectSSL(sqInt handle, char* srcBuf, sqInt srcLen, char *dstBuf, sqInt dstLen);
/* sqEncryptSSL: Encrypt data for SSL transmission.
Arguments:
handle - the SSL handle
srcBuf - the unencrypted input data
srcLen - the size of the input data
dstBuf - the output buffer for the encrypted contents
dstLen - the size of the output buffer
Returns: The size of the output generated or an error code.
*/
sqInt sqEncryptSSL(sqInt handle, char* srcBuf, sqInt srcLen, char *dstBuf, sqInt dstLen);
/* sqDecryptSSL: Decrypt data for SSL transmission.
Arguments:
handle - the SSL handle
srcBuf - the encrypted input data
srcLen - the size of the input data
dstBuf - the output buffer for the decrypted contents
dstLen - the size of the output buffer
Returns: The size of the output generated or an error code.
*/
sqInt sqDecryptSSL(sqInt handle, char* srcBuf, sqInt srcLen, char *dstBuf, sqInt dstLen);
/* sqGetStringPropertySSL: Retrieve a string property from SSL.
Arguments:
handle - the ssl handle
propID - the property id to retrieve
Returns: The string value of the property.
*/
char* sqGetStringPropertySSL(sqInt handle, int propID);
/* sqSetStringPropertySSL: Set a string property in SSL.
Arguments:
handle - the ssl handle
propID - the property id to retrieve
propName - the property string
propLen - the length of the property string
Returns: Non-zero if successful.
*/
sqInt sqSetStringPropertySSL(sqInt handle, int propID, char *propName, sqInt propLen);
/* sqGetIntPropertySSL: Retrieve an integer property from SSL.
Arguments:
handle - the ssl handle
propID - the property id to retrieve
Returns: The integer value of the property.
*/
sqInt sqGetIntPropertySSL(sqInt handle, sqInt propID);
/* sqSetIntPropertySSL: Set an integer property in SSL.
Arguments:
handle - the ssl handle
propID - the property id to retrieve
propValue - the property value
Returns: Non-zero if successful.
*/
sqInt sqSetIntPropertySSL(sqInt handle, sqInt propID, sqInt propValue);
#endif