aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-01-27 14:10:16 +0000
committerMatt Caswell <matt@openssl.org>2015-01-28 10:39:07 +0000
commit488ede07bd9d2a2d3f63851eb28204c9ee998cf9 (patch)
tree348af334edf0ee4ca716d760bb496ff194180691 /crypto
parente640fa02005422c8783b7a452329e8a5059be0b5 (diff)
downloadopenssl-488ede07bd9d2a2d3f63851eb28204c9ee998cf9.tar.gz
Rationalise testing of AEAD modes
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/evp_test.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/crypto/evp/evp_test.c b/crypto/evp/evp_test.c
index 47067e9551..597b9fe23c 100644
--- a/crypto/evp/evp_test.c
+++ b/crypto/evp/evp_test.c
@@ -173,7 +173,8 @@ static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
if (encdec != 0) {
- if ((mode == EVP_CIPH_GCM_MODE) || (mode == EVP_CIPH_OCB_MODE)) {
+ if ((mode == EVP_CIPH_GCM_MODE) || (mode == EVP_CIPH_OCB_MODE)
+ || (mode == EVP_CIPH_CCM_MODE)) {
if (!EVP_EncryptInit_ex(ctx, c, NULL, NULL, NULL)) {
fprintf(stderr, "EncryptInit failed\n");
ERR_print_errors_fp(stderr);
@@ -184,7 +185,7 @@ static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
ERR_print_errors_fp(stderr);
test1_exit(11);
}
- if ((mode == EVP_CIPH_OCB_MODE) &&
+ if ((mode != EVP_CIPH_GCM_MODE) &&
!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tn, NULL)) {
fprintf(stderr, "Tag length set failed\n");
ERR_print_errors_fp(stderr);
@@ -195,33 +196,8 @@ static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
ERR_print_errors_fp(stderr);
test1_exit(12);
}
- if (an && !EVP_EncryptUpdate(ctx, NULL, &outl, aad, an)) {
- fprintf(stderr, "AAD set failed\n");
- ERR_print_errors_fp(stderr);
- test1_exit(13);
- }
- } else if (mode == EVP_CIPH_CCM_MODE) {
- if (!EVP_EncryptInit_ex(ctx, c, NULL, NULL, NULL)) {
- fprintf(stderr, "EncryptInit failed\n");
- ERR_print_errors_fp(stderr);
- test1_exit(10);
- }
- if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_IVLEN, in, NULL)) {
- fprintf(stderr, "IV length set failed\n");
- ERR_print_errors_fp(stderr);
- test1_exit(11);
- }
- if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_TAG, tn, NULL)) {
- fprintf(stderr, "Tag length set failed\n");
- ERR_print_errors_fp(stderr);
- test1_exit(11);
- }
- if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv)) {
- fprintf(stderr, "Key/IV set failed\n");
- ERR_print_errors_fp(stderr);
- test1_exit(12);
- }
- if (!EVP_EncryptUpdate(ctx, NULL, &outl, NULL, pn)) {
+ if ((mode == EVP_CIPH_CCM_MODE) &&
+ !EVP_EncryptUpdate(ctx, NULL, &outl, NULL, pn)) {
fprintf(stderr, "Plaintext length set failed\n");
ERR_print_errors_fp(stderr);
test1_exit(12);