keymgmt: convert to use the params modification detection.
authorPauli <paul.dale@oracle.com>
Thu, 23 Apr 2020 10:31:12 +0000 (20:31 +1000)
committerPauli <paul.dale@oracle.com>
Sat, 25 Apr 2020 08:46:32 +0000 (18:46 +1000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11601)

crypto/evp/keymgmt_lib.c

index 9ed176410a87e07b855e3ea59ff06eaaa03e34b1..3493ceb3cbb2f598a718b54cdd1d911ad66735ba 100644 (file)
@@ -432,25 +432,23 @@ int evp_keymgmt_util_get_deflt_digest_name(EVP_KEYMGMT *keymgmt,
     params[0] =
         OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_DEFAULT_DIGEST,
                                          mddefault, sizeof(mddefault));
-    params[0].return_size = sizeof(mddefault) + 1;
     params[1] =
         OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_MANDATORY_DIGEST,
                                          mdmandatory,
                                          sizeof(mdmandatory));
-    params[1].return_size = sizeof(mdmandatory) + 1;
     params[2] = OSSL_PARAM_construct_end();
 
     if (!evp_keymgmt_get_params(keymgmt, keydata, params))
         return 0;
 
-    if (params[1].return_size != sizeof(mdmandatory) + 1) {
-        if (params[1].return_size == 1) /* Only a NUL byte */
+    if (OSSL_PARAM_modified(params + 1)) {
+        if (params[1].return_size <= 1) /* Only a NUL byte */
             result = SN_undef;
         else
             result = mdmandatory;
         rv = 2;
-    } else if (params[0].return_size != sizeof(mddefault) + 1) {
-        if (params[0].return_size == 1) /* Only a NUL byte */
+    } else if (OSSL_PARAM_modified(params)) {
+        if (params[0].return_size <= 1) /* Only a NUL byte */
             result = SN_undef;
         else
             result = mddefault;