diff options
author | Jack Lloyd <[email protected]> | 2021-04-24 09:15:42 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2021-04-24 09:54:14 -0400 |
commit | 5dc8c0e4984161fb61bb2f6172dd9c1c61ffcfb5 (patch) | |
tree | c5b7a1915828745641039863544885d244fd9cb2 /src/lib/pubkey/ecdsa/ecdsa.cpp | |
parent | 5251aa6694f65ccf92f0ddf169a3e37f219947ad (diff) |
Modify BigInt constructors
Add static methods for very common (eg zero, one) or very uncommon (eg
ECSDA truncated integers) construction methods, instead of using C++
constructors for all of these.
Also adds from_s32 which allows creating a negative BigInt easily,
instead of -BigInt(-x) -> BigInt::from_s32(x)
Diffstat (limited to 'src/lib/pubkey/ecdsa/ecdsa.cpp')
-rw-r--r-- | src/lib/pubkey/ecdsa/ecdsa.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/pubkey/ecdsa/ecdsa.cpp b/src/lib/pubkey/ecdsa/ecdsa.cpp index 490364f8b..2324edf85 100644 --- a/src/lib/pubkey/ecdsa/ecdsa.cpp +++ b/src/lib/pubkey/ecdsa/ecdsa.cpp @@ -52,7 +52,7 @@ PointGFp recover_ecdsa_public_key(const EC_Group& group, try { - const BigInt e(msg.data(), msg.size(), group.get_order_bits()); + const BigInt e = BigInt::from_bytes_with_max_bits(msg.data(), msg.size(), group.get_order_bits()); const BigInt r_inv = group.inverse_mod_order(r); BigInt x = r + add_order*group_order; @@ -179,7 +179,7 @@ secure_vector<uint8_t> ECDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len, RandomNumberGenerator& rng) { - BigInt m(msg, msg_len, m_group.get_order_bits()); + BigInt m = BigInt::from_bytes_with_max_bits(msg, msg_len, m_group.get_order_bits()); #if defined(BOTAN_HAS_RFC6979_GENERATOR) const BigInt k = m_rfc6979->nonce_for(m); @@ -241,7 +241,7 @@ bool ECDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len, if(sig_len != m_group.get_order_bytes() * 2) return false; - const BigInt e(msg, msg_len, m_group.get_order_bits()); + const BigInt e = BigInt::from_bytes_with_max_bits(msg, msg_len, m_group.get_order_bits()); const BigInt r(sig, sig_len / 2); const BigInt s(sig + sig_len / 2, sig_len / 2); |