summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/gost/gostr341001.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/gost/gostr341001.c')
-rw-r--r--src/lib/libcrypto/gost/gostr341001.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/libcrypto/gost/gostr341001.c b/src/lib/libcrypto/gost/gostr341001.c
index c6221e4a01..5fb494009c 100644
--- a/src/lib/libcrypto/gost/gostr341001.c
+++ b/src/lib/libcrypto/gost/gostr341001.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gostr341001.c,v 1.4 2015/02/14 06:40:04 jsing Exp $ */ 1/* $OpenBSD: gostr341001.c,v 1.5 2017/01/21 10:38:29 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> 3 * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
4 * Copyright (c) 2005-2006 Cryptocom LTD 4 * Copyright (c) 2005-2006 Cryptocom LTD
@@ -57,6 +57,8 @@
57#include <openssl/bn.h> 57#include <openssl/bn.h>
58#include <openssl/err.h> 58#include <openssl/err.h>
59#include <openssl/gost.h> 59#include <openssl/gost.h>
60
61#include "bn_lcl.h"
60#include "gost_locl.h" 62#include "gost_locl.h"
61 63
62/* Convert little-endian byte array into bignum */ 64/* Convert little-endian byte array into bignum */
@@ -175,7 +177,7 @@ gost2001_do_sign(BIGNUM *md, GOST_KEY *eckey)
175 priv_key = GOST_KEY_get0_private_key(eckey); 177 priv_key = GOST_KEY_get0_private_key(eckey);
176 if ((e = BN_CTX_get(ctx)) == NULL) 178 if ((e = BN_CTX_get(ctx)) == NULL)
177 goto err; 179 goto err;
178 if (BN_mod(e, md, order, ctx) == 0) 180 if (BN_mod_ct(e, md, order, ctx) == 0)
179 goto err; 181 goto err;
180 if (BN_is_zero(e)) 182 if (BN_is_zero(e))
181 BN_one(e); 183 BN_one(e);
@@ -288,7 +290,7 @@ gost2001_do_verify(BIGNUM *md, ECDSA_SIG *sig, GOST_KEY *ec)
288 goto err; 290 goto err;
289 } 291 }
290 292
291 if (BN_mod(e, md, order, ctx) == 0) 293 if (BN_mod_ct(e, md, order, ctx) == 0)
292 goto err; 294 goto err;
293 if (BN_is_zero(e)) 295 if (BN_is_zero(e))
294 BN_one(e); 296 BN_one(e);
@@ -310,7 +312,7 @@ gost2001_do_verify(BIGNUM *md, ECDSA_SIG *sig, GOST_KEY *ec)
310 GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_EC_LIB); 312 GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_EC_LIB);
311 goto err; 313 goto err;
312 } 314 }
313 if (BN_mod(R, X, order, ctx) == 0) 315 if (BN_mod_ct(R, X, order, ctx) == 0)
314 goto err; 316 goto err;
315 if (BN_cmp(R, sig->r) != 0) { 317 if (BN_cmp(R, sig->r) != 0) {
316 GOSTerr(GOST_F_GOST2001_DO_VERIFY, GOST_R_SIGNATURE_MISMATCH); 318 GOSTerr(GOST_F_GOST2001_DO_VERIFY, GOST_R_SIGNATURE_MISMATCH);