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
|
/*
* (C) 2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "tests.h"
#if defined(BOTAN_HAS_SRP6)
#include <botan/srp6.h>
#endif
namespace Botan_Tests {
namespace {
#if defined(BOTAN_HAS_SRP6)
class SRP6_Unit_Tests : public Test
{
public:
std::vector<Test::Result> run() override
{
std::vector<Test::Result> results;
Test::Result result("SRP6");
const std::string username = "user";
const std::string password = "Awellchosen1_to_be_sure_";
const std::string group_id = "modp/srp/1024";
const std::string hash_id = "SHA-256";
const std::vector<uint8_t> salt = unlock(Test::rng().random_vec(16));
const Botan::BigInt verifier = Botan::generate_srp6_verifier(username, password, salt, group_id, hash_id);
Botan::SRP6_Server_Session server;
const Botan::BigInt B = server.step1(verifier, group_id, hash_id, Test::rng());
auto client = srp6_client_agree(username, password, group_id, hash_id, salt, B, Test::rng());
const Botan::SymmetricKey server_K = server.step2(client.first);
result.test_eq("computed same keys", client.second.bits_of(), server_K.bits_of());
results.push_back(result);
return results;
}
};
BOTAN_REGISTER_TEST("srp6", SRP6_Unit_Tests);
#endif
}
}
|