Botan 3.0.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*/
19 {
20 public:
21
22 /**
23 * Construct a public key from a given public point.
24 * @param dom_par the domain parameters associated with this key
25 * @param public_point the public point defining this key
26 */
28 const EC_Point& public_point) :
29 EC_PublicKey(dom_par, public_point) {}
30
31 /**
32 * Load a public key.
33 * @param alg_id the X.509 algorithm identifier
34 * @param key_bits DER encoded public key bits
35 */
37 std::span<const uint8_t> key_bits) :
38 EC_PublicKey(alg_id, key_bits) {}
39
40 /**
41 * Get this keys algorithm name.
42 */
43 std::string algo_name() const override { return "ECKCDSA"; }
44
45 size_t message_parts() const override { return 2; }
46
47 size_t message_part_size() const override
48 { return domain().get_order().bytes(); }
49
50 bool supports_operation(PublicKeyOperation op) const override
51 {
52 return (op == PublicKeyOperation::Signature);
53 }
54
55 std::unique_ptr<PK_Ops::Verification>
56 create_verification_op(std::string_view params,
57 std::string_view provider) const override;
58
59 std::unique_ptr<PK_Ops::Verification>
60 create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
61 std::string_view provider) const override;
62 protected:
63 ECKCDSA_PublicKey() = default;
64 };
65
66/**
67* This class represents ECKCDSA private keys.
68*/
69
72
74 public EC_PrivateKey
75 {
76 public:
77
78 /**
79 * Load a private key.
80 * @param alg_id the X.509 algorithm identifier
81 * @param key_bits ECPrivateKey bits
82 */
84 std::span<const uint8_t> key_bits) :
85 EC_PrivateKey(alg_id, key_bits, true) {}
86
87 /**
88 * Create a private key.
89 * @param rng a random number generator
90 * @param domain parameters to used for this key
91 * @param x the private key (if zero, generate a new random key)
92 */
94 const EC_Group& domain,
95 const BigInt& x = BigInt::zero()) :
96 EC_PrivateKey(rng, domain, x, true) {}
97
98 bool check_key(RandomNumberGenerator& rng, bool) const override;
99
100 std::unique_ptr<Public_Key> public_key() const override;
101
102 std::unique_ptr<PK_Ops::Signature>
103 create_signature_op(RandomNumberGenerator& rng,
104 std::string_view params,
105 std::string_view provider) const override;
106 };
107
109
110}
111
112#endif
ECKCDSA_PrivateKey(RandomNumberGenerator &rng, const EC_Group &domain, const BigInt &x=BigInt::zero())
Definition: eckcdsa.h:93
ECKCDSA_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition: eckcdsa.h:83
bool supports_operation(PublicKeyOperation op) const override
Definition: eckcdsa.h:50
std::string algo_name() const override
Definition: eckcdsa.h:43
ECKCDSA_PublicKey(const EC_Group &dom_par, const EC_Point &public_point)
Definition: eckcdsa.h:27
size_t message_part_size() const override
Definition: eckcdsa.h:47
size_t message_parts() const override
Definition: eckcdsa.h:45
ECKCDSA_PublicKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition: eckcdsa.h:36
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
Definition: compiler.h:204
#define BOTAN_DIAGNOSTIC_PUSH
Definition: compiler.h:201
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition: compiler.h:203
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:12
PublicKeyOperation
Definition: pk_keys.h:43