/src/openssl30/ssl/t1_enc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * Copyright 2005 Nokia. All rights reserved. |
4 | | * |
5 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
6 | | * this file except in compliance with the License. You can obtain a copy |
7 | | * in the file LICENSE in the source distribution or at |
8 | | * https://www.openssl.org/source/license.html |
9 | | */ |
10 | | |
11 | | #include <stdio.h> |
12 | | #include "ssl_local.h" |
13 | | #include "record/record_local.h" |
14 | | #include "internal/ktls.h" |
15 | | #include "internal/cryptlib.h" |
16 | | #include <openssl/comp.h> |
17 | | #include <openssl/evp.h> |
18 | | #include <openssl/kdf.h> |
19 | | #include <openssl/rand.h> |
20 | | #include <openssl/obj_mac.h> |
21 | | #include <openssl/core_names.h> |
22 | | #include <openssl/trace.h> |
23 | | |
24 | | /* seed1 through seed5 are concatenated */ |
25 | | static int tls1_PRF(SSL *s, |
26 | | const void *seed1, size_t seed1_len, |
27 | | const void *seed2, size_t seed2_len, |
28 | | const void *seed3, size_t seed3_len, |
29 | | const void *seed4, size_t seed4_len, |
30 | | const void *seed5, size_t seed5_len, |
31 | | const unsigned char *sec, size_t slen, |
32 | | unsigned char *out, size_t olen, int fatal) |
33 | 11.6k | { |
34 | 11.6k | const EVP_MD *md = ssl_prf_md(s); |
35 | 11.6k | EVP_KDF *kdf; |
36 | 11.6k | EVP_KDF_CTX *kctx = NULL; |
37 | 11.6k | OSSL_PARAM params[8], *p = params; |
38 | 11.6k | const char *mdname; |
39 | | |
40 | 11.6k | if (md == NULL) { |
41 | | /* Should never happen */ |
42 | 0 | if (fatal) |
43 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
44 | 0 | else |
45 | 0 | ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); |
46 | 0 | return 0; |
47 | 0 | } |
48 | 11.6k | kdf = EVP_KDF_fetch(s->ctx->libctx, OSSL_KDF_NAME_TLS1_PRF, s->ctx->propq); |
49 | 11.6k | if (kdf == NULL) |
50 | 0 | goto err; |
51 | 11.6k | kctx = EVP_KDF_CTX_new(kdf); |
52 | 11.6k | EVP_KDF_free(kdf); |
53 | 11.6k | if (kctx == NULL) |
54 | 0 | goto err; |
55 | 11.6k | mdname = EVP_MD_get0_name(md); |
56 | 11.6k | *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, |
57 | 11.6k | (char *)mdname, 0); |
58 | 11.6k | *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET, |
59 | 11.6k | (unsigned char *)sec, |
60 | 11.6k | (size_t)slen); |
61 | 11.6k | *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED, |
62 | 11.6k | (void *)seed1, (size_t)seed1_len); |
63 | 11.6k | *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED, |
64 | 11.6k | (void *)seed2, (size_t)seed2_len); |
65 | 11.6k | *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED, |
66 | 11.6k | (void *)seed3, (size_t)seed3_len); |
67 | 11.6k | *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED, |
68 | 11.6k | (void *)seed4, (size_t)seed4_len); |
69 | 11.6k | *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED, |
70 | 11.6k | (void *)seed5, (size_t)seed5_len); |
71 | 11.6k | *p = OSSL_PARAM_construct_end(); |
72 | 11.6k | if (EVP_KDF_derive(kctx, out, olen, params)) { |
73 | 11.6k | EVP_KDF_CTX_free(kctx); |
74 | 11.6k | return 1; |
75 | 11.6k | } |
76 | | |
77 | 0 | err: |
78 | 0 | if (fatal) |
79 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
80 | 0 | else |
81 | 0 | ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); |
82 | 0 | EVP_KDF_CTX_free(kctx); |
83 | 0 | return 0; |
84 | 11.6k | } |
85 | | |
86 | | static int tls1_generate_key_block(SSL *s, unsigned char *km, size_t num) |
87 | 5.93k | { |
88 | 5.93k | int ret; |
89 | | |
90 | | /* Calls SSLfatal() as required */ |
91 | 5.93k | ret = tls1_PRF(s, |
92 | 5.93k | TLS_MD_KEY_EXPANSION_CONST, |
93 | 5.93k | TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3.server_random, |
94 | 5.93k | SSL3_RANDOM_SIZE, s->s3.client_random, SSL3_RANDOM_SIZE, |
95 | 5.93k | NULL, 0, NULL, 0, s->session->master_key, |
96 | 5.93k | s->session->master_key_length, km, num, 1); |
97 | | |
98 | 5.93k | return ret; |
99 | 5.93k | } |
100 | | |
101 | | #ifndef OPENSSL_NO_KTLS |
102 | | /* |
103 | | * Count the number of records that were not processed yet from record boundary. |
104 | | * |
105 | | * This function assumes that there are only fully formed records read in the |
106 | | * record layer. If read_ahead is enabled, then this might be false and this |
107 | | * function will fail. |
108 | | */ |
109 | | # ifndef OPENSSL_NO_KTLS_RX |
110 | | static int count_unprocessed_records(SSL *s) |
111 | | { |
112 | | SSL3_BUFFER *rbuf = RECORD_LAYER_get_rbuf(&s->rlayer); |
113 | | PACKET pkt, subpkt; |
114 | | int count = 0; |
115 | | |
116 | | if (!PACKET_buf_init(&pkt, rbuf->buf + rbuf->offset, rbuf->left)) |
117 | | return -1; |
118 | | |
119 | | while (PACKET_remaining(&pkt) > 0) { |
120 | | /* Skip record type and version */ |
121 | | if (!PACKET_forward(&pkt, 3)) |
122 | | return -1; |
123 | | |
124 | | /* Read until next record */ |
125 | | if (!PACKET_get_length_prefixed_2(&pkt, &subpkt)) |
126 | | return -1; |
127 | | |
128 | | count += 1; |
129 | | } |
130 | | |
131 | | return count; |
132 | | } |
133 | | # endif |
134 | | #endif |
135 | | |
136 | | |
137 | | int tls_provider_set_tls_params(SSL *s, EVP_CIPHER_CTX *ctx, |
138 | | const EVP_CIPHER *ciph, |
139 | | const EVP_MD *md) |
140 | 2.31k | { |
141 | | /* |
142 | | * Provided cipher, the TLS padding/MAC removal is performed provider |
143 | | * side so we need to tell the ctx about our TLS version and mac size |
144 | | */ |
145 | 2.31k | OSSL_PARAM params[3], *pprm = params; |
146 | 2.31k | size_t macsize = 0; |
147 | 2.31k | int imacsize = -1; |
148 | | |
149 | 2.31k | if ((EVP_CIPHER_get_flags(ciph) & EVP_CIPH_FLAG_AEAD_CIPHER) == 0 |
150 | | /* |
151 | | * We look at s->ext.use_etm instead of SSL_READ_ETM() or |
152 | | * SSL_WRITE_ETM() because this test applies to both reading |
153 | | * and writing. |
154 | | */ |
155 | 2.31k | && !s->ext.use_etm) |
156 | 1.09k | imacsize = EVP_MD_get_size(md); |
157 | 2.31k | if (imacsize >= 0) |
158 | 1.09k | macsize = (size_t)imacsize; |
159 | | |
160 | 2.31k | *pprm++ = OSSL_PARAM_construct_int(OSSL_CIPHER_PARAM_TLS_VERSION, |
161 | 2.31k | &s->version); |
162 | 2.31k | *pprm++ = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_TLS_MAC_SIZE, |
163 | 2.31k | &macsize); |
164 | 2.31k | *pprm = OSSL_PARAM_construct_end(); |
165 | | |
166 | 2.31k | if (!EVP_CIPHER_CTX_set_params(ctx, params)) { |
167 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
168 | 0 | return 0; |
169 | 0 | } |
170 | | |
171 | 2.31k | return 1; |
172 | 2.31k | } |
173 | | |
174 | | |
175 | | static int tls_iv_length_within_key_block(const EVP_CIPHER *c) |
176 | 8.85k | { |
177 | | /* If GCM/CCM mode only part of IV comes from PRF */ |
178 | 8.85k | if (EVP_CIPHER_get_mode(c) == EVP_CIPH_GCM_MODE) |
179 | 1.29k | return EVP_GCM_TLS_FIXED_IV_LEN; |
180 | 7.55k | else if (EVP_CIPHER_get_mode(c) == EVP_CIPH_CCM_MODE) |
181 | 291 | return EVP_CCM_TLS_FIXED_IV_LEN; |
182 | 7.26k | else |
183 | 7.26k | return EVP_CIPHER_get_iv_length(c); |
184 | 8.85k | } |
185 | | |
186 | | int tls1_change_cipher_state(SSL *s, int which) |
187 | 1.94k | { |
188 | 1.94k | unsigned char *p, *mac_secret; |
189 | 1.94k | unsigned char *ms, *key, *iv; |
190 | 1.94k | EVP_CIPHER_CTX *dd; |
191 | 1.94k | const EVP_CIPHER *c; |
192 | 1.94k | #ifndef OPENSSL_NO_COMP |
193 | 1.94k | const SSL_COMP *comp; |
194 | 1.94k | #endif |
195 | 1.94k | const EVP_MD *m; |
196 | 1.94k | int mac_type; |
197 | 1.94k | size_t *mac_secret_size; |
198 | 1.94k | EVP_MD_CTX *mac_ctx; |
199 | 1.94k | EVP_PKEY *mac_key; |
200 | 1.94k | size_t n, i, j, k, cl; |
201 | 1.94k | int reuse_dd = 0; |
202 | | #ifndef OPENSSL_NO_KTLS |
203 | | ktls_crypto_info_t crypto_info; |
204 | | unsigned char *rec_seq; |
205 | | void *rl_sequence; |
206 | | # ifndef OPENSSL_NO_KTLS_RX |
207 | | int count_unprocessed; |
208 | | int bit; |
209 | | # endif |
210 | | BIO *bio; |
211 | | #endif |
212 | | |
213 | 1.94k | c = s->s3.tmp.new_sym_enc; |
214 | 1.94k | m = s->s3.tmp.new_hash; |
215 | 1.94k | mac_type = s->s3.tmp.new_mac_pkey_type; |
216 | 1.94k | #ifndef OPENSSL_NO_COMP |
217 | 1.94k | comp = s->s3.tmp.new_compression; |
218 | 1.94k | #endif |
219 | | |
220 | 1.94k | if (which & SSL3_CC_READ) { |
221 | 682 | if (s->ext.use_etm) |
222 | 96 | s->s3.flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_READ; |
223 | 586 | else |
224 | 586 | s->s3.flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_READ; |
225 | | |
226 | 682 | if (s->s3.tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC) |
227 | 0 | s->mac_flags |= SSL_MAC_FLAG_READ_MAC_STREAM; |
228 | 682 | else |
229 | 682 | s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM; |
230 | | |
231 | 682 | if (s->s3.tmp.new_cipher->algorithm2 & TLS1_TLSTREE) |
232 | 0 | s->mac_flags |= SSL_MAC_FLAG_READ_MAC_TLSTREE; |
233 | 682 | else |
234 | 682 | s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_TLSTREE; |
235 | | |
236 | 682 | if (s->enc_read_ctx != NULL) { |
237 | 0 | reuse_dd = 1; |
238 | 682 | } else if ((s->enc_read_ctx = EVP_CIPHER_CTX_new()) == NULL) { |
239 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE); |
240 | 0 | goto err; |
241 | 682 | } else { |
242 | | /* |
243 | | * make sure it's initialised in case we exit later with an error |
244 | | */ |
245 | 682 | EVP_CIPHER_CTX_reset(s->enc_read_ctx); |
246 | 682 | } |
247 | 682 | dd = s->enc_read_ctx; |
248 | 682 | mac_ctx = ssl_replace_hash(&s->read_hash, NULL); |
249 | 682 | if (mac_ctx == NULL) { |
250 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
251 | 0 | goto err; |
252 | 0 | } |
253 | 682 | #ifndef OPENSSL_NO_COMP |
254 | 682 | COMP_CTX_free(s->expand); |
255 | 682 | s->expand = NULL; |
256 | 682 | if (comp != NULL) { |
257 | 0 | s->expand = COMP_CTX_new(comp->method); |
258 | 0 | if (s->expand == NULL) { |
259 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, |
260 | 0 | SSL_R_COMPRESSION_LIBRARY_ERROR); |
261 | 0 | goto err; |
262 | 0 | } |
263 | 0 | } |
264 | 682 | #endif |
265 | | /* |
266 | | * this is done by dtls1_reset_seq_numbers for DTLS |
267 | | */ |
268 | 682 | if (!SSL_IS_DTLS(s)) |
269 | 682 | RECORD_LAYER_reset_read_sequence(&s->rlayer); |
270 | 682 | mac_secret = &(s->s3.read_mac_secret[0]); |
271 | 682 | mac_secret_size = &(s->s3.read_mac_secret_size); |
272 | 1.25k | } else { |
273 | 1.25k | s->statem.enc_write_state = ENC_WRITE_STATE_INVALID; |
274 | 1.25k | if (s->ext.use_etm) |
275 | 88 | s->s3.flags |= TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE; |
276 | 1.17k | else |
277 | 1.17k | s->s3.flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE; |
278 | | |
279 | 1.25k | if (s->s3.tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC) |
280 | 0 | s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM; |
281 | 1.25k | else |
282 | 1.25k | s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM; |
283 | | |
284 | 1.25k | if (s->s3.tmp.new_cipher->algorithm2 & TLS1_TLSTREE) |
285 | 0 | s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_TLSTREE; |
286 | 1.25k | else |
287 | 1.25k | s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_TLSTREE; |
288 | 1.25k | if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s)) { |
289 | 0 | reuse_dd = 1; |
290 | 1.25k | } else if ((s->enc_write_ctx = EVP_CIPHER_CTX_new()) == NULL) { |
291 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE); |
292 | 0 | goto err; |
293 | 0 | } |
294 | 1.25k | dd = s->enc_write_ctx; |
295 | 1.25k | if (SSL_IS_DTLS(s)) { |
296 | 0 | mac_ctx = EVP_MD_CTX_new(); |
297 | 0 | if (mac_ctx == NULL) { |
298 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE); |
299 | 0 | goto err; |
300 | 0 | } |
301 | 0 | s->write_hash = mac_ctx; |
302 | 1.25k | } else { |
303 | 1.25k | mac_ctx = ssl_replace_hash(&s->write_hash, NULL); |
304 | 1.25k | if (mac_ctx == NULL) { |
305 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE); |
306 | 0 | goto err; |
307 | 0 | } |
308 | 1.25k | } |
309 | 1.25k | #ifndef OPENSSL_NO_COMP |
310 | 1.25k | COMP_CTX_free(s->compress); |
311 | 1.25k | s->compress = NULL; |
312 | 1.25k | if (comp != NULL) { |
313 | 0 | s->compress = COMP_CTX_new(comp->method); |
314 | 0 | if (s->compress == NULL) { |
315 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, |
316 | 0 | SSL_R_COMPRESSION_LIBRARY_ERROR); |
317 | 0 | goto err; |
318 | 0 | } |
319 | 0 | } |
320 | 1.25k | #endif |
321 | | /* |
322 | | * this is done by dtls1_reset_seq_numbers for DTLS |
323 | | */ |
324 | 1.25k | if (!SSL_IS_DTLS(s)) |
325 | 1.25k | RECORD_LAYER_reset_write_sequence(&s->rlayer); |
326 | 1.25k | mac_secret = &(s->s3.write_mac_secret[0]); |
327 | 1.25k | mac_secret_size = &(s->s3.write_mac_secret_size); |
328 | 1.25k | } |
329 | | |
330 | 1.94k | if (reuse_dd) |
331 | 0 | EVP_CIPHER_CTX_reset(dd); |
332 | | |
333 | 1.94k | p = s->s3.tmp.key_block; |
334 | 1.94k | i = *mac_secret_size = s->s3.tmp.new_mac_secret_size; |
335 | | |
336 | 1.94k | cl = EVP_CIPHER_get_key_length(c); |
337 | 1.94k | j = cl; |
338 | 1.94k | k = tls_iv_length_within_key_block(c); |
339 | 1.94k | if ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) || |
340 | 1.94k | (which == SSL3_CHANGE_CIPHER_SERVER_READ)) { |
341 | 1.57k | ms = &(p[0]); |
342 | 1.57k | n = i + i; |
343 | 1.57k | key = &(p[n]); |
344 | 1.57k | n += j + j; |
345 | 1.57k | iv = &(p[n]); |
346 | 1.57k | n += k + k; |
347 | 1.57k | } else { |
348 | 363 | n = i; |
349 | 363 | ms = &(p[n]); |
350 | 363 | n += i + j; |
351 | 363 | key = &(p[n]); |
352 | 363 | n += j + k; |
353 | 363 | iv = &(p[n]); |
354 | 363 | n += k; |
355 | 363 | } |
356 | | |
357 | 1.94k | if (n > s->s3.tmp.key_block_length) { |
358 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
359 | 0 | goto err; |
360 | 0 | } |
361 | | |
362 | 1.94k | memcpy(mac_secret, ms, i); |
363 | | |
364 | 1.94k | if (!(EVP_CIPHER_get_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER)) { |
365 | 903 | if (mac_type == EVP_PKEY_HMAC) { |
366 | 903 | mac_key = EVP_PKEY_new_raw_private_key_ex(s->ctx->libctx, "HMAC", |
367 | 903 | s->ctx->propq, mac_secret, |
368 | 903 | *mac_secret_size); |
369 | 903 | } else { |
370 | | /* |
371 | | * If its not HMAC then the only other types of MAC we support are |
372 | | * the GOST MACs, so we need to use the old style way of creating |
373 | | * a MAC key. |
374 | | */ |
375 | 0 | mac_key = EVP_PKEY_new_mac_key(mac_type, NULL, mac_secret, |
376 | 0 | (int)*mac_secret_size); |
377 | 0 | } |
378 | 903 | if (mac_key == NULL |
379 | 903 | || EVP_DigestSignInit_ex(mac_ctx, NULL, EVP_MD_get0_name(m), |
380 | 903 | s->ctx->libctx, s->ctx->propq, mac_key, |
381 | 903 | NULL) <= 0) { |
382 | 0 | EVP_PKEY_free(mac_key); |
383 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
384 | 0 | goto err; |
385 | 0 | } |
386 | 903 | EVP_PKEY_free(mac_key); |
387 | 903 | } |
388 | | |
389 | 1.94k | OSSL_TRACE_BEGIN(TLS) { |
390 | 0 | BIO_printf(trc_out, "which = %04X, mac key:\n", which); |
391 | 0 | BIO_dump_indent(trc_out, ms, i, 4); |
392 | 1.94k | } OSSL_TRACE_END(TLS); |
393 | | |
394 | 1.94k | if (EVP_CIPHER_get_mode(c) == EVP_CIPH_GCM_MODE) { |
395 | 444 | if (!EVP_CipherInit_ex(dd, c, NULL, key, NULL, (which & SSL3_CC_WRITE)) |
396 | 444 | || EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_GCM_SET_IV_FIXED, (int)k, |
397 | 444 | iv) <= 0) { |
398 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
399 | 0 | goto err; |
400 | 0 | } |
401 | 1.49k | } else if (EVP_CIPHER_get_mode(c) == EVP_CIPH_CCM_MODE) { |
402 | 72 | int taglen; |
403 | 72 | if (s->s3.tmp. |
404 | 72 | new_cipher->algorithm_enc & (SSL_AES128CCM8 | SSL_AES256CCM8)) |
405 | 50 | taglen = EVP_CCM8_TLS_TAG_LEN; |
406 | 22 | else |
407 | 22 | taglen = EVP_CCM_TLS_TAG_LEN; |
408 | 72 | if (!EVP_CipherInit_ex(dd, c, NULL, NULL, NULL, (which & SSL3_CC_WRITE)) |
409 | 72 | || (EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_IVLEN, 12, NULL) <= 0) |
410 | 72 | || (EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_TAG, taglen, NULL) <= 0) |
411 | 72 | || (EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_CCM_SET_IV_FIXED, (int)k, iv) <= 0) |
412 | 72 | || !EVP_CipherInit_ex(dd, NULL, NULL, key, NULL, -1)) { |
413 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
414 | 0 | goto err; |
415 | 0 | } |
416 | 1.42k | } else { |
417 | 1.42k | if (!EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE))) { |
418 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
419 | 0 | goto err; |
420 | 0 | } |
421 | 1.42k | } |
422 | | /* Needed for "composite" AEADs, such as RC4-HMAC-MD5 */ |
423 | 1.94k | if ((EVP_CIPHER_get_flags(c) & EVP_CIPH_FLAG_AEAD_CIPHER) |
424 | 1.94k | && *mac_secret_size |
425 | 1.94k | && EVP_CIPHER_CTX_ctrl(dd, EVP_CTRL_AEAD_SET_MAC_KEY, |
426 | 497 | (int)*mac_secret_size, mac_secret) <= 0) { |
427 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
428 | 0 | goto err; |
429 | 0 | } |
430 | 1.94k | if (EVP_CIPHER_get0_provider(c) != NULL |
431 | 1.94k | && !tls_provider_set_tls_params(s, dd, c, m)) { |
432 | | /* SSLfatal already called */ |
433 | 0 | goto err; |
434 | 0 | } |
435 | | |
436 | | #ifndef OPENSSL_NO_KTLS |
437 | | if (s->compress || (s->options & SSL_OP_ENABLE_KTLS) == 0) |
438 | | goto skip_ktls; |
439 | | |
440 | | /* ktls supports only the maximum fragment size */ |
441 | | if (ssl_get_max_send_fragment(s) != SSL3_RT_MAX_PLAIN_LENGTH) |
442 | | goto skip_ktls; |
443 | | |
444 | | /* check that cipher is supported */ |
445 | | if (!ktls_check_supported_cipher(s, c, dd)) |
446 | | goto skip_ktls; |
447 | | |
448 | | if (which & SSL3_CC_WRITE) |
449 | | bio = s->wbio; |
450 | | else |
451 | | bio = s->rbio; |
452 | | |
453 | | if (!ossl_assert(bio != NULL)) { |
454 | | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); |
455 | | goto err; |
456 | | } |
457 | | |
458 | | /* All future data will get encrypted by ktls. Flush the BIO or skip ktls */ |
459 | | if (which & SSL3_CC_WRITE) { |
460 | | if (BIO_flush(bio) <= 0) |
461 | | goto skip_ktls; |
462 | | } |
463 | | |
464 | | /* ktls doesn't support renegotiation */ |
465 | | if ((BIO_get_ktls_send(s->wbio) && (which & SSL3_CC_WRITE)) || |
466 | | (BIO_get_ktls_recv(s->rbio) && (which & SSL3_CC_READ))) { |
467 | | SSLfatal(s, SSL_AD_NO_RENEGOTIATION, ERR_R_INTERNAL_ERROR); |
468 | | goto err; |
469 | | } |
470 | | |
471 | | if (which & SSL3_CC_WRITE) |
472 | | rl_sequence = RECORD_LAYER_get_write_sequence(&s->rlayer); |
473 | | else |
474 | | rl_sequence = RECORD_LAYER_get_read_sequence(&s->rlayer); |
475 | | |
476 | | if (!ktls_configure_crypto(s, c, dd, rl_sequence, &crypto_info, &rec_seq, |
477 | | iv, key, ms, *mac_secret_size)) |
478 | | goto skip_ktls; |
479 | | |
480 | | if (which & SSL3_CC_READ) { |
481 | | # ifndef OPENSSL_NO_KTLS_RX |
482 | | count_unprocessed = count_unprocessed_records(s); |
483 | | if (count_unprocessed < 0) |
484 | | goto skip_ktls; |
485 | | |
486 | | /* increment the crypto_info record sequence */ |
487 | | while (count_unprocessed) { |
488 | | for (bit = 7; bit >= 0; bit--) { /* increment */ |
489 | | ++rec_seq[bit]; |
490 | | if (rec_seq[bit] != 0) |
491 | | break; |
492 | | } |
493 | | count_unprocessed--; |
494 | | } |
495 | | # else |
496 | | goto skip_ktls; |
497 | | # endif |
498 | | } |
499 | | |
500 | | /* ktls works with user provided buffers directly */ |
501 | | if (BIO_set_ktls(bio, &crypto_info, which & SSL3_CC_WRITE)) { |
502 | | if (which & SSL3_CC_WRITE) |
503 | | ssl3_release_write_buffer(s); |
504 | | SSL_set_options(s, SSL_OP_NO_RENEGOTIATION); |
505 | | } |
506 | | |
507 | | skip_ktls: |
508 | | #endif /* OPENSSL_NO_KTLS */ |
509 | 1.94k | s->statem.enc_write_state = ENC_WRITE_STATE_VALID; |
510 | | |
511 | 1.94k | OSSL_TRACE_BEGIN(TLS) { |
512 | 0 | BIO_printf(trc_out, "which = %04X, key:\n", which); |
513 | 0 | BIO_dump_indent(trc_out, key, EVP_CIPHER_get_key_length(c), 4); |
514 | 0 | BIO_printf(trc_out, "iv:\n"); |
515 | 0 | BIO_dump_indent(trc_out, iv, k, 4); |
516 | 1.94k | } OSSL_TRACE_END(TLS); |
517 | | |
518 | 1.94k | return 1; |
519 | 0 | err: |
520 | 0 | return 0; |
521 | 1.94k | } |
522 | | |
523 | | int tls1_setup_key_block(SSL *s) |
524 | 1.59k | { |
525 | 1.59k | unsigned char *p; |
526 | 1.59k | const EVP_CIPHER *c; |
527 | 1.59k | const EVP_MD *hash; |
528 | 1.59k | SSL_COMP *comp; |
529 | 1.59k | int mac_type = NID_undef; |
530 | 1.59k | size_t num, mac_secret_size = 0; |
531 | 1.59k | int ret = 0; |
532 | | |
533 | 1.59k | if (s->s3.tmp.key_block_length != 0) |
534 | 0 | return 1; |
535 | | |
536 | 1.59k | if (!ssl_cipher_get_evp(s->ctx, s->session, &c, &hash, &mac_type, |
537 | 1.59k | &mac_secret_size, &comp, s->ext.use_etm)) { |
538 | | /* Error is already recorded */ |
539 | 0 | SSLfatal_alert(s, SSL_AD_INTERNAL_ERROR); |
540 | 0 | return 0; |
541 | 0 | } |
542 | | |
543 | 1.59k | ssl_evp_cipher_free(s->s3.tmp.new_sym_enc); |
544 | 1.59k | s->s3.tmp.new_sym_enc = c; |
545 | 1.59k | ssl_evp_md_free(s->s3.tmp.new_hash); |
546 | 1.59k | s->s3.tmp.new_hash = hash; |
547 | 1.59k | s->s3.tmp.new_mac_pkey_type = mac_type; |
548 | 1.59k | s->s3.tmp.new_mac_secret_size = mac_secret_size; |
549 | 1.59k | num = mac_secret_size + EVP_CIPHER_get_key_length(c) |
550 | 1.59k | + tls_iv_length_within_key_block(c); |
551 | 1.59k | num *= 2; |
552 | | |
553 | 1.59k | ssl3_cleanup_key_block(s); |
554 | | |
555 | 1.59k | if ((p = OPENSSL_malloc(num)) == NULL) { |
556 | 0 | SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE); |
557 | 0 | goto err; |
558 | 0 | } |
559 | | |
560 | 1.59k | s->s3.tmp.key_block_length = num; |
561 | 1.59k | s->s3.tmp.key_block = p; |
562 | | |
563 | 1.59k | OSSL_TRACE_BEGIN(TLS) { |
564 | 0 | BIO_printf(trc_out, "key block length: %zu\n", num); |
565 | 0 | BIO_printf(trc_out, "client random\n"); |
566 | 0 | BIO_dump_indent(trc_out, s->s3.client_random, SSL3_RANDOM_SIZE, 4); |
567 | 0 | BIO_printf(trc_out, "server random\n"); |
568 | 0 | BIO_dump_indent(trc_out, s->s3.server_random, SSL3_RANDOM_SIZE, 4); |
569 | 0 | BIO_printf(trc_out, "master key\n"); |
570 | 0 | BIO_dump_indent(trc_out, |
571 | 0 | s->session->master_key, |
572 | 0 | s->session->master_key_length, 4); |
573 | 1.59k | } OSSL_TRACE_END(TLS); |
574 | | |
575 | 1.59k | if (!tls1_generate_key_block(s, p, num)) { |
576 | | /* SSLfatal() already called */ |
577 | 0 | goto err; |
578 | 0 | } |
579 | | |
580 | 1.59k | OSSL_TRACE_BEGIN(TLS) { |
581 | 0 | BIO_printf(trc_out, "key block\n"); |
582 | 0 | BIO_dump_indent(trc_out, p, num, 4); |
583 | 1.59k | } OSSL_TRACE_END(TLS); |
584 | | |
585 | 1.59k | if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) |
586 | 1.59k | && s->method->version <= TLS1_VERSION) { |
587 | | /* |
588 | | * enable vulnerability countermeasure for CBC ciphers with known-IV |
589 | | * problem (http://www.openssl.org/~bodo/tls-cbc.txt) |
590 | | */ |
591 | 357 | s->s3.need_empty_fragments = 1; |
592 | | |
593 | 357 | if (s->session->cipher != NULL) { |
594 | 357 | if (s->session->cipher->algorithm_enc == SSL_eNULL) |
595 | 42 | s->s3.need_empty_fragments = 0; |
596 | | |
597 | 357 | if (s->session->cipher->algorithm_enc == SSL_RC4) |
598 | 0 | s->s3.need_empty_fragments = 0; |
599 | 357 | } |
600 | 357 | } |
601 | | |
602 | 1.59k | ret = 1; |
603 | 1.59k | err: |
604 | 1.59k | return ret; |
605 | 1.59k | } |
606 | | |
607 | | size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen, |
608 | | unsigned char *out) |
609 | 3.48k | { |
610 | 3.48k | size_t hashlen; |
611 | 3.48k | unsigned char hash[EVP_MAX_MD_SIZE]; |
612 | 3.48k | size_t finished_size = TLS1_FINISH_MAC_LENGTH; |
613 | | |
614 | 3.48k | if (s->s3.tmp.new_cipher->algorithm_mkey & SSL_kGOST18) |
615 | 0 | finished_size = 32; |
616 | | |
617 | 3.48k | if (!ssl3_digest_cached_records(s, 0)) { |
618 | | /* SSLfatal() already called */ |
619 | 0 | return 0; |
620 | 0 | } |
621 | | |
622 | 3.48k | if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) { |
623 | | /* SSLfatal() already called */ |
624 | 0 | return 0; |
625 | 0 | } |
626 | | |
627 | 3.48k | if (!tls1_PRF(s, str, slen, hash, hashlen, NULL, 0, NULL, 0, NULL, 0, |
628 | 3.48k | s->session->master_key, s->session->master_key_length, |
629 | 3.48k | out, finished_size, 1)) { |
630 | | /* SSLfatal() already called */ |
631 | 0 | return 0; |
632 | 0 | } |
633 | 3.48k | OPENSSL_cleanse(hash, hashlen); |
634 | 3.48k | return finished_size; |
635 | 3.48k | } |
636 | | |
637 | | int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, |
638 | | size_t len, size_t *secret_size) |
639 | 4.32k | { |
640 | 4.32k | if (s->session->flags & SSL_SESS_FLAG_EXTMS) { |
641 | 678 | unsigned char hash[EVP_MAX_MD_SIZE * 2]; |
642 | 678 | size_t hashlen; |
643 | | /* |
644 | | * Digest cached records keeping record buffer (if present): this won't |
645 | | * affect client auth because we're freezing the buffer at the same |
646 | | * point (after client key exchange and before certificate verify) |
647 | | */ |
648 | 678 | if (!ssl3_digest_cached_records(s, 1) |
649 | 678 | || !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) { |
650 | | /* SSLfatal() already called */ |
651 | 0 | return 0; |
652 | 0 | } |
653 | 678 | OSSL_TRACE_BEGIN(TLS) { |
654 | 0 | BIO_printf(trc_out, "Handshake hashes:\n"); |
655 | 0 | BIO_dump(trc_out, (char *)hash, hashlen); |
656 | 678 | } OSSL_TRACE_END(TLS); |
657 | 678 | if (!tls1_PRF(s, |
658 | 678 | TLS_MD_EXTENDED_MASTER_SECRET_CONST, |
659 | 678 | TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE, |
660 | 678 | hash, hashlen, |
661 | 678 | NULL, 0, |
662 | 678 | NULL, 0, |
663 | 678 | NULL, 0, p, len, out, |
664 | 678 | SSL3_MASTER_SECRET_SIZE, 1)) { |
665 | | /* SSLfatal() already called */ |
666 | 0 | return 0; |
667 | 0 | } |
668 | 678 | OPENSSL_cleanse(hash, hashlen); |
669 | 3.64k | } else { |
670 | 3.64k | if (!tls1_PRF(s, |
671 | 3.64k | TLS_MD_MASTER_SECRET_CONST, |
672 | 3.64k | TLS_MD_MASTER_SECRET_CONST_SIZE, |
673 | 3.64k | s->s3.client_random, SSL3_RANDOM_SIZE, |
674 | 3.64k | NULL, 0, |
675 | 3.64k | s->s3.server_random, SSL3_RANDOM_SIZE, |
676 | 3.64k | NULL, 0, p, len, out, |
677 | 3.64k | SSL3_MASTER_SECRET_SIZE, 1)) { |
678 | | /* SSLfatal() already called */ |
679 | 0 | return 0; |
680 | 0 | } |
681 | 3.64k | } |
682 | | |
683 | 4.32k | OSSL_TRACE_BEGIN(TLS) { |
684 | 0 | BIO_printf(trc_out, "Premaster Secret:\n"); |
685 | 0 | BIO_dump_indent(trc_out, p, len, 4); |
686 | 0 | BIO_printf(trc_out, "Client Random:\n"); |
687 | 0 | BIO_dump_indent(trc_out, s->s3.client_random, SSL3_RANDOM_SIZE, 4); |
688 | 0 | BIO_printf(trc_out, "Server Random:\n"); |
689 | 0 | BIO_dump_indent(trc_out, s->s3.server_random, SSL3_RANDOM_SIZE, 4); |
690 | 0 | BIO_printf(trc_out, "Master Secret:\n"); |
691 | 0 | BIO_dump_indent(trc_out, |
692 | 0 | s->session->master_key, |
693 | 0 | SSL3_MASTER_SECRET_SIZE, 4); |
694 | 4.32k | } OSSL_TRACE_END(TLS); |
695 | | |
696 | 4.32k | *secret_size = SSL3_MASTER_SECRET_SIZE; |
697 | 4.32k | return 1; |
698 | 4.32k | } |
699 | | |
700 | | int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, |
701 | | const char *label, size_t llen, |
702 | | const unsigned char *context, |
703 | | size_t contextlen, int use_context) |
704 | 0 | { |
705 | 0 | unsigned char *val = NULL; |
706 | 0 | size_t vallen = 0, currentvalpos; |
707 | 0 | int rv; |
708 | | |
709 | | /* |
710 | | * construct PRF arguments we construct the PRF argument ourself rather |
711 | | * than passing separate values into the TLS PRF to ensure that the |
712 | | * concatenation of values does not create a prohibited label. |
713 | | */ |
714 | 0 | vallen = llen + SSL3_RANDOM_SIZE * 2; |
715 | 0 | if (use_context) { |
716 | 0 | vallen += 2 + contextlen; |
717 | 0 | } |
718 | |
|
719 | 0 | val = OPENSSL_malloc(vallen); |
720 | 0 | if (val == NULL) |
721 | 0 | goto err2; |
722 | 0 | currentvalpos = 0; |
723 | 0 | memcpy(val + currentvalpos, (unsigned char *)label, llen); |
724 | 0 | currentvalpos += llen; |
725 | 0 | memcpy(val + currentvalpos, s->s3.client_random, SSL3_RANDOM_SIZE); |
726 | 0 | currentvalpos += SSL3_RANDOM_SIZE; |
727 | 0 | memcpy(val + currentvalpos, s->s3.server_random, SSL3_RANDOM_SIZE); |
728 | 0 | currentvalpos += SSL3_RANDOM_SIZE; |
729 | |
|
730 | 0 | if (use_context) { |
731 | 0 | val[currentvalpos] = (contextlen >> 8) & 0xff; |
732 | 0 | currentvalpos++; |
733 | 0 | val[currentvalpos] = contextlen & 0xff; |
734 | 0 | currentvalpos++; |
735 | 0 | if ((contextlen > 0) || (context != NULL)) { |
736 | 0 | memcpy(val + currentvalpos, context, contextlen); |
737 | 0 | } |
738 | 0 | } |
739 | | |
740 | | /* |
741 | | * disallow prohibited labels note that SSL3_RANDOM_SIZE > max(prohibited |
742 | | * label len) = 15, so size of val > max(prohibited label len) = 15 and |
743 | | * the comparisons won't have buffer overflow |
744 | | */ |
745 | 0 | if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST, |
746 | 0 | TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0) |
747 | 0 | goto err1; |
748 | 0 | if (memcmp(val, TLS_MD_SERVER_FINISH_CONST, |
749 | 0 | TLS_MD_SERVER_FINISH_CONST_SIZE) == 0) |
750 | 0 | goto err1; |
751 | 0 | if (memcmp(val, TLS_MD_MASTER_SECRET_CONST, |
752 | 0 | TLS_MD_MASTER_SECRET_CONST_SIZE) == 0) |
753 | 0 | goto err1; |
754 | 0 | if (memcmp(val, TLS_MD_EXTENDED_MASTER_SECRET_CONST, |
755 | 0 | TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE) == 0) |
756 | 0 | goto err1; |
757 | 0 | if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST, |
758 | 0 | TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0) |
759 | 0 | goto err1; |
760 | | |
761 | 0 | rv = tls1_PRF(s, |
762 | 0 | val, vallen, |
763 | 0 | NULL, 0, |
764 | 0 | NULL, 0, |
765 | 0 | NULL, 0, |
766 | 0 | NULL, 0, |
767 | 0 | s->session->master_key, s->session->master_key_length, |
768 | 0 | out, olen, 0); |
769 | |
|
770 | 0 | goto ret; |
771 | 0 | err1: |
772 | 0 | ERR_raise(ERR_LIB_SSL, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL); |
773 | 0 | rv = 0; |
774 | 0 | goto ret; |
775 | 0 | err2: |
776 | 0 | ERR_raise(ERR_LIB_SSL, ERR_R_MALLOC_FAILURE); |
777 | 0 | rv = 0; |
778 | 0 | ret: |
779 | 0 | OPENSSL_clear_free(val, vallen); |
780 | 0 | return rv; |
781 | 0 | } |
782 | | |
783 | | int tls1_alert_code(int code) |
784 | 22.5k | { |
785 | 22.5k | switch (code) { |
786 | 0 | case SSL_AD_CLOSE_NOTIFY: |
787 | 0 | return SSL3_AD_CLOSE_NOTIFY; |
788 | 1.54k | case SSL_AD_UNEXPECTED_MESSAGE: |
789 | 1.54k | return SSL3_AD_UNEXPECTED_MESSAGE; |
790 | 2.03k | case SSL_AD_BAD_RECORD_MAC: |
791 | 2.03k | return SSL3_AD_BAD_RECORD_MAC; |
792 | 0 | case SSL_AD_DECRYPTION_FAILED: |
793 | 0 | return TLS1_AD_DECRYPTION_FAILED; |
794 | 350 | case SSL_AD_RECORD_OVERFLOW: |
795 | 350 | return TLS1_AD_RECORD_OVERFLOW; |
796 | 0 | case SSL_AD_DECOMPRESSION_FAILURE: |
797 | 0 | return SSL3_AD_DECOMPRESSION_FAILURE; |
798 | 1.18k | case SSL_AD_HANDSHAKE_FAILURE: |
799 | 1.18k | return SSL3_AD_HANDSHAKE_FAILURE; |
800 | 0 | case SSL_AD_NO_CERTIFICATE: |
801 | 0 | return -1; |
802 | 4.08k | case SSL_AD_BAD_CERTIFICATE: |
803 | 4.08k | return SSL3_AD_BAD_CERTIFICATE; |
804 | 0 | case SSL_AD_UNSUPPORTED_CERTIFICATE: |
805 | 0 | return SSL3_AD_UNSUPPORTED_CERTIFICATE; |
806 | 0 | case SSL_AD_CERTIFICATE_REVOKED: |
807 | 0 | return SSL3_AD_CERTIFICATE_REVOKED; |
808 | 0 | case SSL_AD_CERTIFICATE_EXPIRED: |
809 | 0 | return SSL3_AD_CERTIFICATE_EXPIRED; |
810 | 0 | case SSL_AD_CERTIFICATE_UNKNOWN: |
811 | 0 | return SSL3_AD_CERTIFICATE_UNKNOWN; |
812 | 1.89k | case SSL_AD_ILLEGAL_PARAMETER: |
813 | 1.89k | return SSL3_AD_ILLEGAL_PARAMETER; |
814 | 0 | case SSL_AD_UNKNOWN_CA: |
815 | 0 | return TLS1_AD_UNKNOWN_CA; |
816 | 0 | case SSL_AD_ACCESS_DENIED: |
817 | 0 | return TLS1_AD_ACCESS_DENIED; |
818 | 5.47k | case SSL_AD_DECODE_ERROR: |
819 | 5.47k | return TLS1_AD_DECODE_ERROR; |
820 | 2.01k | case SSL_AD_DECRYPT_ERROR: |
821 | 2.01k | return TLS1_AD_DECRYPT_ERROR; |
822 | 0 | case SSL_AD_EXPORT_RESTRICTION: |
823 | 0 | return TLS1_AD_EXPORT_RESTRICTION; |
824 | 1.25k | case SSL_AD_PROTOCOL_VERSION: |
825 | 1.25k | return TLS1_AD_PROTOCOL_VERSION; |
826 | 0 | case SSL_AD_INSUFFICIENT_SECURITY: |
827 | 0 | return TLS1_AD_INSUFFICIENT_SECURITY; |
828 | 2.36k | case SSL_AD_INTERNAL_ERROR: |
829 | 2.36k | return TLS1_AD_INTERNAL_ERROR; |
830 | 0 | case SSL_AD_USER_CANCELLED: |
831 | 0 | return TLS1_AD_USER_CANCELLED; |
832 | 325 | case SSL_AD_NO_RENEGOTIATION: |
833 | 325 | return TLS1_AD_NO_RENEGOTIATION; |
834 | 24 | case SSL_AD_UNSUPPORTED_EXTENSION: |
835 | 24 | return TLS1_AD_UNSUPPORTED_EXTENSION; |
836 | 0 | case SSL_AD_CERTIFICATE_UNOBTAINABLE: |
837 | 0 | return TLS1_AD_CERTIFICATE_UNOBTAINABLE; |
838 | 7 | case SSL_AD_UNRECOGNIZED_NAME: |
839 | 7 | return TLS1_AD_UNRECOGNIZED_NAME; |
840 | 0 | case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: |
841 | 0 | return TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE; |
842 | 0 | case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: |
843 | 0 | return TLS1_AD_BAD_CERTIFICATE_HASH_VALUE; |
844 | 0 | case SSL_AD_UNKNOWN_PSK_IDENTITY: |
845 | 0 | return TLS1_AD_UNKNOWN_PSK_IDENTITY; |
846 | 7 | case SSL_AD_INAPPROPRIATE_FALLBACK: |
847 | 7 | return TLS1_AD_INAPPROPRIATE_FALLBACK; |
848 | 0 | case SSL_AD_NO_APPLICATION_PROTOCOL: |
849 | 0 | return TLS1_AD_NO_APPLICATION_PROTOCOL; |
850 | 0 | case SSL_AD_CERTIFICATE_REQUIRED: |
851 | 0 | return SSL_AD_HANDSHAKE_FAILURE; |
852 | 4 | case TLS13_AD_MISSING_EXTENSION: |
853 | 4 | return SSL_AD_HANDSHAKE_FAILURE; |
854 | 0 | default: |
855 | 0 | return -1; |
856 | 22.5k | } |
857 | 22.5k | } |