diff options
author | lloyd <[email protected]> | 2015-03-23 02:14:48 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-03-23 02:14:48 +0000 |
commit | e9283c9817949aa27ae97f0c9ec06745fb62240d (patch) | |
tree | 8cbdb20e07b5b74e734ded250363776bff1daf04 /src/lib/pubkey/ecdsa/ecdsa.cpp | |
parent | ce679ca4fc75c7f7ffa36d4364392fe0dd2b1294 (diff) |
Move the signature padding schemes to the PK operation classes,
as was previously done with encrypt/decrypt ops.
One feature dropped on the floor here is previously PK_Signer by
default did verification of signatures before releasing them as an
measure against fault attacks. However in addition to being expensive
this turned out to be difficult to implement with the new scheme.
Diffstat (limited to 'src/lib/pubkey/ecdsa/ecdsa.cpp')
-rw-r--r-- | src/lib/pubkey/ecdsa/ecdsa.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lib/pubkey/ecdsa/ecdsa.cpp b/src/lib/pubkey/ecdsa/ecdsa.cpp index d2ad82b94..2518a14fe 100644 --- a/src/lib/pubkey/ecdsa/ecdsa.cpp +++ b/src/lib/pubkey/ecdsa/ecdsa.cpp @@ -32,13 +32,14 @@ namespace { /** * ECDSA signature operation */ -class ECDSA_Signature_Operation : public PK_Ops::Signature +class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA { public: typedef ECDSA_PrivateKey Key_Type; ECDSA_Signature_Operation(const ECDSA_PrivateKey& ecdsa, const std::string& emsa) : + PK_Ops::Signature_with_EMSA(emsa), base_point(ecdsa.domain().get_base_point()), order(ecdsa.domain().get_order()), x(ecdsa.private_value()), @@ -47,12 +48,12 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature { } - secure_vector<byte> sign(const byte msg[], size_t msg_len, - RandomNumberGenerator& rng); + secure_vector<byte> raw_sign(const byte msg[], size_t msg_len, + RandomNumberGenerator& rng) override; - size_t message_parts() const { return 2; } - size_t message_part_size() const { return order.bytes(); } - size_t max_input_bits() const { return order.bits(); } + size_t message_parts() const override { return 2; } + size_t message_part_size() const override { return order.bytes(); } + size_t max_input_bits() const override { return order.bits(); } private: const PointGFp& base_point; @@ -63,8 +64,8 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature }; secure_vector<byte> -ECDSA_Signature_Operation::sign(const byte msg[], size_t msg_len, - RandomNumberGenerator&) +ECDSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len, + RandomNumberGenerator&) { const BigInt m(msg, msg_len); @@ -87,12 +88,13 @@ ECDSA_Signature_Operation::sign(const byte msg[], size_t msg_len, /** * ECDSA verification operation */ -class ECDSA_Verification_Operation : public PK_Ops::Verification +class ECDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA { public: typedef ECDSA_PublicKey Key_Type; ECDSA_Verification_Operation(const ECDSA_PublicKey& ecdsa, - const std::string&) : + const std::string& emsa) : + PK_Ops::Verification_with_EMSA(emsa), m_base_point(ecdsa.domain().get_base_point()), m_public_point(ecdsa.public_point()), m_order(ecdsa.domain().get_order()), @@ -101,14 +103,14 @@ class ECDSA_Verification_Operation : public PK_Ops::Verification //m_public_point.precompute_multiples(); } - size_t message_parts() const { return 2; } - size_t message_part_size() const { return m_order.bytes(); } - size_t max_input_bits() const { return m_order.bits(); } + size_t message_parts() const override { return 2; } + size_t message_part_size() const override { return m_order.bytes(); } + size_t max_input_bits() const override { return m_order.bits(); } - bool with_recovery() const { return false; } + bool with_recovery() const override { return false; } bool verify(const byte msg[], size_t msg_len, - const byte sig[], size_t sig_len); + const byte sig[], size_t sig_len) override; private: const PointGFp& m_base_point; const PointGFp& m_public_point; |