aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-02 22:13:17 -0400
committerJack Lloyd <[email protected]>2017-10-02 22:45:20 -0400
commit114754ec4cca71e3dce6d39ea2e3c94e0fec70cb (patch)
treeb3aad83bb97dbd470519f0eceb5d49bda7679224 /src
parent9f2278ee6fdbbc35e732455e053f8e14b23da440 (diff)
Make m_emsa in PK_{Signature,Verification}_with_EMSA private
Diffstat (limited to 'src')
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.cpp4
-rw-r--r--src/lib/pubkey/pk_ops_impl.h7
2 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.cpp b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
index 93cbf0449..4d88f4cf8 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.cpp
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
@@ -85,7 +85,7 @@ ECKCDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t,
secure_vector<uint8_t> to_be_hashed(k_times_P_x.bytes());
k_times_P_x.binary_encode(to_be_hashed.data());
- std::unique_ptr<EMSA> emsa(m_emsa->clone());
+ std::unique_ptr<EMSA> emsa = this->clone_emsa();
emsa->update(to_be_hashed.data(), to_be_hashed.size());
secure_vector<uint8_t> c = emsa->raw_data();
c = emsa->encoding_of(c, max_input_bits(), rng);
@@ -177,7 +177,7 @@ bool ECKCDSA_Verification_Operation::verify(const uint8_t msg[], size_t,
const BigInt q_x = q.get_affine_x();
secure_vector<uint8_t> c(q_x.bytes());
q_x.binary_encode(c.data());
- std::unique_ptr<EMSA> emsa(m_emsa->clone());
+ std::unique_ptr<EMSA> emsa = this->clone_emsa();
emsa->update(c.data(), c.size());
secure_vector<uint8_t> v = emsa->raw_data();
Null_RNG rng;
diff --git a/src/lib/pubkey/pk_ops_impl.h b/src/lib/pubkey/pk_ops_impl.h
index 22586ae01..1576911fb 100644
--- a/src/lib/pubkey/pk_ops_impl.h
+++ b/src/lib/pubkey/pk_ops_impl.h
@@ -117,9 +117,10 @@ class Verification_with_EMSA : public Verification
throw Invalid_State("Message recovery not supported");
}
- std::unique_ptr<EMSA> m_emsa;
+ std::unique_ptr<EMSA> clone_emsa() const { return std::unique_ptr<EMSA>(m_emsa->clone()); }
private:
+ std::unique_ptr<EMSA> m_emsa;
const std::string m_hash;
bool m_prefix_used;
};
@@ -148,7 +149,8 @@ class Signature_with_EMSA : public Signature
*/
virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); }
- std::unique_ptr<EMSA> m_emsa;
+ std::unique_ptr<EMSA> clone_emsa() const { return std::unique_ptr<EMSA>(m_emsa->clone()); }
+
private:
/**
@@ -163,6 +165,7 @@ class Signature_with_EMSA : public Signature
virtual secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) = 0;
+ std::unique_ptr<EMSA> m_emsa;
const std::string m_hash;
bool m_prefix_used;
};