Botan 2.19.1
Crypto and TLS for C&
dh.h
Go to the documentation of this file.
1/*
2* Diffie-Hellman
3* (C) 1999-2007 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_DIFFIE_HELLMAN_H_
9#define BOTAN_DIFFIE_HELLMAN_H_
10
11#include <botan/dl_algo.h>
12
13namespace Botan {
14
15/**
16* This class represents Diffie-Hellman public keys.
17*/
19 {
20 public:
21 std::string algo_name() const override { return "DH"; }
22
23 std::vector<uint8_t> public_value() const;
24
26
27 /**
28 * Create a public key.
29 * @param alg_id the X.509 algorithm identifier
30 * @param key_bits DER encoded public key bits
31 */
33 const std::vector<uint8_t>& key_bits) :
34 DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42) {}
35
36 /**
37 * Construct a public key with the specified parameters.
38 * @param grp the DL group to use in the key
39 * @param y the public value y
40 */
41 DH_PublicKey(const DL_Group& grp, const BigInt& y);
42 protected:
43 DH_PublicKey() = default;
44 };
45
46/**
47* This class represents Diffie-Hellman private keys.
48*/
51 public virtual DL_Scheme_PrivateKey
52 {
53 public:
54 std::vector<uint8_t> public_value() const override;
55
56 /**
57 * Load a private key.
58 * @param alg_id the X.509 algorithm identifier
59 * @param key_bits PKCS #8 structure
60 */
62 const secure_vector<uint8_t>& key_bits);
63
64 /**
65 * Create a private key.
66 * @param rng random number generator to use
67 * @param grp the group to be used in the key
68 * @param x the key's secret value (or if zero, generate a new key)
69 */
71 const BigInt& x = 0);
72
73 std::unique_ptr<PK_Ops::Key_Agreement>
74 create_key_agreement_op(RandomNumberGenerator& rng,
75 const std::string& params,
76 const std::string& provider) const override;
77 };
78
79}
80
81#endif
DH_PublicKey()=default
DL_Group::Format group_format() const override
Definition: dh.h:25
std::string algo_name() const override
Definition: dh.h:21
DH_PublicKey(const AlgorithmIdentifier &alg_id, const std::vector< uint8_t > &key_bits)
Definition: dh.h:32
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65