Replace EVP_CTRL_OCB_SET_TAGLEN with EVP_CTRL_SET_TAG for consistency with
authorMatt Caswell <matt@openssl.org>
Tue, 27 Jan 2015 14:00:50 +0000 (14:00 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 28 Jan 2015 10:38:38 +0000 (10:38 +0000)
CCM

Reviewed-by: Tim Hudson <tjh@openssl.org>
crypto/evp/e_aes.c
crypto/evp/evp.h
crypto/evp/evp_test.c

index 8b31388690e62c9f042fbcaef0013a52ea255d12..435d9ea772da7d24416b034fa164eaf229b3615f 100644 (file)
@@ -2225,15 +2225,15 @@ static int aes_ocb_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
         octx->ivlen = arg;
         return 1;
 
-    case EVP_CTRL_OCB_SET_TAGLEN:
-        /* Tag len must be 0 to 16 */
-        if (arg < 0 || arg > 16)
-            return 0;
-
-        octx->taglen = arg;
-        return 1;
-
     case EVP_CTRL_SET_TAG:
+        if (!ptr) {
+            /* Tag len must be 0 to 16 */
+            if (arg < 0 || arg > 16)
+                return 0;
+
+            octx->taglen = arg;
+            return 1;
+        }
         if (arg != octx->taglen || c->encrypt)
             return 0;
         memcpy(octx->tag, ptr, arg);
index 74f621788470b8392c84c13d3a2073fc8f18e712..3101905c750f9eaf92ad0bc3489e3c1bf90243cd 100644 (file)
@@ -433,7 +433,6 @@ typedef struct {
 # define         EVP_CTRL_SET_IVLEN                      EVP_CTRL_GCM_SET_IVLEN
 # define         EVP_CTRL_GET_TAG                        EVP_CTRL_GCM_GET_TAG
 # define         EVP_CTRL_SET_TAG                        EVP_CTRL_GCM_SET_TAG
-# define         EVP_CTRL_OCB_SET_TAGLEN         0x1c
 
 /* GCM TLS constants */
 /* Length of fixed part of IV derived from PRF */
index dde9e169032973b1064f7f02084d370fb39d6c4b..5784874baa9bdff7e58cad3e4510d7f0567f8c30 100644 (file)
@@ -185,8 +185,7 @@ static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
                 test1_exit(11);
             }
             if ((mode == EVP_CIPH_OCB_MODE) &&
-                !EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_OCB_SET_TAGLEN, tn, NULL))
-            {
+                !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(15);
@@ -301,8 +300,7 @@ static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
                 test1_exit(11);
             }
             if ((mode == EVP_CIPH_OCB_MODE) &&
-                !EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_OCB_SET_TAGLEN, tn, NULL))
-            {
+                !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(15);