Latest update
This commit is contained in:
@@ -800,7 +800,7 @@ $code.=<<___;
|
||||
#if 0
|
||||
/*
|
||||
* The bn_div_3_words entry point is re-used for constant-time interface.
|
||||
* Implementation is retained as hystorical reference.
|
||||
* Implementation is retained as historical reference.
|
||||
*/
|
||||
.align 5
|
||||
.globl bn_div_3_words
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
static const char Hex[] = "0123456789ABCDEF";
|
||||
|
||||
/* Must 'OPENSSL_free' the returned data */
|
||||
char *BN_bn2hex(const BIGNUM *a)
|
||||
{
|
||||
int i, j, v, z = 0;
|
||||
char *buf;
|
||||
char *p;
|
||||
|
||||
if (BN_is_zero(a))
|
||||
return OPENSSL_strdup("0");
|
||||
buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);
|
||||
if (buf == NULL) {
|
||||
BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
p = buf;
|
||||
if (a->neg)
|
||||
*p++ = '-';
|
||||
for (i = a->top - 1; i >= 0; i--) {
|
||||
for (j = BN_BITS2 - 8; j >= 0; j -= 8) {
|
||||
/* strip leading zeros */
|
||||
v = (int)((a->d[i] >> j) & 0xff);
|
||||
if (z || v != 0) {
|
||||
*p++ = Hex[v >> 4];
|
||||
*p++ = Hex[v & 0x0f];
|
||||
z = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
err:
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
/* No BIO_snprintf in FIPS_MODE */
|
||||
/* Must 'OPENSSL_free' the returned data */
|
||||
char *BN_bn2dec(const BIGNUM *a)
|
||||
{
|
||||
int i = 0, num, ok = 0, n, tbytes;
|
||||
char *buf = NULL;
|
||||
char *p;
|
||||
BIGNUM *t = NULL;
|
||||
BN_ULONG *bn_data = NULL, *lp;
|
||||
int bn_data_num;
|
||||
|
||||
/*-
|
||||
* get an upper bound for the length of the decimal integer
|
||||
* num <= (BN_num_bits(a) + 1) * log(2)
|
||||
* <= 3 * BN_num_bits(a) * 0.101 + log(2) + 1 (rounding error)
|
||||
* <= 3 * BN_num_bits(a) / 10 + 3 * BN_num_bits / 1000 + 1 + 1
|
||||
*/
|
||||
i = BN_num_bits(a) * 3;
|
||||
num = (i / 10 + i / 1000 + 1) + 1;
|
||||
tbytes = num + 3; /* negative and terminator and one spare? */
|
||||
bn_data_num = num / BN_DEC_NUM + 1;
|
||||
bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG));
|
||||
buf = OPENSSL_malloc(tbytes);
|
||||
if (buf == NULL || bn_data == NULL) {
|
||||
BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if ((t = BN_dup(a)) == NULL)
|
||||
goto err;
|
||||
|
||||
p = buf;
|
||||
lp = bn_data;
|
||||
if (BN_is_zero(t)) {
|
||||
*p++ = '0';
|
||||
*p++ = '\0';
|
||||
} else {
|
||||
if (BN_is_negative(t))
|
||||
*p++ = '-';
|
||||
|
||||
while (!BN_is_zero(t)) {
|
||||
if (lp - bn_data >= bn_data_num)
|
||||
goto err;
|
||||
*lp = BN_div_word(t, BN_DEC_CONV);
|
||||
if (*lp == (BN_ULONG)-1)
|
||||
goto err;
|
||||
lp++;
|
||||
}
|
||||
lp--;
|
||||
/*
|
||||
* We now have a series of blocks, BN_DEC_NUM chars in length, where
|
||||
* the last one needs truncation. The blocks need to be reversed in
|
||||
* order.
|
||||
*/
|
||||
n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT1, *lp);
|
||||
if (n < 0)
|
||||
goto err;
|
||||
p += n;
|
||||
while (lp != bn_data) {
|
||||
lp--;
|
||||
n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT2, *lp);
|
||||
if (n < 0)
|
||||
goto err;
|
||||
p += n;
|
||||
}
|
||||
}
|
||||
ok = 1;
|
||||
err:
|
||||
OPENSSL_free(bn_data);
|
||||
BN_free(t);
|
||||
if (ok)
|
||||
return buf;
|
||||
OPENSSL_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int BN_hex2bn(BIGNUM **bn, const char *a)
|
||||
{
|
||||
BIGNUM *ret = NULL;
|
||||
BN_ULONG l = 0;
|
||||
int neg = 0, h, m, i, j, k, c;
|
||||
int num;
|
||||
|
||||
if (a == NULL || *a == '\0')
|
||||
return 0;
|
||||
|
||||
if (*a == '-') {
|
||||
neg = 1;
|
||||
a++;
|
||||
}
|
||||
|
||||
for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++)
|
||||
continue;
|
||||
|
||||
if (i == 0 || i > INT_MAX / 4)
|
||||
goto err;
|
||||
|
||||
num = i + neg;
|
||||
if (bn == NULL)
|
||||
return num;
|
||||
|
||||
/* a is the start of the hex digits, and it is 'i' long */
|
||||
if (*bn == NULL) {
|
||||
if ((ret = BN_new()) == NULL)
|
||||
return 0;
|
||||
} else {
|
||||
ret = *bn;
|
||||
BN_zero(ret);
|
||||
}
|
||||
|
||||
/* i is the number of hex digits */
|
||||
if (bn_expand(ret, i * 4) == NULL)
|
||||
goto err;
|
||||
|
||||
j = i; /* least significant 'hex' */
|
||||
m = 0;
|
||||
h = 0;
|
||||
while (j > 0) {
|
||||
m = (BN_BYTES * 2 <= j) ? BN_BYTES * 2 : j;
|
||||
l = 0;
|
||||
for (;;) {
|
||||
c = a[j - m];
|
||||
k = OPENSSL_hexchar2int(c);
|
||||
if (k < 0)
|
||||
k = 0; /* paranoia */
|
||||
l = (l << 4) | k;
|
||||
|
||||
if (--m <= 0) {
|
||||
ret->d[h++] = l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
j -= BN_BYTES * 2;
|
||||
}
|
||||
ret->top = h;
|
||||
bn_correct_top(ret);
|
||||
|
||||
*bn = ret;
|
||||
bn_check_top(ret);
|
||||
/* Don't set the negative flag if it's zero. */
|
||||
if (ret->top != 0)
|
||||
ret->neg = neg;
|
||||
return num;
|
||||
err:
|
||||
if (*bn == NULL)
|
||||
BN_free(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_dec2bn(BIGNUM **bn, const char *a)
|
||||
{
|
||||
BIGNUM *ret = NULL;
|
||||
BN_ULONG l = 0;
|
||||
int neg = 0, i, j;
|
||||
int num;
|
||||
|
||||
if (a == NULL || *a == '\0')
|
||||
return 0;
|
||||
if (*a == '-') {
|
||||
neg = 1;
|
||||
a++;
|
||||
}
|
||||
|
||||
for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
|
||||
continue;
|
||||
|
||||
if (i == 0 || i > INT_MAX / 4)
|
||||
goto err;
|
||||
|
||||
num = i + neg;
|
||||
if (bn == NULL)
|
||||
return num;
|
||||
|
||||
/*
|
||||
* a is the start of the digits, and it is 'i' long. We chop it into
|
||||
* BN_DEC_NUM digits at a time
|
||||
*/
|
||||
if (*bn == NULL) {
|
||||
if ((ret = BN_new()) == NULL)
|
||||
return 0;
|
||||
} else {
|
||||
ret = *bn;
|
||||
BN_zero(ret);
|
||||
}
|
||||
|
||||
/* i is the number of digits, a bit of an over expand */
|
||||
if (bn_expand(ret, i * 4) == NULL)
|
||||
goto err;
|
||||
|
||||
j = BN_DEC_NUM - i % BN_DEC_NUM;
|
||||
if (j == BN_DEC_NUM)
|
||||
j = 0;
|
||||
l = 0;
|
||||
while (--i >= 0) {
|
||||
l *= 10;
|
||||
l += *a - '0';
|
||||
a++;
|
||||
if (++j == BN_DEC_NUM) {
|
||||
if (!BN_mul_word(ret, BN_DEC_CONV)
|
||||
|| !BN_add_word(ret, l))
|
||||
goto err;
|
||||
l = 0;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bn_correct_top(ret);
|
||||
*bn = ret;
|
||||
bn_check_top(ret);
|
||||
/* Don't set the negative flag if it's zero. */
|
||||
if (ret->top != 0)
|
||||
ret->neg = neg;
|
||||
return num;
|
||||
err:
|
||||
if (*bn == NULL)
|
||||
BN_free(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_asc2bn(BIGNUM **bn, const char *a)
|
||||
{
|
||||
const char *p = a;
|
||||
|
||||
if (*p == '-')
|
||||
p++;
|
||||
|
||||
if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) {
|
||||
if (!BN_hex2bn(bn, p + 2))
|
||||
return 0;
|
||||
} else {
|
||||
if (!BN_dec2bn(bn, p))
|
||||
return 0;
|
||||
}
|
||||
/* Don't set the negative flag if it's zero. */
|
||||
if (*a == '-' && (*bn)->top != 0)
|
||||
(*bn)->neg = 1;
|
||||
return 1;
|
||||
}
|
||||
+32
-6
@@ -86,8 +86,11 @@ struct bignum_ctx {
|
||||
int too_many;
|
||||
/* Flags. */
|
||||
int flags;
|
||||
/* The library context */
|
||||
OPENSSL_CTX *libctx;
|
||||
};
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
/* Debugging functionality */
|
||||
static void ctxdbg(BIO *channel, const char *text, BN_CTX *ctx)
|
||||
{
|
||||
@@ -116,39 +119,54 @@ static void ctxdbg(BIO *channel, const char *text, BN_CTX *ctx)
|
||||
BIO_printf(channel, "\n");
|
||||
}
|
||||
|
||||
#define CTXDBG(str, ctx) \
|
||||
# define CTXDBG(str, ctx) \
|
||||
OSSL_TRACE_BEGIN(BN_CTX) { \
|
||||
ctxdbg(trc_out, str, ctx); \
|
||||
} OSSL_TRACE_END(BN_CTX)
|
||||
#else
|
||||
/* TODO(3.0): Consider if we want to do this in FIPS mode */
|
||||
# define CTXDBG(str, ctx) do {} while(0)
|
||||
#endif /* FIPS_MODE */
|
||||
|
||||
|
||||
BN_CTX *BN_CTX_new(void)
|
||||
BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx)
|
||||
{
|
||||
BN_CTX *ret;
|
||||
|
||||
if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
|
||||
BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
|
||||
BNerr(BN_F_BN_CTX_NEW_EX, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
/* Initialise the structure */
|
||||
BN_POOL_init(&ret->pool);
|
||||
BN_STACK_init(&ret->stack);
|
||||
ret->libctx = ctx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BN_CTX *BN_CTX_secure_new(void)
|
||||
BN_CTX *BN_CTX_new(void)
|
||||
{
|
||||
BN_CTX *ret = BN_CTX_new();
|
||||
return BN_CTX_new_ex(NULL);
|
||||
}
|
||||
|
||||
BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx)
|
||||
{
|
||||
BN_CTX *ret = BN_CTX_new_ex(ctx);
|
||||
|
||||
if (ret != NULL)
|
||||
ret->flags = BN_FLG_SECURE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BN_CTX *BN_CTX_secure_new(void)
|
||||
{
|
||||
return BN_CTX_secure_new_ex(NULL);
|
||||
}
|
||||
|
||||
void BN_CTX_free(BN_CTX *ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
#ifndef FIPS_MODE
|
||||
OSSL_TRACE_BEGIN(BN_CTX) {
|
||||
BN_POOL_ITEM *pool = ctx->pool.head;
|
||||
BIO_printf(trc_out,
|
||||
@@ -163,6 +181,7 @@ void BN_CTX_free(BN_CTX *ctx)
|
||||
}
|
||||
BIO_printf(trc_out, "\n");
|
||||
} OSSL_TRACE_END(BN_CTX);
|
||||
#endif
|
||||
BN_STACK_finish(&ctx->stack);
|
||||
BN_POOL_finish(&ctx->pool);
|
||||
OPENSSL_free(ctx);
|
||||
@@ -226,6 +245,13 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
OPENSSL_CTX *bn_get_lib_ctx(BN_CTX *ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return NULL;
|
||||
return ctx->libctx;
|
||||
}
|
||||
|
||||
/************/
|
||||
/* BN_STACK */
|
||||
/************/
|
||||
|
||||
+1
-1
@@ -258,7 +258,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
||||
*
|
||||
* - availability of constant-time bn_div_3_words;
|
||||
* - dividend is at least as "wide" as divisor, limb-wise, zero-padded
|
||||
* if so requied, which shouldn't be a privacy problem, because
|
||||
* if so required, which shouldn't be a privacy problem, because
|
||||
* divisor's length is considered public;
|
||||
*/
|
||||
int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -29,6 +29,7 @@ static const ERR_STRING_DATA BN_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_COMPUTE_WNAF, 0), "bn_compute_wNAF"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_GET, 0), "BN_CTX_get"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_NEW, 0), "BN_CTX_new"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_NEW_EX, 0), "BN_CTX_new_ex"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_START, 0), "BN_CTX_start"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_DIV, 0), "BN_div"},
|
||||
{ERR_PACK(ERR_LIB_BN, BN_F_BN_DIV_RECP, 0), "BN_div_recp"},
|
||||
@@ -95,6 +96,7 @@ static const ERR_STRING_DATA BN_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NOT_INITIALIZED), "not initialized"},
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_INVERSE), "no inverse"},
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_SOLUTION), "no solution"},
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_SUITABLE_DIGEST), "no suitable digest"},
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_PRIVATE_KEY_TOO_LARGE),
|
||||
"private key too large"},
|
||||
{ERR_PACK(ERR_LIB_BN, 0, BN_R_P_IS_NOT_PRIME), "p is not prime"},
|
||||
|
||||
+3
-1
@@ -295,7 +295,7 @@ struct bn_gencb_st {
|
||||
(b) > 23 ? 3 : 1)
|
||||
|
||||
/*
|
||||
* BN_mod_exp_mont_conttime is based on the assumption that the L1 data cache
|
||||
* BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache
|
||||
* line width of the target processor is at least the following value.
|
||||
*/
|
||||
# define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 )
|
||||
@@ -668,4 +668,6 @@ static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
|
||||
return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
|
||||
}
|
||||
|
||||
OPENSSL_CTX *bn_get_lib_ctx(BN_CTX *ctx);
|
||||
|
||||
#endif
|
||||
@@ -98,8 +98,12 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
|
||||
/* There are no prime numbers this small. */
|
||||
BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);
|
||||
return 0;
|
||||
} else if (bits == 2 && safe) {
|
||||
/* The smallest safe prime (7) is three bits. */
|
||||
} else if (add == NULL && safe && bits < 6 && bits != 3) {
|
||||
/*
|
||||
* The smallest safe prime (7) is three bits.
|
||||
* But the following two safe primes with less than 6 bits (11, 23)
|
||||
* are unreachable for BN_rand with BN_RAND_TOP_TWO.
|
||||
*/
|
||||
BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-276
@@ -8,285 +8,12 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/ctype.h"
|
||||
#include <limits.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/bio.h>
|
||||
#include "bn_lcl.h"
|
||||
|
||||
static const char Hex[] = "0123456789ABCDEF";
|
||||
|
||||
/* Must 'OPENSSL_free' the returned data */
|
||||
char *BN_bn2hex(const BIGNUM *a)
|
||||
{
|
||||
int i, j, v, z = 0;
|
||||
char *buf;
|
||||
char *p;
|
||||
|
||||
if (BN_is_zero(a))
|
||||
return OPENSSL_strdup("0");
|
||||
buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);
|
||||
if (buf == NULL) {
|
||||
BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
p = buf;
|
||||
if (a->neg)
|
||||
*p++ = '-';
|
||||
for (i = a->top - 1; i >= 0; i--) {
|
||||
for (j = BN_BITS2 - 8; j >= 0; j -= 8) {
|
||||
/* strip leading zeros */
|
||||
v = (int)((a->d[i] >> j) & 0xff);
|
||||
if (z || v != 0) {
|
||||
*p++ = Hex[v >> 4];
|
||||
*p++ = Hex[v & 0x0f];
|
||||
z = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
err:
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Must 'OPENSSL_free' the returned data */
|
||||
char *BN_bn2dec(const BIGNUM *a)
|
||||
{
|
||||
int i = 0, num, ok = 0, n, tbytes;
|
||||
char *buf = NULL;
|
||||
char *p;
|
||||
BIGNUM *t = NULL;
|
||||
BN_ULONG *bn_data = NULL, *lp;
|
||||
int bn_data_num;
|
||||
|
||||
/*-
|
||||
* get an upper bound for the length of the decimal integer
|
||||
* num <= (BN_num_bits(a) + 1) * log(2)
|
||||
* <= 3 * BN_num_bits(a) * 0.101 + log(2) + 1 (rounding error)
|
||||
* <= 3 * BN_num_bits(a) / 10 + 3 * BN_num_bits / 1000 + 1 + 1
|
||||
*/
|
||||
i = BN_num_bits(a) * 3;
|
||||
num = (i / 10 + i / 1000 + 1) + 1;
|
||||
tbytes = num + 3; /* negative and terminator and one spare? */
|
||||
bn_data_num = num / BN_DEC_NUM + 1;
|
||||
bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG));
|
||||
buf = OPENSSL_malloc(tbytes);
|
||||
if (buf == NULL || bn_data == NULL) {
|
||||
BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if ((t = BN_dup(a)) == NULL)
|
||||
goto err;
|
||||
|
||||
p = buf;
|
||||
lp = bn_data;
|
||||
if (BN_is_zero(t)) {
|
||||
*p++ = '0';
|
||||
*p++ = '\0';
|
||||
} else {
|
||||
if (BN_is_negative(t))
|
||||
*p++ = '-';
|
||||
|
||||
while (!BN_is_zero(t)) {
|
||||
if (lp - bn_data >= bn_data_num)
|
||||
goto err;
|
||||
*lp = BN_div_word(t, BN_DEC_CONV);
|
||||
if (*lp == (BN_ULONG)-1)
|
||||
goto err;
|
||||
lp++;
|
||||
}
|
||||
lp--;
|
||||
/*
|
||||
* We now have a series of blocks, BN_DEC_NUM chars in length, where
|
||||
* the last one needs truncation. The blocks need to be reversed in
|
||||
* order.
|
||||
*/
|
||||
n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT1, *lp);
|
||||
if (n < 0)
|
||||
goto err;
|
||||
p += n;
|
||||
while (lp != bn_data) {
|
||||
lp--;
|
||||
n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT2, *lp);
|
||||
if (n < 0)
|
||||
goto err;
|
||||
p += n;
|
||||
}
|
||||
}
|
||||
ok = 1;
|
||||
err:
|
||||
OPENSSL_free(bn_data);
|
||||
BN_free(t);
|
||||
if (ok)
|
||||
return buf;
|
||||
OPENSSL_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int BN_hex2bn(BIGNUM **bn, const char *a)
|
||||
{
|
||||
BIGNUM *ret = NULL;
|
||||
BN_ULONG l = 0;
|
||||
int neg = 0, h, m, i, j, k, c;
|
||||
int num;
|
||||
|
||||
if (a == NULL || *a == '\0')
|
||||
return 0;
|
||||
|
||||
if (*a == '-') {
|
||||
neg = 1;
|
||||
a++;
|
||||
}
|
||||
|
||||
for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++)
|
||||
continue;
|
||||
|
||||
if (i == 0 || i > INT_MAX / 4)
|
||||
goto err;
|
||||
|
||||
num = i + neg;
|
||||
if (bn == NULL)
|
||||
return num;
|
||||
|
||||
/* a is the start of the hex digits, and it is 'i' long */
|
||||
if (*bn == NULL) {
|
||||
if ((ret = BN_new()) == NULL)
|
||||
return 0;
|
||||
} else {
|
||||
ret = *bn;
|
||||
BN_zero(ret);
|
||||
}
|
||||
|
||||
/* i is the number of hex digits */
|
||||
if (bn_expand(ret, i * 4) == NULL)
|
||||
goto err;
|
||||
|
||||
j = i; /* least significant 'hex' */
|
||||
m = 0;
|
||||
h = 0;
|
||||
while (j > 0) {
|
||||
m = (BN_BYTES * 2 <= j) ? BN_BYTES * 2 : j;
|
||||
l = 0;
|
||||
for (;;) {
|
||||
c = a[j - m];
|
||||
k = OPENSSL_hexchar2int(c);
|
||||
if (k < 0)
|
||||
k = 0; /* paranoia */
|
||||
l = (l << 4) | k;
|
||||
|
||||
if (--m <= 0) {
|
||||
ret->d[h++] = l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
j -= BN_BYTES * 2;
|
||||
}
|
||||
ret->top = h;
|
||||
bn_correct_top(ret);
|
||||
|
||||
*bn = ret;
|
||||
bn_check_top(ret);
|
||||
/* Don't set the negative flag if it's zero. */
|
||||
if (ret->top != 0)
|
||||
ret->neg = neg;
|
||||
return num;
|
||||
err:
|
||||
if (*bn == NULL)
|
||||
BN_free(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_dec2bn(BIGNUM **bn, const char *a)
|
||||
{
|
||||
BIGNUM *ret = NULL;
|
||||
BN_ULONG l = 0;
|
||||
int neg = 0, i, j;
|
||||
int num;
|
||||
|
||||
if (a == NULL || *a == '\0')
|
||||
return 0;
|
||||
if (*a == '-') {
|
||||
neg = 1;
|
||||
a++;
|
||||
}
|
||||
|
||||
for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++)
|
||||
continue;
|
||||
|
||||
if (i == 0 || i > INT_MAX / 4)
|
||||
goto err;
|
||||
|
||||
num = i + neg;
|
||||
if (bn == NULL)
|
||||
return num;
|
||||
|
||||
/*
|
||||
* a is the start of the digits, and it is 'i' long. We chop it into
|
||||
* BN_DEC_NUM digits at a time
|
||||
*/
|
||||
if (*bn == NULL) {
|
||||
if ((ret = BN_new()) == NULL)
|
||||
return 0;
|
||||
} else {
|
||||
ret = *bn;
|
||||
BN_zero(ret);
|
||||
}
|
||||
|
||||
/* i is the number of digits, a bit of an over expand */
|
||||
if (bn_expand(ret, i * 4) == NULL)
|
||||
goto err;
|
||||
|
||||
j = BN_DEC_NUM - i % BN_DEC_NUM;
|
||||
if (j == BN_DEC_NUM)
|
||||
j = 0;
|
||||
l = 0;
|
||||
while (--i >= 0) {
|
||||
l *= 10;
|
||||
l += *a - '0';
|
||||
a++;
|
||||
if (++j == BN_DEC_NUM) {
|
||||
if (!BN_mul_word(ret, BN_DEC_CONV)
|
||||
|| !BN_add_word(ret, l))
|
||||
goto err;
|
||||
l = 0;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bn_correct_top(ret);
|
||||
*bn = ret;
|
||||
bn_check_top(ret);
|
||||
/* Don't set the negative flag if it's zero. */
|
||||
if (ret->top != 0)
|
||||
ret->neg = neg;
|
||||
return num;
|
||||
err:
|
||||
if (*bn == NULL)
|
||||
BN_free(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_asc2bn(BIGNUM **bn, const char *a)
|
||||
{
|
||||
const char *p = a;
|
||||
|
||||
if (*p == '-')
|
||||
p++;
|
||||
|
||||
if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) {
|
||||
if (!BN_hex2bn(bn, p + 2))
|
||||
return 0;
|
||||
} else {
|
||||
if (!BN_dec2bn(bn, p))
|
||||
return 0;
|
||||
}
|
||||
/* Don't set the negative flag if it's zero. */
|
||||
if (*a == '-' && (*bn)->top != 0)
|
||||
(*bn)->neg = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int BN_print_fp(FILE *fp, const BIGNUM *a)
|
||||
{
|
||||
BIO *b;
|
||||
@@ -299,7 +26,7 @@ int BN_print_fp(FILE *fp, const BIGNUM *a)
|
||||
BIO_free(b);
|
||||
return ret;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int BN_print(BIO *bp, const BIGNUM *a)
|
||||
{
|
||||
|
||||
+61
-20
@@ -10,18 +10,22 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/rand_int.h"
|
||||
#include "bn_lcl.h"
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
typedef enum bnrand_flag_e {
|
||||
NORMAL, TESTING, PRIVATE
|
||||
} BNRAND_FLAG;
|
||||
|
||||
static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom)
|
||||
static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
unsigned char *buf = NULL;
|
||||
int b, ret = 0, bit, bytes, mask;
|
||||
OPENSSL_CTX *libctx = bn_get_lib_ctx(ctx);
|
||||
|
||||
if (bits == 0) {
|
||||
if (top != BN_RAND_TOP_ANY || bottom != BN_RAND_BOTTOM_ANY)
|
||||
@@ -43,7 +47,8 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom)
|
||||
}
|
||||
|
||||
/* make a random number and set the top and bottom bits */
|
||||
b = flag == NORMAL ? RAND_bytes(buf, bytes) : RAND_priv_bytes(buf, bytes);
|
||||
b = flag == NORMAL ? rand_bytes_ex(libctx, buf, bytes)
|
||||
: rand_priv_bytes_ex(libctx, buf, bytes);
|
||||
if (b <= 0)
|
||||
goto err;
|
||||
|
||||
@@ -55,7 +60,7 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom)
|
||||
unsigned char c;
|
||||
|
||||
for (i = 0; i < bytes; i++) {
|
||||
if (RAND_bytes(&c, 1) <= 0)
|
||||
if (rand_bytes_ex(libctx, &c, 1) <= 0)
|
||||
goto err;
|
||||
if (c >= 128 && i > 0)
|
||||
buf[i] = buf[i - 1];
|
||||
@@ -94,23 +99,33 @@ toosmall:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand(NORMAL, rnd, bits, top, bottom, ctx);
|
||||
}
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(NORMAL, rnd, bits, top, bottom);
|
||||
return bnrand(NORMAL, rnd, bits, top, bottom, NULL);
|
||||
}
|
||||
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(TESTING, rnd, bits, top, bottom);
|
||||
return bnrand(TESTING, rnd, bits, top, bottom, NULL);
|
||||
}
|
||||
|
||||
int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand(PRIVATE, rnd, bits, top, bottom, ctx);
|
||||
}
|
||||
|
||||
int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
{
|
||||
return bnrand(PRIVATE, rnd, bits, top, bottom);
|
||||
return bnrand(PRIVATE, rnd, bits, top, bottom, NULL);
|
||||
}
|
||||
|
||||
/* random number r: 0 <= r < range */
|
||||
static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
int n;
|
||||
int count = 100;
|
||||
@@ -132,7 +147,8 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
* than range
|
||||
*/
|
||||
do {
|
||||
if (!bnrand(flag, r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
|
||||
if (!bnrand(flag, r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY,
|
||||
ctx))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@@ -159,7 +175,7 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
} else {
|
||||
do {
|
||||
/* range = 11..._2 or range = 101..._2 */
|
||||
if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
|
||||
if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY, ctx))
|
||||
return 0;
|
||||
|
||||
if (!--count) {
|
||||
@@ -174,14 +190,24 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand_range(NORMAL, r, range, ctx);
|
||||
}
|
||||
|
||||
int BN_rand_range(BIGNUM *r, const BIGNUM *range)
|
||||
{
|
||||
return bnrand_range(NORMAL, r, range);
|
||||
return bnrand_range(NORMAL, r, range, NULL);
|
||||
}
|
||||
|
||||
int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx)
|
||||
{
|
||||
return bnrand_range(PRIVATE, r, range, ctx);
|
||||
}
|
||||
|
||||
int BN_priv_rand_range(BIGNUM *r, const BIGNUM *range)
|
||||
{
|
||||
return bnrand_range(PRIVATE, r, range);
|
||||
return bnrand_range(PRIVATE, r, range, NULL);
|
||||
}
|
||||
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
|
||||
@@ -206,7 +232,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
const BIGNUM *priv, const unsigned char *message,
|
||||
size_t message_len, BN_CTX *ctx)
|
||||
{
|
||||
SHA512_CTX sha;
|
||||
EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
|
||||
/*
|
||||
* We use 512 bits of random data per iteration to ensure that we have at
|
||||
* least |range| bits of randomness.
|
||||
@@ -217,8 +243,13 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
/* We generate |range|+8 bytes of random output. */
|
||||
const unsigned num_k_bytes = BN_num_bytes(range) + 8;
|
||||
unsigned char private_bytes[96];
|
||||
unsigned char *k_bytes;
|
||||
unsigned char *k_bytes = NULL;
|
||||
int ret = 0;
|
||||
EVP_MD *md = NULL;
|
||||
OPENSSL_CTX *libctx = bn_get_lib_ctx(ctx);
|
||||
|
||||
if (mdctx == NULL)
|
||||
goto err;
|
||||
|
||||
k_bytes = OPENSSL_malloc(num_k_bytes);
|
||||
if (k_bytes == NULL)
|
||||
@@ -238,15 +269,23 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
memcpy(private_bytes, priv->d, todo);
|
||||
memset(private_bytes + todo, 0, sizeof(private_bytes) - todo);
|
||||
|
||||
md = EVP_MD_fetch(libctx, "SHA512", NULL);
|
||||
if (md == NULL) {
|
||||
BNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_NO_SUITABLE_DIGEST);
|
||||
goto err;
|
||||
}
|
||||
for (done = 0; done < num_k_bytes;) {
|
||||
if (RAND_priv_bytes(random_bytes, sizeof(random_bytes)) != 1)
|
||||
if (!rand_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes)))
|
||||
goto err;
|
||||
|
||||
if (!EVP_DigestInit_ex(mdctx, md, NULL)
|
||||
|| !EVP_DigestUpdate(mdctx, &done, sizeof(done))
|
||||
|| !EVP_DigestUpdate(mdctx, private_bytes,
|
||||
sizeof(private_bytes))
|
||||
|| !EVP_DigestUpdate(mdctx, message, message_len)
|
||||
|| !EVP_DigestUpdate(mdctx, random_bytes, sizeof(random_bytes))
|
||||
|| !EVP_DigestFinal_ex(mdctx, digest, NULL))
|
||||
goto err;
|
||||
SHA512_Init(&sha);
|
||||
SHA512_Update(&sha, &done, sizeof(done));
|
||||
SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
|
||||
SHA512_Update(&sha, message, message_len);
|
||||
SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
|
||||
SHA512_Final(digest, &sha);
|
||||
|
||||
todo = num_k_bytes - done;
|
||||
if (todo > SHA512_DIGEST_LENGTH)
|
||||
@@ -262,6 +301,8 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
EVP_MD_meth_free(md);
|
||||
OPENSSL_free(k_bytes);
|
||||
OPENSSL_cleanse(private_bytes, sizeof(private_bytes));
|
||||
return ret;
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
|
||||
* = a.
|
||||
*
|
||||
* (This is due to A.O.L. Atkin,
|
||||
* <URL: http://listserv.nodak.edu/scripts/wa.exe?A2=ind9211&L=nmbrthry&O=T&P=562>,
|
||||
* Subject: Square Roots and Cognate Matters modulo p=8n+5.
|
||||
* URL: https://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind9211&L=NMBRTHRY&P=4026
|
||||
* November 1992.)
|
||||
*/
|
||||
|
||||
|
||||
+112
-7
@@ -1,12 +1,117 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
|
||||
bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
|
||||
bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c \
|
||||
{- $target{bn_asm_src} -} \
|
||||
|
||||
$BNASM=bn_asm.c
|
||||
IF[{- !$disabled{asm} -}]
|
||||
# Define source files and macros per asm architecture
|
||||
# Known macros are:
|
||||
#
|
||||
# OPENSSL_BN_ASM_PART_WORDS For any collection with /-586/ file names
|
||||
# OPENSSL_BN_ASM_MONT For any collection with /-mont/ file names
|
||||
# OPENSSL_BN_ASM_MONT5 For any collection with /-mont5/ file names
|
||||
# OPENSSL_BN_ASM_GF2m For any collection with /-gf2m/ file names
|
||||
# OPENSSL_IA32_SSE2 For any collection with /86/ file names
|
||||
# when sse2 is enabled
|
||||
# BN_DIV3W For any collection with /-div3w/ file names
|
||||
#
|
||||
# All variables are named in such a way that they can be "indexed" with
|
||||
# $target{asm_arch}
|
||||
|
||||
$BNASM_x86=bn-586.s co-586.s x86-mont.s x86-gf2m.s
|
||||
# bn-586 is the only one implementing bn_*_part_words
|
||||
# => OPENSSL_BN_ASM_PART_WORDS
|
||||
$BNDEF_x86=OPENSSL_BN_ASM_PART_WORDS OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_GF2m
|
||||
$BNDEF_x86_sse2=OPENSSL_IA32_SSE2
|
||||
|
||||
$BNASM_x86_64=\
|
||||
x86_64-mont.s x86_64-mont5.s x86_64-gf2m.s rsaz_exp.c rsaz-x86_64.s \
|
||||
rsaz-avx2.s
|
||||
IF[{- $config{target} !~ /^VC/ -}]
|
||||
$BNASM_x86_64=asm/x86_64-gcc.c $BNASM_x86_64
|
||||
ELSE
|
||||
$BNASM_x86_64=bn_asm.c $BNASM_x86_64
|
||||
ENDIF
|
||||
$BNDEF_x86_64=OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_MONT5 OPENSSL_BN_ASM_GF2m
|
||||
$BNDEF_x86_64_sse2=OPENSSL_IA32_SSE2
|
||||
|
||||
IF[{- $config{target} !~ /^VC/ -}]
|
||||
$BNASM_ia64=bn-ia64.s ia64-mont.s
|
||||
ELSE
|
||||
$BNASM_ia64=bn_asm.c ia64-mont.s
|
||||
ENDIF
|
||||
|
||||
$BNASM_sparcv9=asm/sparcv8plus.S sparcv9-mont.S sparcv9a-mont.S vis3-mont.S \
|
||||
sparct4-mont.S
|
||||
$BNDEF_sparcv9=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_sparcv9_ec2m=sparcv9-gf2m.S
|
||||
$BNDEF_sparcv9_ec2m=OPENSSL_BN_ASM_GF2m
|
||||
|
||||
$BNASM_sparcv8=asm/sparcv8.S
|
||||
|
||||
$BNASM_alpha=bn_asm.c alpha-mont.S
|
||||
$BNDEF_alpha=OPENSSL_BN_ASM_MONT
|
||||
|
||||
$BNASM_mips32=bn-mips.S mips-mont.S
|
||||
$BNDEF_mips32=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_mips64=$BNASM_mips32
|
||||
$BNDEF_mips64=$BNDEF_mips32
|
||||
|
||||
IF[{- ($target{perlasm_scheme} // '') eq '31' -}]
|
||||
$BNASM_s390x=bn_asm.c s390x-mont.S
|
||||
ELSE
|
||||
$BNASM_s390x=asm/s390x.S s390x-mont.S
|
||||
ENDIF
|
||||
$BNDEF_s390x=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_s390x_ec2m=s390x-gf2m.s
|
||||
$BNDEF_s390x_ec2m=OPENSSL_BN_ASM_GF2m
|
||||
|
||||
$BNASM_armv4=bn_asm.c armv4-mont.S
|
||||
$BNDEF_armv4=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_armv4_ec2m=armv4-gf2m.S
|
||||
$BNDEF_armv4_ec2m=OPENSSL_BN_ASM_GF2m
|
||||
|
||||
$BNASM_aarch64=bn_asm.c armv8-mont.S
|
||||
$BNDEF_aarch64=OPENSSL_BN_ASM_MONT
|
||||
|
||||
$BNASM_parisc11=bn_asm.c parisc-mont.s
|
||||
$BNDEF_parisc11=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_parisc20_64=$BNASM_parisc11
|
||||
$BNDEF_parisc20_64=$BNDEF_parisc11
|
||||
|
||||
$BNASM_ppc32=bn-ppc.s ppc-mont.s
|
||||
$BNDEF_ppc32=OPENSSL_BN_ASM_MONT
|
||||
$BNASM_ppc64=$BNASM_ppc32
|
||||
$BNDEF_ppc64=$BNDEF_ppc32
|
||||
|
||||
$BNASM_c64xplus=asm/bn-c64xplus.asm
|
||||
$BNASM_c64xplus_ec2m=c64xplus-gf2m.s
|
||||
$BNDEF_c64xplus_ec2m=OPENSSL_BN_ASM_GF2m
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate ones, and define the appropriate macros
|
||||
IF[$BNASM_{- $target{asm_arch} -}]
|
||||
$BNASM=$BNASM_{- $target{asm_arch} -}
|
||||
$BNDEF=$BNDEF_{- $target{asm_arch} -}
|
||||
IF[{- !$disabled{ec2m} -}]
|
||||
$BNASM=$BNASM $BNASM_{- $target{asm_arch} -}_ec2m
|
||||
$BNDEF=$BNDEF $BNDEF_{- $target{asm_arch} -}_ec2m
|
||||
ENDIF
|
||||
IF[{- !$disabled{sse2} -}]
|
||||
$BNDEF_sse2=$BNDEF $BNDEF_{- $target{asm_arch} -}_sse2
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
$COMMON=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \
|
||||
bn_mod.c bn_conv.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
|
||||
bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_sqr.c \
|
||||
bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
|
||||
bn_depr.c bn_const.c bn_x931p.c bn_intern.c bn_dh.c bn_srp.c \
|
||||
bn_rsa_fips186_4.c
|
||||
bn_const.c bn_x931p.c bn_intern.c bn_dh.c \
|
||||
bn_rsa_fips186_4.c $BNASM
|
||||
SOURCE[../../libcrypto]=$COMMON bn_print.c bn_err.c bn_depr.c bn_srp.c
|
||||
DEFINE[../../libcrypto]=$BNDEF
|
||||
SOURCE[../../providers/fips]=$COMMON
|
||||
DEFINE[../../providers/fips]=$BNDEF
|
||||
|
||||
INCLUDE[../../libcrypto]=../../crypto/include
|
||||
|
||||
INCLUDE[bn_exp.o]=..
|
||||
|
||||
Reference in New Issue
Block a user