Coverage Report

Created: 2020-06-30 13:58

/src/botan/build/include/botan/ecdsa.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* ECDSA
3
* (C) 2007 Falko Strenzke, FlexSecure GmbH
4
*          Manuel Hartl, FlexSecure GmbH
5
* (C) 2008-2010 Jack Lloyd
6
*
7
* Botan is released under the Simplified BSD License (see license.txt)
8
*/
9
10
#ifndef BOTAN_ECDSA_KEY_H_
11
#define BOTAN_ECDSA_KEY_H_
12
13
#include <botan/ecc_key.h>
14
15
namespace Botan {
16
17
/**
18
* This class represents ECDSA Public Keys.
19
*/
20
class BOTAN_PUBLIC_API(2,0) ECDSA_PublicKey : public virtual EC_PublicKey
21
   {
22
   public:
23
24
      /**
25
      * Create a public key from a given public point.
26
      * @param dom_par the domain parameters associated with this key
27
      * @param public_point the public point defining this key
28
      */
29
      ECDSA_PublicKey(const EC_Group& dom_par,
30
                      const PointGFp& public_point) :
31
0
         EC_PublicKey(dom_par, public_point) {}
32
33
      /**
34
      * Load a public key.
35
      * @param alg_id the X.509 algorithm identifier
36
      * @param key_bits DER encoded public key bits
37
      */
38
      ECDSA_PublicKey(const AlgorithmIdentifier& alg_id,
39
                      const std::vector<uint8_t>& key_bits) :
40
3.09k
         EC_PublicKey(alg_id, key_bits) {}
Botan::ECDSA_PublicKey::ECDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
Line
Count
Source
40
3.09k
         EC_PublicKey(alg_id, key_bits) {}
Unexecuted instantiation: Botan::ECDSA_PublicKey::ECDSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
41
42
      /**
43
      * Recover a public key from a signature/msg pair
44
      * See SEC section 4.6.1
45
      * @param group the elliptic curve group
46
      * @param msg the message
47
      * @param r the r paramter of the signature
48
      * @param s the s paramter of the signature
49
      * @param v the recovery ID
50
      */
51
      ECDSA_PublicKey(const EC_Group& group,
52
                      const std::vector<uint8_t>& msg,
53
                      const BigInt& r,
54
                      const BigInt& s,
55
                      uint8_t v);
56
57
      /**
58
      * Get this keys algorithm name.
59
      * @result this keys algorithm name ("ECDSA")
60
      */
61
2.60k
      std::string algo_name() const override { return "ECDSA"; }
62
63
2.83k
      size_t message_parts() const override { return 2; }
64
65
      size_t message_part_size() const override
66
1.55k
         { return domain().get_order().bytes(); }
67
68
      uint8_t recovery_param(const std::vector<uint8_t>& msg,
69
                             const BigInt& r,
70
                             const BigInt& s) const;
71
72
      std::unique_ptr<PK_Ops::Verification>
73
         create_verification_op(const std::string& params,
74
                                const std::string& provider) const override;
75
   protected:
76
436
      ECDSA_PublicKey() = default;
77
   };
78
79
/**
80
* This class represents ECDSA Private Keys
81
*/
82
class BOTAN_PUBLIC_API(2,0) ECDSA_PrivateKey final : public ECDSA_PublicKey,
83
                                   public EC_PrivateKey
84
   {
85
   public:
86
87
      /**
88
      * Load a private key
89
      * @param alg_id the X.509 algorithm identifier
90
      * @param key_bits ECPrivateKey bits
91
      */
92
      ECDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
93
                       const secure_vector<uint8_t>& key_bits) :
94
436
         EC_PrivateKey(alg_id, key_bits) {}
Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, Botan::secure_allocator<unsigned char> > const&)
Line
Count
Source
94
436
         EC_PrivateKey(alg_id, key_bits) {}
Unexecuted instantiation: Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, Botan::secure_allocator<unsigned char> > const&)
95
96
      /**
97
      * Create a private key.
98
      * @param rng a random number generator
99
      * @param domain parameters to used for this key
100
      * @param x the private key (if zero, generate a new random key)
101
      */
102
      ECDSA_PrivateKey(RandomNumberGenerator& rng,
103
                       const EC_Group& domain,
104
                       const BigInt& x = 0) :
105
0
         EC_PrivateKey(rng, domain, x) {}
Unexecuted instantiation: Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::RandomNumberGenerator&, Botan::EC_Group const&, Botan::BigInt const&)
Unexecuted instantiation: Botan::ECDSA_PrivateKey::ECDSA_PrivateKey(Botan::RandomNumberGenerator&, Botan::EC_Group const&, Botan::BigInt const&)
106
107
      bool check_key(RandomNumberGenerator& rng, bool) const override;
108
109
      std::unique_ptr<PK_Ops::Signature>
110
         create_signature_op(RandomNumberGenerator& rng,
111
                             const std::string& params,
112
                             const std::string& provider) const override;
113
   };
114
115
}
116
117
#endif