Coverage Report

Created: 2023-06-07 07:01

/src/botan/build/include/botan/gost_3410.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* GOST 34.10-2001
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_GOST_3410_KEY_H_
11
#define BOTAN_GOST_3410_KEY_H_
12
13
#include <botan/ecc_key.h>
14
15
namespace Botan {
16
17
/**
18
* GOST-34.10 Public Key
19
*/
20
class BOTAN_PUBLIC_API(2, 0) GOST_3410_PublicKey : public virtual EC_PublicKey {
21
   public:
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
      GOST_3410_PublicKey(const EC_Group& dom_par, const EC_Point& public_point) :
28
0
            EC_PublicKey(dom_par, public_point) {}
Unexecuted instantiation: Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(Botan::EC_Group const&, Botan::EC_Point const&)
Unexecuted instantiation: Botan::GOST_3410_PublicKey::GOST_3410_PublicKey(Botan::EC_Group const&, Botan::EC_Point const&)
29
30
      /**
31
      * Load a public key.
32
      * @param alg_id the X.509 algorithm identifier
33
      * @param key_bits DER encoded public key bits
34
      */
35
      GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
36
37
      /**
38
      * Get this keys algorithm name.
39
      * @result this keys algorithm name
40
      */
41
      std::string algo_name() const override;
42
43
      AlgorithmIdentifier algorithm_identifier() const override;
44
45
      std::vector<uint8_t> public_key_bits() const override;
46
47
74
      size_t message_parts() const override { return 2; }
48
49
74
      size_t message_part_size() const override { return domain().get_order().bytes(); }
50
51
74
      Signature_Format default_x509_signature_format() const override { return Signature_Format::Standard; }
52
53
0
      bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
54
55
      std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
56
                                                                   std::string_view provider) const override;
57
58
      std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
59
                                                                        std::string_view provider) const override;
60
61
   protected:
62
1
      GOST_3410_PublicKey() = default;
63
};
64
65
/**
66
* GOST-34.10 Private Key
67
*/
68
69
BOTAN_DIAGNOSTIC_PUSH
70
BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
71
72
class BOTAN_PUBLIC_API(2, 0) GOST_3410_PrivateKey final : public GOST_3410_PublicKey,
73
                                                          public EC_PrivateKey {
74
   public:
75
      /**
76
      * Load a private key.
77
      * @param alg_id the X.509 algorithm identifier
78
      * @param key_bits ECPrivateKey bits
79
      */
80
      GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits) :
81
1
            EC_PrivateKey(alg_id, key_bits) {}
Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::span<unsigned char const, 18446744073709551615ul>)
Line
Count
Source
81
1
            EC_PrivateKey(alg_id, key_bits) {}
Unexecuted instantiation: Botan::GOST_3410_PrivateKey::GOST_3410_PrivateKey(Botan::AlgorithmIdentifier const&, std::__1::span<unsigned char const, 18446744073709551615ul>)
82
83
      /**
84
      * Generate a new private key
85
      * @param rng a random number generator
86
      * @param domain parameters to used for this key
87
      * @param x the private key; if zero, a new random key is generated
88
      */
89
      GOST_3410_PrivateKey(RandomNumberGenerator& rng, const EC_Group& domain, const BigInt& x = BigInt::zero());
90
91
      std::unique_ptr<Public_Key> public_key() const override;
92
93
0
      AlgorithmIdentifier pkcs8_algorithm_identifier() const override { return EC_PublicKey::algorithm_identifier(); }
94
95
      std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
96
                                                             std::string_view params,
97
                                                             std::string_view provider) const override;
98
};
99
100
BOTAN_DIAGNOSTIC_POP
101
102
}  // namespace Botan
103
104
#endif