update set_ctx_param MAC calls to return 1 for a NULL params
authorPauli <ppzgs1@gmail.com>
Wed, 10 Mar 2021 08:37:07 +0000 (18:37 +1000)
committerPauli <ppzgs1@gmail.com>
Thu, 11 Mar 2021 22:27:30 +0000 (08:27 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14383)

providers/implementations/macs/blake2_mac_impl.c
providers/implementations/macs/cmac_prov.c
providers/implementations/macs/hmac_prov.c
providers/implementations/macs/kmac_prov.c
providers/implementations/macs/siphash_prov.c

index 35a162246eefaf8b2b53f0bbf132e72120710deb..e1ffa04bfddad85fae02881d90e5ccc20ccab7af 100644 (file)
@@ -185,6 +185,9 @@ static int blake2_mac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
     struct blake2_mac_data_st *macctx = vmacctx;
     const OSSL_PARAM *p;
 
+    if (params == NULL)
+        return 1;
+
     if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
         size_t size;
 
index 9807799fe01245c8cb7e420358d1f65ee6c5d337..0795c245a770d40b710723ded0c34ef0706b4eec 100644 (file)
@@ -184,6 +184,9 @@ static int cmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
     OSSL_LIB_CTX *ctx = PROV_LIBCTX_OF(macctx->provctx);
     const OSSL_PARAM *p;
 
+    if (params == NULL)
+        return 1;
+
     if (!ossl_prov_cipher_load_from_params(&macctx->cipher, params, ctx))
         return 0;
 
index 7188232d7d7bff41b16c97e0f4429a40b01eca35..f291e574caa1da5aa8994f8db9a99e1911eab80a 100644 (file)
@@ -294,6 +294,9 @@ static int hmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
     const OSSL_PARAM *p;
     int flags = 0;
 
+    if (params == NULL)
+        return 1;
+
     if (!ossl_prov_digest_load_from_params(&macctx->digest, params, ctx))
         return 0;
 
index 361ff8e716c5c313ee69b6d2c2fd3e5cf50e2921..8735705f1bed9241d93c7b5883596b3bc6d358f0 100644 (file)
@@ -379,6 +379,9 @@ static int kmac_set_ctx_params(void *vmacctx, const OSSL_PARAM *params)
     struct kmac_data_st *kctx = vmacctx;
     const OSSL_PARAM *p;
 
+    if (params == NULL)
+        return 1;
+
     if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_XOF)) != NULL
         && !OSSL_PARAM_get_int(p, &kctx->xof_mode))
         return 0;
index 3f2e3267e0c4b49344b7f4e85cbfcd34f3d46c57..0181d68ed1f997a511d2014c349303df1f4144d0 100644 (file)
@@ -195,6 +195,9 @@ static int siphash_set_params(void *vmacctx, const OSSL_PARAM *params)
     const OSSL_PARAM *p = NULL;
     size_t size;
 
+    if (params == NULL)
+        return 1;
+
     if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
         if (!OSSL_PARAM_get_size_t(p, &size)
             || !SipHash_set_hash_size(&ctx->siphash, size))