• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5111374265

29 May 2023 11:19AM UTC coverage: 92.227% (+0.5%) from 91.723%
5111374265

push

github

randombit
Next release will be 3.1.0. Update release notes

75588 of 81959 relevant lines covered (92.23%)

11886470.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/lib/pubkey/dsa/dsa.h
1
/*
2
* DSA
3
* (C) 1999-2010,2023 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/pk_keys.h>
12
#include <memory>
13

14
namespace Botan {
15

16
class BigInt;
17
class DL_Group;
18
class DL_PublicKey;
19
class DL_PrivateKey;
20

21
/**
22
* DSA Public Key
23
*/
24
class BOTAN_PUBLIC_API(2, 0) DSA_PublicKey : public virtual Public_Key {
25
   public:
26
      bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
558✔
27

28
      /**
29
      * Load a public key from the ASN.1 encoding
30
      * @param alg_id the X.509 algorithm identifier
31
      * @param key_bits DER encoded public key bits
32
      */
33
      DSA_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
34

35
      /**
36
      * Load a public key from the integer value
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::string algo_name() const override { return "DSA"; }
1,190✔
43

44
      size_t message_parts() const override { return 2; }
518✔
45

46
      size_t message_part_size() const override;
47

48
      AlgorithmIdentifier algorithm_identifier() const override;
49
      std::vector<uint8_t> public_key_bits() const override;
50

51
      bool check_key(RandomNumberGenerator& rng, bool strong) const override;
52

53
      size_t estimated_strength() const override;
54
      size_t key_length() const override;
55

56
      const BigInt& get_int_field(std::string_view field) const override;
57

58
      std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
59
                                                                   std::string_view provider) const override;
60

61
      std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
62
                                                                        std::string_view provider) const override;
63

64
   private:
65
      friend class DSA_PrivateKey;
66

67
      DSA_PublicKey() = default;
551✔
68

69
      DSA_PublicKey(std::shared_ptr<const DL_PublicKey> key) : m_public_key(key) {}
305✔
70

71
      std::shared_ptr<const DL_PublicKey> m_public_key;
72
};
73

74
/**
75
* DSA Private Key
76
*/
77

78
BOTAN_DIAGNOSTIC_PUSH
79
BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
80

81
class BOTAN_PUBLIC_API(2, 0) DSA_PrivateKey final : public DSA_PublicKey,
×
82
                                                    public virtual Private_Key {
83
   public:
84
      /**
85
      * Load a private key from the ASN.1 encoding
86
      * @param alg_id the X.509 algorithm identifier
87
      * @param key_bits DER encoded key bits in ANSI X9.57 format
88
      */
89
      DSA_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
90

91
      /**
92
      * Create a new private key.
93
      * @param group the underlying DL group
94
      * @param rng the RNG to use
95
      */
96
      DSA_PrivateKey(RandomNumberGenerator& rng, const DL_Group& group);
97

98
      /**
99
      * Load a private key
100
      * @param group the underlying DL group
101
      * @param private_key the private key
102
      */
103
      DSA_PrivateKey(const DL_Group& group, const BigInt& private_key);
104

105
      std::unique_ptr<Public_Key> public_key() const override;
106

107
      bool check_key(RandomNumberGenerator& rng, bool strong) const override;
108

109
      secure_vector<uint8_t> private_key_bits() const override;
110

111
      const BigInt& get_int_field(std::string_view field) const override;
112
      secure_vector<uint8_t> raw_private_key_bits() const override;
113

114
      std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
115
                                                             std::string_view params,
116
                                                             std::string_view provider) const override;
117

118
   private:
119
      std::shared_ptr<const DL_PrivateKey> m_private_key;
120
};
121

122
BOTAN_DIAGNOSTIC_POP
123

124
}  // namespace Botan
125

126
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc