sync
This commit is contained in:
parent
25f3a6cfac
commit
bfc16459ac
143 changed files with 3115 additions and 4613 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: bn.h,v 1.71 2023/04/27 06:48:47 tb Exp $ */
|
||||
/* $OpenBSD: bn.h,v 1.72 2023/06/13 09:12:22 tb Exp $ */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -547,6 +547,7 @@ void ERR_load_BN_strings(void);
|
|||
#define BN_R_ENCODING_ERROR 104
|
||||
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
#define BN_R_INPUT_NOT_REDUCED 110
|
||||
#define BN_R_INVALID_ARGUMENT 118
|
||||
#define BN_R_INVALID_LENGTH 106
|
||||
#define BN_R_INVALID_RANGE 115
|
||||
#define BN_R_NOT_A_SQUARE 111
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: bn_err.c,v 1.15 2022/07/12 14:42:48 kn Exp $ */
|
||||
/* $OpenBSD: bn_err.c,v 1.16 2023/06/13 09:12:22 tb Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
@ -80,6 +80,7 @@ static ERR_STRING_DATA BN_str_reasons[]= {
|
|||
{ERR_REASON(BN_R_ENCODING_ERROR) , "encoding error"},
|
||||
{ERR_REASON(BN_R_EXPAND_ON_STATIC_BIGNUM_DATA), "expand on static bignum data"},
|
||||
{ERR_REASON(BN_R_INPUT_NOT_REDUCED) , "input not reduced"},
|
||||
{ERR_REASON(BN_R_INVALID_ARGUMENT) , "invalid argument"},
|
||||
{ERR_REASON(BN_R_INVALID_LENGTH) , "invalid length"},
|
||||
{ERR_REASON(BN_R_INVALID_RANGE) , "invalid range"},
|
||||
{ERR_REASON(BN_R_NOT_A_SQUARE) , "not a square"},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: bn_mod.c,v 1.20 2023/03/27 10:21:23 tb Exp $ */
|
||||
/* $OpenBSD: bn_mod.c,v 1.21 2023/06/13 09:28:13 tb Exp $ */
|
||||
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
|
||||
* for the OpenSSL project. */
|
||||
/* ====================================================================
|
||||
|
@ -136,6 +136,10 @@ BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
|||
int
|
||||
BN_nnmod(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_mod_ct(r, a, m, ctx))
|
||||
return 0;
|
||||
if (BN_is_negative(r))
|
||||
|
@ -147,6 +151,10 @@ int
|
|||
BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_add(r, a, b))
|
||||
return 0;
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
|
@ -159,6 +167,10 @@ BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
|||
int
|
||||
BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_uadd(r, a, b))
|
||||
return 0;
|
||||
if (BN_ucmp(r, m) >= 0)
|
||||
|
@ -170,6 +182,10 @@ int
|
|||
BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_sub(r, a, b))
|
||||
return 0;
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
|
@ -182,6 +198,10 @@ BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
|||
int
|
||||
BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (BN_ucmp(a, b) >= 0)
|
||||
return BN_usub(r, a, b);
|
||||
if (!BN_usub(r, b, a))
|
||||
|
@ -198,6 +218,11 @@ BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
|
|||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rr = r;
|
||||
if (rr == a || rr == b)
|
||||
rr = BN_CTX_get(ctx);
|
||||
|
@ -231,6 +256,10 @@ BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
|||
int
|
||||
BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_lshift1(r, a))
|
||||
return 0;
|
||||
return BN_nnmod(r, r, m, ctx);
|
||||
|
@ -243,6 +272,10 @@ BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
|
|||
int
|
||||
BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m)
|
||||
{
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (!BN_lshift1(r, a))
|
||||
return 0;
|
||||
if (BN_ucmp(r, m) >= 0)
|
||||
|
@ -258,6 +291,11 @@ BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx)
|
|||
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!BN_nnmod(r, a, m, ctx))
|
||||
goto err;
|
||||
|
||||
|
@ -288,6 +326,11 @@ BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)
|
|||
{
|
||||
int max_shift;
|
||||
|
||||
if (r == m) {
|
||||
BNerror(BN_R_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!bn_copy(r, a))
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue