Botan
1.10.9
|
#include <dl_group.h>
Public Types | |
enum | Format { ANSI_X9_42, ANSI_X9_57, PKCS_3, DSA_PARAMETERS = ANSI_X9_57, DH_PARAMETERS = ANSI_X9_42, X942_DH_PARAMETERS = ANSI_X9_42, PKCS3_DH_PARAMETERS = PKCS_3 } |
enum | PrimeType { Strong, Prime_Subgroup, DSA_Kosherizer } |
Public Member Functions | |
void | BER_decode (DataSource &src, Format format) |
SecureVector< byte > | DER_encode (Format format) const |
DL_Group () | |
DL_Group (const std::string &name) | |
DL_Group (RandomNumberGenerator &rng, PrimeType type, size_t pbits, size_t qbits=0) | |
DL_Group (RandomNumberGenerator &rng, const MemoryRegion< byte > &seed, size_t pbits=1024, size_t qbits=0) | |
DL_Group (const BigInt &p, const BigInt &g) | |
DL_Group (const BigInt &p, const BigInt &q, const BigInt &g) | |
const BigInt & | get_g () const |
const BigInt & | get_p () const |
const BigInt & | get_q () const |
void | PEM_decode (DataSource &src) |
std::string | PEM_encode (Format format) const |
bool | verify_group (RandomNumberGenerator &rng, bool strong) const |
This class represents discrete logarithm groups. It holds a prime p, a prime q = (p-1)/2 and g = x^((p-1)/q) mod p.
Definition at line 20 of file dl_group.h.
The DL group encoding format variants.
Enumerator | |
---|---|
ANSI_X9_42 | |
ANSI_X9_57 | |
PKCS_3 | |
DSA_PARAMETERS | |
DH_PARAMETERS | |
X942_DH_PARAMETERS | |
PKCS3_DH_PARAMETERS |
Definition at line 44 of file dl_group.h.
Determine the prime creation for DL groups.
Enumerator | |
---|---|
Strong | |
Prime_Subgroup | |
DSA_Kosherizer |
Definition at line 58 of file dl_group.h.
Botan::DL_Group::DL_Group | ( | ) |
Construct a DL group with uninitialized internal value. Use this constructor is you wish to set the groups values from a DER or PEM encoded group.
Definition at line 24 of file dl_group.cpp.
Botan::DL_Group::DL_Group | ( | const std::string & | name | ) |
Construct a DL group that is registered in the configuration.
name | the name that is configured in the global configuration for the desired group. If no configuration file is specified, the default values from the file policy.cpp will be used. For instance, use "modp/ietf/768" as name. |
Definition at line 32 of file dl_group.cpp.
References Botan::Library_State::get(), Botan::Global_State_Management::global_state(), and PEM_decode().
Botan::DL_Group::DL_Group | ( | RandomNumberGenerator & | rng, |
PrimeType | type, | ||
size_t | pbits, | ||
size_t | qbits = 0 |
||
) |
Create a new group randomly.
rng | the random number generator to use |
type | specifies how the creation of primes p and q shall be performed. If type=Strong, then p will be determined as a safe prime, and q will be chosen as (p-1)/2. If type=Prime_Subgroup and qbits = 0, then the size of q will be determined according to the estimated difficulty of the DL problem. If type=DSA_Kosherizer, DSA primes will be created. |
pbits | the number of bits of p |
qbits | the number of bits of q. Leave it as 0 to have the value determined according to pbits. |
Definition at line 46 of file dl_group.cpp.
References Botan::BigInt::bits(), Botan::check_prime(), Botan::dl_work_factor(), DSA_Kosherizer, Botan::generate_dsa_primes(), Botan::Global_State_Management::global_state(), Prime_Subgroup, Botan::random_prime(), Botan::random_safe_prime(), Botan::BigInt::randomize(), Strong, and Botan::to_string().
Botan::DL_Group::DL_Group | ( | RandomNumberGenerator & | rng, |
const MemoryRegion< byte > & | seed, | ||
size_t | pbits = 1024 , |
||
size_t | qbits = 0 |
||
) |
Create a DSA group with a given seed.
rng | the random number generator to use |
seed | the seed to use to create the random primes |
pbits | the desired bit size of the prime p |
qbits | the desired bit size of the prime q. |
Definition at line 92 of file dl_group.cpp.
References Botan::generate_dsa_primes(), and Botan::Global_State_Management::global_state().
Create a DL group. The prime q will be determined according to p.
p | the prime p |
g | the base g |
Definition at line 109 of file dl_group.cpp.
Create a DL group.
p | the prime p |
q | the prime q |
g | the base g |
Definition at line 117 of file dl_group.cpp.
void Botan::DL_Group::BER_decode | ( | DataSource & | src, |
Format | format | ||
) |
Decode a DER/BER encoded group into this instance.
src | a DataSource providing the encoded group |
format | the format of the encoded group |
Definition at line 264 of file dl_group.cpp.
References ANSI_X9_42, ANSI_X9_57, Botan::BER_Decoder::decode(), Botan::BER_Decoder::discard_remaining(), PKCS_3, Botan::SEQUENCE, Botan::BER_Decoder::start_cons(), Botan::to_string(), and Botan::BER_Decoder::verify_end().
Referenced by Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(), Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey(), and PEM_decode().
SecureVector< byte > Botan::DL_Group::DER_encode | ( | Format | format | ) | const |
Encode this group into a string using DER encoding.
format | the encoding format |
Definition at line 205 of file dl_group.cpp.
References ANSI_X9_42, ANSI_X9_57, Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), PKCS_3, Botan::SEQUENCE, Botan::DER_Encoder::start_cons(), and Botan::to_string().
Referenced by Botan::DL_Scheme_PublicKey::algorithm_identifier(), and PEM_encode().
const BigInt & Botan::DL_Group::get_g | ( | ) | const |
Get the base g.
Definition at line 185 of file dl_group.cpp.
Referenced by Botan::generate_srp6_verifier(), Botan::Server_Key_Exchange::Server_Key_Exchange(), Botan::srp6_client_agree(), and Botan::SRP6_Server_Session::step1().
const BigInt & Botan::DL_Group::get_p | ( | ) | const |
Get the prime p.
Definition at line 176 of file dl_group.cpp.
Referenced by Botan::generate_srp6_verifier(), Botan::Server_Key_Exchange::Server_Key_Exchange(), Botan::srp6_client_agree(), and Botan::SRP6_Server_Session::step1().
const BigInt & Botan::DL_Group::get_q | ( | ) | const |
void Botan::DL_Group::PEM_decode | ( | DataSource & | src | ) |
Decode a PEM encoded group into this instance.
src | a DataSource providing the encoded group |
Definition at line 300 of file dl_group.cpp.
References ANSI_X9_42, ANSI_X9_57, BER_decode(), Botan::PEM_Code::decode(), and PKCS_3.
Referenced by DL_Group().
std::string Botan::DL_Group::PEM_encode | ( | Format | format | ) | const |
Encode this group into a string using PEM encoding.
format | the encoding format |
Definition at line 248 of file dl_group.cpp.
References ANSI_X9_42, ANSI_X9_57, DER_encode(), Botan::PEM_Code::encode(), PKCS_3, and Botan::to_string().
bool Botan::DL_Group::verify_group | ( | RandomNumberGenerator & | rng, |
bool | strong | ||
) | const |
Perform validity checks on the group.
rng | the rng to use |
strong | whether to perform stronger by lengthier tests |
Definition at line 153 of file dl_group.cpp.
References Botan::check_prime().
Referenced by Botan::DL_Scheme_PublicKey::check_key(), and Botan::DL_Scheme_PrivateKey::check_key().