Botan 1.10.17
dsa.h
Go to the documentation of this file.
1/*
2* DSA
3* (C) 1999-2010 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_DSA_H__
9#define BOTAN_DSA_H__
10
11#include <botan/dl_algo.h>
12#include <botan/pk_ops.h>
13#include <botan/reducer.h>
14#include <botan/pow_mod.h>
15
16namespace Botan {
17
18/**
19* DSA Public Key
20*/
21class BOTAN_DLL DSA_PublicKey : public virtual DL_Scheme_PublicKey
22 {
23 public:
24 std::string algo_name() const { return "DSA"; }
25
27 size_t message_parts() const { return 2; }
28 size_t message_part_size() const { return group_q().bytes(); }
29 size_t max_input_bits() const { return group_q().bits(); }
30
32 const MemoryRegion<byte>& key_bits) :
33 DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
34 {
35 }
36
37 DSA_PublicKey(const DL_Group& group, const BigInt& y);
38 protected:
40 };
41
42/**
43* DSA Private Key
44*/
45class BOTAN_DLL DSA_PrivateKey : public DSA_PublicKey,
46 public virtual DL_Scheme_PrivateKey
47 {
48 public:
50 const MemoryRegion<byte>& key_bits,
52
54 const DL_Group& group,
55 const BigInt& private_key = 0);
56
57 bool check_key(RandomNumberGenerator& rng, bool strong) const;
58 };
59
60/**
61* Object that can create a DSA signature
62*/
64 {
65 public:
67
68 size_t message_parts() const { return 2; }
69 size_t message_part_size() const { return q.bytes(); }
70 size_t max_input_bits() const { return q.bits(); }
71
72 SecureVector<byte> sign(const byte msg[], size_t msg_len,
74 private:
75 const BigInt& q;
76 const BigInt& x;
77 Fixed_Base_Power_Mod powermod_g_p;
78 Modular_Reducer mod_q;
79 };
80
81/**
82* Object that can verify a DSA signature
83*/
85 {
86 public:
88
89 size_t message_parts() const { return 2; }
90 size_t message_part_size() const { return q.bytes(); }
91 size_t max_input_bits() const { return q.bits(); }
92
93 bool with_recovery() const { return false; }
94
95 bool verify(const byte msg[], size_t msg_len,
96 const byte sig[], size_t sig_len);
97 private:
98 const BigInt& q;
99 const BigInt& y;
100
101 Fixed_Base_Power_Mod powermod_g_p, powermod_y_p;
102 Modular_Reducer mod_p, mod_q;
103 };
104
105}
106
107#endif
DL_Scheme_PrivateKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits, DL_Group::Format group_format)
Definition dl_algo.cpp:41
DL_Scheme_PublicKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits, DL_Group::Format group_format)
Definition dl_algo.cpp:26
const BigInt & group_q() const
Definition dl_algo.h:50
DSA_PrivateKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits, RandomNumberGenerator &rng)
Definition dsa.cpp:44
bool check_key(RandomNumberGenerator &rng, bool strong) const
Definition dsa.cpp:57
size_t message_part_size() const
Definition dsa.h:28
size_t message_parts() const
Definition dsa.h:27
DL_Group::Format group_format() const
Definition dsa.h:26
size_t max_input_bits() const
Definition dsa.h:29
DSA_PublicKey(const AlgorithmIdentifier &alg_id, const MemoryRegion< byte > &key_bits)
Definition dsa.h:31
std::string algo_name() const
Definition dsa.h:24
size_t message_part_size() const
Definition dsa.h:69
size_t message_parts() const
Definition dsa.h:68
DSA_Signature_Operation(const DSA_PrivateKey &dsa)
Definition dsa.cpp:68
size_t max_input_bits() const
Definition dsa.h:70
DSA_Verification_Operation(const DSA_PublicKey &dsa)
Definition dsa.cpp:102
size_t max_input_bits() const
Definition dsa.h:91
size_t message_part_size() const
Definition dsa.h:90
size_t message_parts() const
Definition dsa.h:89