summaryrefslogtreecommitdiffstats
path: root/crypto/sha
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2016-10-24 16:05:31 +0200
committerAndy Polyakov <appro@openssl.org>2016-10-31 22:18:07 +0100
commit4b90430148447ff06f993ed6fec2367183c79f6b (patch)
tree062664bebbe6cd2f1c1e20dd5dd584031890bdda /crypto/sha
parentca1574cec20589885000d039eed3a9375fb29a0d (diff)
sha/keccak1600.c: add couple of soft asserts.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/sha')
-rw-r--r--crypto/sha/keccak1600.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/sha/keccak1600.c b/crypto/sha/keccak1600.c
index 4397372ccb..9e08c504c7 100644
--- a/crypto/sha/keccak1600.c
+++ b/crypto/sha/keccak1600.c
@@ -167,6 +167,8 @@ size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len,
uint64_t *A_flat = (uint64_t *)A;
size_t i, w = r / 8;
+ assert(r < (25 * sizeof(A[0][0])) && (r % 8) == 0);
+
while (len >= r) {
for (i = 0; i < w; i++) {
A_flat[i] ^= (uint64_t)inp[0] | (uint64_t)inp[1] << 8 |
@@ -191,6 +193,8 @@ void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r)
uint64_t *A_flat = (uint64_t *)A;
size_t i, rem, w = r / 8;
+ assert(r < (25 * sizeof(A[0][0])) && (r % 8) == 0);
+
while (len >= r) {
for (i = 0; i < w; i++) {
uint64_t Ai = A_flat[i];