Botan 3.3.0
Crypto and TLS for C&
dl_scheme.h
Go to the documentation of this file.
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
16namespace Botan {
17
18class AlgorithmIdentifier;
19class RandomNumberGenerator;
20
22 public:
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 const DL_Group& group() const { return m_group; }
30
31 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
50 public:
52
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 const DL_Group& group() const { return m_group; }
68
69 /**
70 * Return the integer value of the private key
71 */
72 const BigInt& private_key() const { return m_private_key; }
73
74 /**
75 * DER encode the private key
76 */
78
79 /**
80 * Return the raw serialization of the private key
81 */
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
DL_PrivateKey(const DL_Group &group, const BigInt &private_key)
Definition dl_scheme.cpp:70
const BigInt & private_key() const
Definition dl_scheme.h:72
secure_vector< uint8_t > DER_encode() const
Definition dl_scheme.cpp:87
const BigInt & get_int_field(std::string_view algo_name, std::string_view field) const
secure_vector< uint8_t > raw_private_key_bits() const
Definition dl_scheme.cpp:91
const DL_Group & group() const
Definition dl_scheme.h:67
std::shared_ptr< DL_PublicKey > public_key() const
Definition dl_scheme.cpp:99
bool check_key(RandomNumberGenerator &rng, bool strong) const
Definition dl_scheme.cpp:95
std::vector< uint8_t > public_key_as_bytes() const
Definition dl_scheme.cpp:46
const BigInt & get_int_field(std::string_view algo_name, std::string_view field) const
size_t p_bits() const
Definition dl_scheme.cpp:66
size_t estimated_strength() const
Definition dl_scheme.cpp:62
std::vector< uint8_t > DER_encode() const
Definition dl_scheme.cpp:52
bool check_key(RandomNumberGenerator &rng, bool strong) const
Definition dl_scheme.cpp:58
const BigInt & public_key() const
Definition dl_scheme.h:31
DL_PublicKey(const DL_Group &group, const BigInt &public_key)
Definition dl_scheme.cpp:38
const DL_Group & group() const
Definition dl_scheme.h:29
int(* final)(unsigned char *, CTX *)
DL_Group_Format
Definition dl_group.h:28
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61