Coverage Report

Created: 2022-11-24 06:56

/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
185
      std::string algo_name() const override { return "DSA"; }
22
23
0
      DL_Group_Format group_format() const override { return DL_Group_Format::ANSI_X9_57; }
24
358
      size_t message_parts() const override { return 2; }
25
178
      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
35
      /**
36
      * Create a public key.
37
      * @param group the underlying DL group
38
      * @param y the public value y = g^x mod p
39
      */
40
      DSA_PublicKey(const DL_Group& group, const BigInt& y);
41
42
      std::unique_ptr<PK_Ops::Verification>
43
         create_verification_op(const std::string& params,
44
                                const std::string& provider) const override;
45
   protected:
46
106
      DSA_PublicKey() = default;
47
   };
48
49
/**
50
* DSA Private Key
51
*/
52
class BOTAN_PUBLIC_API(2,0) DSA_PrivateKey final : public DSA_PublicKey,
53
                                 public virtual DL_Scheme_PrivateKey
54
   {
55
   public:
56
      /**
57
      * Load a private key.
58
      * @param alg_id the X.509 algorithm identifier
59
      * @param key_bits DER encoded key bits in ANSI X9.57 format
60
      */
61
      DSA_PrivateKey(const AlgorithmIdentifier& alg_id,
62
                     const secure_vector<uint8_t>& key_bits);
63
64
      /**
65
      * Create a private key.
66
      * @param rng the RNG to use
67
      * @param group the underlying DL group
68
      * @param private_key the private key (if zero, a new random key is generated)
69
      */
70
      DSA_PrivateKey(RandomNumberGenerator& rng,
71
                     const DL_Group& group,
72
                     const BigInt& private_key = BigInt::zero());
73
74
      std::unique_ptr<Public_Key> public_key() const override;
75
76
      bool check_key(RandomNumberGenerator& rng, bool strong) const override;
77
78
      std::unique_ptr<PK_Ops::Signature>
79
         create_signature_op(RandomNumberGenerator& rng,
80
                             const std::string& params,
81
                             const std::string& provider) const override;
82
   };
83
84
}
85
86
#endif