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/gost_3410 | |
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/gost_3410')
-rw-r--r-- | src/lib/pubkey/gost_3410/gost_3410.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp index 497712fd9..8eb711617 100644 --- a/src/lib/pubkey/gost_3410/gost_3410.cpp +++ b/src/lib/pubkey/gost_3410/gost_3410.cpp @@ -94,21 +94,23 @@ BigInt decode_le(const byte msg[], size_t msg_len) /** * GOST-34.10 signature operation */ -class GOST_3410_Signature_Operation : public PK_Ops::Signature +class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA { public: typedef GOST_3410_PrivateKey Key_Type; - GOST_3410_Signature_Operation(const GOST_3410_PrivateKey& gost_3410, const std::string&): + GOST_3410_Signature_Operation(const GOST_3410_PrivateKey& gost_3410, + const std::string& emsa) : + PK_Ops::Signature_with_EMSA(emsa), base_point(gost_3410.domain().get_base_point()), order(gost_3410.domain().get_order()), x(gost_3410.private_value()) {} - 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(); } - 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 PointGFp& base_point; @@ -117,8 +119,8 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature }; secure_vector<byte> -GOST_3410_Signature_Operation::sign(const byte msg[], size_t msg_len, - RandomNumberGenerator& rng) +GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len, + RandomNumberGenerator& rng) { BigInt k; do @@ -150,21 +152,23 @@ GOST_3410_Signature_Operation::sign(const byte msg[], size_t msg_len, /** * GOST-34.10 verification operation */ -class GOST_3410_Verification_Operation : public PK_Ops::Verification +class GOST_3410_Verification_Operation : public PK_Ops::Verification_with_EMSA { public: typedef GOST_3410_PublicKey Key_Type; - GOST_3410_Verification_Operation(const GOST_3410_PublicKey& gost, const std::string&) : + GOST_3410_Verification_Operation(const GOST_3410_PublicKey& gost, + const std::string& emsa) : + PK_Ops::Verification_with_EMSA(emsa), base_point(gost.domain().get_base_point()), public_point(gost.public_point()), order(gost.domain().get_order()) {} - 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(); } - 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); |