aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_srp6.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-05-13 03:00:10 +0000
committerlloyd <[email protected]>2015-05-13 03:00:10 +0000
commitcb2b4498d2a0c8a15e2a66aa3c5f0d7ffa4cf058 (patch)
treec002be7e34bd0c6973b9d49f92ee7973c5152e59 /src/tests/test_srp6.cpp
parenta1524df3c1b7bee3bfd7cab3309f763b3e9599a7 (diff)
Add tests for compression and SRP.
Fix zlib decompression which was not ignoring Z_BUF_ERROR which is harmless in this context as process is already checking avail_in and avail_out after run returns. Bump version to 1.11.17
Diffstat (limited to 'src/tests/test_srp6.cpp')
-rw-r--r--src/tests/test_srp6.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tests/test_srp6.cpp b/src/tests/test_srp6.cpp
new file mode 100644
index 000000000..010576110
--- /dev/null
+++ b/src/tests/test_srp6.cpp
@@ -0,0 +1,39 @@
+#include "tests.h"
+#include <botan/srp6.h>
+#include <iostream>
+
+size_t test_srp6()
+ {
+ using namespace Botan;
+
+ size_t fails = 0;
+
+ 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";
+ auto& rng = test_rng();
+
+ const auto salt = unlock(rng.random_vec(16));
+
+ const BigInt verifier = generate_srp6_verifier(username, password, salt, group_id, hash_id);
+
+ SRP6_Server_Session server;
+
+ const BigInt B = server.step1(verifier, group_id, hash_id, rng);
+
+ auto client = srp6_client_agree(username, password, group_id, hash_id, salt, B, rng);
+
+ const SymmetricKey server_K = server.step2(client.first);
+
+ if(client.second != server_K)
+ {
+ std::cout << "SRP6 computed different keys\n";
+ ++fails;
+ }
+
+ test_report("SRP6", 1, fails);
+
+ return fails;
+
+ }