Botan 3.4.0
Crypto and TLS for C&
ecgdsa.h
Go to the documentation of this file.
1/*
2* ECGDSA (BSI-TR-03111, version 2.0)
3* (C) 2016 René Korthaus
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_ECGDSA_KEY_H_
9#define BOTAN_ECGDSA_KEY_H_
10
11#include <botan/ecc_key.h>
12
13namespace Botan {
14
15/**
16* This class represents ECGDSA public keys.
17*/
18class BOTAN_PUBLIC_API(2, 0) ECGDSA_PublicKey : public virtual EC_PublicKey {
19 public:
20 /**
21 * Construct a public key from a given public point.
22 * @param dom_par the domain parameters associated with this key
23 * @param public_point the public point defining this key
24 */
25 ECGDSA_PublicKey(const EC_Group& dom_par, const EC_Point& public_point) : EC_PublicKey(dom_par, public_point) {}
26
27 /**
28 * Load a public key.
29 * @param alg_id the X.509 algorithm identifier
30 * @param key_bits DER encoded public key bits
31 */
32 ECGDSA_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
33 EC_PublicKey(alg_id, key_bits) {}
34
35 /**
36 * Get this keys algorithm name.
37 * @result this keys algorithm name ("ECGDSA")
38 */
39 std::string algo_name() const override { return "ECGDSA"; }
40
41 size_t message_parts() const override { return 2; }
42
43 size_t message_part_size() const override { return domain().get_order().bytes(); }
44
45 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
46
47 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
48
49 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
50 std::string_view provider) const override;
51
52 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
53 std::string_view provider) const override;
54
55 protected:
56 ECGDSA_PublicKey() = default;
57};
58
59/**
60* This class represents ECGDSA private keys.
61*/
62
65
67 public EC_PrivateKey {
68 public:
69 /**
70 * Load a private key.
71 * @param alg_id the X.509 algorithm identifier
72 * @param key_bits ECPrivateKey bits
73 */
74 ECGDSA_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
75 EC_PrivateKey(alg_id, key_bits, true) {}
76
77 /**
78 * Generate a new private key.
79 * @param rng a random number generator
80 * @param domain parameters to used for this key
81 * @param x the private key (if zero, generate a new random key)
82 */
83 ECGDSA_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x = BigInt::zero()) :
84 EC_PrivateKey(rng, domain, x, true) {}
85
86 std::unique_ptr<Public_Key> public_key() const override;
87
88 bool check_key(RandomNumberGenerator& rng, bool) const override;
89
90 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
91 std::string_view params,
92 std::string_view provider) const override;
93};
94
96
97} // namespace Botan
98
99#endif
ECGDSA_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition ecgdsa.h:74
ECGDSA_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=BigInt::zero())
Definition ecgdsa.h:83
bool supports_operation(PublicKeyOperation op) const override
Definition ecgdsa.h:47
ECGDSA_PublicKey(const EC_Group &dom_par, const EC_Point &public_point)
Definition ecgdsa.h:25
std::string algo_name() const override
Definition ecgdsa.h:39
size_t message_parts() const override
Definition ecgdsa.h:41
ECGDSA_PublicKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition ecgdsa.h:32
size_t message_part_size() const override
Definition ecgdsa.h:43
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
Definition compiler.h:191
#define BOTAN_DIAGNOSTIC_PUSH
Definition compiler.h:188
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition compiler.h:190
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
PublicKeyOperation
Definition pk_keys.h:45