diff options
Diffstat (limited to 'src/lib/pk_pad')
-rw-r--r-- | src/lib/pk_pad/emsa.h | 2 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa1/emsa1.cpp | 6 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa1/emsa1.h | 3 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp | 1 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_pssr/pssr.cpp | 1 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_raw/emsa_raw.cpp | 7 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_raw/emsa_raw.h | 5 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_x931/emsa_x931.cpp | 5 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_x931/emsa_x931.h | 4 | ||||
-rw-r--r-- | src/lib/pk_pad/info.txt | 1 | ||||
-rw-r--r-- | src/lib/pk_pad/iso9796/iso9796.cpp | 25 | ||||
-rw-r--r-- | src/lib/pk_pad/iso9796/iso9796.h | 10 |
12 files changed, 48 insertions, 22 deletions
diff --git a/src/lib/pk_pad/emsa.h b/src/lib/pk_pad/emsa.h index d18edc757..f1175ca86 100644 --- a/src/lib/pk_pad/emsa.h +++ b/src/lib/pk_pad/emsa.h @@ -10,10 +10,10 @@ #include <botan/secmem.h> #include <botan/alg_id.h> -#include <botan/pk_keys.h> namespace Botan { +class Private_Key; class RandomNumberGenerator; /** diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp index 76f668f83..b4391b48d 100644 --- a/src/lib/pk_pad/emsa1/emsa1.cpp +++ b/src/lib/pk_pad/emsa1/emsa1.cpp @@ -8,6 +8,7 @@ #include <botan/emsa1.h> #include <botan/exceptn.h> #include <botan/oids.h> +#include <botan/pk_keys.h> #include <botan/internal/padding.h> namespace Botan { @@ -43,6 +44,11 @@ secure_vector<uint8_t> emsa1_encoding(const secure_vector<uint8_t>& msg, } +std::string EMSA1::name() const + { + return "EMSA1(" + m_hash->name() + ")"; + } + EMSA* EMSA1::clone() { return new EMSA1(m_hash->clone()); diff --git a/src/lib/pk_pad/emsa1/emsa1.h b/src/lib/pk_pad/emsa1/emsa1.h index 35071675f..7b4d027da 100644 --- a/src/lib/pk_pad/emsa1/emsa1.h +++ b/src/lib/pk_pad/emsa1/emsa1.h @@ -27,8 +27,7 @@ class BOTAN_PUBLIC_API(2,0) EMSA1 final : public EMSA EMSA* clone() override; - virtual std::string name() const override - { return "EMSA1(" + m_hash->name() + ")"; }; + std::string name() const override; AlgorithmIdentifier config_for_x509(const Private_Key& key, const std::string& cert_hash_name) const override; diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp index 5e5024806..0fabb87da 100644 --- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp +++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp @@ -9,6 +9,7 @@ #include <botan/hash_id.h> #include <botan/exceptn.h> #include <botan/oids.h> +#include <botan/pk_keys.h> #include <botan/internal/padding.h> namespace Botan { diff --git a/src/lib/pk_pad/emsa_pssr/pssr.cpp b/src/lib/pk_pad/emsa_pssr/pssr.cpp index 510d84a99..abe84f455 100644 --- a/src/lib/pk_pad/emsa_pssr/pssr.cpp +++ b/src/lib/pk_pad/emsa_pssr/pssr.cpp @@ -12,6 +12,7 @@ #include <botan/internal/bit_ops.h> #include <botan/oids.h> #include <botan/der_enc.h> +#include <botan/pk_keys.h> #include <botan/internal/padding.h> namespace Botan { diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp index 0302033f0..0ac11dc5a 100644 --- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp +++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp @@ -10,6 +10,13 @@ namespace Botan { +std::string EMSA_Raw::name() const + { + if(m_expected_size > 0) + return "Raw(" + std::to_string(m_expected_size) + ")"; + return "Raw"; + } + /* * EMSA-Raw Encode Operation */ diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.h b/src/lib/pk_pad/emsa_raw/emsa_raw.h index 5f2b994f5..3bac4ef67 100644 --- a/src/lib/pk_pad/emsa_raw/emsa_raw.h +++ b/src/lib/pk_pad/emsa_raw/emsa_raw.h @@ -24,10 +24,7 @@ class BOTAN_PUBLIC_API(2,0) EMSA_Raw final : public EMSA explicit EMSA_Raw(size_t expected_hash_size = 0) : m_expected_size(expected_hash_size) {} - virtual std::string name() const override - { if(m_expected_size > 0) - return "Raw(" + std::to_string(m_expected_size) + ")"; - else return "Raw"; } + std::string name() const override; private: void update(const uint8_t[], size_t) override; secure_vector<uint8_t> raw_data() override; diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp index 91227328e..b1f698f86 100644 --- a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp +++ b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp @@ -43,6 +43,11 @@ secure_vector<uint8_t> emsa2_encoding(const secure_vector<uint8_t>& msg, } +std::string EMSA_X931::name() const + { + return "EMSA2(" + m_hash->name() + ")"; + } + void EMSA_X931::update(const uint8_t input[], size_t length) { m_hash->update(input, length); diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.h b/src/lib/pk_pad/emsa_x931/emsa_x931.h index 6ce9e339a..e20d303b6 100644 --- a/src/lib/pk_pad/emsa_x931/emsa_x931.h +++ b/src/lib/pk_pad/emsa_x931/emsa_x931.h @@ -28,8 +28,8 @@ class BOTAN_PUBLIC_API(2,0) EMSA_X931 final : public EMSA EMSA* clone() override { return new EMSA_X931(m_hash->clone()); } - virtual std::string name() const override - { return "EMSA2(" + m_hash->name() + ")"; }; + std::string name() const override; + private: void update(const uint8_t[], size_t) override; secure_vector<uint8_t> raw_data() override; diff --git a/src/lib/pk_pad/info.txt b/src/lib/pk_pad/info.txt index 6994cf097..afadf5655 100644 --- a/src/lib/pk_pad/info.txt +++ b/src/lib/pk_pad/info.txt @@ -7,6 +7,7 @@ load_on auto <requires> asn1 rng +pubkey </requires> <header:internal> diff --git a/src/lib/pk_pad/iso9796/iso9796.cpp b/src/lib/pk_pad/iso9796/iso9796.cpp index 5b74319e0..99a1dfd29 100644 --- a/src/lib/pk_pad/iso9796/iso9796.cpp +++ b/src/lib/pk_pad/iso9796/iso9796.cpp @@ -128,7 +128,7 @@ bool iso9796_verification(const secure_vector<uint8_t>& const_coded, } secure_vector<uint8_t> coded = const_coded; - + CT::poison(coded.data(), coded.size()); //remove mask uint8_t* DB = coded.data(); @@ -149,18 +149,18 @@ bool iso9796_verification(const secure_vector<uint8_t>& const_coded, const uint8_t one_m = CT::is_equal<uint8_t>(DB[j], 0x01); const uint8_t zero_m = CT::is_zero(DB[j]); const uint8_t add_m = waiting_for_delim & zero_m; - + bad_input |= waiting_for_delim & ~(zero_m | one_m); msg1_offset += CT::select<uint8_t>(add_m, 1, 0); - + waiting_for_delim &= zero_m; } - + //invalid, if delimiter 0x01 was not found or msg1_offset is too big bad_input |= waiting_for_delim; bad_input |= CT::is_less(coded.size(), tLength + HASH_SIZE + msg1_offset + SALT_SIZE); - //in case that msg1_offset is too big, just continue with offset = 0. + //in case that msg1_offset is too big, just continue with offset = 0. msg1_offset = CT::select<size_t>(bad_input, 0, msg1_offset); CT::unpoison(coded.data(), coded.size()); @@ -202,15 +202,21 @@ bool iso9796_verification(const secure_vector<uint8_t>& const_coded, hash->update(msg2); hash->update(salt); secure_vector<uint8_t> H2 = hash->final(); - + //check if H3 == H2 bad_input |= CT::is_equal<uint8_t>(constant_time_compare(H3.data(), H2.data(), HASH_SIZE), false); - + CT::unpoison(bad_input); return (bad_input == 0); } } + +EMSA* ISO_9796_DS2::clone() + { + return new ISO_9796_DS2(m_hash->clone(), m_implicit, m_SALT_SIZE); + } + /* * ISO-9796-2 signature scheme 2 * DS 2 is probabilistic @@ -258,6 +264,11 @@ std::string ISO_9796_DS2::name() const + (m_implicit ? "imp" : "exp") + "," + std::to_string(m_SALT_SIZE) + ")"; } +EMSA* ISO_9796_DS3::clone() + { + return new ISO_9796_DS3(m_hash->clone(), m_implicit); + } + /* * ISO-9796-2 signature scheme 3 * DS 3 is deterministic and equals DS2 without salt diff --git a/src/lib/pk_pad/iso9796/iso9796.h b/src/lib/pk_pad/iso9796/iso9796.h index 994295f0f..7af9a269b 100644 --- a/src/lib/pk_pad/iso9796/iso9796.h +++ b/src/lib/pk_pad/iso9796/iso9796.h @@ -34,10 +34,9 @@ class BOTAN_PUBLIC_API(2,0) ISO_9796_DS2 final : public EMSA ISO_9796_DS2(HashFunction* hash, bool implicit, size_t salt_size) : m_hash(hash), m_implicit(implicit), m_SALT_SIZE(salt_size) {} - EMSA* clone() override - {return new ISO_9796_DS2(m_hash->clone(), m_implicit, m_SALT_SIZE);} + EMSA* clone() override; - virtual std::string name() const override; + std::string name() const override; private: void update(const uint8_t input[], size_t length) override; @@ -70,10 +69,9 @@ class BOTAN_PUBLIC_API(2,0) ISO_9796_DS3 final : public EMSA ISO_9796_DS3(HashFunction* hash, bool implicit = false) : m_hash(hash), m_implicit(implicit) {} - EMSA* clone() override - {return new ISO_9796_DS3(m_hash->clone(), m_implicit);} + EMSA* clone() override; - virtual std::string name() const override; + std::string name() const override; private: void update(const uint8_t input[], size_t length) override; |