aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pubkey/dl_algo/dl_algo.cpp28
-rw-r--r--src/pubkey/dl_algo/dl_algo.h7
-rw-r--r--src/pubkey/ecc_key/ecc_key.cpp26
-rw-r--r--src/pubkey/ecc_key/ecc_key.h27
-rw-r--r--src/pubkey/gost_3410/gost_3410.cpp45
-rw-r--r--src/pubkey/gost_3410/gost_3410.h10
-rw-r--r--src/pubkey/if_algo/if_algo.cpp30
-rw-r--r--src/pubkey/if_algo/if_algo.h2
-rw-r--r--src/pubkey/pk_keys.h7
-rw-r--r--src/pubkey/x509_key.h15
10 files changed, 24 insertions, 173 deletions
diff --git a/src/pubkey/dl_algo/dl_algo.cpp b/src/pubkey/dl_algo/dl_algo.cpp
index bf7ab0a6a..7ec6877e1 100644
--- a/src/pubkey/dl_algo/dl_algo.cpp
+++ b/src/pubkey/dl_algo/dl_algo.cpp
@@ -33,34 +33,6 @@ DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
BER_Decoder(key_bits).decode(y);
}
-/*
-* Return the X.509 public key decoder
-*/
-X509_Decoder* DL_Scheme_PublicKey::x509_decoder()
- {
- class DL_Scheme_Decoder : public X509_Decoder
- {
- public:
- void alg_id(const AlgorithmIdentifier& alg_id)
- {
- DataSource_Memory source(alg_id.parameters);
- key->group.BER_decode(source, key->group_format());
- }
-
- void key_bits(const MemoryRegion<byte>& bits)
- {
- BER_Decoder(bits).decode(key->y);
- key->X509_load_hook();
- }
-
- DL_Scheme_Decoder(DL_Scheme_PublicKey* k) : key(k) {}
- private:
- DL_Scheme_PublicKey* key;
- };
-
- return new DL_Scheme_Decoder(this);
- }
-
MemoryVector<byte> DL_Scheme_PrivateKey::pkcs8_private_key() const
{
return DER_Encoder().encode(x).get_contents();
diff --git a/src/pubkey/dl_algo/dl_algo.h b/src/pubkey/dl_algo/dl_algo.h
index 7492dc3bd..66e6eafd0 100644
--- a/src/pubkey/dl_algo/dl_algo.h
+++ b/src/pubkey/dl_algo/dl_algo.h
@@ -62,13 +62,6 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
*/
virtual DL_Group::Format group_format() const = 0;
- /**
- * Get an X509 decoder for this key.
- * @return an decoder usable to decode a DL key and store the
- * values in this instance.
- */
- X509_Decoder* x509_decoder();
-
DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits,
DL_Group::Format group_format);
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp
index 8e1f40665..f80e2bb15 100644
--- a/src/pubkey/ecc_key/ecc_key.cpp
+++ b/src/pubkey/ecc_key/ecc_key.cpp
@@ -74,32 +74,6 @@ EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id,
}
}
-X509_Decoder* EC_PublicKey::x509_decoder()
- {
- class EC_Key_Decoder : public X509_Decoder
- {
- public:
- void alg_id(const AlgorithmIdentifier& alg_id)
- {
- key->domain_params = EC_Domain_Params(alg_id.parameters);
- }
-
- void key_bits(const MemoryRegion<byte>& bits)
- {
- key->public_key = PointGFp(
- OS2ECP(bits, key->domain().get_curve()));
-
- key->X509_load_hook();
- }
-
- EC_Key_Decoder(EC_PublicKey* k): key(k) {}
- private:
- EC_PublicKey* key;
- };
-
- return new EC_Key_Decoder(this);
- }
-
void EC_PublicKey::set_parameter_encoding(EC_Domain_Params_Encoding form)
{
if(form != EC_DOMPAR_ENC_EXPLICIT &&
diff --git a/src/pubkey/ecc_key/ecc_key.h b/src/pubkey/ecc_key/ecc_key.h
index 52aad4f03..1b8ac3ff5 100644
--- a/src/pubkey/ecc_key/ecc_key.h
+++ b/src/pubkey/ecc_key/ecc_key.h
@@ -32,6 +32,16 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
{
public:
+ EC_PublicKey() : domain_encoding(EC_DOMPAR_ENC_EXPLICIT) {}
+
+ EC_PublicKey(const EC_Domain_Params& dom_par,
+ const PointGFp& pub_point);
+
+ EC_PublicKey(const AlgorithmIdentifier& alg_id,
+ const MemoryRegion<byte>& key_bits);
+
+ virtual ~EC_PublicKey() {}
+
/**
* Get the public point of this key.
* @throw Invalid_State is thrown if the
@@ -71,23 +81,6 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
*/
EC_Domain_Params_Encoding domain_format() const
{ return domain_encoding; }
-
- /**
- * 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();
-
- EC_PublicKey() : domain_encoding(EC_DOMPAR_ENC_EXPLICIT) {}
-
- EC_PublicKey(const EC_Domain_Params& dom_par,
- const PointGFp& pub_point);
-
- EC_PublicKey(const AlgorithmIdentifier& alg_id,
- const MemoryRegion<byte>& key_bits);
-
- virtual ~EC_PublicKey() {}
protected:
virtual void X509_load_hook();
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() {}
};
diff --git a/src/pubkey/if_algo/if_algo.cpp b/src/pubkey/if_algo/if_algo.cpp
index 8260d56e0..682870663 100644
--- a/src/pubkey/if_algo/if_algo.cpp
+++ b/src/pubkey/if_algo/if_algo.cpp
@@ -39,36 +39,6 @@ IF_Scheme_PublicKey::IF_Scheme_PublicKey(const AlgorithmIdentifier&,
.end_cons();
}
-/*
-* Return the X.509 public key decoder
-*/
-X509_Decoder* IF_Scheme_PublicKey::x509_decoder()
- {
- class IF_Scheme_Decoder : public X509_Decoder
- {
- public:
- void alg_id(const AlgorithmIdentifier&) {}
-
- void key_bits(const MemoryRegion<byte>& bits)
- {
- BER_Decoder(bits)
- .start_cons(SEQUENCE)
- .decode(key->n)
- .decode(key->e)
- .verify_end()
- .end_cons();
-
- key->X509_load_hook();
- }
-
- IF_Scheme_Decoder(IF_Scheme_PublicKey* k) : key(k) {}
- private:
- IF_Scheme_PublicKey* key;
- };
-
- return new IF_Scheme_Decoder(this);
- }
-
MemoryVector<byte> IF_Scheme_PrivateKey::pkcs8_private_key() const
{
return DER_Encoder()
diff --git a/src/pubkey/if_algo/if_algo.h b/src/pubkey/if_algo/if_algo.h
index fc09f2881..958735c4d 100644
--- a/src/pubkey/if_algo/if_algo.h
+++ b/src/pubkey/if_algo/if_algo.h
@@ -41,8 +41,6 @@ class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key
u32bit max_input_bits() const { return (n.bits() - 1); }
- X509_Decoder* x509_decoder();
-
IF_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits);
protected:
diff --git a/src/pubkey/pk_keys.h b/src/pubkey/pk_keys.h
index f9448b8bd..c6f652117 100644
--- a/src/pubkey/pk_keys.h
+++ b/src/pubkey/pk_keys.h
@@ -71,13 +71,6 @@ class BOTAN_DLL Public_Key
*/
virtual MemoryVector<byte> x509_subject_public_key() const = 0;
- /**
- * Get an X509 decoder that can be used to set the values of this
- * key based on an X509 encoded key object.
- * @return an X509 decoder for this key
- */
- virtual class X509_Decoder* x509_decoder() = 0;
-
virtual ~Public_Key() {}
protected:
virtual void load_check(RandomNumberGenerator&) const;
diff --git a/src/pubkey/x509_key.h b/src/pubkey/x509_key.h
index a8f5267d7..13f11646e 100644
--- a/src/pubkey/x509_key.h
+++ b/src/pubkey/x509_key.h
@@ -16,25 +16,10 @@
namespace Botan {
/**
-* This class represents abstract X.509 public key decoders.
-*/
-class BOTAN_DLL X509_Decoder
- {
- public:
- virtual void alg_id(const AlgorithmIdentifier&) = 0;
- virtual void key_bits(const MemoryRegion<byte>&) = 0;
- virtual ~X509_Decoder() {}
- };
-
-/**
* This namespace contains functions for handling X509 objects.
*/
namespace X509 {
-/*
-* X.509 Public Key Encoding/Decoding
-*/
-
/**
* Encode a key into a pipe.
* @param key the public key to encode