Coverage Report

Created: 2020-05-23 13:54

/src/botan/build/include/botan/dsa.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* DSA
3
* (C) 1999-2010 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_DSA_H_
9
#define BOTAN_DSA_H_
10
11
#include <botan/dl_algo.h>
12
13
namespace Botan {
14
15
/**
16
* DSA Public Key
17
*/
18
class BOTAN_PUBLIC_API(2,0) DSA_PublicKey : public virtual DL_Scheme_PublicKey
19
   {
20
   public:
21
89
      std::string algo_name() const override { return "DSA"; }
22
23
0
      DL_Group::Format group_format() const override { return DL_Group::ANSI_X9_57; }
24
172
      size_t message_parts() const override { return 2; }
25
86
      size_t message_part_size() const override { return group_q().bytes(); }
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
      DSA_PublicKey(const AlgorithmIdentifier& alg_id,
33
                    const std::vector<uint8_t>& key_bits) :
34
         DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
35
105
         {
36
105
         }
Botan::DSA_PublicKey::DSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
Line
Count
Source
35
105
         {
36
105
         }
Unexecuted instantiation: Botan::DSA_PublicKey::DSA_PublicKey(Botan::AlgorithmIdentifier const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&)
37
38
      /**
39
      * Create a public key.
40
      * @param group the underlying DL group
41
      * @param y the public value y = g^x mod p
42
      */
43
      DSA_PublicKey(const DL_Group& group, const BigInt& y);
44
45
      std::unique_ptr<PK_Ops::Verification>
46
         create_verification_op(const std::string& params,
47
                                const std::string& provider) const override;
48
   protected:
49
91
      DSA_PublicKey() = default;
50
   };
51
52
/**
53
* DSA Private Key
54
*/
55
class BOTAN_PUBLIC_API(2,0) DSA_PrivateKey final : public DSA_PublicKey,
56
                                 public virtual DL_Scheme_PrivateKey
57
   {
58
   public:
59
      /**
60
      * Load a private key.
61
      * @param alg_id the X.509 algorithm identifier
62
      * @param key_bits DER encoded key bits in ANSI X9.57 format
63
      */
64
      DSA_PrivateKey(const AlgorithmIdentifier& alg_id,
65
                     const secure_vector<uint8_t>& key_bits);
66
67
      /**
68
      * Create a private key.
69
      * @param rng the RNG to use
70
      * @param group the underlying DL group
71
      * @param private_key the private key (if zero, a new random key is generated)
72
      */
73
      DSA_PrivateKey(RandomNumberGenerator& rng,
74
                     const DL_Group& group,
75
                     const BigInt& private_key = 0);
76
77
      bool check_key(RandomNumberGenerator& rng, bool strong) const override;
78
79
      std::unique_ptr<PK_Ops::Signature>
80
         create_signature_op(RandomNumberGenerator& rng,
81
                             const std::string& params,
82
                             const std::string& provider) const override;
83
   };
84
85
}
86
87
#endif