/crypto/fipsmodule/bn/ |
A D | bn.cc.inc | 43 return bn; 66 void BN_clear_free(BIGNUM *bn) { BN_free(bn); } 106 OPENSSL_memset(bn->d, 0, bn->dmax * sizeof(bn->d[0])); 110 bn->neg = 0; 188 void BN_zero(BIGNUM *bn) { bn->width = bn->neg = 0; } 190 int BN_one(BIGNUM *bn) { return BN_set_word(bn, 1); } 202 bn->neg = 0; 315 OPENSSL_memcpy(a, bn->d, sizeof(BN_ULONG) * bn->width); 318 bn->d = a; 337 OPENSSL_memset(bn->d + bn->width, 0, [all …]
|
A D | cmp.cc.inc | 15 #include <openssl/bn.h> 90 if (bn->width == 0) { 93 BN_ULONG mask = bn->d[0] ^ w; 95 mask |= bn->d[i]; 112 return bn_fits_in_words(bn, 0); 116 return bn->neg == 0 && BN_abs_is_word(bn, 1); 120 return BN_abs_is_word(bn, w) && (w == 0 || bn->neg == 0); 124 return bn->width > 0 && (bn->d[0] & 1) == 1; 129 if (width == 0 || bn->neg) { 134 if (bn->d[i] != 0) { [all …]
|
A D | bytes.cc.inc | 15 #include <openssl/bn.h> 52 BIGNUM *bn = NULL; 54 bn = BN_new(); 55 if (bn == NULL) { 58 ret = bn; 68 BN_free(bn); 83 BIGNUM *bn = NULL; 85 bn = BN_new(); 89 ret = bn; 101 BN_free(bn); [all …]
|
A D | bn_test.cc | 1212 ASSERT_TRUE(bn); in TEST_F() 1217 ASSERT_TRUE(bn); in TEST_F() 1222 ASSERT_TRUE(bn); in TEST_F() 1227 ASSERT_TRUE(bn); in TEST_F() 1232 ASSERT_TRUE(bn); in TEST_F() 1237 ASSERT_TRUE(bn); in TEST_F() 1242 ASSERT_TRUE(bn); in TEST_F() 1247 ASSERT_TRUE(bn); in TEST_F() 1290 ASSERT_TRUE(bn); in TEST_F() 1359 ASSERT_TRUE(bn); in TEST_F() [all …]
|
A D | internal.h | 110 int bn_minimal_width(const BIGNUM *bn); 114 void bn_set_minimal_width(BIGNUM *bn); 119 int bn_wexpand(BIGNUM *bn, size_t words); 123 int bn_expand(BIGNUM *bn, size_t bits); 127 OPENSSL_EXPORT int bn_resize_words(BIGNUM *bn, size_t words); 148 int bn_fits_in_words(const BIGNUM *bn, size_t num); 158 void bn_assert_fits_in_bytes(const BIGNUM *bn, size_t num); 162 inline void bn_secret(BIGNUM *bn) { in bn_secret() argument 163 CONSTTIME_SECRET(bn->d, bn->width * sizeof(BN_ULONG)); in bn_secret() 168 inline void bn_declassify(BIGNUM *bn) { in bn_declassify() argument [all …]
|
A D | mul.cc.inc | 15 #include <openssl/bn.h> 264 int BN_mul_word(BIGNUM *bn, BN_ULONG w) { 265 if (!bn->width) { 270 BN_zero(bn); 274 BN_ULONG ll = bn_mul_words(bn->d, bn->d, bn->width, w); 276 if (!bn_wexpand(bn, bn->width + 1)) { 279 bn->d[bn->width++] = ll;
|
A D | div_extra.cc.inc | 15 #include <openssl/bn.h> 62 uint16_t bn_mod_u16_consttime(const BIGNUM *bn, uint16_t d) { 76 for (int i = bn->width - 1; i >= 0; i--) { 78 ret = shift_and_add_mod_u16(ret, bn->d[i], d, p, m); 80 ret = shift_and_add_mod_u16(ret, bn->d[i] >> 32, d, p, m); 81 ret = shift_and_add_mod_u16(ret, bn->d[i] & 0xffffffff, d, p, m);
|
A D | shift.cc.inc | 15 #include <openssl/bn.h> 295 int BN_count_low_zero_bits(const BIGNUM *bn) { 303 for (int i = 0; i < bn->width; i++) { 304 crypto_word_t nonzero = ~constant_time_is_zero_w(bn->d[i]); 308 int bits = bn_count_low_zero_bits_word(bn->d[i]); 312 // If got to the end of |bn| and saw no non-zero words, |bn| is zero. |ret|
|
A D | ctx.cc.inc | 15 #include <openssl/bn.h> 82 bssl::UniquePtr<BIGNUM> bn(BN_new()); 83 if (bn == nullptr || !ctx->bignums_.Push(std::move(bn))) {
|
A D | prime.cc.inc | 15 #include <openssl/bn.h> 384 static int bn_trial_division(uint16_t *out, const BIGNUM *bn) { 385 const size_t num_primes = num_trial_division_primes(bn); 387 // During RSA key generation, |bn| may be secret, but only if |bn| was 389 if (constant_time_declassify_int(bn_mod_u16_consttime(bn, kPrimes[i]) == 398 int bn_odd_number_is_obviously_composite(const BIGNUM *bn) { 400 return bn_trial_division(&prime, bn) && !BN_is_word(bn, prime);
|
A D | div.cc.inc | 15 #include <openssl/bn.h> 493 // bn_resized_from_ctx returns |bn| with width at least |width| or NULL on 496 // in |ctx|, so the caller does not need to explicitly free it. |bn| must fit in 498 static const BIGNUM *bn_resized_from_ctx(const BIGNUM *bn, size_t width, 500 if ((size_t)bn->width >= width) { 502 assert(bn_fits_in_words(bn, width)); 503 return bn; 506 if (ret == NULL || !BN_copy(ret, bn) || !bn_resize_words(ret, width)) {
|
A D | montgomery.cc.inc | 15 #include <openssl/bn.h> 330 int bn_less_than_montgomery_R(const BIGNUM *bn, const BN_MONT_CTX *mont) { 331 return !BN_is_negative(bn) && bn_fits_in_words(bn, mont->N.width);
|
/crypto/bn/ |
A D | convert.cc | 39 char *BN_bn2hex(const BIGNUM *bn) { in BN_bn2hex() argument 40 int width = bn_minimal_width(bn); in BN_bn2hex() 49 if (bn->neg) { in BN_bn2hex() 53 if (BN_is_zero(bn)) { in BN_bn2hex() 61 int v = ((int)(bn->d[i] >> (long)j)) & 0xff; in BN_bn2hex() 75 static int decode_hex(BIGNUM *bn, const char *in, int in_len) { in decode_hex() argument 81 if (!bn_expand(bn, in_len * 4)) { in decode_hex() 104 bn->d[i++] = word; in decode_hex() 107 assert(i <= bn->dmax); in decode_hex() 108 bn->width = i; in decode_hex() [all …]
|
A D | bn_asn1.cc | 38 int BN_marshal_asn1(CBB *cbb, const BIGNUM *bn) { in BN_marshal_asn1() argument 40 if (BN_is_negative(bn)) { in BN_marshal_asn1() 49 (BN_num_bits(bn) % 8 == 0 && !CBB_add_u8(&child, 0x00)) || in BN_marshal_asn1() 50 !BN_bn2cbb_padded(&child, BN_num_bytes(bn), bn) || in BN_marshal_asn1()
|
/crypto/asn1/ |
A D | a_int.cc | 390 if (BN_is_negative(bn) && !BN_is_zero(bn)) { in bn_to_asn1_string() 396 len = BN_num_bytes(bn); in bn_to_asn1_string() 398 !BN_bn2bin_padded(ret->data, len, bn)) { in bn_to_asn1_string() 410 ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai) { in BN_to_ASN1_INTEGER() argument 411 return bn_to_asn1_string(bn, ai, V_ASN1_INTEGER); in BN_to_ASN1_INTEGER() 415 return bn_to_asn1_string(bn, ai, V_ASN1_ENUMERATED); in BN_to_ASN1_ENUMERATED() 425 if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL) { in asn1_string_to_bn() 433 BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn) { in ASN1_INTEGER_to_BN() argument 434 return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER); in ASN1_INTEGER_to_BN() 437 BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn) { in ASN1_ENUMERATED_to_BN() argument [all …]
|
A D | asn1_test.cc | 123 bssl::UniquePtr<BIGNUM> bn(BN_new()); in BIGNUMPow2() local 124 if (!bn || // in BIGNUMPow2() 125 !BN_set_bit(bn.get(), bit)) { in BIGNUMPow2() 128 return bn; in BIGNUMPow2() 331 bssl::UniquePtr<BIGNUM> bn(bn_raw); in TEST() local 350 if (BN_get_u64(bn.get(), &abs_u64)) { in TEST() 351 fits_in_u64 = !BN_is_negative(bn.get()); in TEST() 361 BN_cmp(bn.get(), int64_max.get()) <= 0; in TEST() 363 if (BN_is_negative(bn.get())) { in TEST() 391 if (BN_is_zero(bn.get())) { in TEST() [all …]
|
/crypto/chacha/asm/ |
A D | chacha-x86.pl | 65 my ($an,$bn,$cn,$dn)=map(($_&~3)+(($_+1)&3),($ai,$bi,$ci,$di)); # next 84 ($an,$bn,$cn,$dn)=map(($_&~3)+(($_+$j++)&3),($an,$bn,$cn,$dn)); 90 ($an,$bn,$cn,$dn)=map(($_&~3)+(($_-$j++)&3),($an,$bn,$cn,$dn)); 103 &mov ($b_,&DWP(4*$bn,"esp")) if ($i<7); 355 my ($an,$bn,$cn,$dn)=map(($_&~3)+(($_+1)&3),($ai,$bi,$ci,$di)); # next 374 ($an,$bn,$cn,$dn)=map(($_&~3)+(($_+$j++)&3),($an,$bn,$cn,$dn)); 380 ($an,$bn,$cn,$dn)=map(($_&~3)+(($_-$j++)&3),($an,$bn,$cn,$dn)); 391 &movdqa($xb_,&QWP(16*$bn-128,"ebx")) if ($i<7);
|
/crypto/x509/ |
A D | v3_utl.cc | 131 if (BN_num_bits(bn) < 32) { in bignum_to_string() 132 return BN_bn2dec(bn); in bignum_to_string() 135 tmp = BN_bn2hex(bn); in bignum_to_string() 178 BIGNUM *bn = NULL; in s2i_ASN1_INTEGER() local 186 bn = BN_new(); in s2i_ASN1_INTEGER() 202 ret = BN_hex2bn(&bn, value); in s2i_ASN1_INTEGER() 210 BN_free(bn); in s2i_ASN1_INTEGER() 214 ret = BN_dec2bn(&bn, value); in s2i_ASN1_INTEGER() 218 BN_free(bn); in s2i_ASN1_INTEGER() 223 if (isneg && BN_is_zero(bn)) { in s2i_ASN1_INTEGER() [all …]
|
/crypto/test/ |
A D | wycheproof_util.cc | 141 BIGNUM *bn = nullptr; in GetWycheproofBIGNUM() local 143 BN_hex2bn(&bn, value.c_str()) != static_cast<int>(value.size())) { in GetWycheproofBIGNUM() 144 BN_free(bn); in GetWycheproofBIGNUM() 148 bssl::UniquePtr<BIGNUM> ret(bn); in GetWycheproofBIGNUM()
|
/crypto/dh/ |
A D | dh_asn1.cc | 37 static int marshal_integer(CBB *cbb, BIGNUM *bn) { in marshal_integer() argument 38 if (bn == NULL) { in marshal_integer() 43 return BN_marshal_asn1(cbb, bn); in marshal_integer()
|
A D | dh_test.cc | 201 static bool BIGNUMEqualsHex(const BIGNUM *bn, const char *hex) { in BIGNUMEqualsHex() argument 207 return BN_cmp(bn, hex_bn) == 0; in BIGNUMEqualsHex() 281 bssl::UniquePtr<BIGNUM> bn(BN_get_rfc3526_prime_1536(nullptr)); in TEST() local 282 ASSERT_TRUE(bn); in TEST() 304 ASSERT_EQ(BN_num_bytes(bn.get()), sizeof(kPrime1536)); in TEST() 305 ASSERT_EQ(BN_bn2bin(bn.get(), buffer), sizeof(kPrime1536)); in TEST()
|
/crypto/rsa/ |
A D | rsa_asn1.cc | 40 static int marshal_integer(CBB *cbb, BIGNUM *bn) { in marshal_integer() argument 41 if (bn == NULL) { in marshal_integer() 46 return BN_marshal_asn1(cbb, bn); in marshal_integer()
|
/crypto/fipsmodule/ec/ |
A D | ec_test.cc | 477 BIGNUM *bn = nullptr; in HexToBIGNUM() local 478 BN_hex2bn(&bn, hex); in HexToBIGNUM() 479 return bssl::UniquePtr<BIGNUM>(bn); in HexToBIGNUM() 846 bssl::UniquePtr<BIGNUM> bn(BN_dup(BN_value_one())); in TEST_P() local 847 ASSERT_TRUE(bn); in TEST_P() 848 BN_set_negative(bn.get(), 1); in TEST_P() 849 EXPECT_FALSE(EC_KEY_set_private_key(key.get(), bn.get())) in TEST_P() 854 BN_copy(bn.get(), EC_GROUP_get0_order(EC_KEY_get0_group(key.get())))); in TEST_P() 855 EXPECT_FALSE(EC_KEY_set_private_key(key.get(), bn.get())) in TEST_P() 859 BN_zero(bn.get()); in TEST_P() [all …]
|
/crypto/dsa/ |
A D | dsa_asn1.cc | 100 static int marshal_integer(CBB *cbb, BIGNUM *bn) { in marshal_integer() argument 101 if (bn == NULL) { in marshal_integer() 106 return BN_marshal_asn1(cbb, bn); in marshal_integer()
|
A D | dsa_test.cc | 173 auto expect_bn_bytes = [](const char *msg, const BIGNUM *bn, in TEST() 175 std::vector<uint8_t> buf(BN_num_bytes(bn)); in TEST() 176 BN_bn2bin(bn, buf.data()); in TEST()
|