Sanity check EVP_CTRL_AEAD_TLS_AAD
[openssl.git] / crypto / evp / e_rc4_hmac_md5.c
index 7c4bd34d9b58f907224c0ae51bd5de98038182cc..1ba690da11c48c00d6b187ddb252254ec5c0d3ac 100644 (file)
@@ -257,7 +257,12 @@ static int rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
     case EVP_CTRL_AEAD_TLS1_AAD:
         {
             unsigned char *p = ptr;
-            unsigned int len = p[arg - 2] << 8 | p[arg - 1];
+            unsigned int len;
+
+            if (arg != EVP_AEAD_TLS1_AAD_LEN)
+                return -1;
+
+            len = p[arg - 2] << 8 | p[arg - 1];
 
             if (!ctx->encrypt) {
                 len -= MD5_DIGEST_LENGTH;