aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/gost_3410
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-04 03:28:48 +0000
committerlloyd <[email protected]>2010-03-04 03:28:48 +0000
commitde89566f633d5ed807ca57a59cc1071f79fdded3 (patch)
tree4a0109b931df0f28ec01c3ae40b3d3f69543bbd8 /src/pubkey/gost_3410
parent76f39cc9fe4b2a3354db22f8beaf0c3788578b79 (diff)
Remove X509_Decoder. Fix GOST-34.10 DER constructor (was default to normal ECC)
Diffstat (limited to 'src/pubkey/gost_3410')
-rw-r--r--src/pubkey/gost_3410/gost_3410.cpp45
-rw-r--r--src/pubkey/gost_3410/gost_3410.h10
2 files changed, 14 insertions, 41 deletions
diff --git a/src/pubkey/gost_3410/gost_3410.cpp b/src/pubkey/gost_3410/gost_3410.cpp
index d36b9e3d4..f2fb15a2e 100644
--- a/src/pubkey/gost_3410/gost_3410.cpp
+++ b/src/pubkey/gost_3410/gost_3410.cpp
@@ -30,46 +30,27 @@ MemoryVector<byte> GOST_3410_PublicKey::x509_subject_public_key() const
return DER_Encoder().encode(bits, OCTET_STRING).get_contents();
}
-X509_Decoder* GOST_3410_PublicKey::x509_decoder()
+GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
+ const MemoryRegion<byte>& key_bits)
{
- class GOST_3410_Key_Decoder : public X509_Decoder
- {
- public:
- void alg_id(const AlgorithmIdentifier& alg_id)
- {
- // Also includes hash and cipher OIDs... brilliant design guys
- OID ecc_param_id;
+ OID ecc_param_id;
- BER_Decoder ber(alg_id.parameters);
- ber.start_cons(SEQUENCE).decode(ecc_param_id);
+ // Also includes hash and cipher OIDs... brilliant design guys
+ BER_Decoder(alg_id.parameters).start_cons(SEQUENCE).decode(ecc_param_id);
- key->domain_params = EC_Domain_Params(ecc_param_id);
- }
+ domain_params = EC_Domain_Params(ecc_param_id);
- void key_bits(const MemoryRegion<byte>& bits)
- {
- SecureVector<byte> key_bits;
- BER_Decoder ber(bits);
- ber.decode(key_bits, OCTET_STRING);
+ SecureVector<byte> bits;
+ BER_Decoder(key_bits).decode(bits, OCTET_STRING);
- const u32bit part_size = key_bits.size() / 2;
+ const u32bit part_size = bits.size() / 2;
- BigInt y(key_bits, part_size);
- BigInt x(key_bits + part_size, part_size);
+ BigInt y(bits, part_size);
+ BigInt x(bits + part_size, part_size);
- const BigInt p = key->domain().get_curve().get_p();
+ public_key = PointGFp(domain().get_curve(), x, y);
- key->public_key = PointGFp(key->domain().get_curve(), x, y);
-
- key->X509_load_hook();
- }
-
- GOST_3410_Key_Decoder(GOST_3410_PublicKey* k): key(k) {}
- private:
- GOST_3410_PublicKey* key;
- };
-
- return new GOST_3410_Key_Decoder(this);
+ X509_load_hook();
}
bool GOST_3410_PublicKey::verify(const byte msg[], u32bit msg_len,
diff --git a/src/pubkey/gost_3410/gost_3410.h b/src/pubkey/gost_3410/gost_3410.h
index 345833ede..7dda6ccae 100644
--- a/src/pubkey/gost_3410/gost_3410.h
+++ b/src/pubkey/gost_3410/gost_3410.h
@@ -35,8 +35,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey,
* Construct from X.509 algorithm id and subject public key bits
*/
GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const MemoryRegion<byte>& key_bits) :
- EC_PublicKey(alg_id, key_bits) {}
+ const MemoryRegion<byte>& key_bits);
/**
* Get this keys algorithm name.
@@ -69,13 +68,6 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey,
bool verify(const byte message[], u32bit mess_len,
const byte signature[], u32bit sig_len) const;
- /**
- * Get an x509_decoder that can be used to decode a stored key into
- * this key.
- * @result an x509_decoder for this key
- */
- X509_Decoder* x509_decoder();
-
protected:
GOST_3410_PublicKey() {}
};