Botan 3.4.0
Crypto and TLS for C&
eckcdsa.h
Go to the documentation of this file.
1/*
2* ECKCDSA (ISO/IEC 14888-3:2018)
3* (C) 2016 René Korthaus, Sirrix AG
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_ECKCDSA_KEY_H_
9#define BOTAN_ECKCDSA_KEY_H_
10
11#include <botan/ecc_key.h>
12
13namespace Botan {
14
15/**
16* This class represents ECKCDSA public keys.
17*/
18class BOTAN_PUBLIC_API(2, 0) ECKCDSA_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 ECKCDSA_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 ECKCDSA_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 */
38 std::string algo_name() const override { return "ECKCDSA"; }
39
40 size_t message_parts() const override { return 2; }
41
42 size_t message_part_size() const override { return domain().get_order().bytes(); }
43
44 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
45
46 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
47
48 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
49 std::string_view provider) const override;
50
51 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
52 std::string_view provider) const override;
53
54 protected:
55 ECKCDSA_PublicKey() = default;
56};
57
58/**
59* This class represents ECKCDSA private keys.
60*/
61
64
66 public EC_PrivateKey {
67 public:
68 /**
69 * Load a private key.
70 * @param alg_id the X.509 algorithm identifier
71 * @param key_bits ECPrivateKey bits
72 */
73 ECKCDSA_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
74 EC_PrivateKey(alg_id, key_bits, true) {}
75
76 /**
77 * Create a private key.
78 * @param rng a random number generator
79 * @param domain parameters to used for this key
80 * @param x the private key (if zero, generate a new random key)
81 */
82 ECKCDSA_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x = BigInt::zero()) :
83 EC_PrivateKey(rng, domain, x, true) {}
84
85 bool check_key(RandomNumberGenerator& rng, bool) const override;
86
87 std::unique_ptr<Public_Key> public_key() const override;
88
89 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
90 std::string_view params,
91 std::string_view provider) const override;
92};
93
95
96} // namespace Botan
97
98#endif
ECKCDSA_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=BigInt::zero())
Definition eckcdsa.h:82
ECKCDSA_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition eckcdsa.h:73
bool supports_operation(PublicKeyOperation op) const override
Definition eckcdsa.h:46
std::string algo_name() const override
Definition eckcdsa.h:38
ECKCDSA_PublicKey(const EC_Group &dom_par, const EC_Point &public_point)
Definition eckcdsa.h:25
size_t message_part_size() const override
Definition eckcdsa.h:42
size_t message_parts() const override
Definition eckcdsa.h:40
ECKCDSA_PublicKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition eckcdsa.h:32
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