aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/pubkey/dsa/dsa.cpp12
-rw-r--r--src/lib/pubkey/ecdsa/ecdsa.cpp12
2 files changed, 16 insertions, 8 deletions
diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp
index c419eec97..706722d72 100644
--- a/src/lib/pubkey/dsa/dsa.cpp
+++ b/src/lib/pubkey/dsa/dsa.cpp
@@ -83,9 +83,11 @@ class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
m_q(dsa.group_q()),
m_x(dsa.get_x()),
m_powermod_g_p(dsa.group_g(), dsa.group_p()),
- m_mod_q(dsa.group_q()),
- m_emsa(emsa)
+ m_mod_q(dsa.group_q())
{
+#if defined(BOTAN_HAS_RFC6979_GENERATOR)
+ m_rfc6979_hash = hash_for_emsa(emsa);
+#endif
}
size_t max_input_bits() const override { return m_q.bits(); }
@@ -97,7 +99,9 @@ class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
const BigInt& m_x;
Fixed_Base_Power_Mod m_powermod_g_p;
Modular_Reducer m_mod_q;
- std::string m_emsa;
+#if defined(BOTAN_HAS_RFC6979_GENERATOR)
+ std::string m_rfc6979_hash;
+#endif
};
secure_vector<uint8_t>
@@ -111,7 +115,7 @@ DSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
#if defined(BOTAN_HAS_RFC6979_GENERATOR)
BOTAN_UNUSED(rng);
- const BigInt k = generate_rfc6979_nonce(m_x, m_q, i, hash_for_emsa(m_emsa));
+ const BigInt k = generate_rfc6979_nonce(m_x, m_q, i, m_rfc6979_hash);
#else
const BigInt k = BigInt::random_integer(rng, 1, m_q);
#endif
diff --git a/src/lib/pubkey/ecdsa/ecdsa.cpp b/src/lib/pubkey/ecdsa/ecdsa.cpp
index 72551c8c7..8b0248770 100644
--- a/src/lib/pubkey/ecdsa/ecdsa.cpp
+++ b/src/lib/pubkey/ecdsa/ecdsa.cpp
@@ -55,9 +55,11 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
m_order(ecdsa.domain().get_order()),
m_base_point(ecdsa.domain().get_base_point(), m_order),
m_x(ecdsa.private_value()),
- m_mod_order(m_order),
- m_emsa(emsa)
+ m_mod_order(m_order)
{
+#if defined(BOTAN_HAS_RFC6979_GENERATOR)
+ m_rfc6979_hash = hash_for_emsa(emsa);
+#endif
}
size_t max_input_bits() const override { return m_order.bits(); }
@@ -70,7 +72,9 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
Blinded_Point_Multiply m_base_point;
const BigInt& m_x;
Modular_Reducer m_mod_order;
- std::string m_emsa;
+#if defined(BOTAN_HAS_RFC6979_GENERATOR)
+ std::string m_rfc6979_hash;
+#endif
};
secure_vector<uint8_t>
@@ -80,7 +84,7 @@ ECDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
const BigInt m(msg, msg_len);
#if defined(BOTAN_HAS_RFC6979_GENERATOR)
- const BigInt k = generate_rfc6979_nonce(m_x, m_order, m, hash_for_emsa(m_emsa));
+ const BigInt k = generate_rfc6979_nonce(m_x, m_order, m, m_rfc6979_hash);
#else
const BigInt k = BigInt::random_integer(rng, 1, m_order);
#endif