aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/dsa/dsa.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-03-23 02:14:48 +0000
committerlloyd <[email protected]>2015-03-23 02:14:48 +0000
commite9283c9817949aa27ae97f0c9ec06745fb62240d (patch)
tree8cbdb20e07b5b74e734ded250363776bff1daf04 /src/lib/pubkey/dsa/dsa.cpp
parentce679ca4fc75c7f7ffa36d4364392fe0dd2b1294 (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/dsa/dsa.cpp')
-rw-r--r--src/lib/pubkey/dsa/dsa.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp
index ca5e93f4e..90cc18fdc 100644
--- a/src/lib/pubkey/dsa/dsa.cpp
+++ b/src/lib/pubkey/dsa/dsa.cpp
@@ -74,11 +74,12 @@ namespace {
/**
* Object that can create a DSA signature
*/
-class DSA_Signature_Operation : public PK_Ops::Signature
+class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
{
public:
typedef DSA_PrivateKey Key_Type;
DSA_Signature_Operation(const DSA_PrivateKey& dsa, const std::string& emsa) :
+ PK_Ops::Signature_with_EMSA(emsa),
q(dsa.group_q()),
x(dsa.get_x()),
powermod_g_p(dsa.group_g(), dsa.group_p()),
@@ -91,8 +92,8 @@ class DSA_Signature_Operation : public PK_Ops::Signature
size_t message_part_size() const override { return q.bytes(); }
size_t max_input_bits() const override { return q.bits(); }
- secure_vector<byte> sign(const byte msg[], size_t msg_len,
- RandomNumberGenerator& rng) override;
+ secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ RandomNumberGenerator& rng) override;
private:
const BigInt& q;
const BigInt& x;
@@ -102,8 +103,8 @@ class DSA_Signature_Operation : public PK_Ops::Signature
};
secure_vector<byte>
-DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
- RandomNumberGenerator&)
+DSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+ RandomNumberGenerator&)
{
BigInt i(msg, msg_len);
@@ -132,12 +133,13 @@ DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
/**
* Object that can verify a DSA signature
*/
-class DSA_Verification_Operation : public PK_Ops::Verification
+class DSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
{
public:
typedef DSA_PublicKey Key_Type;
DSA_Verification_Operation(const DSA_PublicKey& dsa,
- const std::string&) :
+ const std::string& emsa) :
+ PK_Ops::Verification_with_EMSA(emsa),
q(dsa.group_q()), y(dsa.get_y())
{
powermod_g_p = Fixed_Base_Power_Mod(dsa.group_g(), dsa.group_p());