aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/gost_3410/gost_3410.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-04 02:07:14 +0000
committerlloyd <[email protected]>2010-03-04 02:07:14 +0000
commitc58d02b152b11bae78985aa441560f49ef6b5d09 (patch)
treec01bbbbe6ee86f60faf238a271c28dd03326ac5c /src/pubkey/gost_3410/gost_3410.cpp
parentf109029f5f1cc33512091e228e6ee6532058c42f (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/gost_3410.cpp')
-rw-r--r--src/pubkey/gost_3410/gost_3410.cpp35
1 files changed, 8 insertions, 27 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()