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/rw | |
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/rw')
-rw-r--r-- | src/lib/pubkey/rw/rw.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/lib/pubkey/rw/rw.cpp b/src/lib/pubkey/rw/rw.cpp index 32ba398b0..b706d6730 100644 --- a/src/lib/pubkey/rw/rw.cpp +++ b/src/lib/pubkey/rw/rw.cpp @@ -67,13 +67,14 @@ namespace { /** * Rabin-Williams Signature Operation */ -class RW_Signature_Operation : public PK_Ops::Signature +class RW_Signature_Operation : public PK_Ops::Signature_with_EMSA { public: typedef RW_PrivateKey Key_Type; RW_Signature_Operation(const RW_PrivateKey& rw, - const std::string&) : + const std::string& emsa) : + PK_Ops::Signature_with_EMSA(emsa), n(rw.get_n()), e(rw.get_e()), q(rw.get_q()), @@ -87,10 +88,10 @@ class RW_Signature_Operation : public PK_Ops::Signature { } - size_t max_input_bits() const { return (n.bits() - 1); } + size_t max_input_bits() const override { return (n.bits() - 1); } - 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; private: const BigInt& n; const BigInt& e; @@ -103,8 +104,8 @@ class RW_Signature_Operation : public PK_Ops::Signature }; secure_vector<byte> -RW_Signature_Operation::sign(const byte msg[], size_t msg_len, - RandomNumberGenerator&) +RW_Signature_Operation::raw_sign(const byte msg[], size_t msg_len, + RandomNumberGenerator&) { BigInt i(msg, msg_len); @@ -130,12 +131,13 @@ RW_Signature_Operation::sign(const byte msg[], size_t msg_len, /** * Rabin-Williams Verification Operation */ -class RW_Verification_Operation : public PK_Ops::Verification +class RW_Verification_Operation : public PK_Ops::Verification_with_EMSA { public: typedef RW_PublicKey Key_Type; - RW_Verification_Operation(const RW_PublicKey& rw, const std::string&) : + RW_Verification_Operation(const RW_PublicKey& rw, const std::string& emsa) : + PK_Ops::Verification_with_EMSA(emsa), n(rw.get_n()), powermod_e_n(rw.get_e(), rw.get_n()) {} |