aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-07-06 13:08:46 +0200
committerSimon Warta <[email protected]>2015-07-08 15:53:03 +0200
commit619ac24bba4441762576d47a36099788afadb685 (patch)
tree7ac45fce6c4101ceb07053362f0248a4032699b6 /src
parent54c6336c7105e59506a4f6f0214693834c216d7e (diff)
Fix module combi: adler32,mce
Diffstat (limited to 'src')
-rw-r--r--src/lib/pubkey/mceies/info.txt2
-rw-r--r--src/lib/pubkey/mceies/mceies.cpp11
-rw-r--r--src/tests/test_mceliece.cpp30
3 files changed, 26 insertions, 17 deletions
diff --git a/src/lib/pubkey/mceies/info.txt b/src/lib/pubkey/mceies/info.txt
index b4a25329e..547e4a47a 100644
--- a/src/lib/pubkey/mceies/info.txt
+++ b/src/lib/pubkey/mceies/info.txt
@@ -1,5 +1,7 @@
+define MCEIES 20150706
<requires>
+aes
mce
ocb
</requires>
diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp
index 9e9ae1cb8..58dde2e27 100644
--- a/src/lib/pubkey/mceies/mceies.cpp
+++ b/src/lib/pubkey/mceies/mceies.cpp
@@ -45,9 +45,10 @@ mceies_encrypt(const McEliece_PublicKey& pubkey,
BOTAN_ASSERT(mce_ciphertext.size() == mce_code_bytes, "Unexpected size");
- std::unique_ptr<AEAD_Mode> aead(get_aead("AES-256/OCB", ENCRYPTION));
+ const std::string algo = "AES-256/OCB";
+ std::unique_ptr<AEAD_Mode> aead(get_aead(algo, ENCRYPTION));
if(!aead)
- throw std::runtime_error("mce_encrypt unable to create AEAD instance");
+ throw std::runtime_error("mce_encrypt unable to create AEAD instance '" + algo + "'");
const size_t nonce_len = aead->default_nonce_length();
@@ -77,9 +78,11 @@ mceies_decrypt(const McEliece_PrivateKey& privkey,
const size_t mce_code_bytes = (privkey.get_code_length() + 7) / 8;
- std::unique_ptr<AEAD_Mode> aead(get_aead("AES-256/OCB", DECRYPTION));
+
+ const std::string algo = "AES-256/OCB";
+ std::unique_ptr<AEAD_Mode> aead(get_aead(algo, DECRYPTION));
if(!aead)
- throw std::runtime_error("Unable to create AEAD instance");
+ throw std::runtime_error("Unable to create AEAD instance '" + algo + "'");
const size_t nonce_len = aead->default_nonce_length();
diff --git a/src/tests/test_mceliece.cpp b/src/tests/test_mceliece.cpp
index c0ff1d435..616f64be9 100644
--- a/src/tests/test_mceliece.cpp
+++ b/src/tests/test_mceliece.cpp
@@ -11,20 +11,18 @@
#if defined(BOTAN_HAS_MCELIECE)
#include <botan/pubkey.h>
-#include <botan/ecdsa.h>
-#include <botan/rsa.h>
-#include <botan/x509cert.h>
#include <botan/oids.h>
#include <botan/mceliece.h>
#include <botan/mce_kem.h>
-#include <botan/mceies.h>
#include <botan/loadstor.h>
-
#include <botan/hex.h>
-
#include <iostream>
#include <memory>
+#if defined(BOTAN_HAS_MCEIES)
+#include <botan/mceies.h>
+#endif
+
using namespace Botan;
#define CHECK_MESSAGE(expr, print) do {if(!(expr)) {std::cout << print << std::endl; return 1;} }while(0)
@@ -161,11 +159,11 @@ size_t test_mceliece_raw(const McEliece_PrivateKey& sk,
return err_cnt;
}
+#if defined(BOTAN_HAS_MCEIES)
size_t test_mceies(const McEliece_PrivateKey& sk,
const McEliece_PublicKey& pk,
RandomNumberGenerator& rng)
{
-
size_t fails = 0;
for(size_t i = 0; i != 5; ++i)
@@ -209,6 +207,7 @@ size_t test_mceies(const McEliece_PrivateKey& sk,
return fails;
}
+#endif // BOTAN_HAS_MCEIES
}
@@ -216,7 +215,7 @@ size_t test_mceliece()
{
auto& rng = test_rng();
- size_t fails = 0;
+ size_t fails = 0;
size_t params__n__t_min_max[] = {
256, 5, 15,
512, 5, 33,
@@ -241,9 +240,10 @@ size_t test_mceliece()
}
catch(std::exception& e)
{
- std::cout << e.what();
+ std::cout << e.what() << std::endl;
fails++;
}
+ tests += 1;
McEliece_PrivateKey sk1(rng, code_length, t);
const McEliece_PublicKey& pk1 = sk1;
@@ -278,9 +278,10 @@ size_t test_mceliece()
}
catch(std::exception& e)
{
- std::cout << e.what();
+ std::cout << e.what() << std::endl;
fails++;
}
+ tests += 1;
try
{
@@ -288,21 +289,24 @@ size_t test_mceliece()
}
catch(std::exception& e)
{
- std::cout << e.what();
+ std::cout << e.what() << std::endl;
fails++;
}
+ tests += 1;
+#if defined(BOTAN_HAS_MCEIES)
try
{
fails += test_mceies(sk, pk, rng);
}
catch(std::exception& e)
{
- std::cout << e.what();
+ std::cout << e.what() << std::endl;
fails++;
}
+ tests += 1;
+#endif // BOTAN_HAS_MCEIES
- tests += 4;
}
}