aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <lloyd@randombit.net>2015-11-11 05:43:01 -0500
committerJack Lloyd <lloyd@randombit.net>2015-11-11 05:43:01 -0500
commitcf05aea092fad448c2f4a8e8b66159237096ba8e (patch)
tree00631bcc84809a1eeac5dd32dd92c62143ef831b /src/lib
parent6bb38ae2fa0e1be46b3a3256ac03f435b16a57ea (diff)
Update and consolidate the test framework.
The tests previously had used 4 to 6 different schemes internally (the vec file reader framework, Catch, the old InSiTo Boost.Test tests, the PK/BigInt tests which escaped the rewrite in 1.11.7, plus a number of one-offs). Converge on a design that works everywhere, and update all the things. Fix also a few bugs found by the test changes: SHA-512-256 name incorrect, OpenSSL RC4 name incorrect, signature of FFI function botan_pubkey_destroy was wrong.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cert/cvc/cvc_gen_cert.h2
-rw-r--r--src/lib/ffi/ffi.cpp2
-rw-r--r--src/lib/ffi/ffi.h2
-rw-r--r--src/lib/hash/sha2_64/sha2_64.h2
-rw-r--r--src/lib/kdf/kdf.cpp1
-rw-r--r--src/lib/pubkey/mceies/mceies.cpp4
-rw-r--r--src/lib/rng/rng.h1
-rw-r--r--src/lib/stream/rc4/openssl_rc4.cpp14
-rw-r--r--src/lib/utils/calendar.cpp8
-rw-r--r--src/lib/utils/calendar.h4
10 files changed, 29 insertions, 11 deletions
diff --git a/src/lib/cert/cvc/cvc_gen_cert.h b/src/lib/cert/cvc/cvc_gen_cert.h
index 02c6f7324..6bdf116f3 100644
--- a/src/lib/cert/cvc/cvc_gen_cert.h
+++ b/src/lib/cert/cvc/cvc_gen_cert.h
@@ -77,7 +77,7 @@ class EAC1_1_gen_CVC : public EAC1_1_obj<Derived> // CRTP continuation from EAC1
const std::vector<byte>& tbs_bits,
RandomNumberGenerator& rng);
- EAC1_1_gen_CVC() { m_pk = 0; }
+ EAC1_1_gen_CVC() { m_pk = nullptr; }
virtual ~EAC1_1_gen_CVC<Derived>()
{ delete m_pk; }
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp
index 7ed279bbd..eaf24eca6 100644
--- a/src/lib/ffi/ffi.cpp
+++ b/src/lib/ffi/ffi.cpp
@@ -876,7 +876,7 @@ int botan_privkey_destroy(botan_privkey_t key)
return 0;
}
-int botan_pubkey_destroy(botan_privkey_t key)
+int botan_pubkey_destroy(botan_pubkey_t key)
{
delete key;
return 0;
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index 2def4f4d5..6cbe56743 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -351,7 +351,7 @@ BOTAN_DLL int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t* estima
BOTAN_DLL int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash,
uint8_t out[], size_t* out_len);
-BOTAN_DLL int botan_pubkey_destroy(botan_privkey_t key);
+BOTAN_DLL int botan_pubkey_destroy(botan_pubkey_t key);
/*
diff --git a/src/lib/hash/sha2_64/sha2_64.h b/src/lib/hash/sha2_64/sha2_64.h
index 5aae5effe..736b33d12 100644
--- a/src/lib/hash/sha2_64/sha2_64.h
+++ b/src/lib/hash/sha2_64/sha2_64.h
@@ -60,7 +60,7 @@ class BOTAN_DLL SHA_512 : public MDx_HashFunction
class BOTAN_DLL SHA_512_256 : public MDx_HashFunction
{
public:
- std::string name() const override { return "SHA-512/256"; }
+ std::string name() const override { return "SHA-512-256"; }
size_t output_length() const override { return 32; }
HashFunction* clone() const override { return new SHA_512_256; }
diff --git a/src/lib/kdf/kdf.cpp b/src/lib/kdf/kdf.cpp
index 3eba8a5cd..cf13c4803 100644
--- a/src/lib/kdf/kdf.cpp
+++ b/src/lib/kdf/kdf.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/kdf.h>
+#include <botan/exceptn.h>
#include <botan/internal/algo_registry.h>
#if defined(BOTAN_HAS_HKDF)
diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp
index d4d956a54..301c5dda4 100644
--- a/src/lib/pubkey/mceies/mceies.cpp
+++ b/src/lib/pubkey/mceies/mceies.cpp
@@ -99,6 +99,10 @@ mceies_decrypt(const McEliece_PrivateKey& privkey,
aead->finish(pt, 0);
return pt;
}
+ catch(Integrity_Failure)
+ {
+ throw;
+ }
catch(std::exception& e)
{
throw std::runtime_error("mce_decrypt failed: " + std::string(e.what()));
diff --git a/src/lib/rng/rng.h b/src/lib/rng/rng.h
index 261880d5d..a28a676a6 100644
--- a/src/lib/rng/rng.h
+++ b/src/lib/rng/rng.h
@@ -183,6 +183,7 @@ class BOTAN_DLL Serialized_RNG : public RandomNumberGenerator
}
Serialized_RNG() : m_rng(RandomNumberGenerator::make_rng()) {}
+ Serialized_RNG(RandomNumberGenerator* rng) : m_rng(rng) {}
private:
mutable std::mutex m_mutex;
std::unique_ptr<RandomNumberGenerator> m_rng;
diff --git a/src/lib/stream/rc4/openssl_rc4.cpp b/src/lib/stream/rc4/openssl_rc4.cpp
index e4f180a9b..84d739c91 100644
--- a/src/lib/stream/rc4/openssl_rc4.cpp
+++ b/src/lib/stream/rc4/openssl_rc4.cpp
@@ -23,7 +23,19 @@ class OpenSSL_RC4 : public StreamCipher
public:
void clear() { clear_mem(&m_rc4, 1); }
- std::string name() const { return "RC4"; }
+ std::string name() const
+ {
+ switch(m_skip)
+ {
+ case 0:
+ return "RC4";
+ case 256:
+ return "MARK-4";
+ default:
+ return "RC4_skip(" + std::to_string(m_skip) + ")";
+ }
+ }
+
StreamCipher* clone() const { return new OpenSSL_RC4; }
Key_Length_Specification key_spec() const
diff --git a/src/lib/utils/calendar.cpp b/src/lib/utils/calendar.cpp
index f071a7328..73602d634 100644
--- a/src/lib/utils/calendar.cpp
+++ b/src/lib/utils/calendar.cpp
@@ -58,7 +58,7 @@ std::time_t boost_timegm(std::tm *tm)
using namespace boost::posix_time;
using namespace boost::gregorian;
const auto epoch = ptime(date(1970, 01, 01));
- const auto time = ptime(date(year, mon, day),
+ const auto time = ptime(date(year, mon, day),
hours(hour) + minutes(min) + seconds(sec));
const time_duration diff(time - epoch);
out = diff.ticks() / diff.ticks_per_second();
@@ -88,7 +88,7 @@ std::time_t fallback_timegm(std::tm *tm)
// Clear value of TZ
::setenv("TZ", "", 1);
::tzset();
-
+
out = ::mktime(tm);
// Restore TZ
@@ -113,10 +113,10 @@ std::time_t fallback_timegm(std::tm *tm)
}
-std::chrono::system_clock::time_point calendar_point::to_std_timepoint()
+std::chrono::system_clock::time_point calendar_point::to_std_timepoint() const
{
if (year < 1970)
- throw Invalid_Argument("calendar_point::to_std_timepoint() does not support years before 1990.");
+ throw Invalid_Argument("calendar_point::to_std_timepoint() does not support years before 1970.");
// 32 bit time_t ends at January 19, 2038
// https://msdn.microsoft.com/en-us/library/2093ets1.aspx
diff --git a/src/lib/utils/calendar.h b/src/lib/utils/calendar.h
index 0c87e62dd..a0b91f913 100644
--- a/src/lib/utils/calendar.h
+++ b/src/lib/utils/calendar.h
@@ -1,6 +1,6 @@
/*
* Calendar Functions
-* (C) 1999-2009 Jack Lloyd
+* (C) 1999-2009,2015 Jack Lloyd
* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
@@ -55,7 +55,7 @@ struct BOTAN_DLL calendar_point
/**
* Returns an STL timepoint object
*/
- std::chrono::system_clock::time_point to_std_timepoint();
+ std::chrono::system_clock::time_point to_std_timepoint() const;
/**
* Returns a human readable string of the struct's components.