summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
Diffstat (limited to 'ssl')
-rw-r--r--ssl/s3_cbc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ssl/s3_cbc.c b/ssl/s3_cbc.c
index f15c5b5966..27f309e72d 100644
--- a/ssl/s3_cbc.c
+++ b/ssl/s3_cbc.c
@@ -94,7 +94,7 @@ int ssl3_cbc_remove_padding(const SSL* s,
/* SSLv3 requires that the padding is minimal. */
good &= constant_time_ge(block_size, padding_length+1);
rec->length -= good & (padding_length+1);
- return (int)((good & 1) | (~good & -1));
+ return constant_time_select_int(good, 1, -1);
}
/* tls1_cbc_remove_padding removes the CBC padding from the decrypted, TLS, CBC
@@ -190,7 +190,7 @@ int tls1_cbc_remove_padding(const SSL* s,
good = constant_time_eq(0xff, good & 0xff);
rec->length -= good & (padding_length+1);
- return (int)((good & 1) | (~good & -1));
+ return constant_time_select_int(good, 1, -1);
}
/* ssl3_cbc_copy_mac copies |md_size| bytes from the end of |rec| to |out| in
@@ -650,7 +650,7 @@ void ssl3_cbc_digest_record(
/* If this is the block containing the end of the
* application data, and we are at the offset for the
* 0x80 value, then overwrite b with 0x80. */
- b = (b&~is_past_c) | (0x80&is_past_c);
+ b = constant_time_select_8(is_past_c, 0x80, b);
/* If this the the block containing the end of the
* application data and we're past the 0x80 value then
* just write zero. */
@@ -666,7 +666,8 @@ void ssl3_cbc_digest_record(
if (j >= md_block_size - md_length_size)
{
/* If this is index_b, write a length byte. */
- b = (b&~is_block_b) | (is_block_b&length_bytes[j-(md_block_size-md_length_size)]);
+ b = constant_time_select_8(
+ is_block_b, length_bytes[j-(md_block_size-md_length_size)], b);
}
block[j] = b;
}