aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-12 20:00:20 +0000
committerlloyd <[email protected]>2010-10-12 20:00:20 +0000
commit9abeb56f7d355b8ff86cbb465ba1e0a08257ec12 (patch)
tree034f8a50d241c996e6ea1889e68a8650085bf2ff
parent39306575081f043d1c79ade43797d3595fd5aeec (diff)
Use size_t instead of u32bit in pk_pad
-rw-r--r--src/pk_pad/eme.cpp12
-rw-r--r--src/pk_pad/eme.h22
-rw-r--r--src/pk_pad/eme1/eme1.cpp14
-rw-r--r--src/pk_pad/eme1/eme1.h8
-rw-r--r--src/pk_pad/eme_pkcs/eme_pkcs.cpp16
-rw-r--r--src/pk_pad/eme_pkcs/eme_pkcs.h6
-rw-r--r--src/pk_pad/emsa.h6
-rw-r--r--src/pk_pad/emsa1/emsa1.cpp20
-rw-r--r--src/pk_pad/emsa1/emsa1.h6
-rw-r--r--src/pk_pad/emsa1_bsi/emsa1_bsi.cpp2
-rw-r--r--src/pk_pad/emsa1_bsi/emsa1_bsi.h2
-rw-r--r--src/pk_pad/emsa2/emsa2.cpp14
-rw-r--r--src/pk_pad/emsa2/emsa2.h6
-rw-r--r--src/pk_pad/emsa3/emsa3.cpp20
-rw-r--r--src/pk_pad/emsa3/emsa3.h12
-rw-r--r--src/pk_pad/emsa4/emsa4.cpp26
-rw-r--r--src/pk_pad/emsa4/emsa4.h10
-rw-r--r--src/pk_pad/emsa_raw/emsa_raw.cpp10
-rw-r--r--src/pk_pad/emsa_raw/emsa_raw.h6
19 files changed, 109 insertions, 109 deletions
diff --git a/src/pk_pad/eme.cpp b/src/pk_pad/eme.cpp
index 320f19034..cfdaa240d 100644
--- a/src/pk_pad/eme.cpp
+++ b/src/pk_pad/eme.cpp
@@ -12,8 +12,8 @@ namespace Botan {
/*
* Encode a message
*/
-SecureVector<byte> EME::encode(const byte msg[], u32bit msg_len,
- u32bit key_bits,
+SecureVector<byte> EME::encode(const byte msg[], size_t msg_len,
+ size_t key_bits,
RandomNumberGenerator& rng) const
{
return pad(msg, msg_len, key_bits, rng);
@@ -23,7 +23,7 @@ SecureVector<byte> EME::encode(const byte msg[], u32bit msg_len,
* Encode a message
*/
SecureVector<byte> EME::encode(const MemoryRegion<byte>& msg,
- u32bit key_bits,
+ size_t key_bits,
RandomNumberGenerator& rng) const
{
return pad(&msg[0], msg.size(), key_bits, rng);
@@ -32,8 +32,8 @@ SecureVector<byte> EME::encode(const MemoryRegion<byte>& msg,
/*
* Decode a message
*/
-SecureVector<byte> EME::decode(const byte msg[], u32bit msg_len,
- u32bit key_bits) const
+SecureVector<byte> EME::decode(const byte msg[], size_t msg_len,
+ size_t key_bits) const
{
return unpad(msg, msg_len, key_bits);
}
@@ -42,7 +42,7 @@ SecureVector<byte> EME::decode(const byte msg[], u32bit msg_len,
* Decode a message
*/
SecureVector<byte> EME::decode(const MemoryRegion<byte>& msg,
- u32bit key_bits) const
+ size_t key_bits) const
{
return unpad(&msg[0], msg.size(), key_bits);
}
diff --git a/src/pk_pad/eme.h b/src/pk_pad/eme.h
index 1bc3ba3c9..4e89ef9d3 100644
--- a/src/pk_pad/eme.h
+++ b/src/pk_pad/eme.h
@@ -24,7 +24,7 @@ class BOTAN_DLL EME
* @param keybits the size of the key in bits
* @return upper bound of input in bytes
*/
- virtual u32bit maximum_input_size(u32bit keybits) const = 0;
+ virtual size_t maximum_input_size(size_t keybits) const = 0;
/**
* Encode an input
@@ -35,8 +35,8 @@ class BOTAN_DLL EME
* @return encoded plaintext
*/
SecureVector<byte> encode(const byte in[],
- u32bit in_length,
- u32bit key_length,
+ size_t in_length,
+ size_t key_length,
RandomNumberGenerator& rng) const;
/**
@@ -47,7 +47,7 @@ class BOTAN_DLL EME
* @return encoded plaintext
*/
SecureVector<byte> encode(const MemoryRegion<byte>& in,
- u32bit key_length,
+ size_t key_length,
RandomNumberGenerator& rng) const;
/**
@@ -58,8 +58,8 @@ class BOTAN_DLL EME
* @return plaintext
*/
SecureVector<byte> decode(const byte in[],
- u32bit in_length,
- u32bit key_length) const;
+ size_t in_length,
+ size_t key_length) const;
/**
* Decode an input
@@ -68,7 +68,7 @@ class BOTAN_DLL EME
* @return plaintext
*/
SecureVector<byte> decode(const MemoryRegion<byte>& in,
- u32bit key_length) const;
+ size_t key_length) const;
virtual ~EME() {}
private:
@@ -81,8 +81,8 @@ class BOTAN_DLL EME
* @return encoded plaintext
*/
virtual SecureVector<byte> pad(const byte in[],
- u32bit in_length,
- u32bit key_length,
+ size_t in_length,
+ size_t key_length,
RandomNumberGenerator& rng) const = 0;
/**
@@ -93,8 +93,8 @@ class BOTAN_DLL EME
* @return plaintext
*/
virtual SecureVector<byte> unpad(const byte in[],
- u32bit in_length,
- u32bit key_length) const = 0;
+ size_t in_length,
+ size_t key_length) const = 0;
};
}
diff --git a/src/pk_pad/eme1/eme1.cpp b/src/pk_pad/eme1/eme1.cpp
index 4352231c9..4ad47f41a 100644
--- a/src/pk_pad/eme1/eme1.cpp
+++ b/src/pk_pad/eme1/eme1.cpp
@@ -15,8 +15,8 @@ namespace Botan {
/*
* EME1 Pad Operation
*/
-SecureVector<byte> EME1::pad(const byte in[], u32bit in_length,
- u32bit key_length,
+SecureVector<byte> EME1::pad(const byte in[], size_t in_length,
+ size_t key_length,
RandomNumberGenerator& rng) const
{
key_length /= 8;
@@ -44,8 +44,8 @@ SecureVector<byte> EME1::pad(const byte in[], u32bit in_length,
/*
* EME1 Unpad Operation
*/
-SecureVector<byte> EME1::unpad(const byte in[], u32bit in_length,
- u32bit key_length) const
+SecureVector<byte> EME1::unpad(const byte in[], size_t in_length,
+ size_t key_length) const
{
/*
Must be careful about error messages here; if an attacker can
@@ -76,10 +76,10 @@ SecureVector<byte> EME1::unpad(const byte in[], u32bit in_length,
const bool phash_ok = same_mem(&tmp[HASH_LENGTH], &Phash[0], Phash.size());
bool delim_ok = true;
- u32bit delim_idx = 0;
+ size_t delim_idx = 0;
// Is this vulnerable to timing attacks?
- for(u32bit i = HASH_LENGTH + Phash.size(); i != tmp.size(); ++i)
+ for(size_t i = HASH_LENGTH + Phash.size(); i != tmp.size(); ++i)
{
if(tmp[i] && !delim_idx)
{
@@ -102,7 +102,7 @@ SecureVector<byte> EME1::unpad(const byte in[], u32bit in_length,
/*
* Return the max input size for a given key size
*/
-u32bit EME1::maximum_input_size(u32bit keybits) const
+size_t EME1::maximum_input_size(size_t keybits) const
{
if(keybits / 8 > 2*HASH_LENGTH + 1)
return ((keybits / 8) - 2*HASH_LENGTH - 1);
diff --git a/src/pk_pad/eme1/eme1.h b/src/pk_pad/eme1/eme1.h
index 0ecdb279e..f99dceb8c 100644
--- a/src/pk_pad/eme1/eme1.h
+++ b/src/pk_pad/eme1/eme1.h
@@ -20,7 +20,7 @@ namespace Botan {
class BOTAN_DLL EME1 : public EME
{
public:
- u32bit maximum_input_size(u32bit) const;
+ size_t maximum_input_size(size_t) const;
/**
* @param hash object to use for hashing (takes ownership)
@@ -30,11 +30,11 @@ class BOTAN_DLL EME1 : public EME
~EME1() { delete mgf; }
private:
- SecureVector<byte> pad(const byte[], u32bit, u32bit,
+ SecureVector<byte> pad(const byte[], size_t, size_t,
RandomNumberGenerator&) const;
- SecureVector<byte> unpad(const byte[], u32bit, u32bit) const;
+ SecureVector<byte> unpad(const byte[], size_t, size_t) const;
- const u32bit HASH_LENGTH;
+ const size_t HASH_LENGTH;
SecureVector<byte> Phash;
MGF* mgf;
};
diff --git a/src/pk_pad/eme_pkcs/eme_pkcs.cpp b/src/pk_pad/eme_pkcs/eme_pkcs.cpp
index c2f9c91d2..c4d6838b1 100644
--- a/src/pk_pad/eme_pkcs/eme_pkcs.cpp
+++ b/src/pk_pad/eme_pkcs/eme_pkcs.cpp
@@ -12,8 +12,8 @@ namespace Botan {
/*
* PKCS1 Pad Operation
*/
-SecureVector<byte> EME_PKCS1v15::pad(const byte in[], u32bit inlen,
- u32bit olen,
+SecureVector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
+ size_t olen,
RandomNumberGenerator& rng) const
{
olen /= 8;
@@ -26,7 +26,7 @@ SecureVector<byte> EME_PKCS1v15::pad(const byte in[], u32bit inlen,
SecureVector<byte> out(olen);
out[0] = 0x02;
- for(u32bit j = 1; j != olen - inlen - 1; ++j)
+ for(size_t j = 1; j != olen - inlen - 1; ++j)
while(out[j] == 0)
out[j] = rng.next_byte();
out.copy(olen - inlen, in, inlen);
@@ -37,14 +37,14 @@ SecureVector<byte> EME_PKCS1v15::pad(const byte in[], u32bit inlen,
/*
* PKCS1 Unpad Operation
*/
-SecureVector<byte> EME_PKCS1v15::unpad(const byte in[], u32bit inlen,
- u32bit key_len) const
+SecureVector<byte> EME_PKCS1v15::unpad(const byte in[], size_t inlen,
+ size_t key_len) const
{
if(inlen != key_len / 8 || inlen < 10 || in[0] != 0x02)
throw Decoding_Error("PKCS1::unpad");
- u32bit seperator = 0;
- for(u32bit j = 0; j != inlen; ++j)
+ size_t seperator = 0;
+ for(size_t j = 0; j != inlen; ++j)
if(in[j] == 0)
{
seperator = j;
@@ -59,7 +59,7 @@ SecureVector<byte> EME_PKCS1v15::unpad(const byte in[], u32bit inlen,
/*
* Return the max input size for a given key size
*/
-u32bit EME_PKCS1v15::maximum_input_size(u32bit keybits) const
+size_t EME_PKCS1v15::maximum_input_size(size_t keybits) const
{
if(keybits / 8 > 10)
return ((keybits / 8) - 10);
diff --git a/src/pk_pad/eme_pkcs/eme_pkcs.h b/src/pk_pad/eme_pkcs/eme_pkcs.h
index 450d668d7..4c4614bda 100644
--- a/src/pk_pad/eme_pkcs/eme_pkcs.h
+++ b/src/pk_pad/eme_pkcs/eme_pkcs.h
@@ -18,11 +18,11 @@ namespace Botan {
class BOTAN_DLL EME_PKCS1v15 : public EME
{
public:
- u32bit maximum_input_size(u32bit) const;
+ size_t maximum_input_size(size_t) const;
private:
- SecureVector<byte> pad(const byte[], u32bit, u32bit,
+ SecureVector<byte> pad(const byte[], size_t, size_t,
RandomNumberGenerator&) const;
- SecureVector<byte> unpad(const byte[], u32bit, u32bit) const;
+ SecureVector<byte> unpad(const byte[], size_t, size_t) const;
};
}
diff --git a/src/pk_pad/emsa.h b/src/pk_pad/emsa.h
index 372eb836d..e943fc5eb 100644
--- a/src/pk_pad/emsa.h
+++ b/src/pk_pad/emsa.h
@@ -24,7 +24,7 @@ class BOTAN_DLL EMSA
* @param input some data
* @param length length of input in bytes
*/
- virtual void update(const byte input[], u32bit length) = 0;
+ virtual void update(const byte input[], size_t length) = 0;
/**
* @return raw hash
@@ -39,7 +39,7 @@ class BOTAN_DLL EMSA
* @return encoded signature
*/
virtual SecureVector<byte> encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator& rng) = 0;
/**
@@ -51,7 +51,7 @@ class BOTAN_DLL EMSA
*/
virtual bool verify(const MemoryRegion<byte>& coded,
const MemoryRegion<byte>& raw,
- u32bit key_bits) = 0;
+ size_t key_bits) = 0;
virtual ~EMSA() {}
};
diff --git a/src/pk_pad/emsa1/emsa1.cpp b/src/pk_pad/emsa1/emsa1.cpp
index 0ae7e8d2d..691f4b7e7 100644
--- a/src/pk_pad/emsa1/emsa1.cpp
+++ b/src/pk_pad/emsa1/emsa1.cpp
@@ -12,23 +12,23 @@ namespace Botan {
namespace {
SecureVector<byte> emsa1_encoding(const MemoryRegion<byte>& msg,
- u32bit output_bits)
+ size_t output_bits)
{
if(8*msg.size() <= output_bits)
return msg;
- u32bit shift = 8*msg.size() - output_bits;
+ size_t shift = 8*msg.size() - output_bits;
- u32bit byte_shift = shift / 8, bit_shift = shift % 8;
+ size_t byte_shift = shift / 8, bit_shift = shift % 8;
SecureVector<byte> digest(msg.size() - byte_shift);
- for(u32bit j = 0; j != msg.size() - byte_shift; ++j)
+ for(size_t j = 0; j != msg.size() - byte_shift; ++j)
digest[j] = msg[j];
if(bit_shift)
{
byte carry = 0;
- for(u32bit j = 0; j != digest.size(); ++j)
+ for(size_t j = 0; j != digest.size(); ++j)
{
byte temp = digest[j];
digest[j] = (temp >> bit_shift) | carry;
@@ -43,7 +43,7 @@ SecureVector<byte> emsa1_encoding(const MemoryRegion<byte>& msg,
/*
* EMSA1 Update Operation
*/
-void EMSA1::update(const byte input[], u32bit length)
+void EMSA1::update(const byte input[], size_t length)
{
hash->update(input, length);
}
@@ -60,7 +60,7 @@ SecureVector<byte> EMSA1::raw_data()
* EMSA1 Encode Operation
*/
SecureVector<byte> EMSA1::encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator&)
{
if(msg.size() != hash->OUTPUT_LENGTH)
@@ -72,7 +72,7 @@ SecureVector<byte> EMSA1::encoding_of(const MemoryRegion<byte>& msg,
* EMSA1 Decode/Verify Operation
*/
bool EMSA1::verify(const MemoryRegion<byte>& coded,
- const MemoryRegion<byte>& raw, u32bit key_bits)
+ const MemoryRegion<byte>& raw, size_t key_bits)
{
try {
if(raw.size() != hash->OUTPUT_LENGTH)
@@ -84,13 +84,13 @@ bool EMSA1::verify(const MemoryRegion<byte>& coded,
if(our_coding[0] != 0) return false;
if(our_coding.size() <= coded.size()) return false;
- u32bit offset = 0;
+ size_t offset = 0;
while(our_coding[offset] == 0 && offset < our_coding.size())
++offset;
if(our_coding.size() - offset != coded.size())
return false;
- for(u32bit j = 0; j != coded.size(); ++j)
+ for(size_t j = 0; j != coded.size(); ++j)
if(coded[j] != our_coding[j+offset])
return false;
diff --git a/src/pk_pad/emsa1/emsa1.h b/src/pk_pad/emsa1/emsa1.h
index 50fda5273..120cb0cd3 100644
--- a/src/pk_pad/emsa1/emsa1.h
+++ b/src/pk_pad/emsa1/emsa1.h
@@ -31,14 +31,14 @@ class BOTAN_DLL EMSA1 : public EMSA
*/
const HashFunction* hash_ptr() const { return hash; }
private:
- void update(const byte[], u32bit);
+ void update(const byte[], size_t);
SecureVector<byte> raw_data();
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
- u32bit);
+ size_t);
HashFunction* hash;
};
diff --git a/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp b/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp
index 212091e22..a19ecfe58 100644
--- a/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp
+++ b/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp
@@ -14,7 +14,7 @@ namespace Botan {
* EMSA1 BSI Encode Operation
*/
SecureVector<byte> EMSA1_BSI::encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator&)
{
if(msg.size() != hash_ptr()->OUTPUT_LENGTH)
diff --git a/src/pk_pad/emsa1_bsi/emsa1_bsi.h b/src/pk_pad/emsa1_bsi/emsa1_bsi.h
index a0a3515fb..51ed6bc00 100644
--- a/src/pk_pad/emsa1_bsi/emsa1_bsi.h
+++ b/src/pk_pad/emsa1_bsi/emsa1_bsi.h
@@ -26,7 +26,7 @@ class BOTAN_DLL EMSA1_BSI : public EMSA1
*/
EMSA1_BSI(HashFunction* hash) : EMSA1(hash) {}
private:
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator& rng);
};
diff --git a/src/pk_pad/emsa2/emsa2.cpp b/src/pk_pad/emsa2/emsa2.cpp
index fe337a80b..96ac8e908 100644
--- a/src/pk_pad/emsa2/emsa2.cpp
+++ b/src/pk_pad/emsa2/emsa2.cpp
@@ -16,13 +16,13 @@ namespace {
* EMSA2 Encode Operation
*/
SecureVector<byte> emsa2_encoding(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
const MemoryRegion<byte>& empty_hash,
byte hash_id)
{
- const u32bit HASH_SIZE = empty_hash.size();
+ const size_t HASH_SIZE = empty_hash.size();
- u32bit output_length = (output_bits + 1) / 8;
+ size_t output_length = (output_bits + 1) / 8;
if(msg.size() != HASH_SIZE)
throw Encoding_Error("EMSA2::encoding_of: Bad input length");
@@ -30,7 +30,7 @@ SecureVector<byte> emsa2_encoding(const MemoryRegion<byte>& msg,
throw Encoding_Error("EMSA2::encoding_of: Output length is too small");
bool empty = true;
- for(u32bit j = 0; j != HASH_SIZE; ++j)
+ for(size_t j = 0; j != HASH_SIZE; ++j)
if(empty_hash[j] != msg[j])
empty = false;
@@ -51,7 +51,7 @@ SecureVector<byte> emsa2_encoding(const MemoryRegion<byte>& msg,
/*
* EMSA2 Update Operation
*/
-void EMSA2::update(const byte input[], u32bit length)
+void EMSA2::update(const byte input[], size_t length)
{
hash->update(input, length);
}
@@ -68,7 +68,7 @@ SecureVector<byte> EMSA2::raw_data()
* EMSA2 Encode Operation
*/
SecureVector<byte> EMSA2::encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator&)
{
return emsa2_encoding(msg, output_bits, empty_hash, hash_id);
@@ -79,7 +79,7 @@ SecureVector<byte> EMSA2::encoding_of(const MemoryRegion<byte>& msg,
*/
bool EMSA2::verify(const MemoryRegion<byte>& coded,
const MemoryRegion<byte>& raw,
- u32bit key_bits)
+ size_t key_bits)
{
try
{
diff --git a/src/pk_pad/emsa2/emsa2.h b/src/pk_pad/emsa2/emsa2.h
index cfb3f9e12..9e0fa6a95 100644
--- a/src/pk_pad/emsa2/emsa2.h
+++ b/src/pk_pad/emsa2/emsa2.h
@@ -26,14 +26,14 @@ class BOTAN_DLL EMSA2 : public EMSA
EMSA2(HashFunction* hash);
~EMSA2() { delete hash; }
private:
- void update(const byte[], u32bit);
+ void update(const byte[], size_t);
SecureVector<byte> raw_data();
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
- u32bit);
+ size_t);
SecureVector<byte> empty_hash;
HashFunction* hash;
diff --git a/src/pk_pad/emsa3/emsa3.cpp b/src/pk_pad/emsa3/emsa3.cpp
index 0fa9d5429..cf6578154 100644
--- a/src/pk_pad/emsa3/emsa3.cpp
+++ b/src/pk_pad/emsa3/emsa3.cpp
@@ -16,16 +16,16 @@ namespace {
* EMSA3 Encode Operation
*/
SecureVector<byte> emsa3_encoding(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
const byte hash_id[],
- u32bit hash_id_length)
+ size_t hash_id_length)
{
- u32bit output_length = output_bits / 8;
+ 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");
SecureVector<byte> T(output_length);
- const u32bit P_LENGTH = output_length - msg.size() - hash_id_length - 2;
+ const size_t P_LENGTH = output_length - msg.size() - hash_id_length - 2;
T[0] = 0x01;
set_mem(&T[1], P_LENGTH, 0xFF);
@@ -40,7 +40,7 @@ SecureVector<byte> emsa3_encoding(const MemoryRegion<byte>& msg,
/*
* EMSA3 Update Operation
*/
-void EMSA3::update(const byte input[], u32bit length)
+void EMSA3::update(const byte input[], size_t length)
{
hash->update(input, length);
}
@@ -57,7 +57,7 @@ SecureVector<byte> EMSA3::raw_data()
* EMSA3 Encode Operation
*/
SecureVector<byte> EMSA3::encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator&)
{
if(msg.size() != hash->OUTPUT_LENGTH)
@@ -72,7 +72,7 @@ SecureVector<byte> EMSA3::encoding_of(const MemoryRegion<byte>& msg,
*/
bool EMSA3::verify(const MemoryRegion<byte>& coded,
const MemoryRegion<byte>& raw,
- u32bit key_bits)
+ size_t key_bits)
{
if(raw.size() != hash->OUTPUT_LENGTH)
return false;
@@ -107,7 +107,7 @@ EMSA3::~EMSA3()
/*
* EMSA3_Raw Update Operation
*/
-void EMSA3_Raw::update(const byte input[], u32bit length)
+void EMSA3_Raw::update(const byte input[], size_t length)
{
message += std::make_pair(input, length);
}
@@ -126,7 +126,7 @@ SecureVector<byte> EMSA3_Raw::raw_data()
* EMSA3_Raw Encode Operation
*/
SecureVector<byte> EMSA3_Raw::encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator&)
{
return emsa3_encoding(msg, output_bits, 0, 0);
@@ -137,7 +137,7 @@ SecureVector<byte> EMSA3_Raw::encoding_of(const MemoryRegion<byte>& msg,
*/
bool EMSA3_Raw::verify(const MemoryRegion<byte>& coded,
const MemoryRegion<byte>& raw,
- u32bit key_bits)
+ size_t key_bits)
{
try
{
diff --git a/src/pk_pad/emsa3/emsa3.h b/src/pk_pad/emsa3/emsa3.h
index 09c1e40cc..5faf9d7e5 100644
--- a/src/pk_pad/emsa3/emsa3.h
+++ b/src/pk_pad/emsa3/emsa3.h
@@ -27,15 +27,15 @@ class BOTAN_DLL EMSA3 : public EMSA
EMSA3(HashFunction* hash);
~EMSA3();
- void update(const byte[], u32bit);
+ void update(const byte[], size_t);
SecureVector<byte> raw_data();
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
- u32bit);
+ size_t);
private:
HashFunction* hash;
SecureVector<byte> hash_id;
@@ -49,15 +49,15 @@ class BOTAN_DLL EMSA3 : public EMSA
class BOTAN_DLL EMSA3_Raw : public EMSA
{
public:
- void update(const byte[], u32bit);
+ void update(const byte[], size_t);
SecureVector<byte> raw_data();
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
- u32bit);
+ size_t);
private:
SecureVector<byte> message;
diff --git a/src/pk_pad/emsa4/emsa4.cpp b/src/pk_pad/emsa4/emsa4.cpp
index a647a521d..968a34111 100644
--- a/src/pk_pad/emsa4/emsa4.cpp
+++ b/src/pk_pad/emsa4/emsa4.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* EMSA4 Update Operation
*/
-void EMSA4::update(const byte input[], u32bit length)
+void EMSA4::update(const byte input[], size_t length)
{
hash->update(input, length);
}
@@ -31,21 +31,21 @@ SecureVector<byte> EMSA4::raw_data()
* EMSA4 Encode Operation
*/
SecureVector<byte> EMSA4::encoding_of(const MemoryRegion<byte>& msg,
- u32bit output_bits,
+ size_t output_bits,
RandomNumberGenerator& rng)
{
- const u32bit HASH_SIZE = hash->OUTPUT_LENGTH;
+ const size_t HASH_SIZE = hash->OUTPUT_LENGTH;
if(msg.size() != HASH_SIZE)
throw Encoding_Error("EMSA4::encoding_of: Bad input length");
if(output_bits < 8*HASH_SIZE + 8*SALT_SIZE + 9)
throw Encoding_Error("EMSA4::encoding_of: Output length is too small");
- const u32bit output_length = (output_bits + 7) / 8;
+ const size_t output_length = (output_bits + 7) / 8;
SecureVector<byte> salt = rng.random_vec(SALT_SIZE);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t j = 0; j != 8; ++j)
hash->update(0);
hash->update(msg);
hash->update(salt, SALT_SIZE);
@@ -67,10 +67,10 @@ SecureVector<byte> EMSA4::encoding_of(const MemoryRegion<byte>& msg,
* EMSA4 Decode/Verify Operation
*/
bool EMSA4::verify(const MemoryRegion<byte>& const_coded,
- const MemoryRegion<byte>& raw, u32bit key_bits)
+ const MemoryRegion<byte>& raw, size_t key_bits)
{
- const u32bit HASH_SIZE = hash->OUTPUT_LENGTH;
- const u32bit KEY_BYTES = (key_bits + 7) / 8;
+ const size_t HASH_SIZE = hash->OUTPUT_LENGTH;
+ const size_t KEY_BYTES = (key_bits + 7) / 8;
if(key_bits < 8*HASH_SIZE + 9)
return false;
@@ -89,7 +89,7 @@ bool EMSA4::verify(const MemoryRegion<byte>& const_coded,
coded = temp;
}
- const u32bit TOP_BITS = 8 * ((key_bits + 7) / 8) - key_bits;
+ const size_t TOP_BITS = 8 * ((key_bits + 7) / 8) - key_bits;
if(TOP_BITS > 8 - high_bit(coded[0]))
return false;
@@ -99,8 +99,8 @@ bool EMSA4::verify(const MemoryRegion<byte>& const_coded,
mgf->mask(H, H.size(), DB, coded.size() - H.size() - 1);
DB[0] &= 0xFF >> TOP_BITS;
- u32bit salt_offset = 0;
- for(u32bit j = 0; j != DB.size(); ++j)
+ size_t salt_offset = 0;
+ for(size_t j = 0; j != DB.size(); ++j)
{
if(DB[j] == 0x01)
{ salt_offset = j + 1; break; }
@@ -112,7 +112,7 @@ bool EMSA4::verify(const MemoryRegion<byte>& const_coded,
SecureVector<byte> salt(&DB[salt_offset], DB.size() - salt_offset);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t j = 0; j != 8; ++j)
hash->update(0);
hash->update(raw);
hash->update(salt);
@@ -133,7 +133,7 @@ EMSA4::EMSA4(HashFunction* h) :
/*
* EMSA4 Constructor
*/
-EMSA4::EMSA4(HashFunction* h, u32bit salt_size) :
+EMSA4::EMSA4(HashFunction* h, size_t salt_size) :
SALT_SIZE(salt_size), hash(h)
{
mgf = new MGF1(hash->clone());
diff --git a/src/pk_pad/emsa4/emsa4.h b/src/pk_pad/emsa4/emsa4.h
index 7dfc3892a..bd8b32ca1 100644
--- a/src/pk_pad/emsa4/emsa4.h
+++ b/src/pk_pad/emsa4/emsa4.h
@@ -29,19 +29,19 @@ class BOTAN_DLL EMSA4 : public EMSA
* @param hash the hash object to use
* @param salt_size the size of the salt to use in bytes
*/
- EMSA4(HashFunction* hash, u32bit salt_size);
+ EMSA4(HashFunction* hash, size_t salt_size);
~EMSA4() { delete hash; delete mgf; }
private:
- void update(const byte[], u32bit);
+ void update(const byte[], size_t);
SecureVector<byte> raw_data();
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator& rng);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
- u32bit);
+ size_t);
- u32bit SALT_SIZE;
+ size_t SALT_SIZE;
HashFunction* hash;
const MGF* mgf;
};
diff --git a/src/pk_pad/emsa_raw/emsa_raw.cpp b/src/pk_pad/emsa_raw/emsa_raw.cpp
index 4d32ef7a9..d0f3918dd 100644
--- a/src/pk_pad/emsa_raw/emsa_raw.cpp
+++ b/src/pk_pad/emsa_raw/emsa_raw.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* EMSA-Raw Encode Operation
*/
-void EMSA_Raw::update(const byte input[], u32bit length)
+void EMSA_Raw::update(const byte input[], size_t length)
{
message += std::make_pair(input, length);
}
@@ -31,7 +31,7 @@ SecureVector<byte> EMSA_Raw::raw_data()
* EMSA-Raw Encode Operation
*/
SecureVector<byte> EMSA_Raw::encoding_of(const MemoryRegion<byte>& msg,
- u32bit,
+ size_t,
RandomNumberGenerator&)
{
return msg;
@@ -42,7 +42,7 @@ SecureVector<byte> EMSA_Raw::encoding_of(const MemoryRegion<byte>& msg,
*/
bool EMSA_Raw::verify(const MemoryRegion<byte>& coded,
const MemoryRegion<byte>& raw,
- u32bit)
+ size_t)
{
if(coded.size() == raw.size())
return (coded == raw);
@@ -51,11 +51,11 @@ bool EMSA_Raw::verify(const MemoryRegion<byte>& coded,
return false;
// handle zero padding differences
- const u32bit leading_zeros_expected = raw.size() - coded.size();
+ const size_t leading_zeros_expected = raw.size() - coded.size();
bool same_modulo_leading_zeros = true;
- for(u32bit i = 0; i != leading_zeros_expected; ++i)
+ for(size_t i = 0; i != leading_zeros_expected; ++i)
if(raw[i])
same_modulo_leading_zeros = false;
diff --git a/src/pk_pad/emsa_raw/emsa_raw.h b/src/pk_pad/emsa_raw/emsa_raw.h
index ab27877a6..2ccd076f2 100644
--- a/src/pk_pad/emsa_raw/emsa_raw.h
+++ b/src/pk_pad/emsa_raw/emsa_raw.h
@@ -19,13 +19,13 @@ namespace Botan {
class BOTAN_DLL EMSA_Raw : public EMSA
{
private:
- void update(const byte[], u32bit);
+ void update(const byte[], size_t);
SecureVector<byte> raw_data();
- SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit,
+ SecureVector<byte> encoding_of(const MemoryRegion<byte>&, size_t,
RandomNumberGenerator&);
bool verify(const MemoryRegion<byte>&, const MemoryRegion<byte>&,
- u32bit);
+ size_t);
SecureVector<byte> message;
};