aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/iso9796
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-23 05:58:20 -0500
committerJack Lloyd <[email protected]>2017-12-23 05:58:20 -0500
commit969007e52ec5f5d5d1c8ba8b54e8cd3c9b117f04 (patch)
tree3b71828831e1f15f494a72dcc196a3bf927ab0a9 /src/lib/pk_pad/iso9796
parent5d59f00cec3f2d5d549b004a154ba82d098bc4b0 (diff)
Deinline functions in EMSA, add pubkey as dependency
Diffstat (limited to 'src/lib/pk_pad/iso9796')
-rw-r--r--src/lib/pk_pad/iso9796/iso9796.cpp25
-rw-r--r--src/lib/pk_pad/iso9796/iso9796.h10
2 files changed, 22 insertions, 13 deletions
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;