aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pk_pad')
-rw-r--r--src/lib/pk_pad/eme.cpp4
-rw-r--r--src/lib/pk_pad/eme.h10
-rw-r--r--src/lib/pk_pad/eme_oaep/oaep.cpp28
-rw-r--r--src/lib/pk_pad/eme_oaep/oaep.h8
-rw-r--r--src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp26
-rw-r--r--src/lib/pk_pad/eme_pkcs1/eme_pkcs.h6
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.cpp8
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.h6
-rw-r--r--src/lib/pk_pad/emsa.h10
-rw-r--r--src/lib/pk_pad/emsa1/emsa1.cpp20
-rw-r--r--src/lib/pk_pad/emsa1/emsa1.h10
-rw-r--r--src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp32
-rw-r--r--src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h20
-rw-r--r--src/lib/pk_pad/emsa_pssr/pssr.cpp26
-rw-r--r--src/lib/pk_pad/emsa_pssr/pssr.h10
-rw-r--r--src/lib/pk_pad/emsa_raw/emsa_raw.cpp12
-rw-r--r--src/lib/pk_pad/emsa_raw/emsa_raw.h10
-rw-r--r--src/lib/pk_pad/emsa_x931/emsa_x931.cpp18
-rw-r--r--src/lib/pk_pad/emsa_x931/emsa_x931.h12
-rw-r--r--src/lib/pk_pad/hash_id/hash_id.cpp42
-rw-r--r--src/lib/pk_pad/hash_id/hash_id.h8
-rw-r--r--src/lib/pk_pad/iso9796/iso9796.cpp70
-rw-r--r--src/lib/pk_pad/iso9796/iso9796.h24
-rw-r--r--src/lib/pk_pad/mgf1/mgf1.cpp8
-rw-r--r--src/lib/pk_pad/mgf1/mgf1.h4
25 files changed, 216 insertions, 216 deletions
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp
index eab9862af..85efe1615 100644
--- a/src/lib/pk_pad/eme.cpp
+++ b/src/lib/pk_pad/eme.cpp
@@ -56,7 +56,7 @@ EME* get_eme(const std::string& algo_spec)
/*
* Encode a message
*/
-secure_vector<byte> EME::encode(const byte msg[], size_t msg_len,
+secure_vector<uint8_t> EME::encode(const uint8_t msg[], size_t msg_len,
size_t key_bits,
RandomNumberGenerator& rng) const
{
@@ -66,7 +66,7 @@ secure_vector<byte> EME::encode(const byte msg[], size_t msg_len,
/*
* Encode a message
*/
-secure_vector<byte> EME::encode(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EME::encode(const secure_vector<uint8_t>& msg,
size_t key_bits,
RandomNumberGenerator& rng) const
{
diff --git a/src/lib/pk_pad/eme.h b/src/lib/pk_pad/eme.h
index a5ad27b4e..e9b4386ab 100644
--- a/src/lib/pk_pad/eme.h
+++ b/src/lib/pk_pad/eme.h
@@ -36,7 +36,7 @@ class BOTAN_DLL EME
* @param rng a random number generator
* @return encoded plaintext
*/
- secure_vector<byte> encode(const byte in[],
+ secure_vector<uint8_t> encode(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const;
@@ -48,7 +48,7 @@ class BOTAN_DLL EME
* @param rng a random number generator
* @return encoded plaintext
*/
- secure_vector<byte> encode(const secure_vector<byte>& in,
+ secure_vector<uint8_t> encode(const secure_vector<uint8_t>& in,
size_t key_length,
RandomNumberGenerator& rng) const;
@@ -60,8 +60,8 @@ class BOTAN_DLL EME
* @return bytes of out[] written to along with
* validity mask (0xFF if valid, else 0x00)
*/
- virtual secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ virtual secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const = 0;
/**
@@ -72,7 +72,7 @@ class BOTAN_DLL EME
* @param rng a random number generator
* @return encoded plaintext
*/
- virtual secure_vector<byte> pad(const byte in[],
+ virtual secure_vector<uint8_t> pad(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const = 0;
diff --git a/src/lib/pk_pad/eme_oaep/oaep.cpp b/src/lib/pk_pad/eme_oaep/oaep.cpp
index f58254fdd..ef2fb81bb 100644
--- a/src/lib/pk_pad/eme_oaep/oaep.cpp
+++ b/src/lib/pk_pad/eme_oaep/oaep.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* OAEP Pad Operation
*/
-secure_vector<byte> OAEP::pad(const byte in[], size_t in_length,
+secure_vector<uint8_t> OAEP::pad(const uint8_t in[], size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const
{
@@ -25,7 +25,7 @@ secure_vector<byte> OAEP::pad(const byte in[], size_t in_length,
throw Invalid_Argument("OAEP: Input is too large");
}
- secure_vector<byte> out(key_length);
+ secure_vector<uint8_t> out(key_length);
rng.randomize(out.data(), m_Phash.size());
@@ -47,8 +47,8 @@ secure_vector<byte> OAEP::pad(const byte in[], size_t in_length,
/*
* OAEP Unpad Operation
*/
-secure_vector<byte> OAEP::unpad(byte& valid_mask,
- const byte in[], size_t in_length) const
+secure_vector<uint8_t> OAEP::unpad(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_length) const
{
/*
Must be careful about error messages here; if an attacker can
@@ -70,9 +70,9 @@ secure_vector<byte> OAEP::unpad(byte& valid_mask,
Therefore, the first byte can always be skipped safely.
*/
- byte skip_first = CT::is_zero<byte>(in[0]) & 0x01;
+ uint8_t skip_first = CT::is_zero<uint8_t>(in[0]) & 0x01;
- secure_vector<byte> input(in + skip_first, in + in_length);
+ secure_vector<uint8_t> input(in + skip_first, in + in_length);
CT::poison(input.data(), input.size());
@@ -87,26 +87,26 @@ secure_vector<byte> OAEP::unpad(byte& valid_mask,
&input[hlen], input.size() - hlen);
size_t delim_idx = 2 * hlen;
- byte waiting_for_delim = 0xFF;
- byte bad_input = 0;
+ uint8_t waiting_for_delim = 0xFF;
+ uint8_t bad_input = 0;
for(size_t i = delim_idx; i < input.size(); ++i)
{
- const byte zero_m = CT::is_zero<byte>(input[i]);
- const byte one_m = CT::is_equal<byte>(input[i], 1);
+ const uint8_t zero_m = CT::is_zero<uint8_t>(input[i]);
+ const uint8_t one_m = CT::is_equal<uint8_t>(input[i], 1);
- const byte add_m = waiting_for_delim & zero_m;
+ const uint8_t add_m = waiting_for_delim & zero_m;
bad_input |= waiting_for_delim & ~(zero_m | one_m);
- delim_idx += CT::select<byte>(add_m, 1, 0);
+ delim_idx += CT::select<uint8_t>(add_m, 1, 0);
waiting_for_delim &= zero_m;
}
// If we never saw any non-zero byte, then it's not valid input
bad_input |= waiting_for_delim;
- bad_input |= CT::is_equal<byte>(same_mem(&input[hlen], m_Phash.data(), hlen), false);
+ bad_input |= CT::is_equal<uint8_t>(same_mem(&input[hlen], m_Phash.data(), hlen), false);
CT::unpoison(input.data(), input.size());
CT::unpoison(&bad_input, 1);
@@ -114,7 +114,7 @@ secure_vector<byte> OAEP::unpad(byte& valid_mask,
valid_mask = ~bad_input;
- secure_vector<byte> output(input.begin() + delim_idx + 1, input.end());
+ secure_vector<uint8_t> output(input.begin() + delim_idx + 1, input.end());
CT::cond_zero_mem(bad_input, output.data(), output.size());
return output;
diff --git a/src/lib/pk_pad/eme_oaep/oaep.h b/src/lib/pk_pad/eme_oaep/oaep.h
index 3e476f6a3..9cd213eab 100644
--- a/src/lib/pk_pad/eme_oaep/oaep.h
+++ b/src/lib/pk_pad/eme_oaep/oaep.h
@@ -27,16 +27,16 @@ class BOTAN_DLL OAEP final : public EME
*/
OAEP(HashFunction* hash, const std::string& P = "");
private:
- secure_vector<byte> pad(const byte in[],
+ secure_vector<uint8_t> pad(const uint8_t in[],
size_t in_length,
size_t key_length,
RandomNumberGenerator& rng) const override;
- secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
- secure_vector<byte> m_Phash;
+ secure_vector<uint8_t> m_Phash;
std::unique_ptr<HashFunction> m_hash;
};
diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
index 2b5ee4ba0..5d4f950f5 100644
--- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
+++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
@@ -13,7 +13,7 @@ namespace Botan {
/*
* PKCS1 Pad Operation
*/
-secure_vector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
+secure_vector<uint8_t> EME_PKCS1v15::pad(const uint8_t in[], size_t inlen,
size_t key_length,
RandomNumberGenerator& rng) const
{
@@ -24,7 +24,7 @@ secure_vector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
throw Invalid_Argument("PKCS1: Input is too large");
}
- secure_vector<byte> out(key_length);
+ secure_vector<uint8_t> out(key_length);
out[0] = 0x02;
rng.randomize(out.data() + 1, (key_length - inlen - 2));
@@ -45,31 +45,31 @@ secure_vector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
/*
* PKCS1 Unpad Operation
*/
-secure_vector<byte> EME_PKCS1v15::unpad(byte& valid_mask,
- const byte in[], size_t inlen) const
+secure_vector<uint8_t> EME_PKCS1v15::unpad(uint8_t& valid_mask,
+ const uint8_t in[], size_t inlen) const
{
if(inlen < 2)
{
valid_mask = false;
- return secure_vector<byte>();
+ return secure_vector<uint8_t>();
}
CT::poison(in, inlen);
- byte bad_input_m = 0;
- byte seen_zero_m = 0;
+ uint8_t bad_input_m = 0;
+ uint8_t seen_zero_m = 0;
size_t delim_idx = 0;
- bad_input_m |= ~CT::is_equal<byte>(in[0], 0);
- bad_input_m |= ~CT::is_equal<byte>(in[1], 2);
+ bad_input_m |= ~CT::is_equal<uint8_t>(in[0], 0);
+ bad_input_m |= ~CT::is_equal<uint8_t>(in[1], 2);
for(size_t i = 2; i < inlen; ++i)
{
- const byte is_zero_m = CT::is_zero<byte>(in[i]);
+ const uint8_t is_zero_m = CT::is_zero<uint8_t>(in[i]);
- delim_idx += CT::select<byte>(~seen_zero_m, 1, 0);
+ delim_idx += CT::select<uint8_t>(~seen_zero_m, 1, 0);
- bad_input_m |= is_zero_m & CT::expand_mask<byte>(i < 10);
+ bad_input_m |= is_zero_m & CT::expand_mask<uint8_t>(i < 10);
seen_zero_m |= is_zero_m;
}
@@ -80,7 +80,7 @@ secure_vector<byte> EME_PKCS1v15::unpad(byte& valid_mask,
CT::unpoison(bad_input_m);
CT::unpoison(delim_idx);
- secure_vector<byte> output(&in[delim_idx + 2], &in[inlen]);
+ secure_vector<uint8_t> output(&in[delim_idx + 2], &in[inlen]);
CT::cond_zero_mem(bad_input_m, output.data(), output.size());
valid_mask = ~bad_input_m;
return output;
diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h
index 006b39997..9e06403ac 100644
--- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h
+++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.h
@@ -20,11 +20,11 @@ class BOTAN_DLL EME_PKCS1v15 final : public EME
public:
size_t maximum_input_size(size_t) const override;
private:
- secure_vector<byte> pad(const byte[], size_t, size_t,
+ secure_vector<uint8_t> pad(const uint8_t[], size_t, size_t,
RandomNumberGenerator&) const override;
- secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
};
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.cpp b/src/lib/pk_pad/eme_raw/eme_raw.cpp
index 84fd6f545..066e7afd8 100644
--- a/src/lib/pk_pad/eme_raw/eme_raw.cpp
+++ b/src/lib/pk_pad/eme_raw/eme_raw.cpp
@@ -10,15 +10,15 @@
namespace Botan {
-secure_vector<byte> EME_Raw::pad(const byte in[], size_t in_length,
+secure_vector<uint8_t> EME_Raw::pad(const uint8_t in[], size_t in_length,
size_t,
RandomNumberGenerator&) const
{
- return secure_vector<byte>(in, in + in_length);
+ return secure_vector<uint8_t>(in, in + in_length);
}
-secure_vector<byte> EME_Raw::unpad(byte& valid_mask,
- const byte in[], size_t in_length) const
+secure_vector<uint8_t> EME_Raw::unpad(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_length) const
{
valid_mask = 0xFF;
return CT::strip_leading_zeros(in, in_length);
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.h b/src/lib/pk_pad/eme_raw/eme_raw.h
index fa30c684e..ec698f759 100644
--- a/src/lib/pk_pad/eme_raw/eme_raw.h
+++ b/src/lib/pk_pad/eme_raw/eme_raw.h
@@ -18,11 +18,11 @@ class BOTAN_DLL EME_Raw final : public EME
EME_Raw() {}
private:
- secure_vector<byte> pad(const byte[], size_t, size_t,
+ secure_vector<uint8_t> pad(const uint8_t[], size_t, size_t,
RandomNumberGenerator&) const override;
- secure_vector<byte> unpad(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> unpad(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
};
diff --git a/src/lib/pk_pad/emsa.h b/src/lib/pk_pad/emsa.h
index bc930ae22..4b932fd78 100644
--- a/src/lib/pk_pad/emsa.h
+++ b/src/lib/pk_pad/emsa.h
@@ -26,12 +26,12 @@ class BOTAN_DLL EMSA
* @param input some data
* @param length length of input in bytes
*/
- virtual void update(const byte input[], size_t length) = 0;
+ virtual void update(const uint8_t input[], size_t length) = 0;
/**
* @return raw hash
*/
- virtual secure_vector<byte> raw_data() = 0;
+ virtual secure_vector<uint8_t> raw_data() = 0;
/**
* Return the encoding of a message
@@ -40,7 +40,7 @@ class BOTAN_DLL EMSA
* @param rng a random number generator
* @return encoded signature
*/
- virtual secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ virtual secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) = 0;
@@ -51,8 +51,8 @@ class BOTAN_DLL EMSA
* @param key_bits the size of the key in bits
* @return true if coded is a valid encoding of raw, otherwise false
*/
- virtual bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ virtual bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) = 0;
virtual ~EMSA();
diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp
index 11130920f..82c3b86a7 100644
--- a/src/lib/pk_pad/emsa1/emsa1.cpp
+++ b/src/lib/pk_pad/emsa1/emsa1.cpp
@@ -11,7 +11,7 @@ namespace Botan {
namespace {
-secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> emsa1_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits)
{
if(8*msg.size() <= output_bits)
@@ -20,17 +20,17 @@ secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg,
size_t shift = 8*msg.size() - output_bits;
size_t byte_shift = shift / 8, bit_shift = shift % 8;
- secure_vector<byte> digest(msg.size() - byte_shift);
+ secure_vector<uint8_t> digest(msg.size() - byte_shift);
for(size_t j = 0; j != msg.size() - byte_shift; ++j)
digest[j] = msg[j];
if(bit_shift)
{
- byte carry = 0;
+ uint8_t carry = 0;
for(size_t j = 0; j != digest.size(); ++j)
{
- byte temp = digest[j];
+ uint8_t temp = digest[j];
digest[j] = (temp >> bit_shift) | carry;
carry = (temp << (8 - bit_shift));
}
@@ -45,17 +45,17 @@ EMSA* EMSA1::clone()
return new EMSA1(m_hash->clone());
}
-void EMSA1::update(const byte input[], size_t length)
+void EMSA1::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
-secure_vector<byte> EMSA1::raw_data()
+secure_vector<uint8_t> EMSA1::raw_data()
{
return m_hash->final();
}
-secure_vector<byte> EMSA1::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EMSA1::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
@@ -64,8 +64,8 @@ secure_vector<byte> EMSA1::encoding_of(const secure_vector<byte>& msg,
return emsa1_encoding(msg, output_bits);
}
-bool EMSA1::verify(const secure_vector<byte>& input,
- const secure_vector<byte>& raw,
+bool EMSA1::verify(const secure_vector<uint8_t>& input,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
try {
@@ -73,7 +73,7 @@ bool EMSA1::verify(const secure_vector<byte>& input,
throw Encoding_Error("EMSA1::encoding_of: Invalid size for input");
// Call emsa1_encoding to handle any required bit shifting
- const secure_vector<byte> our_coding = emsa1_encoding(raw, key_bits);
+ const secure_vector<uint8_t> our_coding = emsa1_encoding(raw, key_bits);
if(our_coding.size() < input.size())
return false;
diff --git a/src/lib/pk_pad/emsa1/emsa1.h b/src/lib/pk_pad/emsa1/emsa1.h
index 5a4b4b372..6d7b2bca8 100644
--- a/src/lib/pk_pad/emsa1/emsa1.h
+++ b/src/lib/pk_pad/emsa1/emsa1.h
@@ -33,15 +33,15 @@ class BOTAN_DLL EMSA1 : public EMSA
std::unique_ptr<HashFunction> m_hash;
private:
- void update(const byte[], size_t) override;
- secure_vector<byte> raw_data() override;
+ void update(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
};
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
index b3f74930b..c4cdc6f35 100644
--- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
+++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp
@@ -12,16 +12,16 @@ namespace Botan {
namespace {
-secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> emsa3_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits,
- const byte hash_id[],
+ const uint8_t hash_id[],
size_t hash_id_length)
{
size_t output_length = output_bits / 8;
if(output_length < hash_id_length + msg.size() + 10)
throw Encoding_Error("emsa3_encoding: Output length is too small");
- secure_vector<byte> T(output_length);
+ secure_vector<uint8_t> T(output_length);
const size_t P_LENGTH = output_length - msg.size() - hash_id_length - 2;
T[0] = 0x01;
@@ -34,18 +34,18 @@ secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg,
}
-void EMSA_PKCS1v15::update(const byte input[], size_t length)
+void EMSA_PKCS1v15::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
-secure_vector<byte> EMSA_PKCS1v15::raw_data()
+secure_vector<uint8_t> EMSA_PKCS1v15::raw_data()
{
return m_hash->final();
}
-secure_vector<byte>
-EMSA_PKCS1v15::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t>
+EMSA_PKCS1v15::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
@@ -56,8 +56,8 @@ EMSA_PKCS1v15::encoding_of(const secure_vector<byte>& msg,
m_hash_id.data(), m_hash_id.size());
}
-bool EMSA_PKCS1v15::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_PKCS1v15::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
if(raw.size() != m_hash->output_length())
@@ -79,28 +79,28 @@ EMSA_PKCS1v15::EMSA_PKCS1v15(HashFunction* hash) : m_hash(hash)
m_hash_id = pkcs_hash_id(m_hash->name());
}
-void EMSA_PKCS1v15_Raw::update(const byte input[], size_t length)
+void EMSA_PKCS1v15_Raw::update(const uint8_t input[], size_t length)
{
m_message += std::make_pair(input, length);
}
-secure_vector<byte> EMSA_PKCS1v15_Raw::raw_data()
+secure_vector<uint8_t> EMSA_PKCS1v15_Raw::raw_data()
{
- secure_vector<byte> ret;
+ secure_vector<uint8_t> ret;
std::swap(ret, m_message);
return ret;
}
-secure_vector<byte>
-EMSA_PKCS1v15_Raw::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t>
+EMSA_PKCS1v15_Raw::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
return emsa3_encoding(msg, output_bits, nullptr, 0);
}
-bool EMSA_PKCS1v15_Raw::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_PKCS1v15_Raw::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
try
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
index 65daaf7ce..95ccafa4d 100644
--- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
+++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
@@ -28,18 +28,18 @@ class BOTAN_DLL EMSA_PKCS1v15 final : public EMSA
EMSA* clone() override { return new EMSA_PKCS1v15(m_hash->clone()); }
- void update(const byte[], size_t) override;
+ void update(const uint8_t[], size_t) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
private:
std::unique_ptr<HashFunction> m_hash;
- std::vector<byte> m_hash_id;
+ std::vector<uint8_t> m_hash_id;
};
/**
@@ -52,18 +52,18 @@ class BOTAN_DLL EMSA_PKCS1v15_Raw final : public EMSA
public:
EMSA* clone() override { return new EMSA_PKCS1v15_Raw(); }
- void update(const byte[], size_t) override;
+ void update(const uint8_t[], size_t) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
private:
- secure_vector<byte> m_message;
+ secure_vector<uint8_t> m_message;
};
}
diff --git a/src/lib/pk_pad/emsa_pssr/pssr.cpp b/src/lib/pk_pad/emsa_pssr/pssr.cpp
index a41e79e78..5f76b5a6f 100644
--- a/src/lib/pk_pad/emsa_pssr/pssr.cpp
+++ b/src/lib/pk_pad/emsa_pssr/pssr.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* PSSR Update Operation
*/
-void PSSR::update(const byte input[], size_t length)
+void PSSR::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
@@ -22,7 +22,7 @@ void PSSR::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> PSSR::raw_data()
+secure_vector<uint8_t> PSSR::raw_data()
{
return m_hash->final();
}
@@ -30,7 +30,7 @@ secure_vector<byte> PSSR::raw_data()
/*
* PSSR Encode Operation
*/
-secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> PSSR::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng)
{
@@ -43,15 +43,15 @@ secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg,
const size_t output_length = (output_bits + 7) / 8;
- secure_vector<byte> salt = rng.random_vec(m_SALT_SIZE);
+ secure_vector<uint8_t> salt = rng.random_vec(m_SALT_SIZE);
for(size_t j = 0; j != 8; ++j)
m_hash->update(0);
m_hash->update(msg);
m_hash->update(salt);
- secure_vector<byte> H = m_hash->final();
+ secure_vector<uint8_t> H = m_hash->final();
- secure_vector<byte> EM(output_length);
+ secure_vector<uint8_t> EM(output_length);
EM[output_length - HASH_SIZE - m_SALT_SIZE - 2] = 0x01;
buffer_insert(EM, output_length - 1 - HASH_SIZE - m_SALT_SIZE, salt);
@@ -66,8 +66,8 @@ secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg,
/*
* PSSR Decode/Verify Operation
*/
-bool PSSR::verify(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits)
+bool PSSR::verify(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits)
{
const size_t HASH_SIZE = m_hash->output_length();
const size_t KEY_BYTES = (key_bits + 7) / 8;
@@ -84,10 +84,10 @@ bool PSSR::verify(const secure_vector<byte>& const_coded,
if(const_coded[const_coded.size()-1] != 0xBC)
return false;
- secure_vector<byte> coded = const_coded;
+ secure_vector<uint8_t> coded = const_coded;
if(coded.size() < KEY_BYTES)
{
- secure_vector<byte> temp(KEY_BYTES);
+ secure_vector<uint8_t> temp(KEY_BYTES);
buffer_insert(temp, KEY_BYTES - coded.size(), coded);
coded = temp;
}
@@ -96,10 +96,10 @@ bool PSSR::verify(const secure_vector<byte>& const_coded,
if(TOP_BITS > 8 - high_bit(coded[0]))
return false;
- byte* DB = coded.data();
+ uint8_t* DB = coded.data();
const size_t DB_size = coded.size() - HASH_SIZE - 1;
- const byte* H = &coded[DB_size];
+ const uint8_t* H = &coded[DB_size];
const size_t H_size = HASH_SIZE;
mgf1_mask(*m_hash, H, H_size, DB, DB_size);
@@ -120,7 +120,7 @@ bool PSSR::verify(const secure_vector<byte>& const_coded,
m_hash->update(0);
m_hash->update(raw);
m_hash->update(&DB[salt_offset], DB_size - salt_offset);
- secure_vector<byte> H2 = m_hash->final();
+ secure_vector<uint8_t> H2 = m_hash->final();
return same_mem(H, H2.data(), HASH_SIZE);
}
diff --git a/src/lib/pk_pad/emsa_pssr/pssr.h b/src/lib/pk_pad/emsa_pssr/pssr.h
index bf465eadf..0ed47c466 100644
--- a/src/lib/pk_pad/emsa_pssr/pssr.h
+++ b/src/lib/pk_pad/emsa_pssr/pssr.h
@@ -33,16 +33,16 @@ class BOTAN_DLL PSSR final : public EMSA
EMSA* clone() override { return new PSSR(m_hash->clone(), m_SALT_SIZE); }
private:
- void update(const byte input[], size_t length) override;
+ void update(const uint8_t input[], size_t length) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
size_t m_SALT_SIZE;
diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
index 8d3bbdbc3..d15012a0d 100644
--- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
+++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* EMSA-Raw Encode Operation
*/
-void EMSA_Raw::update(const byte input[], size_t length)
+void EMSA_Raw::update(const uint8_t input[], size_t length)
{
m_message += std::make_pair(input, length);
}
@@ -20,9 +20,9 @@ void EMSA_Raw::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> EMSA_Raw::raw_data()
+secure_vector<uint8_t> EMSA_Raw::raw_data()
{
- secure_vector<byte> output;
+ secure_vector<uint8_t> output;
std::swap(m_message, output);
return output;
}
@@ -30,7 +30,7 @@ secure_vector<byte> EMSA_Raw::raw_data()
/*
* EMSA-Raw Encode Operation
*/
-secure_vector<byte> EMSA_Raw::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EMSA_Raw::encoding_of(const secure_vector<uint8_t>& msg,
size_t,
RandomNumberGenerator&)
{
@@ -40,8 +40,8 @@ secure_vector<byte> EMSA_Raw::encoding_of(const secure_vector<byte>& msg,
/*
* EMSA-Raw Verify Operation
*/
-bool EMSA_Raw::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_Raw::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t)
{
if(coded.size() == raw.size())
diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.h b/src/lib/pk_pad/emsa_raw/emsa_raw.h
index cc2d5d63a..288969257 100644
--- a/src/lib/pk_pad/emsa_raw/emsa_raw.h
+++ b/src/lib/pk_pad/emsa_raw/emsa_raw.h
@@ -22,15 +22,15 @@ class BOTAN_DLL EMSA_Raw final : public EMSA
EMSA* clone() override { return new EMSA_Raw(); }
private:
- void update(const byte[], size_t) override;
- secure_vector<byte> raw_data() override;
+ void update(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator&) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
- secure_vector<byte> m_message;
+ secure_vector<uint8_t> m_message;
};
}
diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
index 2feedee1c..8d90bd245 100644
--- a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
+++ b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp
@@ -12,10 +12,10 @@ namespace Botan {
namespace {
-secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> emsa2_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits,
- const secure_vector<byte>& empty_hash,
- byte hash_id)
+ const secure_vector<uint8_t>& empty_hash,
+ uint8_t hash_id)
{
const size_t HASH_SIZE = empty_hash.size();
@@ -28,7 +28,7 @@ secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
const bool empty_input = (msg == empty_hash);
- secure_vector<byte> output(output_length);
+ secure_vector<uint8_t> output(output_length);
output[0] = (empty_input ? 0x4B : 0x6B);
output[output_length - 3 - HASH_SIZE] = 0xBA;
@@ -42,12 +42,12 @@ secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg,
}
-void EMSA_X931::update(const byte input[], size_t length)
+void EMSA_X931::update(const uint8_t input[], size_t length)
{
m_hash->update(input, length);
}
-secure_vector<byte> EMSA_X931::raw_data()
+secure_vector<uint8_t> EMSA_X931::raw_data()
{
return m_hash->final();
}
@@ -55,7 +55,7 @@ secure_vector<byte> EMSA_X931::raw_data()
/*
* EMSA_X931 Encode Operation
*/
-secure_vector<byte> EMSA_X931::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> EMSA_X931::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator&)
{
@@ -65,8 +65,8 @@ secure_vector<byte> EMSA_X931::encoding_of(const secure_vector<byte>& msg,
/*
* EMSA_X931 Verify Operation
*/
-bool EMSA_X931::verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+bool EMSA_X931::verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits)
{
try
diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.h b/src/lib/pk_pad/emsa_x931/emsa_x931.h
index fe5866002..ec48d01de 100644
--- a/src/lib/pk_pad/emsa_x931/emsa_x931.h
+++ b/src/lib/pk_pad/emsa_x931/emsa_x931.h
@@ -28,18 +28,18 @@ class BOTAN_DLL EMSA_X931 final : public EMSA
EMSA* clone() override { return new EMSA_X931(m_hash->clone()); }
private:
- void update(const byte[], size_t) override;
- secure_vector<byte> raw_data() override;
+ void update(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
+ bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
size_t) override;
- secure_vector<byte> m_empty_hash;
+ secure_vector<uint8_t> m_empty_hash;
std::unique_ptr<HashFunction> m_hash;
- byte m_hash_id;
+ uint8_t m_hash_id;
};
}
diff --git a/src/lib/pk_pad/hash_id/hash_id.cpp b/src/lib/pk_pad/hash_id/hash_id.cpp
index 2af0f6878..70b7470c4 100644
--- a/src/lib/pk_pad/hash_id/hash_id.cpp
+++ b/src/lib/pk_pad/hash_id/hash_id.cpp
@@ -12,39 +12,39 @@ namespace Botan {
namespace {
-const byte MD5_PKCS_ID[] = {
+const uint8_t MD5_PKCS_ID[] = {
0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86,
0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 };
-const byte RIPEMD_160_PKCS_ID[] = {
+const uint8_t RIPEMD_160_PKCS_ID[] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02,
0x01, 0x05, 0x00, 0x04, 0x14 };
-const byte SHA_160_PKCS_ID[] = {
+const uint8_t SHA_160_PKCS_ID[] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02,
0x1A, 0x05, 0x00, 0x04, 0x14 };
-const byte SHA_224_PKCS_ID[] = {
+const uint8_t SHA_224_PKCS_ID[] = {
0x30, 0x2D, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C };
-const byte SHA_256_PKCS_ID[] = {
+const uint8_t SHA_256_PKCS_ID[] = {
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 };
-const byte SHA_384_PKCS_ID[] = {
+const uint8_t SHA_384_PKCS_ID[] = {
0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30 };
-const byte SHA_512_PKCS_ID[] = {
+const uint8_t SHA_512_PKCS_ID[] = {
0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 };
-const byte SHA_512_256_PKCS_ID[] = {
+const uint8_t SHA_512_256_PKCS_ID[] = {
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
0x65, 0x03, 0x04, 0x02, 0x06, 0x05, 0x00, 0x04, 0x20 };
-const byte TIGER_PKCS_ID[] = {
+const uint8_t TIGER_PKCS_ID[] = {
0x30, 0x29, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04,
0x01, 0xDA, 0x47, 0x0C, 0x02, 0x05, 0x00, 0x04, 0x18 };
@@ -53,46 +53,46 @@ const byte TIGER_PKCS_ID[] = {
/*
* HashID as specified by PKCS
*/
-std::vector<byte> pkcs_hash_id(const std::string& name)
+std::vector<uint8_t> pkcs_hash_id(const std::string& name)
{
// Special case for SSL/TLS RSA signatures
if(name == "Parallel(MD5,SHA-160)")
- return std::vector<byte>();
+ return std::vector<uint8_t>();
if(name == "MD5")
- return std::vector<byte>(MD5_PKCS_ID,
+ return std::vector<uint8_t>(MD5_PKCS_ID,
MD5_PKCS_ID + sizeof(MD5_PKCS_ID));
if(name == "RIPEMD-160")
- return std::vector<byte>(RIPEMD_160_PKCS_ID,
+ return std::vector<uint8_t>(RIPEMD_160_PKCS_ID,
RIPEMD_160_PKCS_ID + sizeof(RIPEMD_160_PKCS_ID));
if(name == "SHA-160")
- return std::vector<byte>(SHA_160_PKCS_ID,
+ return std::vector<uint8_t>(SHA_160_PKCS_ID,
SHA_160_PKCS_ID + sizeof(SHA_160_PKCS_ID));
if(name == "SHA-224")
- return std::vector<byte>(SHA_224_PKCS_ID,
+ return std::vector<uint8_t>(SHA_224_PKCS_ID,
SHA_224_PKCS_ID + sizeof(SHA_224_PKCS_ID));
if(name == "SHA-256")
- return std::vector<byte>(SHA_256_PKCS_ID,
+ return std::vector<uint8_t>(SHA_256_PKCS_ID,
SHA_256_PKCS_ID + sizeof(SHA_256_PKCS_ID));
if(name == "SHA-384")
- return std::vector<byte>(SHA_384_PKCS_ID,
+ return std::vector<uint8_t>(SHA_384_PKCS_ID,
SHA_384_PKCS_ID + sizeof(SHA_384_PKCS_ID));
if(name == "SHA-512")
- return std::vector<byte>(SHA_512_PKCS_ID,
+ return std::vector<uint8_t>(SHA_512_PKCS_ID,
SHA_512_PKCS_ID + sizeof(SHA_512_PKCS_ID));
if(name == "SHA-512-256")
- return std::vector<byte>(SHA_512_256_PKCS_ID,
+ return std::vector<uint8_t>(SHA_512_256_PKCS_ID,
SHA_512_256_PKCS_ID + sizeof(SHA_512_256_PKCS_ID));
if(name == "Tiger(24,3)")
- return std::vector<byte>(TIGER_PKCS_ID,
+ return std::vector<uint8_t>(TIGER_PKCS_ID,
TIGER_PKCS_ID + sizeof(TIGER_PKCS_ID));
throw Invalid_Argument("No PKCS #1 identifier for " + name);
@@ -101,7 +101,7 @@ std::vector<byte> pkcs_hash_id(const std::string& name)
/*
* HashID as specified by IEEE 1363/X9.31
*/
-byte ieee1363_hash_id(const std::string& name)
+uint8_t ieee1363_hash_id(const std::string& name)
{
if(name == "SHA-160") return 0x33;
diff --git a/src/lib/pk_pad/hash_id/hash_id.h b/src/lib/pk_pad/hash_id/hash_id.h
index 5eab8bc2b..4e5492bd0 100644
--- a/src/lib/pk_pad/hash_id/hash_id.h
+++ b/src/lib/pk_pad/hash_id/hash_id.h
@@ -17,17 +17,17 @@ namespace Botan {
* Return the PKCS #1 hash identifier
* @see RFC 3447 section 9.2
* @param hash_name the name of the hash function
-* @return byte sequence identifying the hash
+* @return uint8_t sequence identifying the hash
* @throw Invalid_Argument if the hash has no known PKCS #1 hash id
*/
-BOTAN_DLL std::vector<byte> pkcs_hash_id(const std::string& hash_name);
+BOTAN_DLL std::vector<uint8_t> pkcs_hash_id(const std::string& hash_name);
/**
* Return the IEEE 1363 hash identifier
* @param hash_name the name of the hash function
-* @return byte code identifying the hash, or 0 if not known
+* @return uint8_t code identifying the hash, or 0 if not known
*/
-BOTAN_DLL byte ieee1363_hash_id(const std::string& hash_name);
+BOTAN_DLL uint8_t ieee1363_hash_id(const std::string& hash_name);
}
diff --git a/src/lib/pk_pad/iso9796/iso9796.cpp b/src/lib/pk_pad/iso9796/iso9796.cpp
index db79661e3..f123a7e15 100644
--- a/src/lib/pk_pad/iso9796/iso9796.cpp
+++ b/src/lib/pk_pad/iso9796/iso9796.cpp
@@ -14,7 +14,7 @@ namespace Botan {
namespace {
-secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
+secure_vector<uint8_t> iso9796_encoding(const secure_vector<uint8_t>& msg,
size_t output_bits, std::unique_ptr<HashFunction>& hash, size_t SALT_SIZE, bool implicit, RandomNumberGenerator& rng)
{
const size_t output_length = (output_bits + 7) / 8;
@@ -37,12 +37,12 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
- HASH_SIZE - SALT_SIZE - tLength - 1;
//msg1 is the recoverable and msg2 the unrecoverable message part.
- secure_vector<byte> msg1;
- secure_vector<byte> msg2;
+ secure_vector<uint8_t> msg1;
+ secure_vector<uint8_t> msg2;
if(msg.size() > capacity)
{
- msg1 = secure_vector<byte> (msg.begin(), msg.begin() + capacity);
- msg2 = secure_vector<byte> (msg.begin() + capacity, msg.end());
+ msg1 = secure_vector<uint8_t> (msg.begin(), msg.begin() + capacity);
+ msg2 = secure_vector<uint8_t> (msg.begin() + capacity, msg.end());
hash->update(msg2);
}
else
@@ -53,14 +53,14 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
//compute H(C||msg1 ||H(msg2)||S)
uint64_t msgLength = msg1.size();
- secure_vector<byte> salt = rng.random_vec(SALT_SIZE);
+ secure_vector<uint8_t> salt = rng.random_vec(SALT_SIZE);
hash->update_be(msgLength * 8);
hash->update(msg1);
hash->update(msg2);
hash->update(salt);
- secure_vector<byte> H = hash->final();
+ secure_vector<uint8_t> H = hash->final();
- secure_vector<byte> EM(output_length);
+ secure_vector<uint8_t> EM(output_length);
//compute message offset.
size_t offset = output_length - HASH_SIZE - SALT_SIZE - tLength
@@ -78,7 +78,7 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
//set implicit/ISO trailer
if(!implicit)
{
- byte hash_id = ieee1363_hash_id(hash->name());
+ uint8_t hash_id = ieee1363_hash_id(hash->name());
if(!hash_id)
{
throw Encoding_Error("ISO9796-2::encoding_of: no hash identifier for " + hash->name());
@@ -97,8 +97,8 @@ secure_vector<byte> iso9796_encoding(const secure_vector<byte>& msg,
return EM;
}
-bool iso9796_verification(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits, std::unique_ptr<HashFunction>& hash, size_t SALT_SIZE)
+bool iso9796_verification(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits, std::unique_ptr<HashFunction>& hash, size_t SALT_SIZE)
{
const size_t HASH_SIZE = hash->output_length();
const size_t KEY_BYTES = (key_bits + 7) / 8;
@@ -115,7 +115,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
}
else
{
- byte hash_id = ieee1363_hash_id(hash->name());
+ uint8_t hash_id = ieee1363_hash_id(hash->name());
if((!const_coded[const_coded.size() - 2]) || (const_coded[const_coded.size() - 2] != hash_id) ||
(const_coded[const_coded.size() - 1] != 0xCC))
{
@@ -124,13 +124,13 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
tLength = 2;
}
- secure_vector<byte> coded = const_coded;
+ secure_vector<uint8_t> coded = const_coded;
//remove mask
- byte* DB = coded.data();
+ uint8_t* DB = coded.data();
const size_t DB_size = coded.size() - HASH_SIZE - tLength;
- const byte* H = &coded[DB_size];
+ const uint8_t* H = &coded[DB_size];
mgf1_mask(*hash, H, HASH_SIZE, DB, DB_size);
//clear the leftmost bit (confer bouncy castle)
@@ -150,20 +150,20 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
{
return false;
}
- secure_vector<byte> msg1(coded.begin() + msg1_offset,
+ secure_vector<uint8_t> msg1(coded.begin() + msg1_offset,
coded.end() - tLength - HASH_SIZE - SALT_SIZE);
- secure_vector<byte> salt(coded.begin() + msg1_offset + msg1.size(),
+ secure_vector<uint8_t> salt(coded.begin() + msg1_offset + msg1.size(),
coded.end() - tLength - HASH_SIZE);
//compute H2(C||msg1||H(msg2)||S*). * indicates a recovered value
const size_t capacity = (key_bits - 2 + 7) / 8 - HASH_SIZE
- SALT_SIZE - tLength - 1;
- secure_vector<byte> msg1raw;
- secure_vector<byte> msg2;
+ secure_vector<uint8_t> msg1raw;
+ secure_vector<uint8_t> msg2;
if(raw.size() > capacity)
{
- msg1raw = secure_vector<byte> (raw.begin(), raw.begin() + capacity);
- msg2 = secure_vector<byte> (raw.begin() + capacity, raw.end());
+ msg1raw = secure_vector<uint8_t> (raw.begin(), raw.begin() + capacity);
+ msg2 = secure_vector<uint8_t> (raw.begin() + capacity, raw.end());
hash->update(msg2);
}
else
@@ -177,7 +177,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
hash->update(msg1raw);
hash->update(msg2);
hash->update(salt);
- secure_vector<byte> H3 = hash->final();
+ secure_vector<uint8_t> H3 = hash->final();
//compute H3(C*||msg1*||H(msg2)||S*) * indicates a recovered value
uint64_t msgLength = msg1.size();
@@ -185,7 +185,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
hash->update(msg1);
hash->update(msg2);
hash->update(salt);
- secure_vector<byte> H2 = hash->final();
+ secure_vector<uint8_t> H2 = hash->final();
//check if H3 == H2
return same_mem(H3.data(), H2.data(), HASH_SIZE);
@@ -196,7 +196,7 @@ bool iso9796_verification(const secure_vector<byte>& const_coded,
* ISO-9796-2 signature scheme 2
* DS 2 is probabilistic
*/
-void ISO_9796_DS2::update(const byte input[], size_t length)
+void ISO_9796_DS2::update(const uint8_t input[], size_t length)
{
//need to buffer message completely, before digest
m_msg_buffer.insert(m_msg_buffer.end(), input, input+length);
@@ -205,9 +205,9 @@ void ISO_9796_DS2::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> ISO_9796_DS2::raw_data()
+secure_vector<uint8_t> ISO_9796_DS2::raw_data()
{
- secure_vector<byte> retbuffer = m_msg_buffer;
+ secure_vector<uint8_t> retbuffer = m_msg_buffer;
m_msg_buffer.clear();
return retbuffer;
}
@@ -215,7 +215,7 @@ secure_vector<byte> ISO_9796_DS2::raw_data()
/*
* ISO-9796-2 scheme 2 encode operation
*/
-secure_vector<byte> ISO_9796_DS2::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> ISO_9796_DS2::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits, RandomNumberGenerator& rng)
{
return iso9796_encoding(msg, output_bits, m_hash, m_SALT_SIZE, m_implicit, rng);
@@ -224,8 +224,8 @@ secure_vector<byte> ISO_9796_DS2::encoding_of(const secure_vector<byte>& msg,
/*
* ISO-9796-2 scheme 2 verify operation
*/
-bool ISO_9796_DS2::verify(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits)
+bool ISO_9796_DS2::verify(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits)
{
return iso9796_verification(const_coded,raw,key_bits,m_hash,m_SALT_SIZE);
}
@@ -234,7 +234,7 @@ bool ISO_9796_DS2::verify(const secure_vector<byte>& const_coded,
* ISO-9796-2 signature scheme 3
* DS 3 is deterministic and equals DS2 without salt
*/
-void ISO_9796_DS3::update(const byte input[], size_t length)
+void ISO_9796_DS3::update(const uint8_t input[], size_t length)
{
//need to buffer message completely, before digest
m_msg_buffer.insert(m_msg_buffer.end(), input, input+length);
@@ -243,9 +243,9 @@ void ISO_9796_DS3::update(const byte input[], size_t length)
/*
* Return the raw (unencoded) data
*/
-secure_vector<byte> ISO_9796_DS3::raw_data()
+secure_vector<uint8_t> ISO_9796_DS3::raw_data()
{
- secure_vector<byte> retbuffer = m_msg_buffer;
+ secure_vector<uint8_t> retbuffer = m_msg_buffer;
m_msg_buffer.clear();
return retbuffer;
}
@@ -253,7 +253,7 @@ secure_vector<byte> ISO_9796_DS3::raw_data()
/*
* ISO-9796-2 scheme 3 encode operation
*/
-secure_vector<byte> ISO_9796_DS3::encoding_of(const secure_vector<byte>& msg,
+secure_vector<uint8_t> ISO_9796_DS3::encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits, RandomNumberGenerator& rng)
{
return iso9796_encoding(msg, output_bits, m_hash, 0, m_implicit, rng);
@@ -262,8 +262,8 @@ secure_vector<byte> ISO_9796_DS3::encoding_of(const secure_vector<byte>& msg,
/*
* ISO-9796-2 scheme 3 verify operation
*/
-bool ISO_9796_DS3::verify(const secure_vector<byte>& const_coded,
- const secure_vector<byte>& raw, size_t key_bits)
+bool ISO_9796_DS3::verify(const secure_vector<uint8_t>& const_coded,
+ const secure_vector<uint8_t>& raw, size_t key_bits)
{
return iso9796_verification(const_coded, raw, key_bits, m_hash, 0);
}
diff --git a/src/lib/pk_pad/iso9796/iso9796.h b/src/lib/pk_pad/iso9796/iso9796.h
index da3fff055..81e008e47 100644
--- a/src/lib/pk_pad/iso9796/iso9796.h
+++ b/src/lib/pk_pad/iso9796/iso9796.h
@@ -37,22 +37,22 @@ class BOTAN_DLL ISO_9796_DS2 final : public EMSA
EMSA* clone() override
{return new ISO_9796_DS2(m_hash->clone(), m_implicit, m_SALT_SIZE);}
private:
- void update(const byte input[], size_t length) override;
+ void update(const uint8_t input[], size_t length) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
std::unique_ptr<HashFunction> m_hash;
bool m_implicit;
size_t m_SALT_SIZE;
- secure_vector<byte> m_msg_buffer;
+ secure_vector<uint8_t> m_msg_buffer;
};
/**
@@ -71,21 +71,21 @@ class BOTAN_DLL ISO_9796_DS3 final : public EMSA
EMSA* clone() override
{return new ISO_9796_DS3(m_hash->clone(), m_implicit);}
private:
- void update(const byte input[], size_t length) override;
+ void update(const uint8_t input[], size_t length) override;
- secure_vector<byte> raw_data() override;
+ secure_vector<uint8_t> raw_data() override;
- secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
+ secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
size_t output_bits,
RandomNumberGenerator& rng) override;
- bool verify(const secure_vector<byte>& coded,
- const secure_vector<byte>& raw,
+ bool verify(const secure_vector<uint8_t>& coded,
+ const secure_vector<uint8_t>& raw,
size_t key_bits) override;
std::unique_ptr<HashFunction> m_hash;
bool m_implicit;
- secure_vector<byte> m_msg_buffer;
+ secure_vector<uint8_t> m_msg_buffer;
};
}
diff --git a/src/lib/pk_pad/mgf1/mgf1.cpp b/src/lib/pk_pad/mgf1/mgf1.cpp
index 34bc4a9a9..8903ac6f0 100644
--- a/src/lib/pk_pad/mgf1/mgf1.cpp
+++ b/src/lib/pk_pad/mgf1/mgf1.cpp
@@ -12,16 +12,16 @@
namespace Botan {
void mgf1_mask(HashFunction& hash,
- const byte in[], size_t in_len,
- byte out[], size_t out_len)
+ const uint8_t in[], size_t in_len,
+ uint8_t out[], size_t out_len)
{
- u32bit counter = 0;
+ uint32_t counter = 0;
while(out_len)
{
hash.update(in, in_len);
hash.update_be(counter);
- secure_vector<byte> buffer = hash.final();
+ secure_vector<uint8_t> buffer = hash.final();
size_t xored = std::min<size_t>(buffer.size(), out_len);
xor_buf(out, buffer.data(), xored);
diff --git a/src/lib/pk_pad/mgf1/mgf1.h b/src/lib/pk_pad/mgf1/mgf1.h
index 034b0328e..27160bd9a 100644
--- a/src/lib/pk_pad/mgf1/mgf1.h
+++ b/src/lib/pk_pad/mgf1/mgf1.h
@@ -21,8 +21,8 @@ namespace Botan {
* @param out_len size of the output buffer in bytes
*/
void BOTAN_DLL mgf1_mask(HashFunction& hash,
- const byte in[], size_t in_len,
- byte out[], size_t out_len);
+ const uint8_t in[], size_t in_len,
+ uint8_t out[], size_t out_len);
}