Coverage report: /home/ellis/comp/core/ffi/rustls/types.lisp

KindCoveredAll%
expression053 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; rustls/types.lisp --- Rustls FFI Types
2
 
3
 ;;
4
 
5
 ;;; Code:
6
 (in-package :rustls)
7
 
8
 (define-alien-enum (rustls-handshake-kind int)
9
   :unknown 0
10
   :full 1
11
   :full-with-hello-retry-request 2
12
   :resumed 3)
13
 
14
 (define-alien-enum (rustls-result unsigned-int)
15
   :ok 7000
16
   :io 7001
17
   :null-parameter 7002
18
   :invalid-dns-name-error 7003
19
   :panic 7004
20
   :certificate-parse-error 7005
21
   :private-key-parse-error 7006
22
   :insufficient-size 7007
23
   :not-found 7008
24
   :invalid-parameter 7009
25
   :unexpected-eof 7010
26
   :plaintext-empty 7011
27
   :acceptor-not-ready 7012
28
   :already-used 7013
29
   :certificate-revocation-list-parse-error 7014
30
   :no-server-cert-verifier 7015
31
   :no-default-crypto-provider 7016
32
   :get-random-failed 7017
33
   :no-cert-resolver 7018
34
   :hpke-error 7019
35
   :builder-incompatible-tls-versions 7020
36
   :no-certificates-presented 7101
37
   :decrypt-error 7102
38
   :failed-to-get-current-time 7103
39
   :failed-to-get-random-bytes 7113
40
   :handshake-not-complete 7104
41
   :peer-sent-oversized-record 7105
42
   :no-application-protocol 7106
43
   :bad-max-fragment-size 7114
44
   :unsupported-name-type 7115
45
   :encrypt-error 7116
46
   :cert-encoding-bad 7121
47
   :cert-expired 7122
48
   :cert-not-yet-valid 7123
49
   :cert-revoked 7124
50
   :cert-unhandled-critical-extension 7125
51
   :cert-unknown-issuer 7126
52
   :cert-bad-signature 7127
53
   :cert-not-valid-for-name 7128
54
   :cert-invalid-purpose 7129
55
   :cert-application-verification-failure 7130
56
   :cert-other-error 7131
57
   :message-handshake-payload-too-large 7133
58
   :message-invalid-ccs 7134
59
   :message-invalid-content-type 7135
60
   :message-invalid-cert-status-type 7136
61
   :message-invalid-cert-request 7137
62
   :message-invalid-dh-params 7138
63
   :message-invalid-empty-payload 7139
64
   :message-invalid-key-update 7140
65
   :message-invalid-server-name 7141
66
   :message-too-large 7142
67
   :message-too-short 7143
68
   :message-missing-data 7144
69
   :message-missing-key-exchange 7145
70
   :message-no-signature-schemes 7146
71
   :message-trailing-data 7147
72
   :message-unexpected-message 7148
73
   :message-unknown-protocol-version 7149
74
   :message-unsupported-compression 7150
75
   :message-unsupported-curve-type 7151
76
   :message-unsupported-key-exchange-algorithm 7152
77
   :message-invalid-other 7153
78
   :peer-incompatible-error 7107
79
   :peer-misbehaved-error 7108
80
   :inappropriate-message 7109
81
   :inappropriate-handshake-message 7110
82
   :general 7112
83
   :alert-close-notify 7200
84
   :alert-unexpected-message 7201
85
   :alert-bad-record-mac 7202
86
   :alert-decryption-failed 7203
87
   :alert-record-overflow 7204
88
   :alert-decompression-failure 7205
89
   :alert-handshake-failure 7206
90
   :alert-no-certificate 7207
91
   :alert-bad-certificate 7208
92
   :alert-unsupported-certificate 7209
93
   :alert-certificate-revoked 7210
94
   :alert-certificate-expired 7211
95
   :alert-certificate-unknown 7212
96
   :alert-illegal-parameter 7213
97
   :alert-unknown-ca 7214
98
   :alert-access-denied 7215
99
   :alert-decode-error 7216
100
   :alert-decrypt-error 7217
101
   :alert-export-restriction 7218
102
   :alert-protocol-version 7219
103
   :alert-insufficient-security 7220
104
   :alert-internal-error 7221
105
   :alert-inappropriate-fallback 7222
106
   :alert-user-canceled 7223
107
   :alert-no-renegotiation 7224
108
   :alert-missing-extension 7225
109
   :alert-unsupported-extension 7226
110
   :alert-certificate-unobtainable 7227
111
   :alert-unrecognised-name 7228
112
   :alert-bad-certificate-status-response 7229
113
   :alert-bad-certificate-hash-value 7230
114
   :alert-unknown-psk-identity 7231
115
   :alert-certificate-required 7232
116
   :alert-no-application-protocol 7233
117
   :alert-unknown 7234
118
   :cert-revocation-list-bad-signature 7400
119
   :cert-revocation-list-invalid-crl-number 7401
120
   :cert-revocation-list-invalid-revoked-cert-serial-number 7402
121
   :cert-revocation-list-issuer-invalid-for-crl 7403
122
   :cert-revocation-list-other-error 7404
123
   :cert-revocation-list-parse-error 7405
124
   :cert-revocation-list-unsupported-crl-version 7406
125
   :cert-revocation-list-unsupported-critical-extension 7407
126
   :cert-revocation-list-unsupported-delta-crl 7408
127
   :cert-revocation-list-unsupported-indirect-crl 7409
128
   :cert-revocation-list-unsupported-revocation-reason 7410
129
   :client-cert-verifier-builder-no-root-anchors 7500)
