Botan 2.19.2
Crypto and TLS for C&
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
13namespace Botan {
14
15/**
16* DSA Public Key
17*/
19 {
20 public:
21 std::string algo_name() const override { return "DSA"; }
22
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 */
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*/
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 */
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 */
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
DL_Group::Format group_format() const override
Definition: dsa.h:23
size_t message_parts() const override
Definition: dsa.h:24
DSA_PublicKey(const AlgorithmIdentifier &alg_id, const std::vector< uint8_t > &key_bits)
Definition: dsa.h:32
size_t message_part_size() const override
Definition: dsa.h:25
std::string algo_name() const override
Definition: dsa.h:21
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65