diff options
Diffstat (limited to 'src/lib/libssl/s3_cbc.c')
-rw-r--r-- | src/lib/libssl/s3_cbc.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/lib/libssl/s3_cbc.c b/src/lib/libssl/s3_cbc.c index 8ae87d7303..004b92118e 100644 --- a/src/lib/libssl/s3_cbc.c +++ b/src/lib/libssl/s3_cbc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_cbc.c,v 1.20 2020/03/12 17:09:02 jsing Exp $ */ | 1 | /* $OpenBSD: s3_cbc.c,v 1.21 2020/03/16 15:25:13 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2012 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2012 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -73,20 +73,20 @@ | |||
73 | * bits. They use the fact that arithmetic shift shifts-in the sign bit. | 73 | * bits. They use the fact that arithmetic shift shifts-in the sign bit. |
74 | * However, this is not ensured by the C standard so you may need to replace | 74 | * However, this is not ensured by the C standard so you may need to replace |
75 | * them with something else on odd CPUs. */ | 75 | * them with something else on odd CPUs. */ |
76 | #define DUPLICATE_MSB_TO_ALL(x) ((unsigned)((int)(x) >> (sizeof(int) * 8 - 1))) | 76 | #define DUPLICATE_MSB_TO_ALL(x) ((unsigned int)((int)(x) >> (sizeof(int) * 8 - 1))) |
77 | #define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x))) | 77 | #define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x))) |
78 | 78 | ||
79 | /* constant_time_lt returns 0xff if a<b and 0x00 otherwise. */ | 79 | /* constant_time_lt returns 0xff if a<b and 0x00 otherwise. */ |
80 | static unsigned | 80 | static unsigned int |
81 | constant_time_lt(unsigned a, unsigned b) | 81 | constant_time_lt(unsigned int a, unsigned int b) |
82 | { | 82 | { |
83 | a -= b; | 83 | a -= b; |
84 | return DUPLICATE_MSB_TO_ALL(a); | 84 | return DUPLICATE_MSB_TO_ALL(a); |
85 | } | 85 | } |
86 | 86 | ||
87 | /* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */ | 87 | /* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */ |
88 | static unsigned | 88 | static unsigned int |
89 | constant_time_ge(unsigned a, unsigned b) | 89 | constant_time_ge(unsigned int a, unsigned int b) |
90 | { | 90 | { |
91 | a -= b; | 91 | a -= b; |
92 | return DUPLICATE_MSB_TO_ALL(~a); | 92 | return DUPLICATE_MSB_TO_ALL(~a); |
@@ -94,9 +94,9 @@ constant_time_ge(unsigned a, unsigned b) | |||
94 | 94 | ||
95 | /* constant_time_eq_8 returns 0xff if a==b and 0x00 otherwise. */ | 95 | /* constant_time_eq_8 returns 0xff if a==b and 0x00 otherwise. */ |
96 | static unsigned char | 96 | static unsigned char |
97 | constant_time_eq_8(unsigned a, unsigned b) | 97 | constant_time_eq_8(unsigned int a, unsigned int b) |
98 | { | 98 | { |
99 | unsigned c = a ^ b; | 99 | unsigned int c = a ^ b; |
100 | c--; | 100 | c--; |
101 | return DUPLICATE_MSB_TO_ALL_8(c); | 101 | return DUPLICATE_MSB_TO_ALL_8(c); |
102 | } | 102 | } |
@@ -114,10 +114,10 @@ constant_time_eq_8(unsigned a, unsigned b) | |||
114 | * -1: otherwise. */ | 114 | * -1: otherwise. */ |
115 | int | 115 | int |
116 | tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD_INTERNAL *rec, | 116 | tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD_INTERNAL *rec, |
117 | unsigned block_size, unsigned mac_size) | 117 | unsigned int block_size, unsigned int mac_size) |
118 | { | 118 | { |
119 | unsigned padding_length, good, to_check, i; | 119 | unsigned int padding_length, good, to_check, i; |
120 | const unsigned overhead = 1 /* padding length byte */ + mac_size; | 120 | const unsigned int overhead = 1 /* padding length byte */ + mac_size; |
121 | 121 | ||
122 | /* Check if version requires explicit IV */ | 122 | /* Check if version requires explicit IV */ |
123 | if (SSL_USE_EXPLICIT_IV(s)) { | 123 | if (SSL_USE_EXPLICIT_IV(s)) { |
@@ -195,7 +195,7 @@ tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD_INTERNAL *rec, | |||
195 | 195 | ||
196 | void | 196 | void |
197 | ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD_INTERNAL *rec, | 197 | ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD_INTERNAL *rec, |
198 | unsigned md_size, unsigned orig_len) | 198 | unsigned int md_size, unsigned int orig_len) |
199 | { | 199 | { |
200 | #if defined(CBC_MAC_ROTATE_IN_PLACE) | 200 | #if defined(CBC_MAC_ROTATE_IN_PLACE) |
201 | unsigned char rotated_mac_buf[64 + EVP_MAX_MD_SIZE]; | 201 | unsigned char rotated_mac_buf[64 + EVP_MAX_MD_SIZE]; |
@@ -205,14 +205,14 @@ ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD_INTERNAL *rec, | |||
205 | #endif | 205 | #endif |
206 | 206 | ||
207 | /* mac_end is the index of |rec->data| just after the end of the MAC. */ | 207 | /* mac_end is the index of |rec->data| just after the end of the MAC. */ |
208 | unsigned mac_end = rec->length; | 208 | unsigned int mac_end = rec->length; |
209 | unsigned mac_start = mac_end - md_size; | 209 | unsigned int mac_start = mac_end - md_size; |
210 | /* scan_start contains the number of bytes that we can ignore because | 210 | /* scan_start contains the number of bytes that we can ignore because |
211 | * the MAC's position can only vary by 255 bytes. */ | 211 | * the MAC's position can only vary by 255 bytes. */ |
212 | unsigned scan_start = 0; | 212 | unsigned int scan_start = 0; |
213 | unsigned i, j; | 213 | unsigned int i, j; |
214 | unsigned div_spoiler; | 214 | unsigned int div_spoiler; |
215 | unsigned rotate_offset; | 215 | unsigned int rotate_offset; |
216 | 216 | ||
217 | OPENSSL_assert(orig_len >= md_size); | 217 | OPENSSL_assert(orig_len >= md_size); |
218 | OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE); | 218 | OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE); |
@@ -316,7 +316,7 @@ static void | |||
316 | tls1_sha256_final_raw(void* ctx, unsigned char *md_out) | 316 | tls1_sha256_final_raw(void* ctx, unsigned char *md_out) |
317 | { | 317 | { |
318 | SHA256_CTX *sha256 = ctx; | 318 | SHA256_CTX *sha256 = ctx; |
319 | unsigned i; | 319 | unsigned int i; |
320 | 320 | ||
321 | for (i = 0; i < 8; i++) { | 321 | for (i = 0; i < 8; i++) { |
322 | l2n(sha256->h[i], md_out); | 322 | l2n(sha256->h[i], md_out); |
@@ -327,7 +327,7 @@ static void | |||
327 | tls1_sha512_final_raw(void* ctx, unsigned char *md_out) | 327 | tls1_sha512_final_raw(void* ctx, unsigned char *md_out) |
328 | { | 328 | { |
329 | SHA512_CTX *sha512 = ctx; | 329 | SHA512_CTX *sha512 = ctx; |
330 | unsigned i; | 330 | unsigned int i; |
331 | 331 | ||
332 | for (i = 0; i < 8; i++) { | 332 | for (i = 0; i < 8; i++) { |
333 | l2n8(sha512->h[i], md_out); | 333 | l2n8(sha512->h[i], md_out); |
@@ -382,7 +382,7 @@ ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char* md_out, | |||
382 | size_t* md_out_size, const unsigned char header[13], | 382 | size_t* md_out_size, const unsigned char header[13], |
383 | const unsigned char *data, size_t data_plus_mac_size, | 383 | const unsigned char *data, size_t data_plus_mac_size, |
384 | size_t data_plus_mac_plus_padding_size, const unsigned char *mac_secret, | 384 | size_t data_plus_mac_plus_padding_size, const unsigned char *mac_secret, |
385 | unsigned mac_secret_length) | 385 | unsigned int mac_secret_length) |
386 | { | 386 | { |
387 | union { | 387 | union { |
388 | /* | 388 | /* |
@@ -395,8 +395,8 @@ ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char* md_out, | |||
395 | } md_state; | 395 | } md_state; |
396 | void (*md_final_raw)(void *ctx, unsigned char *md_out); | 396 | void (*md_final_raw)(void *ctx, unsigned char *md_out); |
397 | void (*md_transform)(void *ctx, const unsigned char *block); | 397 | void (*md_transform)(void *ctx, const unsigned char *block); |
398 | unsigned md_size, md_block_size = 64; | 398 | unsigned int md_size, md_block_size = 64; |
399 | unsigned header_length, variance_blocks, | 399 | unsigned int header_length, variance_blocks, |
400 | len, max_mac_bytes, num_blocks, | 400 | len, max_mac_bytes, num_blocks, |
401 | num_starting_blocks, k, mac_end_offset, c, index_a, index_b; | 401 | num_starting_blocks, k, mac_end_offset, c, index_a, index_b; |
402 | unsigned int bits; /* at most 18 bits */ | 402 | unsigned int bits; /* at most 18 bits */ |
@@ -405,11 +405,11 @@ ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char* md_out, | |||
405 | unsigned char hmac_pad[MAX_HASH_BLOCK_SIZE]; | 405 | unsigned char hmac_pad[MAX_HASH_BLOCK_SIZE]; |
406 | unsigned char first_block[MAX_HASH_BLOCK_SIZE]; | 406 | unsigned char first_block[MAX_HASH_BLOCK_SIZE]; |
407 | unsigned char mac_out[EVP_MAX_MD_SIZE]; | 407 | unsigned char mac_out[EVP_MAX_MD_SIZE]; |
408 | unsigned i, j, md_out_size_u; | 408 | unsigned int i, j, md_out_size_u; |
409 | EVP_MD_CTX md_ctx; | 409 | EVP_MD_CTX md_ctx; |
410 | /* mdLengthSize is the number of bytes in the length field that terminates | 410 | /* mdLengthSize is the number of bytes in the length field that terminates |
411 | * the hash. */ | 411 | * the hash. */ |
412 | unsigned md_length_size = 8; | 412 | unsigned int md_length_size = 8; |
413 | char length_is_big_endian = 1; | 413 | char length_is_big_endian = 1; |
414 | 414 | ||
415 | /* This is a, hopefully redundant, check that allows us to forget about | 415 | /* This is a, hopefully redundant, check that allows us to forget about |