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