Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

dsa.h
Go to the documentation of this file.
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_DLL DSA_PublicKey : public virtual DL_Scheme_PublicKey
19 {
20 public:
21 std::string algo_name() const override { return "DSA"; }
22
23 DL_Group::Format group_format() const override { return DL_Group::ANSI_X9_57; }
24 size_t message_parts() const override { return 2; }
25 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 {
36 }
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 DSA_PublicKey() = default;
50 };
51
52 /**
53 * DSA Private Key
54 */
55 class BOTAN_DLL DSA_PrivateKey : 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
Botan::DSA_PublicKey::message_part_size
size_t message_part_size() const override
Definition: dsa.h:25
Botan::DL_Scheme_PrivateKey
Definition: dl_algo.h:95
Botan::BigInt
Definition: bigint.h:23
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::DL_Group::ANSI_X9_57
Definition: dl_group.h:47
Botan::DL_Scheme_PublicKey
Definition: dl_algo.h:19
Botan::DSA_PublicKey::group_format
DL_Group::Format group_format() const override
Definition: dsa.h:23
Botan::DL_Group
Definition: dl_group.h:20
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::DSA_PublicKey::message_parts
size_t message_parts() const override
Definition: dsa.h:24
Botan::DL_Group::Format
Format
Definition: dl_group.h:45
Botan::DSA_PublicKey::algo_name
std::string algo_name() const override
Definition: dsa.h:21
Botan::DSA_PrivateKey
Definition: dsa.h:55
Botan
Definition: alg_id.cpp:13
Botan::DSA_PublicKey
Definition: dsa.h:18
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::DSA_PublicKey::DSA_PublicKey
DSA_PublicKey(const AlgorithmIdentifier &alg_id, const std::vector< uint8_t > &key_bits)
Definition: dsa.h:32