]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
gost_md: Rework alias support in digest registration
authorVitaly Chikunov <vt@altlinux.org>
Tue, 12 May 2020 22:55:49 +0000 (01:55 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Wed, 13 May 2020 17:12:23 +0000 (20:12 +0300)
gost_lcl.h
gost_md.c
gost_md2012.c

index d2d2e79273eac49e7472a821761a663169031500..d00955a5cb62b1c1bdd09077adf3694a8b9ed863 100644 (file)
@@ -363,6 +363,7 @@ extern GOST_cipher kuznyechik_kexp15_cipher;
 struct gost_digest_st {
     struct gost_digest_st *template;
     int nid;
+    const char *alias;
     EVP_MD *digest;
     int result_size;
     int input_blocksize;
index 1de9ffd67abb4d9d57e902c8a8f6e80cde6a3cdd..909054fba2a8f2b6a366a5c4c9acc7131ef83c87 100644 (file)
--- a/gost_md.c
+++ b/gost_md.c
@@ -63,12 +63,16 @@ EVP_MD *GOST_init_digest(GOST_digest *d)
         EVP_MD_meth_free(md);
         md = NULL;
     }
+    if (md && d->alias)
+        EVP_add_digest_alias(EVP_MD_name(md), d->alias);
     d->digest = md;
     return md;
 }
 
 void GOST_deinit_digest(GOST_digest *d)
 {
+    if (d->alias)
+        EVP_delete_digest_alias(d->alias);
     EVP_MD_meth_free(d->digest);
     d->digest = NULL;
 }
index 8d1bde8d8e0912e48e942acb943ffe6195015b9a..3900e5a2dcae8a55019643520a95091b6d55b7f4 100644 (file)
@@ -39,6 +39,7 @@ GOST_digest GostR3411_2012_template_digest = {
 
 GOST_digest GostR3411_2012_256_digest = {
     .nid = NID_id_GostR3411_2012_256,
+    .alias = "streebog256",
     .template = &GostR3411_2012_template_digest,
     .result_size = 32,
     .init = gost_digest_init256,
@@ -57,6 +58,7 @@ void digest_gost2012_256_destroy(void)
 
 GOST_digest GostR3411_2012_512_digest = {
     .nid = NID_id_GostR3411_2012_512,
+    .alias = "streebog512",
     .template = &GostR3411_2012_template_digest,
     .result_size = 64,
     .init = gost_digest_init512,