]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_prov.c
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
[openssl-gost/engine.git] / gost_prov.c
index fe65c4d14a686e99e89620ebbd7944793475be69..eab5918ac229adffdf5a74873197f5390d0c2364 100644 (file)
@@ -8,6 +8,7 @@
  **********************************************************************/
 
 #include <openssl/core_dispatch.h>
+#include <openssl/core_names.h>
 #include "gost_prov.h"
 #include "gost_lcl.h"
 #include "prov/err.h"           /* libprov err functions */
@@ -48,7 +49,7 @@ static void provider_ctx_free(PROV_CTX *ctx)
         proverr_free_handle(ctx->proverr_handle);
         OSSL_LIB_CTX_free(ctx->libctx);
     }
-    free(ctx);
+    OPENSSL_free(ctx);
 }
 
 extern int populate_gost_engine(ENGINE *e);
@@ -57,7 +58,7 @@ static PROV_CTX *provider_ctx_new(const OSSL_CORE_HANDLE *core,
 {
     PROV_CTX *ctx;
 
-    if ((ctx = malloc(sizeof(*ctx))) != NULL
+    if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) != NULL
         && (ctx->proverr_handle = proverr_new_handle(core, in)) != NULL
         && (ctx->libctx = OSSL_LIB_CTX_new()) != NULL
         && (ctx->e = ENGINE_new()) != NULL
@@ -86,11 +87,28 @@ static const OSSL_ALGORITHM *gost_operation(void *vprovctx,
                                                 int operation_id,
                                                 const int *no_cache)
 {
+    switch (operation_id) {
+    case OSSL_OP_CIPHER:
+        return GOST_prov_ciphers;
+    case OSSL_OP_DIGEST:
+        return GOST_prov_digests;
+    case OSSL_OP_MAC:
+        return GOST_prov_macs;
+    }
     return NULL;
 }
 
 static int gost_get_params(void *provctx, OSSL_PARAM *params)
 {
+    OSSL_PARAM *p;
+
+    p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
+    if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL GOST Provider"))
+        return 0;
+    p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS);
+    if (p != NULL && !OSSL_PARAM_set_int(p, 1)) /* We never fail. */
+        return 0;
+
     return 1;
 }
 
@@ -105,6 +123,9 @@ static const OSSL_ITEM *gost_get_reason_strings(void *provctx)
 /* The function that tears down this provider */
 static void gost_teardown(void *vprovctx)
 {
+    GOST_prov_deinit_ciphers();
+    GOST_prov_deinit_digests();
+    GOST_prov_deinit_mac_digests();
     provider_ctx_free(vprovctx);
 }
 
@@ -132,6 +153,7 @@ struct prov_ctx_st {
 # define OSSL_provider_init GOST_provider_init
 #endif
 
+OPENSSL_EXPORT
 int OSSL_provider_init(const OSSL_CORE_HANDLE *core,
                        const OSSL_DISPATCH *in,
                        const OSSL_DISPATCH **out,