From 757bf5016ad880961ee3a42f99b7bf2e99ec692a Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 6 Apr 2012 15:54:22 +0000 Subject: Use just 256 bits of secret exponent (recomended value in RFC 5054). Much faster, especially when using 8192 bit groups as OpenSSL does by default. Use BOTAN_DLL symbol visibility macros. --- src/constructs/srp6/srp6.cpp | 8 ++++---- src/constructs/srp6/srp6.h | 29 +++++++++++++++-------------- src/constructs/srp6/srp6_files.cpp | 2 +- src/constructs/srp6/srp6_files.h | 4 ++-- 4 files changed, 22 insertions(+), 21 deletions(-) (limited to 'src/constructs') diff --git a/src/constructs/srp6/srp6.cpp b/src/constructs/srp6/srp6.cpp index cb9bf27bc..0dfe2104b 100644 --- a/src/constructs/srp6/srp6.cpp +++ b/src/constructs/srp6/srp6.cpp @@ -1,6 +1,6 @@ /* -* SRP-6a -* (C) 2011 Jack Lloyd +* SRP-6a (RFC 5054 compatatible) +* (C) 2011,2012 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -112,7 +112,7 @@ srp6_client_agree(const std::string& identifier, BigInt k = hash_seq(hash_id, p_bytes, p, g); - BigInt a(rng, p.bits() - 1); + BigInt a(rng, 256); BigInt A = power_mod(g, a, p); @@ -152,7 +152,7 @@ BigInt SRP6_Server_Session::step1(const BigInt& v, BigInt k = hash_seq(hash_id, p_bytes, p, g); - BigInt b(rng, p.bits() - 1); + BigInt b(rng, 256); B = (v*k + power_mod(g, b, p)) % p; diff --git a/src/constructs/srp6/srp6.h b/src/constructs/srp6/srp6.h index bf5cb4863..4fd127c70 100644 --- a/src/constructs/srp6/srp6.h +++ b/src/constructs/srp6/srp6.h @@ -1,6 +1,6 @@ /* * SRP-6a (RFC 5054 compatatible) -* (C) 2011 Jack Lloyd +* (C) 2011,2012 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -28,13 +28,14 @@ namespace Botan { * * @return (A,K) the client public key and the shared secret key */ -std::pair srp6_client_agree(const std::string& username, - const std::string& password, - const std::string& group_id, - const std::string& hash_id, - const MemoryRegion& salt, - const BigInt& B, - RandomNumberGenerator& rng); +std::pair +BOTAN_DLL srp6_client_agree(const std::string& username, + const std::string& password, + const std::string& group_id, + const std::string& hash_id, + const MemoryRegion& salt, + const BigInt& B, + RandomNumberGenerator& rng); /** * Generate a new SRP-6 verifier @@ -42,17 +43,17 @@ std::pair srp6_client_agree(const std::string& username, * @param password the secret used to authenticate user * @param salt a randomly chosen value, at least 128 bits long */ -BigInt generate_srp6_verifier(const std::string& identifier, - const std::string& password, - const MemoryRegion& salt, - const std::string& group_id, - const std::string& hash_id); +BigInt BOTAN_DLL generate_srp6_verifier(const std::string& identifier, + const std::string& password, + const MemoryRegion& salt, + const std::string& group_id, + const std::string& hash_id); /** * Return the group id for this SRP param set, or else thrown an * exception */ -std::string srp6_group_identifier(const BigInt& N, const BigInt& g); +std::string BOTAN_DLL srp6_group_identifier(const BigInt& N, const BigInt& g); /** * Represents a SRP-6a server session diff --git a/src/constructs/srp6/srp6_files.cpp b/src/constructs/srp6/srp6_files.cpp index 2d685614f..bc321745f 100644 --- a/src/constructs/srp6/srp6_files.cpp +++ b/src/constructs/srp6/srp6_files.cpp @@ -51,7 +51,7 @@ SRP6_Authenticator_File::SRP6_Authenticator_File(const std::string& filename) bool SRP6_Authenticator_File::lookup_user(const std::string& username, BigInt& v, - MemoryVector& salt, + MemoryRegion& salt, std::string& group_id) const { std::map::const_iterator i = entries.find(username); diff --git a/src/constructs/srp6/srp6_files.h b/src/constructs/srp6/srp6_files.h index 1def0fd51..4e3293423 100644 --- a/src/constructs/srp6/srp6_files.h +++ b/src/constructs/srp6/srp6_files.h @@ -17,7 +17,7 @@ namespace Botan { /** * A GnuTLS compatible SRP6 authenticator file */ -class SRP6_Authenticator_File +class BOTAN_DLL SRP6_Authenticator_File { public: /** @@ -28,7 +28,7 @@ class SRP6_Authenticator_File bool lookup_user(const std::string& username, BigInt& v, - MemoryVector& salt, + MemoryRegion& salt, std::string& group_id) const; private: struct SRP6_Data -- cgit v1.2.3