diff options
author | lloyd <[email protected]> | 2006-09-06 19:48:09 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-09-06 19:48:09 +0000 |
commit | e00227828d80f9c9a17ef236586211faa01e4193 (patch) | |
tree | 2573533839150184038b18d7789eaef1ee5dd904 /include | |
parent | 7f176fd2259fcb395ca03751f19790eac15bd9ce (diff) |
Split PK_Key into Public_Key and Private_Key; these new classes merge in
the interfaces previously included in X509_PublicKey and PKCS8_PrivateKey.
Diffstat (limited to 'include')
-rw-r--r-- | include/dh.h | 4 | ||||
-rw-r--r-- | include/dl_algo.h | 6 | ||||
-rw-r--r-- | include/dsa.h | 2 | ||||
-rw-r--r-- | include/elgamal.h | 2 | ||||
-rw-r--r-- | include/if_algo.h | 2 | ||||
-rw-r--r-- | include/nr.h | 2 | ||||
-rw-r--r-- | include/pk_keys.h | 48 | ||||
-rw-r--r-- | include/pkcs8.h | 11 | ||||
-rw-r--r-- | include/x509_key.h | 13 | ||||
-rw-r--r-- | include/x509_obj.h | 2 | ||||
-rw-r--r-- | include/x509stor.h | 1 |
11 files changed, 45 insertions, 48 deletions
diff --git a/include/dh.h b/include/dh.h index f30033d9d..3bf2f1c24 100644 --- a/include/dh.h +++ b/include/dh.h @@ -18,6 +18,8 @@ class DH_PublicKey : public virtual DL_Scheme_PublicKey { public: MemoryVector<byte> public_value() const; + u32bit max_input_bits() const; + DH_PublicKey(const DL_Group&, const BigInt&); protected: std::string algo_name() const { return "DH"; } @@ -46,7 +48,7 @@ class DH_PrivateKey : public DH_PublicKey, DH_PrivateKey(const DL_Group&, const BigInt&, const BigInt& = 0); private: friend PKCS8_PrivateKey* get_private_key(const std::string&); - void PKCS8_load_hook(); + void PKCS8_load_hook(bool = false); DH_PrivateKey() {} DH_Core core; diff --git a/include/dl_algo.h b/include/dl_algo.h index b72b3df42..5a12370f6 100644 --- a/include/dl_algo.h +++ b/include/dl_algo.h @@ -15,7 +15,7 @@ namespace Botan { /************************************************* * DL Public Key * *************************************************/ -class DL_Scheme_PublicKey : public virtual X509_PublicKey +class DL_Scheme_PublicKey : public virtual Public_Key { public: bool check_key(bool) const; @@ -43,7 +43,7 @@ class DL_Scheme_PublicKey : public virtual X509_PublicKey * DL Private Key * *************************************************/ class DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey, - public virtual PKCS8_PrivateKey + public virtual Private_Key { public: bool check_key(bool) const; @@ -56,7 +56,7 @@ class DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey, private: PKCS8_Encoder* pkcs8_encoder() const; PKCS8_Decoder* pkcs8_decoder(); - virtual void PKCS8_load_hook() {} + virtual void PKCS8_load_hook(bool = false) {} }; } diff --git a/include/dsa.h b/include/dsa.h index f2f630e7c..28e2eefbf 100644 --- a/include/dsa.h +++ b/include/dsa.h @@ -51,7 +51,7 @@ class DSA_PrivateKey : public DSA_PublicKey, DSA_PrivateKey(const DL_Group&, const BigInt&, const BigInt& = 0); private: friend PKCS8_PrivateKey* get_private_key(const std::string&); - void PKCS8_load_hook(); + void PKCS8_load_hook(bool = false); DSA_PrivateKey() {} }; diff --git a/include/elgamal.h b/include/elgamal.h index 3731e8f1b..f3ba15bba 100644 --- a/include/elgamal.h +++ b/include/elgamal.h @@ -50,7 +50,7 @@ class ElGamal_PrivateKey : public ElGamal_PublicKey, ElGamal_PrivateKey(const DL_Group&, const BigInt&, const BigInt& = 0); private: friend PKCS8_PrivateKey* get_private_key(const std::string&); - void PKCS8_load_hook(); + void PKCS8_load_hook(bool = false); ElGamal_PrivateKey() {} }; diff --git a/include/if_algo.h b/include/if_algo.h index 02f8763d8..550d07440 100644 --- a/include/if_algo.h +++ b/include/if_algo.h @@ -50,7 +50,7 @@ class IF_Scheme_PrivateKey : public virtual IF_Scheme_PublicKey, virtual ~IF_Scheme_PrivateKey() {} protected: - virtual void PKCS8_load_hook(); + virtual void PKCS8_load_hook(bool = false); BigInt d, p, q, d1, d2, c; private: PKCS8_Encoder* pkcs8_encoder() const; diff --git a/include/nr.h b/include/nr.h index 14749a6b5..a48985ff6 100644 --- a/include/nr.h +++ b/include/nr.h @@ -51,7 +51,7 @@ class NR_PrivateKey : public NR_PublicKey, NR_PrivateKey(const DL_Group&, const BigInt&, const BigInt& = 0); private: friend PKCS8_PrivateKey* get_private_key(const std::string&); - void PKCS8_load_hook(); + void PKCS8_load_hook(bool = false); NR_PrivateKey() {} }; diff --git a/include/pk_keys.h b/include/pk_keys.h index 96fb2051e..d1f6a2204 100644 --- a/include/pk_keys.h +++ b/include/pk_keys.h @@ -12,29 +12,44 @@ namespace Botan { /************************************************* -* Generic PK Key * +* Public Key Base Class * *************************************************/ -class PK_Key +class Public_Key { public: virtual std::string algo_name() const = 0; - virtual OID get_oid() const; - virtual u32bit max_input_bits() const { return 0; } + virtual bool check_key(bool) const { return true; } virtual u32bit message_parts() const { return 1; } virtual u32bit message_part_size() const { return 0; } - virtual ~PK_Key() {} + virtual u32bit max_input_bits() const = 0; + + virtual class X509_Encoder* x509_encoder() const { return 0; } + virtual class X509_Decoder* x509_decoder() { return 0; } + + virtual ~Public_Key() {} protected: - void check_loaded_public() const; - void check_loaded_private() const; - void check_generated_private() const; + virtual void load_check() const; + }; + +/************************************************* +* Private Key Base Class * +*************************************************/ +class Private_Key : public virtual Public_Key + { + public: + virtual class PKCS8_Encoder* pkcs8_encoder() const { return 0; } + virtual class PKCS8_Decoder* pkcs8_decoder() { return 0; } + protected: + void load_check() const; + void gen_check() const; }; /************************************************* * PK Encrypting Key * *************************************************/ -class PK_Encrypting_Key : public virtual PK_Key +class PK_Encrypting_Key : public virtual Public_Key { public: virtual SecureVector<byte> encrypt(const byte[], u32bit) const = 0; @@ -44,7 +59,7 @@ class PK_Encrypting_Key : public virtual PK_Key /************************************************* * PK Decrypting Key * *************************************************/ -class PK_Decrypting_Key : public virtual PK_Key +class PK_Decrypting_Key : public virtual Private_Key { public: virtual SecureVector<byte> decrypt(const byte[], u32bit) const = 0; @@ -54,7 +69,7 @@ class PK_Decrypting_Key : public virtual PK_Key /************************************************* * PK Signing Key * *************************************************/ -class PK_Signing_Key : public virtual PK_Key +class PK_Signing_Key : public virtual Private_Key { public: virtual SecureVector<byte> sign(const byte[], u32bit) const = 0; @@ -64,7 +79,7 @@ class PK_Signing_Key : public virtual PK_Key /************************************************* * PK Verifying Key, Message Recovery Version * *************************************************/ -class PK_Verifying_with_MR_Key : public virtual PK_Key +class PK_Verifying_with_MR_Key : public virtual Public_Key { public: virtual SecureVector<byte> verify(const byte[], u32bit) const = 0; @@ -74,7 +89,7 @@ class PK_Verifying_with_MR_Key : public virtual PK_Key /************************************************* * PK Verifying Key, No Message Recovery Version * *************************************************/ -class PK_Verifying_wo_MR_Key : public virtual PK_Key +class PK_Verifying_wo_MR_Key : public virtual Public_Key { public: virtual bool verify(const byte[], u32bit, @@ -85,7 +100,7 @@ class PK_Verifying_wo_MR_Key : public virtual PK_Key /************************************************* * PK Secret Value Derivation Key * *************************************************/ -class PK_Key_Agreement_Key : public virtual PK_Key +class PK_Key_Agreement_Key : public virtual Private_Key { public: virtual SecureVector<byte> derive_key(const byte[], u32bit) const = 0; @@ -93,7 +108,12 @@ class PK_Key_Agreement_Key : public virtual PK_Key virtual ~PK_Key_Agreement_Key() {} }; +/************************************************* +* Typedefs * +*************************************************/ typedef PK_Key_Agreement_Key PK_KA_Key; +typedef Public_Key X509_PublicKey; +typedef Private_Key PKCS8_PrivateKey; } diff --git a/include/pkcs8.h b/include/pkcs8.h index 5e3e1c097..2dd863848 100644 --- a/include/pkcs8.h +++ b/include/pkcs8.h @@ -34,17 +34,6 @@ class PKCS8_Decoder }; /************************************************* -* PKCS #8 Private Key * -*************************************************/ -class PKCS8_PrivateKey : public virtual X509_PublicKey - { - public: - virtual PKCS8_Encoder* pkcs8_encoder() const = 0; - virtual PKCS8_Decoder* pkcs8_decoder() = 0; - virtual ~PKCS8_PrivateKey() {} - }; - -/************************************************* * PKCS #8 General Exception * *************************************************/ struct PKCS8_Exception : public Decoding_Error diff --git a/include/x509_key.h b/include/x509_key.h index 330444097..c0b7c24d7 100644 --- a/include/x509_key.h +++ b/include/x509_key.h @@ -34,19 +34,6 @@ class X509_Decoder virtual ~X509_Decoder() {} }; -/************************************************* -* X.509 Public Key * -*************************************************/ -class X509_PublicKey : public virtual PK_Key - { - public: - u64bit key_id() const; - - virtual X509_Encoder* x509_encoder() const = 0; - virtual X509_Decoder* x509_decoder() = 0; - virtual ~X509_PublicKey() {} - }; - namespace X509 { /************************************************* diff --git a/include/x509_obj.h b/include/x509_obj.h index 47c95a041..61483ffd1 100644 --- a/include/x509_obj.h +++ b/include/x509_obj.h @@ -26,7 +26,7 @@ class X509_Object const AlgorithmIdentifier&, const MemoryRegion<byte>&); - bool check_signature(class X509_PublicKey&) const; + bool check_signature(class Public_Key&) const; void encode(Pipe&, X509_Encoding = PEM) const; SecureVector<byte> BER_encode() const; diff --git a/include/x509stor.h b/include/x509stor.h index e3dd763d2..fd26cd2bd 100644 --- a/include/x509stor.h +++ b/include/x509stor.h @@ -137,7 +137,6 @@ namespace X509_Store_Search { std::vector<X509_Certificate> by_email(const X509_Store&, const std::string&); std::vector<X509_Certificate> by_name(const X509_Store&, const std::string&); std::vector<X509_Certificate> by_dns(const X509_Store&, const std::string&); -std::vector<X509_Certificate> by_keyid(const X509_Store&, u64bit); std::vector<X509_Certificate> by_iands(const X509_Store&, const X509_DN&, const MemoryRegion<byte>&); std::vector<X509_Certificate> by_SKID(const X509_Store&, |