130
 
131
 (define-alien-enum (rustls-tls-version int)
132
   :unknown 0
133
   :sslv2 512
134
   :sslv3 768
135
   :tlsv1-0 769
136
   :tlsv1-1 770
137
   :tlsv1-2 771
138
   :tlsv1-3 772)
139
 
140
 (define-alien-type rustls-crypto-provider (struct rustls-crypto-provider))
141
 (define-alien-type rustls-crypto-provider-builder (struct rustls-crypto-provider-builder))
142
 (define-alien-type rustls-signing-key (struct rustls-signing-key))
143
 
144
 (define-alien-type rustls-accepted (struct rustls-accepted))
145
 
146
 (define-alien-type rustls-accepted-alert (struct rustls-accepted-alert))
147
 
148
 (define-alien-type rustls-acceptor (struct rustls-acceptor))
149
 
150
 (define-alien-type rustls-certificate (struct rustls-certificate))
151
 
152
 (define-alien-type rustls-hpke (struct rustls-hpke))
153
 
154
 (define-alien-type rustls-certified-key (struct rustls-certified-key))
155
 
156
 (define-alien-type rustls-client-cert-verifier (struct rustls-client-cert-verifier))
157
 
158
 (define-alien-type rustls-client-config (struct rustls-client-config))
159
 
160
 (define-alien-type rustls-client-config-builder (struct rustls-client-config-builder))
161
 
162
 (define-alien-type rustls-connection (struct rustls-connection))
163
 
164
 (define-alien-type rustls-iovec (struct rustls-iovec))
165
 
166
 (define-alien-type rustls-root-cert-store (struct rustls-root-cert-store))
167
 
168
 (define-alien-type rustls-root-cert-store-builder (struct rustls-root-cert-store-builder))
169
 
170
 (define-alien-type rustls-server-cert-verifier (struct rustls-server-cert-verifier))
171
 
172
 (define-alien-type rustls-server-config (struct rustls-server-config))
173
 
174
 (define-alien-type rustls-server-config-builder (struct rustls-server-config-builder))
175
 
176
 (define-alien-type rustls-slice-slice-bytes 
177
     (struct rustls-slice-slice-bytes
178
       (data (* unsigned-char))
179
       (len size-t)))
180
 
181
 (define-alien-type rustls-slice-str (struct rustls-slice-str))
182
 
183
 (define-alien-type rustls-supported-ciphersuite (struct rustls-supported-ciphersuite))
184
 
185
 (define-alien-type rustls-web-pki-client-cert-verifier (struct rustls-web-pki-client-cert-verifier))
186
 
187
 (define-alien-type rustls-web-pki-server-cert-verifier (struct rustls-web-pki-server-cert-verifier))
188
 
189
 (define-alien-type rustls-str 
190
     (struct rustls-str
191
       (data (* char))
192
       (len size-t)))
193
 
194
 (define-alien-type rustls-io-result int)
195
 
196
 (define-alien-type rustls-slice-bytes 
197
     (struct rustls-slice-bytes
198
       (data (* unsigned-char))
199
       (len size-t)))
