Skip to content

Commit 74a6baf

Browse files
author
tb
committed
Do not zero cofactor on ec_guess_cofactor() success
The cofactor we tried to calculate should only be zeroed if we failed to compute it. ok inoguchi jsing
1 parent a4d0d43 commit 74a6baf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/libcrypto/ec/ec_lib.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: ec_lib.c,v 1.42 2022/03/29 13:44:06 tb Exp $ */
1+
/* $OpenBSD: ec_lib.c,v 1.43 2022/03/29 13:48:40 tb Exp $ */
22
/*
33
* Originally written by Bodo Moeller for the OpenSSL project.
44
*/
@@ -321,10 +321,14 @@ ec_guess_cofactor(EC_GROUP *group)
321321
goto err;
322322

323323
ret = 1;
324+
324325
err:
325326
BN_CTX_end(ctx);
326327
BN_CTX_free(ctx);
327-
BN_zero(&group->cofactor);
328+
329+
if (ret != 1)
330+
BN_zero(&group->cofactor);
331+
328332
return ret;
329333
}
330334

0 commit comments

Comments
 (0)