early-access version 2698

This commit is contained in:
pineappleEA
2022-04-24 22:29:35 +02:00
parent c96f949832
commit caa0c2911b
486 changed files with 37806 additions and 14362 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: rsa_gen.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */
/* $OpenBSD: rsa_gen.c,v 1.25 2022/01/20 11:11:17 inoguchi Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -70,6 +70,7 @@
#include <openssl/rsa.h>
#include "bn_lcl.h"
#include "rsa_locl.h"
static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb);
@@ -194,12 +195,14 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb)
if (!BN_mul(r0, r1, r2, ctx)) /* (p-1)(q-1) */
goto err;
BN_init(&pr0);
BN_with_flags(&pr0, r0, BN_FLG_CONSTTIME);
if (!BN_mod_inverse_ct(rsa->d, rsa->e, &pr0, ctx)) /* d */
if (BN_mod_inverse_ct(rsa->d, rsa->e, &pr0, ctx) == NULL) /* d */
goto err;
/* set up d for correct BN_FLG_CONSTTIME flag */
BN_init(&d);
BN_with_flags(&d, rsa->d, BN_FLG_CONSTTIME);
/* calculate d mod (p-1) */
@@ -211,8 +214,9 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb)
goto err;
/* calculate inverse of q mod p */
BN_init(&p);
BN_with_flags(&p, rsa->p, BN_FLG_CONSTTIME);
if (!BN_mod_inverse_ct(rsa->iqmp, rsa->q, &p, ctx))
if (BN_mod_inverse_ct(rsa->iqmp, rsa->q, &p, ctx) == NULL)
goto err;
ok = 1;