ocb3_init fix (preventing index overflow)

This commit is contained in:
Karel Miko 2012-09-04 15:43:55 +02:00 committed by Steffen Jaeckel
parent abab7089a3
commit 9c2193b722

View File

@ -64,11 +64,15 @@ int ocb3_init(ocb3_state *ocb, int cipher,
/* determine which polys to use */
ocb->block_len = cipher_descriptor[cipher].block_length;
for (poly = 0; poly < (int)(sizeof(polys)/sizeof(polys[0])); poly++) {
x = (int)(sizeof(polys)/sizeof(polys[0]));
for (poly = 0; poly < x; poly++) {
if (polys[poly].len == ocb->block_len) {
break;
}
}
if (poly == x) {
return CRYPT_INVALID_ARG; /* block_len not found in polys */
}
if (polys[poly].len != ocb->block_len) {
return CRYPT_INVALID_ARG;
}