summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_cbc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/s3_cbc.c')
-rw-r--r--src/lib/libssl/s3_cbc.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/lib/libssl/s3_cbc.c b/src/lib/libssl/s3_cbc.c
index 57485caacf..824ccf983b 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.10 2015/07/17 07:04:40 doug Exp $ */ 1/* $OpenBSD: s3_cbc.c,v 1.11 2015/09/11 17:17:44 jsing 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 *
@@ -101,36 +101,6 @@ constant_time_eq_8(unsigned a, unsigned b)
101 return DUPLICATE_MSB_TO_ALL_8(c); 101 return DUPLICATE_MSB_TO_ALL_8(c);
102} 102}
103 103
104/* ssl3_cbc_remove_padding removes padding from the decrypted, SSLv3, CBC
105 * record in |rec| by updating |rec->length| in constant time.
106 *
107 * block_size: the block size of the cipher used to encrypt the record.
108 * returns:
109 * 0: (in non-constant time) if the record is publicly invalid.
110 * 1: if the padding was valid
111 * -1: otherwise. */
112int
113ssl3_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size,
114 unsigned mac_size)
115{
116 unsigned padding_length, good;
117 const unsigned overhead = 1 /* padding length byte */ + mac_size;
118
119 /* These lengths are all public so we can test them in non-constant
120 * time. */
121 if (overhead > rec->length)
122 return 0;
123
124 padding_length = rec->data[rec->length - 1];
125 good = constant_time_ge(rec->length, padding_length + overhead);
126 /* SSLv3 requires that the padding is minimal. */
127 good &= constant_time_ge(block_size, padding_length + 1);
128 padding_length = good & (padding_length + 1);
129 rec->length -= padding_length;
130 rec->type |= padding_length << 8; /* kludge: pass padding length */
131 return (int)((good & 1) | (~good & -1));
132}
133
134/* tls1_cbc_remove_padding removes the CBC padding from the decrypted, TLS, CBC 104/* tls1_cbc_remove_padding removes the CBC padding from the decrypted, TLS, CBC
135 * record in |rec| in constant time and returns 1 if the padding is valid and 105 * record in |rec| in constant time and returns 1 if the padding is valid and
136 * -1 otherwise. It also removes any explicit IV from the start of the record 106 * -1 otherwise. It also removes any explicit IV from the start of the record