From: Vitaly Chikunov Date: Tue, 12 May 2020 22:55:49 +0000 (+0300) Subject: gost_md: Rework alias support in digest registration X-Git-Tag: v3.0.0~101^2~7 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=522de4bf0a1f1d14228034568dc6a3e74e2ffb08;p=openssl-gost%2Fengine.git gost_md: Rework alias support in digest registration --- diff --git a/gost_lcl.h b/gost_lcl.h index d2d2e79..d00955a 100644 --- a/gost_lcl.h +++ b/gost_lcl.h @@ -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; diff --git a/gost_md.c b/gost_md.c index 1de9ffd..909054f 100644 --- 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; } diff --git a/gost_md2012.c b/gost_md2012.c index 8d1bde8..3900e5a 100644 --- a/gost_md2012.c +++ b/gost_md2012.c @@ -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,