diff options
author | lloyd <[email protected]> | 2010-03-04 02:07:14 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-04 02:07:14 +0000 |
commit | c58d02b152b11bae78985aa441560f49ef6b5d09 (patch) | |
tree | c01bbbbe6ee86f60faf238a271c28dd03326ac5c /src/pubkey/gost_3410 | |
parent | f109029f5f1cc33512091e228e6ee6532058c42f (diff) |
Add a new function to public key x509_subject_public_key which returns
what x509_encoder()->key_bits() used to return. This is much simpler
than using the explicit encoder objects. Remove X509_Encoder entirely.
Diffstat (limited to 'src/pubkey/gost_3410')
-rw-r--r-- | src/pubkey/gost_3410/gost_3410.cpp | 35 | ||||
-rw-r--r-- | src/pubkey/gost_3410/gost_3410.h | 8 |
2 files changed, 10 insertions, 33 deletions
diff --git a/src/pubkey/gost_3410/gost_3410.cpp b/src/pubkey/gost_3410/gost_3410.cpp index d23229d9b..d36b9e3d4 100644 --- a/src/pubkey/gost_3410/gost_3410.cpp +++ b/src/pubkey/gost_3410/gost_3410.cpp @@ -16,37 +16,18 @@ namespace Botan { -X509_Encoder* GOST_3410_PublicKey::x509_encoder() const +MemoryVector<byte> GOST_3410_PublicKey::x509_subject_public_key() const { - class GOST_3410_Key_Encoder : public X509_Encoder - { - public: - AlgorithmIdentifier alg_id() const - { - return AlgorithmIdentifier(key->get_oid(), - key->DER_domain()); - } - - MemoryVector<byte> key_bits() const - { - // Trust CryptoPro to come up with something obnoxious - const BigInt x = key->public_point().get_affine_x(); - const BigInt y = key->public_point().get_affine_y(); + // Trust CryptoPro to come up with something obnoxious + const BigInt& x = public_point().get_affine_x(); + const BigInt& y = public_point().get_affine_y(); - SecureVector<byte> bits(2*std::max(x.bytes(), y.bytes())); + MemoryVector<byte> bits(2*std::max(x.bytes(), y.bytes())); - y.binary_encode(bits + (bits.size() / 2 - y.bytes())); - x.binary_encode(bits + (bits.size() - y.bytes())); - - return DER_Encoder().encode(bits, OCTET_STRING).get_contents(); - } - - GOST_3410_Key_Encoder(const GOST_3410_PublicKey* k): key(k) {} - private: - const GOST_3410_PublicKey* key; - }; + y.binary_encode(bits + (bits.size() / 2 - y.bytes())); + x.binary_encode(bits + (bits.size() - y.bytes())); - return new GOST_3410_Key_Encoder(this); + return DER_Encoder().encode(bits, OCTET_STRING).get_contents(); } X509_Decoder* GOST_3410_PublicKey::x509_decoder() diff --git a/src/pubkey/gost_3410/gost_3410.h b/src/pubkey/gost_3410/gost_3410.h index 6daa0eaf8..c1cd0d293 100644 --- a/src/pubkey/gost_3410/gost_3410.h +++ b/src/pubkey/gost_3410/gost_3410.h @@ -28,6 +28,8 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey, */ std::string algo_name() const { return "GOST-34.10"; } + MemoryVector<byte> x509_subject_public_key() const; + /** * Get the maximum number of bits allowed to be fed to this key. * This is the bitlength of the order of the base point. @@ -67,12 +69,6 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey, EC_PublicKey(dom_par, public_point) {} /** - * Get an x509_encoder that can be used to encode this key. - * @result an x509_encoder for this key - */ - X509_Encoder* x509_encoder() const; - - /** * Get an x509_decoder that can be used to decode a stored key into * this key. * @result an x509_decoder for this key |