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/if_algo | |
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/if_algo')
-rw-r--r-- | src/pubkey/if_algo/if_algo.cpp | 35 | ||||
-rw-r--r-- | src/pubkey/if_algo/if_algo.h | 3 |
2 files changed, 9 insertions, 29 deletions
diff --git a/src/pubkey/if_algo/if_algo.cpp b/src/pubkey/if_algo/if_algo.cpp index ee34b1418..2a7b19d3b 100644 --- a/src/pubkey/if_algo/if_algo.cpp +++ b/src/pubkey/if_algo/if_algo.cpp @@ -18,35 +18,14 @@ AlgorithmIdentifier IF_Scheme_PublicKey::algorithm_identifier() const AlgorithmIdentifier::USE_NULL_PARAM); } -/* -* Return the X.509 public key encoder -*/ -X509_Encoder* IF_Scheme_PublicKey::x509_encoder() const +MemoryVector<byte> IF_Scheme_PublicKey::x509_subject_public_key() const { - class IF_Scheme_Encoder : public X509_Encoder - { - public: - AlgorithmIdentifier alg_id() const - { - return key->algorithm_identifier(); - } - - MemoryVector<byte> key_bits() const - { - return DER_Encoder() - .start_cons(SEQUENCE) - .encode(key->n) - .encode(key->e) - .end_cons() - .get_contents(); - } - - IF_Scheme_Encoder(const IF_Scheme_PublicKey* k) : key(k) {} - private: - const IF_Scheme_PublicKey* key; - }; - - return new IF_Scheme_Encoder(this); + return DER_Encoder() + .start_cons(SEQUENCE) + .encode(n) + .encode(e) + .end_cons() + .get_contents(); } /* diff --git a/src/pubkey/if_algo/if_algo.h b/src/pubkey/if_algo/if_algo.h index 98ae070c9..17598dd52 100644 --- a/src/pubkey/if_algo/if_algo.h +++ b/src/pubkey/if_algo/if_algo.h @@ -25,6 +25,8 @@ class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key AlgorithmIdentifier algorithm_identifier() const; + MemoryVector<byte> x509_subject_public_key() const; + /** * Get n = p * q. * @return n @@ -39,7 +41,6 @@ class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key u32bit max_input_bits() const { return (n.bits() - 1); } - X509_Encoder* x509_encoder() const; X509_Decoder* x509_decoder(); protected: virtual void X509_load_hook(); |