X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=include%2Fcrypto%2Fbn.h;h=cf69bea848f1c7b64ca24aa187b30d0cf18007fd;hp=6652760aa270710056f503a657503947af861cd2;hb=HEAD;hpb=b425001010044adbdbcd98f8682694b30b73bbf4 diff --git a/include/crypto/bn.h b/include/crypto/bn.h index 6652760aa2..9a988a467d 100644 --- a/include/crypto/bn.h +++ b/include/crypto/bn.h @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-2024 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 @@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_BN_H # define OSSL_CRYPTO_BN_H +# pragma once # include # include @@ -86,32 +87,51 @@ int bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int ossl_bn_mask_bits_fixed_top(BIGNUM *a, int n); +int ossl_bn_is_word_fixed_top(const BIGNUM *a, BN_ULONG w); +int ossl_bn_priv_rand_range_fixed_top(BIGNUM *r, const BIGNUM *range, + unsigned int strength, BN_CTX *ctx); +int ossl_bn_gen_dsa_nonce_fixed_top(BIGNUM *out, const BIGNUM *range, + const BIGNUM *priv, + const unsigned char *message, + size_t message_len, BN_CTX *ctx); #define BN_PRIMETEST_COMPOSITE 0 #define BN_PRIMETEST_COMPOSITE_WITH_FACTOR 1 #define BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME 2 #define BN_PRIMETEST_PROBABLY_PRIME 3 -int bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx, - BN_GENCB *cb, int enhanced, int *status); +int ossl_bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx, + BN_GENCB *cb, int enhanced, int *status); +int ossl_bn_check_generated_prime(const BIGNUM *w, int checks, BN_CTX *ctx, + BN_GENCB *cb); -const BIGNUM *bn_get0_small_factors(void); +const BIGNUM *ossl_bn_get0_small_factors(void); -int bn_rsa_fips186_4_prime_MR_min_checks(int nbits); +int ossl_bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout, + BIGNUM *p1, BIGNUM *p2, + const BIGNUM *Xp, const BIGNUM *Xp1, + const BIGNUM *Xp2, int nlen, + const BIGNUM *e, BN_CTX *ctx, + BN_GENCB *cb); -int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout, - BIGNUM *p1, BIGNUM *p2, - const BIGNUM *Xp, const BIGNUM *Xp1, - const BIGNUM *Xp2, int nlen, - const BIGNUM *e, BN_CTX *ctx, - BN_GENCB *cb); +int ossl_bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin, + const BIGNUM *r1, const BIGNUM *r2, + int nlen, const BIGNUM *e, BN_CTX *ctx, + BN_GENCB *cb); -int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin, - const BIGNUM *r1, const BIGNUM *r2, int nlen, - const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); +OSSL_LIB_CTX *ossl_bn_get_libctx(BN_CTX *ctx); -OSSL_LIB_CTX *bn_get_lib_ctx(BN_CTX *ctx); +extern const BIGNUM ossl_bn_inv_sqrt_2; -extern const BIGNUM bn_inv_sqrt_2; +#if defined(OPENSSL_SYS_LINUX) && !defined(FIPS_MODULE) && defined (__s390x__) \ + && !defined (OPENSSL_NO_ASM) +# define S390X_MOD_EXP +#endif + +int s390x_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int s390x_crt(BIGNUM *r, const BIGNUM *i, const BIGNUM *p, const BIGNUM *q, + const BIGNUM *dmp, const BIGNUM *dmq, const BIGNUM *iqmp); #endif