diff options
Diffstat (limited to 'src/pubkey/dl_algo/dl_algo.h')
-rw-r--r-- | src/pubkey/dl_algo/dl_algo.h | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/src/pubkey/dl_algo/dl_algo.h b/src/pubkey/dl_algo/dl_algo.h index a8d8d1d51..ff543d0b4 100644 --- a/src/pubkey/dl_algo/dl_algo.h +++ b/src/pubkey/dl_algo/dl_algo.h @@ -13,22 +13,60 @@ namespace Botan { -/************************************************* -* DL Public Key * -*************************************************/ +/** +* This class represents discrete logarithm (DL) public keys. +*/ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key { public: bool check_key(RandomNumberGenerator& rng, bool) const; + /** + * Get the DL domain parameters of this key. + * @return the DL domain parameters of this key + */ const DL_Group& get_domain() const { return group; } + + /** + * Get the public value y with y = g^x mod p where x is the secret key. + */ const BigInt& get_y() const { return y; } + + /** + * Get the prime p of the underlying DL group. + * @return the prime p + */ const BigInt& group_p() const { return group.get_p(); } + + /** + * Get the prime q of the underlying DL group. + * @return the prime q + */ const BigInt& group_q() const { return group.get_q(); } + + /** + * Get the generator g of the underlying DL group. + * @return the generator g + */ const BigInt& group_g() const { return group.get_g(); } + + /** + * Get the underlying groups encoding format. + * @return the encoding format + */ virtual DL_Group::Format group_format() const = 0; + /** + * Get an X509 encoder for this key. + * @return an encoder usable to encode this key. + */ X509_Encoder* x509_encoder() const; + + /** + * 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(); protected: BigInt y; @@ -37,19 +75,34 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key virtual void X509_load_hook() {} }; -/************************************************* -* DL Private Key * -*************************************************/ +/** +* This class represents discrete logarithm (DL) private keys. +*/ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey, public virtual Private_Key { public: bool check_key(RandomNumberGenerator& rng, bool) const; + /** + * Get the secret key x. + * @return the secret key + */ const BigInt& get_x() const { return x; } + /** + * Get an PKCS#8 encoder for this key. + * @return an encoder usable to encode this key. + */ PKCS8_Encoder* pkcs8_encoder() const; - PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator&); + + /** + * Get an PKCS#8 decoder for this key. + * @param rng the rng to use + * @return an decoder usable to decode a DL key and store the + * values in this instance. + */ + PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator& rng); protected: BigInt x; private: |