aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-09-15 09:16:46 -0400
committerJack Lloyd <[email protected]>2016-09-15 09:25:49 -0400
commit04bf8dc51861bab37d6260de8b318dc71ea4bba7 (patch)
tree03cf4b8d607607444049bc2b9880abc4c1fc6a8e /src/tests
parenta7eba3629cc0d76444f5241fb4b9e8793ddb61cd (diff)
Add T::provider() to allow user to inquire about implementation used
For block ciphers, stream ciphers, hashes, MACs, and cipher modes. Cipher_Mode already had it, with a slightly different usage.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_block.cpp8
-rw-r--r--src/tests/test_hash.cpp8
-rw-r--r--src/tests/test_mac.cpp9
-rw-r--r--src/tests/test_modes.cpp1
-rw-r--r--src/tests/test_stream.cpp8
-rw-r--r--src/tests/tests.cpp7
-rw-r--r--src/tests/tests.h2
7 files changed, 31 insertions, 12 deletions
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp
index 0863cb891..acbe6702b 100644
--- a/src/tests/test_block.cpp
+++ b/src/tests/test_block.cpp
@@ -30,16 +30,18 @@ class Block_Cipher_Tests : public Text_Based_Test
return result;
}
- for(auto&& provider: providers)
+ for(auto&& provider_ask : providers)
{
- std::unique_ptr<Botan::BlockCipher> cipher(Botan::BlockCipher::create(algo, provider));
+ std::unique_ptr<Botan::BlockCipher> cipher(Botan::BlockCipher::create(algo, provider_ask));
if(!cipher)
{
- result.note_missing(algo + " from " + provider);
+ result.note_missing(algo + " from " + provider_ask);
continue;
}
+ const std::string provider(cipher->provider());
+ result.test_is_nonempty("provider", provider);
result.test_eq(provider, cipher->name(), algo);
result.test_gte(provider, cipher->parallelism(), 1);
result.test_gte(provider, cipher->block_size(), 8);
diff --git a/src/tests/test_hash.cpp b/src/tests/test_hash.cpp
index 811e95727..aca9d7ef6 100644
--- a/src/tests/test_hash.cpp
+++ b/src/tests/test_hash.cpp
@@ -36,16 +36,18 @@ class Hash_Function_Tests : public Text_Based_Test
return result;
}
- for(auto&& provider: providers)
+ for(auto&& provider_ask : providers)
{
- std::unique_ptr<Botan::HashFunction> hash(Botan::HashFunction::create(algo, provider));
+ std::unique_ptr<Botan::HashFunction> hash(Botan::HashFunction::create(algo, provider_ask));
if(!hash)
{
- result.note_missing(algo + " from " + provider);
+ result.note_missing(algo + " from " + provider_ask);
continue;
}
+ const std::string provider(hash->provider());
+ result.test_is_nonempty("provider", provider);
result.test_eq(provider, hash->name(), algo);
hash->update(input);
diff --git a/src/tests/test_mac.cpp b/src/tests/test_mac.cpp
index c7efb7f08..6183e88f7 100644
--- a/src/tests/test_mac.cpp
+++ b/src/tests/test_mac.cpp
@@ -38,16 +38,19 @@ class Message_Auth_Tests : public Text_Based_Test
return result;
}
- for(auto&& provider: providers)
+ for(auto&& provider_ask : providers)
{
- std::unique_ptr<Botan::MessageAuthenticationCode> mac(Botan::MessageAuthenticationCode::create(algo, provider));
+ std::unique_ptr<Botan::MessageAuthenticationCode> mac(Botan::MessageAuthenticationCode::create(algo, provider_ask));
if(!mac)
{
- result.note_missing(algo + " from " + provider);
+ result.note_missing(algo + " from " + provider_ask);
continue;
}
+ const std::string provider(mac->provider());
+
+ result.test_is_nonempty("provider", provider);
result.test_eq(provider, mac->name(), algo);
mac->set_key(key);
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp
index 66f537346..ada4d5b82 100644
--- a/src/tests/test_modes.cpp
+++ b/src/tests/test_modes.cpp
@@ -39,6 +39,7 @@ class Cipher_Mode_Tests : public Text_Based_Test
return result;
}
+ result.test_is_nonempty("provider", enc->provider());
result.test_eq("name", enc->name(), algo);
result.test_eq("mode not authenticated", enc->authenticated(), false);
diff --git a/src/tests/test_stream.cpp b/src/tests/test_stream.cpp
index be7b9a548..6097fd3e8 100644
--- a/src/tests/test_stream.cpp
+++ b/src/tests/test_stream.cpp
@@ -41,16 +41,18 @@ class Stream_Cipher_Tests : public Text_Based_Test
return result;
}
- for(auto&& provider: providers)
+ for(auto&& provider_ask : providers)
{
- std::unique_ptr<Botan::StreamCipher> cipher(Botan::StreamCipher::create(algo, provider));
+ std::unique_ptr<Botan::StreamCipher> cipher(Botan::StreamCipher::create(algo, provider_ask));
if(!cipher)
{
- result.note_missing(algo + " from " + provider);
+ result.note_missing(algo + " from " + provider_ask);
continue;
}
+ const std::string provider(cipher->provider());
+ result.test_is_nonempty("provider", provider);
result.test_eq(provider, cipher->name(), algo);
cipher->set_key(key);
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 2e8a1e4de..b47f2a7ab 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -175,6 +175,13 @@ bool Test::Result::test_eq(const char* producer, const std::string& what,
return test_failure(err.str());
}
+bool Test::Result::test_is_nonempty(const std::string& what_is_it, const std::string& to_examine)
+ {
+ if(to_examine.empty())
+ return test_failure(what_is_it + " was empty");
+ return test_success();
+ }
+
bool Test::Result::test_eq(const std::string& what, const std::string& produced, const std::string& expected)
{
return test_is_eq(what, produced, expected);
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 43b9e0d3a..1ceb24f48 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -171,6 +171,8 @@ class Test
bool test_eq(const std::string& what, const char* produced, const char* expected);
+ bool test_is_nonempty(const std::string& what_is_it, const std::string& to_examine);
+
bool test_eq(const std::string& what,
const std::string& produced,
const std::string& expected);