From 0d84f62acc3a66a91d846a15824b9d939d54aa79 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Mon, 12 Dec 2016 14:36:18 +0300 Subject: [PATCH] Fix signature verification. --- gost_pmeth.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gost_pmeth.c b/gost_pmeth.c index 9a01822..ce162f5 100644 --- a/gost_pmeth.c +++ b/gost_pmeth.c @@ -417,20 +417,20 @@ static int pkey_gost_ec_cp_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, /* ------------------- verify callbacks ---------------------------*/ /* Unpack signature according to cryptopro rules */ -DSA_SIG *unpack_cp_signature(const unsigned char *sig, size_t siglen) +DSA_SIG *unpack_cp_signature(const unsigned char *sigbuf, size_t siglen) { - DSA_SIG *s; - const BIGNUM *sig_r = NULL, *sig_s = NULL; + DSA_SIG *sig; + BIGNUM *r = NULL, *s = NULL; - s = DSA_SIG_new(); - if (s == NULL) { + sig = DSA_SIG_new(); + if (sig == NULL) { GOSTerr(GOST_F_UNPACK_CP_SIGNATURE, ERR_R_MALLOC_FAILURE); return NULL; } - DSA_SIG_get0(s, &sig_r, &sig_s); - sig_s = BN_bin2bn(sig, siglen / 2, NULL); - sig_r = BN_bin2bn(sig + siglen / 2, siglen / 2, NULL); - return s; + s = BN_bin2bn(sigbuf, siglen / 2, NULL); + r = BN_bin2bn(sigbuf + siglen / 2, siglen / 2, NULL); + DSA_SIG_set0(sig, r, s); + return sig; } static int pkey_gost_ec_cp_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, -- 2.39.5