Skip to content

Commit

Permalink
add GCM tests back
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Dec 7, 2015
1 parent 222c1df commit 8d5a8ba
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/krb5/aes-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ iov_test(krb5_context context, krb5_enctype enctype)
krb5_crypto_iov iov[6];
size_t len, i;
unsigned char *base, *p;
unsigned char ivec[16], *ivecp;

#define RESET_IVEC(ivecp) do { if (ivecp) memset(ivecp, 0, 16); } while (0)

ivecp = _krb5_enctype_is_aead(context, enctype) ? ivec : NULL;

ret = krb5_generate_random_keyblock(context, enctype, &key);
if (ret)
Expand Down Expand Up @@ -875,18 +880,18 @@ iov_test(krb5_context context, krb5_enctype enctype)
/*
* Encrypt
*/

RESET_IVEC(ivecp);
ret = krb5_encrypt_iov_ivec(context, crypto, 7, iov,
sizeof(iov)/sizeof(iov[0]), NULL);
sizeof(iov)/sizeof(iov[0]), ivecp);
if (ret)
krb5_err(context, 1, ret, "krb5_encrypt_iov_ivec");

/*
* Decrypt
*/

RESET_IVEC(ivecp);
ret = krb5_decrypt_iov_ivec(context, crypto, 7,
iov, sizeof(iov)/sizeof(iov[0]), NULL);
iov, sizeof(iov)/sizeof(iov[0]), ivecp);
if (ret)
krb5_err(context, 1, ret, "krb5_decrypt_iov_ivec");

Expand Down Expand Up @@ -942,18 +947,18 @@ iov_test(krb5_context context, krb5_enctype enctype)
/*
* Encrypt
*/

RESET_IVEC(ivecp);
ret = krb5_encrypt_iov_ivec(context, crypto, 7,
iov, sizeof(iov)/sizeof(iov[0]), NULL);
iov, sizeof(iov)/sizeof(iov[0]), ivecp);
if (ret)
krb5_err(context, 1, ret, "krb5_encrypt_iov_ivec");

/*
* Decrypt
*/

RESET_IVEC(ivecp);
ret = krb5_decrypt_iov_ivec(context, crypto, 7,
iov, sizeof(iov)/sizeof(iov[0]), NULL);
iov, sizeof(iov)/sizeof(iov[0]), ivecp);
if (ret)
krb5_err(context, 1, ret, "krb5_decrypt_iov_ivec");

Expand Down Expand Up @@ -1032,6 +1037,8 @@ main(int argc, char **argv)
val |= iov_test(context, KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96);
val |= iov_test(context, KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128);
val |= iov_test(context, KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192);
val |= iov_test(context, KRB5_ENCTYPE_AES128_GCM_128);
val |= iov_test(context, KRB5_ENCTYPE_AES256_GCM_128);

if (verbose && val == 0)
printf("all ok\n");
Expand Down

0 comments on commit 8d5a8ba

Please sign in to comment.