OCBv3: fix demos/timing failures

This commit is contained in:
Karel Miko 2017-08-07 07:48:21 +02:00
parent 3ecd18763b
commit 6ac1c5fa34
2 changed files with 4 additions and 6 deletions

View File

@ -1273,7 +1273,7 @@ static void time_encmacs_(unsigned long MAC_SIZE)
t_start(); t_start();
t1 = t_read(); t1 = t_read();
z = 16; z = 16;
if ((err = ocb3_encrypt_authenticate_memory(cipher_idx, key, 16, IV, 16, (unsigned char*)"", 0, buf, MAC_SIZE*1024, buf, tag, &z)) != CRYPT_OK) { if ((err = ocb3_encrypt_authenticate_memory(cipher_idx, key, 16, IV, 15, (unsigned char*)"", 0, buf, MAC_SIZE*1024, buf, tag, &z)) != CRYPT_OK) {
fprintf(stderr, "\nOCB3 error... %s\n", error_to_string(err)); fprintf(stderr, "\nOCB3 error... %s\n", error_to_string(err));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -54,11 +54,9 @@ int ocb3_add_aad(ocb3_state *ocb, const unsigned char *aad, unsigned long aadlen
unsigned char *data; unsigned char *data;
unsigned long datalen, l; unsigned long datalen, l;
LTC_ARGCHK(ocb != NULL); LTC_ARGCHK(ocb != NULL);
if (aad == NULL) LTC_ARGCHK(aadlen == 0); if (aadlen == 0) return CRYPT_OK;
if (aadlen == 0) LTC_ARGCHK(aad == NULL); LTC_ARGCHK(aad != NULL);
if (aad == NULL || aadlen == 0) return CRYPT_OK;
if (ocb->adata_buffer_bytes > 0) { if (ocb->adata_buffer_bytes > 0) {
l = ocb->block_len - ocb->adata_buffer_bytes; l = ocb->block_len - ocb->adata_buffer_bytes;