1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*************************************************
* Discrete Logarithm Group Header File *
* (C) 1999-2008 The Botan Project *
*************************************************/
#ifndef BOTAN_DL_PARAM_H__
#define BOTAN_DL_PARAM_H__
#include <botan/bigint.h>
#include <botan/data_src.h>
namespace Botan {
/*************************************************
* Discrete Logarithm Group *
*************************************************/
class DL_Group
{
public:
const BigInt& get_p() const;
const BigInt& get_q() const;
const BigInt& get_g() const;
enum Format { ANSI_X9_42, ANSI_X9_57, PKCS_3 };
enum PrimeType { Strong, Prime_Subgroup, DSA_Kosherizer };
bool verify_group(bool) const;
std::string PEM_encode(Format) const;
SecureVector<byte> DER_encode(Format) const;
void BER_decode(DataSource&, Format);
void PEM_decode(DataSource&);
DL_Group();
DL_Group(const std::string&);
DL_Group(PrimeType, u32bit, u32bit = 0);
DL_Group(const MemoryRegion<byte>&, u32bit = 1024, u32bit = 0);
DL_Group(const BigInt&, const BigInt&);
DL_Group(const BigInt&, const BigInt&, const BigInt&);
private:
static BigInt make_dsa_generator(const BigInt&, const BigInt&);
static SecureVector<byte> generate_dsa_primes(BigInt&, BigInt&,
u32bit, u32bit);
static bool generate_dsa_primes(BigInt&, BigInt&, u32bit, u32bit,
const MemoryRegion<byte>&);
void init_check() const;
void initialize(const BigInt&, const BigInt&, const BigInt&);
bool initialized;
BigInt p, q, g;
};
}
#endif
|