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/rsa/rsa.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/rsa/rsa.cpp')
-rw-r--r-- | src/lib/pubkey/rsa/rsa.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp index 464055cd7..13425a46f 100644 --- a/src/lib/pubkey/rsa/rsa.cpp +++ b/src/lib/pubkey/rsa/rsa.cpp @@ -112,7 +112,7 @@ class RSA_Private_Operation Blinder m_blinder; }; -class RSA_Signature_Operation : public PK_Ops::Signature, +class RSA_Signature_Operation : public PK_Ops::Signature_with_EMSA, private RSA_Private_Operation { public: @@ -120,20 +120,18 @@ class RSA_Signature_Operation : public PK_Ops::Signature, size_t max_input_bits() const override { return get_max_input_bits(); }; - RSA_Signature_Operation(const RSA_PrivateKey& rsa, const std::string&) : + RSA_Signature_Operation(const RSA_PrivateKey& rsa, const std::string& emsa) : + PK_Ops::Signature_with_EMSA(emsa), RSA_Private_Operation(rsa) { } - secure_vector<byte> sign(const byte msg[], size_t msg_len, - RandomNumberGenerator&) override + secure_vector<byte> raw_sign(const byte msg[], size_t msg_len, + RandomNumberGenerator&) override { - /* We don't check signatures against powermod_e_n here because - PK_Signer checks verification consistency for all signature - algorithms. - */ const BigInt m(msg, msg_len); const BigInt x = blinded_private_op(m); + BOTAN_ASSERT(m == m_powermod_e_n(x), "RSA sign consistency check"); return BigInt::encode_1363(x, n.bytes()); } }; @@ -161,7 +159,6 @@ class RSA_Decryption_Operation : public PK_Ops::Decryption_with_EME, } }; - /** * RSA public (encrypt/verify) operation */ @@ -208,7 +205,7 @@ class RSA_Encryption_Operation : public PK_Ops::Encryption_with_EME, } }; -class RSA_Verify_Operation : public PK_Ops::Verification, +class RSA_Verify_Operation : public PK_Ops::Verification_with_EMSA, private RSA_Public_Operation { public: @@ -216,7 +213,8 @@ class RSA_Verify_Operation : public PK_Ops::Verification, size_t max_input_bits() const override { return get_max_input_bits(); }; - RSA_Verify_Operation(const RSA_PublicKey& rsa, const std::string&) : + RSA_Verify_Operation(const RSA_PublicKey& rsa, const std::string& emsa) : + PK_Ops::Verification_with_EMSA(emsa), RSA_Public_Operation(rsa) { } |