Botan: src/pubkey/dl_algo/dl_algo.h Source File

Botan 1.10.17

dl_algo.h
Go to the documentation of this file.
1 /*
2 * DL Scheme
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_DL_ALGO_H__
9 #define BOTAN_DL_ALGO_H__
10
11 #include <botan/dl_group.h>
12 #include <botan/x509_key.h>
13 #include <botan/pkcs8.h>
14
15 namespace Botan {
16
17 /**
18 * This class represents discrete logarithm (DL) public keys.
19 */
20 class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
21 {
22 public:
23 bool check_key(RandomNumberGenerator& rng, bool) const;
24
25 AlgorithmIdentifier algorithm_identifier() const;
26
27 MemoryVector<byte> x509_subject_public_key() const;
28
29 /**
30 * Get the DL domain parameters of this key.
31 * @return DL domain parameters of this key
32 */
33 const DL_Group& get_domain() const { return group; }
34
35 /**
36 * Get the public value y with y = g^x mod p where x is the secret key.
37 */
38 const BigInt& get_y() const { return y; }
39
40 /**
41 * Get the prime p of the underlying DL group.
42 * @return prime p
43 */
44 const BigInt& group_p() const { return group.get_p(); }
45
46 /**
47 * Get the prime q of the underlying DL group.
48 * @return prime q
49 */
50 const BigInt& group_q() const { return group.get_q(); }
51
52 /**
53 * Get the generator g of the underlying DL group.
54 * @return generator g
55 */
56 const BigInt& group_g() const { return group.get_g(); }
57
58 /**
59 * Get the underlying groups encoding format.
60 * @return encoding format
61 */
62 virtual DL_Group::Format group_format() const = 0;
63
64 DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
65 const MemoryRegion<byte>& key_bits,
66 DL_Group::Format group_format);
67
68 protected:
69 DL_Scheme_PublicKey() {}
70
71 /**
72 * The DL public key
73 */
74 BigInt y;
75
76 /**
77 * The DL group
78 */
79 DL_Group group;
80 };
81
82 /**
83 * This class represents discrete logarithm (DL) private keys.
84 */
85 class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
86 public virtual Private_Key
87 {
88 public:
89 bool check_key(RandomNumberGenerator& rng, bool) const;
90
91 /**
92 * Get the secret key x.
93 * @return secret key
94 */
95 const BigInt& get_x() const { return x; }
96
97 MemoryVector<byte> pkcs8_private_key() const;
98
99 DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
100 const MemoryRegion<byte>& key_bits,
101 DL_Group::Format group_format);
102
103 protected:
104 DL_Scheme_PrivateKey() {}
105
106 /**
107 * The DL private key
108 */
109 BigInt x;
110 };
111
112 }
113
114 #endif
Botan::DL_Scheme_PrivateKey
Definition: dl_algo.h:85
Botan::DL_Scheme_PublicKey::get_domain
const DL_Group & get_domain() const
Definition: dl_algo.h:33
Botan::BigInt
Definition: bigint.h:22
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::Private_Key
Definition: pk_keys.h:86
Botan::DL_Scheme_PublicKey
Definition: dl_algo.h:20
Botan::DL_Scheme_PublicKey::get_y
const BigInt & get_y() const
Definition: dl_algo.h:38
Botan::DL_Group
Definition: dl_group.h:20
Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey
DL_Scheme_PublicKey()
Definition: dl_algo.h:69
Botan::DL_Group::Format
Format
Definition: dl_group.h:44
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::MemoryVector< byte >
Botan::Public_Key
Definition: pk_keys.h:21
Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey
DL_Scheme_PrivateKey()
Definition: dl_algo.h:104
Botan::DL_Scheme_PublicKey::group_p
const BigInt & group_p() const
Definition: dl_algo.h:44
Botan::DL_Scheme_PrivateKey::x
BigInt x
Definition: dl_algo.h:109
Botan::DL_Scheme_PublicKey::group
DL_Group group
Definition: dl_algo.h:79
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::DL_Scheme_PrivateKey::get_x
const BigInt & get_x() const
Definition: dl_algo.h:95
Botan::DL_Scheme_PublicKey::group_g
const BigInt & group_g() const
Definition: dl_algo.h:56
Botan::DL_Scheme_PublicKey::group_q
const BigInt & group_q() const
Definition: dl_algo.h:50
Botan::DL_Scheme_PublicKey::y
BigInt y
Definition: dl_algo.h:74