8 #include <botan/numthry.h>     9 #include <botan/algo_factory.h>    10 #include <botan/hash.h>    11 #include <botan/parsing.h>    22 bool fips186_3_valid_size(
size_t pbits, 
size_t qbits)
    25       return (pbits == 512 || pbits == 768 || pbits == 1024);
    28       return (pbits == 2048);
    31       return (pbits == 2048 || pbits == 3072);
    44                          size_t pbits, 
size_t qbits,
    47    if(!fips186_3_valid_size(pbits, qbits))
    49          "FIPS 186-3 does not allow DSA domain parameters of " +
    52    if(seed_c.
size() * 8 < qbits)
    54          "Generating a DSA parameter set with a " + 
to_string(qbits) +
    55          "long q requires a seed at least as many bits long");
    57    std::auto_ptr<HashFunction> hash(
    60    const size_t HASH_SIZE = hash->output_length();
    71             for(
size_t j = seed.size(); j > 0; --j)
    89    const size_t n = (pbits-1) / (HASH_SIZE * 8),
    90                 b = (pbits-1) % (HASH_SIZE * 8);
    95    for(
size_t j = 0; j != 4096; ++j)
    97       for(
size_t k = 0; k <= n; ++k)
   101          hash->final(&V[HASH_SIZE * (n-k)]);
   105                       V.
size() - (HASH_SIZE - 1 - b/8));
   108       p = X - (X % (2*q) - 1);
   122                                        size_t pbits, 
size_t qbits)
 
SecureVector< byte > random_vec(size_t bytes)
void binary_decode(const byte buf[], size_t length)
std::invalid_argument Invalid_Argument
HashFunction * make_hash_function(const std::string &algo_spec, const std::string &provider="")
std::string to_string(u64bit n, size_t min_len)
bool generate_dsa_primes(RandomNumberGenerator &rng, Algorithm_Factory &af, BigInt &p, BigInt &q, size_t pbits, size_t qbits, const MemoryRegion< byte > &seed_c)
bool check_prime(const BigInt &n, RandomNumberGenerator &rng)