Browse Source

OCBv3: fix demos/timing failures

Karel Miko 8 years ago
parent
commit
6ac1c5fa34
2 changed files with 4 additions and 6 deletions
  1. 1 1
      demos/timing.c
  2. 3 5
      src/encauth/ocb3/ocb3_add_aad.c

+ 1 - 1
demos/timing.c

@@ -1273,7 +1273,7 @@ static void time_encmacs_(unsigned long MAC_SIZE)
         t_start();
         t1 = t_read();
         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));
            exit(EXIT_FAILURE);
         }

+ 3 - 5
src/encauth/ocb3/ocb3_add_aad.c

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