Coverage Report

Created: 2022-09-23 06:05

/src/botan/build/include/botan/ecgdsa.h
Line
Count
Source (jump to first uncovered line)
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
13
namespace Botan {
14
15
/**
16
* This class represents ECGDSA public keys.
17
*/
18
class BOTAN_PUBLIC_API(2,0) ECGDSA_PublicKey : public virtual EC_PublicKey
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
      */
27
      ECGDSA_PublicKey(const EC_Group& dom_par,
28
                      const PointGFp& public_point) :
29
0
         EC_PublicKey(dom_par, public_point) {}
Unexecuted instantiation: Botan::ECGDSA_PublicKey::ECGDSA_PublicKey(Botan::EC_Group const&, Botan::PointGFp const&)
Unexecuted instantiation: Botan::ECGDSA_PublicKey::ECGDSA_PublicKey(Botan::EC_Group const&, Botan::PointGFp const&)
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
      */
36
      ECGDSA_PublicKey(const AlgorithmIdentifier& alg_id,
37
                      const std::vector<uint8_t>& key_bits) :
38
0
         EC_PublicKey(alg_id, key_bits) {}
Unexecuted instantiation: Botan::ECGDSA_PublicKey::ECGDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
Unexecuted instantiation: Botan::ECGDSA_PublicKey::ECGDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
39
40
      /**
41
      * Get this keys algorithm name.
42
      * @result this keys algorithm name ("ECGDSA")
43
      */
44
0
      std::string algo_name() const override { return "ECGDSA"; }
45
46
0
      size_t message_parts() const override { return 2; }
47
48
      size_t message_part_size() const override
49
0
         { return domain().get_order().bytes(); }
50
51
      std::unique_ptr<PK_Ops::Verification>
52
         create_verification_op(const std::string& params,
53
                                const std::string& provider) const override;
54
   protected:
55
0
      ECGDSA_PublicKey() = default;
56
   };
57
58
/**
59
* This class represents ECGDSA private keys.
60
*/
61
class BOTAN_PUBLIC_API(2,0) ECGDSA_PrivateKey final : public ECGDSA_PublicKey,
62
                                    public EC_PrivateKey
63
   {
64
   public:
65
66
      /**
67
      * Load a private key.
68
      * @param alg_id the X.509 algorithm identifier
69
      * @param key_bits ECPrivateKey bits
70
      */
71
      ECGDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
72
                       const secure_vector<uint8_t>& key_bits) :
73
0
         EC_PrivateKey(alg_id, key_bits, true) {}
Unexecuted instantiation: Botan::ECGDSA_PrivateKey::ECGDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, Botan::secure_allocator<unsigned char> > const&)
Unexecuted instantiation: Botan::ECGDSA_PrivateKey::ECGDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, Botan::secure_allocator<unsigned char> > const&)
74
75
      /**
76
      * Generate a new private key.
77
      * @param rng a random number generator
78
      * @param domain parameters to used for this key
79
      * @param x the private key (if zero, generate a new random key)
80
      */
81
      ECGDSA_PrivateKey(RandomNumberGenerator& rng,
82
                        const EC_Group& domain,
83
                        const BigInt& x = BigInt::zero()) :
84
0
         EC_PrivateKey(rng, domain, x, true) {}
Unexecuted instantiation: Botan::ECGDSA_PrivateKey::ECGDSA_PrivateKey(Botan::RandomNumberGenerator&, Botan::EC_Group const&, Botan::BigInt const&)
Unexecuted instantiation: Botan::ECGDSA_PrivateKey::ECGDSA_PrivateKey(Botan::RandomNumberGenerator&, Botan::EC_Group const&, Botan::BigInt const&)
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>
91
         create_signature_op(RandomNumberGenerator& rng,
92
                             const std::string& params,
93
                             const std::string& provider) const override;
94
   };
95
96
}
97
98
#endif