200
 
201
 (define-alien-type rustls-verify-server-cert-user-data (* t))
202
 
203
 (define-alien-type rustls-verify-server-cert-params 
204
     (struct rustls-verify-server-cert-params
205
       (end-entity-cert-der rustls-slice-bytes)
206
       (intermediate-certs-der (* rustls-slice-slice-bytes))
207
       (server-name rustls-str)
208
       (ocsp-response rustls-slice-bytes)))
209
 
210
 (define-alien-type rustls-verify-server-cert-callback
211
     (function unsigned-int
212
         rustls-verify-server-cert-user-data ; userdata
213
         (* rustls-verify-server-cert-params))) ; params
214
 
215
 (define-alien-type rustls-log-level size-t)
216
 
217
 (define-alien-type rustls-log-params 
218
     (struct rustls-log-params
219
       (level rustls-log-level)
220
       (message rustls-str)))
221
 
222
 (define-alien-type rustls-log-callback
223
     (function void
224
         (* t) ; userdata
225
         (* rustls-log-params))) ; params
226
 
227
 (define-alien-type rustls-keylog-log-callback
228
     (function void
229
         rustls-str ; label
230
         (* unsigned-char) ; client-random
231
       size-t ; client-random-len
232
       (* unsigned-char) ; secret
233
       size-t)) ; secret-len
234
 
235
 (define-alien-type rustls-keylog-will-log-callback 
236
     (function int 
237
         rustls-str)) ; label
238
         
239
 (define-alien-type rustls-client-hello-userdata (* t))
240
 
241
 (define-alien-type rustls-slice-u16 
242
     (struct rustls-slice-u16
243
       (data (* unsigned-short))
244
       (len size-t)))
245
 
246
 (define-alien-type rustls-client-hello 
247
     (struct rustls-client-hello
248
       (server-name rustls-str)
249
       (signature-schemes rustls-slice-u16)
250
       (alpn (* rustls-slice-slice-bytes))))
251
 
252
 (define-alien-type rustls-certified-key (struct rustls-certified-key))
253
 
254
 #|
255
 * NOTE:
256
 * - the passed in `hello` and all its values are only available during the
257
 *   callback invocations.
258
 * - the passed callback function must be safe to call multiple times concurrently
259
 *   with the same userdata, unless there is only a single config and connection
260
 *   where it is installed.
261
 |#
262
 (define-alien-type rustls-client-hello-callback 
263
     (function (* rustls-certified-key)
264
         rustls-client-hello-userdata ; userdata
265
         (* rustls-client-hello))) ; hello
266
 
267
 (define-alien-type rustls-session-store-userdata (* t))
268
 
269
 (define-alien-type rustls-session-store-get-callback
270
     (function unsigned-int
271
         rustls-session-store-userdata ; userdata
272
         (* rustls-slice-bytes) ; key
273
       int ; remove-after
274
       (* unsigned-char) ; buf
275
       size-t ; count
276
       (* size-t))) ; out-n
277
 
278
 (define-alien-type rustls-session-store-put-callback
279
     (function unsigned-int
280
         rustls-session-store-userdata ; userdata
281
         (* rustls-slice-bytes) ; key
282
       (* rustls-slice-bytes))) ; val
283
 
284
 (define-alien-type rustls-supported-ciphersuite (struct rustls-supported-ciphersuite))
285
 
286
 (define-alien-type rustls-web-pki-client-cert-verifier-builder (struct rustls-web-pki-client-vert-verifier-builder))
287
 
288
 (define-alien-type rustls-web-pki-server-cert-verifier-builder (struct rustls-web-pki-server-cert-verifier-builder))
289
 
290
 (define-alien-type rustls-read-callback
291
     (function rustls-io-result
292
         (* t) ; userdata
293
         (* unsigned-char) ; buf
294
       size-t ; n
295
       (* size-t))) ; out-n
296
 
297
 (define-alien-type rustls-write-callback
298
     (function rustls-io-result
299
         (* t) ; userdata
300
         (* unsigned-char) ; buf
301
       size-t ; n
302
       (* size-t))) ; out-n
303
 
304
 (define-alien-type rustls-write-vectored-callback
305
     (function rustls-io-result
306
         (* t) ; userdata
307
         (* rustls-iovec) ; iov
308
       size-t ; count
309
       (* size-t))) ; out-n
310