/src/botan/build/include/internal/botan/internal/dl_scheme.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * (C) 2023 Jack Lloyd |
3 | | * |
4 | | * Botan is released under the Simplified BSD License (see license.txt) |
5 | | */ |
6 | | |
7 | | #ifndef BOTAN_DL_SCHEME_H_ |
8 | | #define BOTAN_DL_SCHEME_H_ |
9 | | |
10 | | #include <botan/bigint.h> |
11 | | #include <botan/dl_group.h> |
12 | | #include <memory> |
13 | | #include <span> |
14 | | #include <string_view> |
15 | | |
16 | | namespace Botan { |
17 | | |
18 | | class AlgorithmIdentifier; |
19 | | class RandomNumberGenerator; |
20 | | |
21 | | class DL_PublicKey final { |
22 | | public: |
23 | | DL_PublicKey(const DL_Group& group, const BigInt& public_key); |
24 | | |
25 | | DL_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits, DL_Group_Format format); |
26 | | |
27 | | bool check_key(RandomNumberGenerator& rng, bool strong) const; |
28 | | |
29 | 46 | const DL_Group& group() const { return m_group; } |
30 | | |
31 | 0 | const BigInt& public_key() const { return m_public_key; } |
32 | | |
33 | | // Return the binary representation of the integer public key |
34 | | std::vector<uint8_t> public_key_as_bytes() const; |
35 | | |
36 | | const BigInt& get_int_field(std::string_view algo_name, std::string_view field) const; |
37 | | |
38 | | std::vector<uint8_t> DER_encode() const; |
39 | | |
40 | | size_t estimated_strength() const; |
41 | | |
42 | | size_t p_bits() const; |
43 | | |
44 | | private: |
45 | | const DL_Group m_group; |
46 | | const BigInt m_public_key; |
47 | | }; |
48 | | |
49 | | class DL_PrivateKey final { |
50 | | public: |
51 | | DL_PrivateKey(const DL_Group& group, const BigInt& private_key); |
52 | | |
53 | | DL_PrivateKey(const DL_Group& group, RandomNumberGenerator& rng); |
54 | | |
55 | | DL_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits, DL_Group_Format format); |
56 | | |
57 | | bool check_key(RandomNumberGenerator& rng, bool strong) const; |
58 | | |
59 | | /** |
60 | | * Return a new shared_ptr of the associated public key |
61 | | */ |
62 | | std::shared_ptr<DL_PublicKey> public_key() const; |
63 | | |
64 | | /** |
65 | | * Return the group this key operates in |
66 | | */ |
67 | 41 | const DL_Group& group() const { return m_group; } |
68 | | |
69 | | /** |
70 | | * Return the integer value of the private key |
71 | | */ |
72 | 0 | const BigInt& private_key() const { return m_private_key; } |
73 | | |
74 | | /** |
75 | | * DER encode the private key |
76 | | */ |
77 | | secure_vector<uint8_t> DER_encode() const; |
78 | | |
79 | | /** |
80 | | * Return the raw serialization of the private key |
81 | | */ |
82 | | secure_vector<uint8_t> raw_private_key_bits() const; |
83 | | |
84 | | const BigInt& get_int_field(std::string_view algo_name, std::string_view field) const; |
85 | | |
86 | | private: |
87 | | const DL_Group m_group; |
88 | | const BigInt m_private_key; |
89 | | const BigInt m_public_key; |
90 | | }; |
91 | | |
92 | | } // namespace Botan |
93 | | |
94 | | #endif |