Rename <openssl/core_numbers.h> -> <openssl/core_dispatch.h>
[oweals/openssl.git] / crypto / evp / mac_meth.c
index e2bb016c0f63dd846802a91464c00be15c2667ad..c22ebd335fc370044ccef75169bbff3348ee5ecc 100644 (file)
@@ -1,10 +1,10 @@
 #include <openssl/evp.h>
 #include <openssl/err.h>
 #include <openssl/core.h>
-#include <openssl/core_numbers.h>
-#include "internal/evp_int.h"
+#include <openssl/core_dispatch.h>
+#include "crypto/evp.h"
 #include "internal/provider.h"
-#include "evp_locl.h"
+#include "evp_local.h"
 
 static int evp_mac_up_ref(void *vmac)
 {
@@ -27,7 +27,6 @@ static void evp_mac_free(void *vmac)
     if (ref > 0)
         return;
     ossl_provider_free(mac->prov);
-    OPENSSL_free(mac->name);
     CRYPTO_THREAD_lock_free(mac->lock);
     OPENSSL_free(mac);
 }
@@ -47,18 +46,18 @@ static void *evp_mac_new(void)
     return mac;
 }
 
-static void *evp_mac_from_dispatch(const char *name, const OSSL_DISPATCH *fns,
+static void *evp_mac_from_dispatch(int name_id,
+                                   const OSSL_DISPATCH *fns,
                                    OSSL_PROVIDER *prov)
 {
     EVP_MAC *mac = NULL;
     int fnmaccnt = 0, fnctxcnt = 0;
 
-    if ((mac = evp_mac_new()) == NULL
-        || (mac->name = OPENSSL_strdup(name)) == NULL) {
-        EVP_MAC_free(mac);
+    if ((mac = evp_mac_new()) == NULL) {
         EVPerr(0, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
+    mac->name_id = name_id;
 
     for (; fns->function_id != 0; fns++) {
         switch (fns->function_id) {
@@ -120,15 +119,15 @@ static void *evp_mac_from_dispatch(const char *name, const OSSL_DISPATCH *fns,
                 break;
             mac->get_params = OSSL_get_OP_mac_get_params(fns);
             break;
-        case OSSL_FUNC_MAC_CTX_GET_PARAMS:
-            if (mac->ctx_get_params != NULL)
+        case OSSL_FUNC_MAC_GET_CTX_PARAMS:
+            if (mac->get_ctx_params != NULL)
                 break;
-            mac->ctx_get_params = OSSL_get_OP_mac_ctx_get_params(fns);
+            mac->get_ctx_params = OSSL_get_OP_mac_get_ctx_params(fns);
             break;
-        case OSSL_FUNC_MAC_CTX_SET_PARAMS:
-            if (mac->ctx_set_params != NULL)
+        case OSSL_FUNC_MAC_SET_CTX_PARAMS:
+            if (mac->set_ctx_params != NULL)
                 break;
-            mac->ctx_set_params = OSSL_get_OP_mac_ctx_set_params(fns);
+            mac->set_ctx_params = OSSL_get_OP_mac_set_ctx_params(fns);
             break;
         }
     }
@@ -168,11 +167,6 @@ void EVP_MAC_free(EVP_MAC *mac)
     evp_mac_free(mac);
 }
 
-const char *EVP_MAC_name(const EVP_MAC *mac)
-{
-    return mac->name;
-}
-
 const OSSL_PROVIDER *EVP_MAC_provider(const EVP_MAC *mac)
 {
     return mac->prov;
@@ -185,16 +179,25 @@ const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac)
     return mac->gettable_params();
 }
 
-const OSSL_PARAM *EVP_MAC_CTX_gettable_params(const EVP_MAC *mac)
+const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac)
 {
     if (mac->gettable_ctx_params == NULL)
         return NULL;
     return mac->gettable_ctx_params();
 }
 
-const OSSL_PARAM *EVP_MAC_CTX_settable_params(const EVP_MAC *mac)
+const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac)
 {
     if (mac->settable_ctx_params == NULL)
         return NULL;
     return mac->settable_ctx_params();
 }
+
+void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx,
+                             void (*fn)(EVP_MAC *mac, void *arg),
+                             void *arg)
+{
+    evp_generic_do_all(libctx, OSSL_OP_MAC,
+                       (void (*)(void *, void *))fn, arg,
+                       evp_mac_from_dispatch, evp_mac_free);
+}