blob: 61f535dd7cfb4b3acdba96bc1ff2209d358e5c1f (
plain)
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
|
/*
* (C) 2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "apps.h"
#if defined(BOTAN_HAS_NUMBERTHEORY)
#include <botan/numthry.h>
#include <algorithm>
#include <iostream>
namespace {
int prime(int argc, char* argv[])
{
if(argc < 2)
{
std::cout << "Usage: " << argv[0] << " bits count" << std::endl;
return 1;
}
AutoSeeded_RNG rng;
const size_t bits = to_u32bit(argv[1]);
const size_t cnt = argv[2] != nullptr ? to_u32bit(argv[2]) : 1;
for(size_t i = 0; i != cnt; ++i)
{
const BigInt p = random_prime(rng, bits);
std::cout << p << "\n";
if(p.bits() != bits)
{
std::cout << "Result not exactly requested bit size, got " << p.bits() << "\n";
}
}
return 0;
}
}
REGISTER_APP(prime);
#endif
|