Allow NULL input/output only in CCM mode. 86/78986/2
authorDariusz Michaluk <d.michaluk@samsung.com>
Thu, 7 Jul 2016 14:27:30 +0000 (16:27 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 8 Jul 2016 13:45:54 +0000 (06:45 -0700)
Change-Id: I0758a1f2d8fa7accf8517aec6c93f79cf5f369d5

src/encrypt.c

index 6dc4527..5cdbeab 100644 (file)
@@ -483,6 +483,10 @@ int encrypt_update(yaca_context_h ctx,
        if (c == NULL || input_len == 0 || output_len == NULL || op_type != c->op_type)
                return YACA_ERROR_INVALID_PARAMETER;
 
+       if (EVP_CIPHER_CTX_mode(c->cipher_ctx) != EVP_CIPH_CCM_MODE)
+               if (input == NULL || output == NULL)
+                       return YACA_ERROR_INVALID_PARAMETER;
+
        switch (op_type) {
        case OP_ENCRYPT:
                ret = EVP_EncryptUpdate(c->cipher_ctx, output, &loutput_len, input, input_len);