aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-12 19:59:26 +0000
committerlloyd <[email protected]>2010-10-12 19:59:26 +0000
commit39306575081f043d1c79ade43797d3595fd5aeec (patch)
tree926b8833f6cbde9f929b2b6156fd27b5d69f5266 /src
parenta85f136550c08fc878e3983866af0e6460e980da (diff)
Use size_t instead of u32bit in all of pubkey
Diffstat (limited to 'src')
-rw-r--r--src/engine/gnump/gnump_pk.cpp48
-rw-r--r--src/engine/openssl/ossl_pk.cpp48
-rw-r--r--src/pubkey/dh/dh.cpp2
-rw-r--r--src/pubkey/dh/dh.h4
-rw-r--r--src/pubkey/dl_group/dl_group.cpp6
-rw-r--r--src/pubkey/dl_group/dl_group.h4
-rw-r--r--src/pubkey/dlies/dlies.cpp20
-rw-r--r--src/pubkey/dlies/dlies.h14
-rw-r--r--src/pubkey/dsa/dsa.cpp6
-rw-r--r--src/pubkey/dsa/dsa.h24
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.cpp4
-rw-r--r--src/pubkey/ecdh/ecdh.cpp2
-rw-r--r--src/pubkey/ecdh/ecdh.h4
-rw-r--r--src/pubkey/ecdsa/ecdsa.cpp6
-rw-r--r--src/pubkey/ecdsa/ecdsa.h24
-rw-r--r--src/pubkey/elgamal/elgamal.cpp6
-rw-r--r--src/pubkey/elgamal/elgamal.h10
-rw-r--r--src/pubkey/gost_3410/gost_3410.cpp16
-rw-r--r--src/pubkey/gost_3410/gost_3410.h24
-rw-r--r--src/pubkey/if_algo/if_algo.h2
-rw-r--r--src/pubkey/nr/nr.cpp4
-rw-r--r--src/pubkey/nr/nr.h22
-rw-r--r--src/pubkey/pk_keys.h6
-rw-r--r--src/pubkey/pk_ops.h30
-rw-r--r--src/pubkey/pkcs8.cpp4
-rw-r--r--src/pubkey/pubkey.cpp34
-rw-r--r--src/pubkey/pubkey.h46
-rw-r--r--src/pubkey/pubkey_enums.cpp2
-rw-r--r--src/pubkey/rsa/rsa.cpp6
-rw-r--r--src/pubkey/rsa/rsa.h14
-rw-r--r--src/pubkey/rw/rw.cpp6
-rw-r--r--src/pubkey/rw/rw.h10
-rw-r--r--src/pubkey/workfactor.cpp8
-rw-r--r--src/pubkey/workfactor.h2
34 files changed, 233 insertions, 235 deletions
diff --git a/src/engine/gnump/gnump_pk.cpp b/src/engine/gnump/gnump_pk.cpp
index 758e73520..25735fe55 100644
--- a/src/engine/gnump/gnump_pk.cpp
+++ b/src/engine/gnump/gnump_pk.cpp
@@ -38,7 +38,7 @@ class GMP_DH_KA_Operation : public PK_Ops::Key_Agreement
GMP_DH_KA_Operation(const DH_PrivateKey& dh) :
x(dh.get_x()), p(dh.group_p()) {}
- SecureVector<byte> agree(const byte w[], u32bit w_len)
+ SecureVector<byte> agree(const byte w[], size_t w_len)
{
GMP_MPZ z(w, w_len);
mpz_powm(z.value, z.value, x.value, p.value);
@@ -62,22 +62,22 @@ class GMP_DSA_Signature_Operation : public PK_Ops::Signature
g(dsa.group_g()),
q_bits(dsa.group_q().bits()) {}
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return (q_bits + 7) / 8; }
- u32bit max_input_bits() const { return q_bits; }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return (q_bits + 7) / 8; }
+ size_t max_input_bits() const { return q_bits; }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const GMP_MPZ x, p, q, g;
- u32bit q_bits;
+ size_t q_bits;
};
SecureVector<byte>
-GMP_DSA_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+GMP_DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
- const u32bit q_bytes = (q_bits + 7) / 8;
+ const size_t q_bytes = (q_bits + 7) / 8;
rng.add_entropy(msg, msg_len);
@@ -120,23 +120,23 @@ class GMP_DSA_Verification_Operation : public PK_Ops::Verification
g(dsa.group_g()),
q_bits(dsa.group_q().bits()) {}
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return (q_bits + 7) / 8; }
- u32bit max_input_bits() const { return q_bits; }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return (q_bits + 7) / 8; }
+ size_t max_input_bits() const { return q_bits; }
bool with_recovery() const { return false; }
- bool verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len);
+ bool verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len);
private:
const GMP_MPZ y, p, q, g;
- u32bit q_bits;
+ size_t q_bits;
};
-bool GMP_DSA_Verification_Operation::verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len)
+bool GMP_DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len)
{
- const u32bit q_bytes = q.bytes();
+ const size_t q_bytes = q.bytes();
if(sig_len != 2*q_bytes || msg_len > q_bytes)
return false;
@@ -190,9 +190,9 @@ class GMP_RSA_Private_Operation : public PK_Ops::Signature,
n_bits(rsa.get_n().bits())
{}
- u32bit max_input_bits() const { return (n_bits - 1); }
+ size_t max_input_bits() const { return (n_bits - 1); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
@@ -200,7 +200,7 @@ class GMP_RSA_Private_Operation : public PK_Ops::Signature,
return BigInt::encode_1363(x, (n_bits + 7) / 8);
}
- SecureVector<byte> decrypt(const byte msg[], u32bit msg_len)
+ SecureVector<byte> decrypt(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(private_op(m));
@@ -210,7 +210,7 @@ class GMP_RSA_Private_Operation : public PK_Ops::Signature,
BigInt private_op(const BigInt& m) const;
GMP_MPZ mod, p, q, d1, d2, c;
- u32bit n_bits;
+ size_t n_bits;
};
BigInt GMP_RSA_Private_Operation::private_op(const BigInt& m) const
@@ -235,17 +235,17 @@ class GMP_RSA_Public_Operation : public PK_Ops::Verification,
n(rsa.get_n()), e(rsa.get_e()), mod(rsa.get_n())
{}
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
+ SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
return BigInt::encode_1363(public_op(m), n.bytes());
}
- SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len)
+ SecureVector<byte> verify_mr(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(public_op(m));
diff --git a/src/engine/openssl/ossl_pk.cpp b/src/engine/openssl/ossl_pk.cpp
index 38bcaf260..23ae6b25d 100644
--- a/src/engine/openssl/ossl_pk.cpp
+++ b/src/engine/openssl/ossl_pk.cpp
@@ -36,7 +36,7 @@ class OSSL_DH_KA_Operation : public PK_Ops::Key_Agreement
OSSL_DH_KA_Operation(const DH_PrivateKey& dh) :
x(dh.get_x()), p(dh.group_p()) {}
- SecureVector<byte> agree(const byte w[], u32bit w_len)
+ SecureVector<byte> agree(const byte w[], size_t w_len)
{
OSSL_BN i(w, w_len), r;
BN_mod_exp(r.value, i.value, x.value, p.value, ctx.value);
@@ -61,23 +61,23 @@ class OSSL_DSA_Signature_Operation : public PK_Ops::Signature
g(dsa.group_g()),
q_bits(dsa.group_q().bits()) {}
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return (q_bits + 7) / 8; }
- u32bit max_input_bits() const { return q_bits; }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return (q_bits + 7) / 8; }
+ size_t max_input_bits() const { return q_bits; }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const OSSL_BN x, p, q, g;
const OSSL_BN_CTX ctx;
- u32bit q_bits;
+ size_t q_bits;
};
SecureVector<byte>
-OSSL_DSA_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+OSSL_DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
- const u32bit q_bytes = (q_bits + 7) / 8;
+ const size_t q_bytes = (q_bits + 7) / 8;
rng.add_entropy(msg, msg_len);
@@ -119,24 +119,24 @@ class OSSL_DSA_Verification_Operation : public PK_Ops::Verification
g(dsa.group_g()),
q_bits(dsa.group_q().bits()) {}
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return (q_bits + 7) / 8; }
- u32bit max_input_bits() const { return q_bits; }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return (q_bits + 7) / 8; }
+ size_t max_input_bits() const { return q_bits; }
bool with_recovery() const { return false; }
- bool verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len);
+ bool verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len);
private:
const OSSL_BN y, p, q, g;
const OSSL_BN_CTX ctx;
- u32bit q_bits;
+ size_t q_bits;
};
-bool OSSL_DSA_Verification_Operation::verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len)
+bool OSSL_DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len)
{
- const u32bit q_bytes = q.bytes();
+ const size_t q_bytes = q.bytes();
if(sig_len != 2*q_bytes || msg_len > q_bytes)
return false;
@@ -189,9 +189,9 @@ class OSSL_RSA_Private_Operation : public PK_Ops::Signature,
n_bits(rsa.get_n().bits())
{}
- u32bit max_input_bits() const { return (n_bits - 1); }
+ size_t max_input_bits() const { return (n_bits - 1); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
@@ -199,7 +199,7 @@ class OSSL_RSA_Private_Operation : public PK_Ops::Signature,
return BigInt::encode_1363(x, (n_bits + 7) / 8);
}
- SecureVector<byte> decrypt(const byte msg[], u32bit msg_len)
+ SecureVector<byte> decrypt(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(private_op(m));
@@ -210,7 +210,7 @@ class OSSL_RSA_Private_Operation : public PK_Ops::Signature,
const OSSL_BN mod, p, q, d1, d2, c;
const OSSL_BN_CTX ctx;
- u32bit n_bits;
+ size_t n_bits;
};
BigInt OSSL_RSA_Private_Operation::private_op(const BigInt& m) const
@@ -234,17 +234,17 @@ class OSSL_RSA_Public_Operation : public PK_Ops::Verification,
n(rsa.get_n()), e(rsa.get_e()), mod(rsa.get_n())
{}
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
+ SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
return BigInt::encode_1363(public_op(m), n.bytes());
}
- SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len)
+ SecureVector<byte> verify_mr(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(public_op(m));
diff --git a/src/pubkey/dh/dh.cpp b/src/pubkey/dh/dh.cpp
index f7d1838ce..d58fece12 100644
--- a/src/pubkey/dh/dh.cpp
+++ b/src/pubkey/dh/dh.cpp
@@ -83,7 +83,7 @@ DH_KA_Operation::DH_KA_Operation(const DH_PrivateKey& dh) :
blinder = Blinder(k, powermod_x_p(inverse_mod(k, p)), p);
}
-SecureVector<byte> DH_KA_Operation::agree(const byte w[], u32bit w_len)
+SecureVector<byte> DH_KA_Operation::agree(const byte w[], size_t w_len)
{
BigInt input = BigInt::decode(w, w_len);
diff --git a/src/pubkey/dh/dh.h b/src/pubkey/dh/dh.h
index 88b57922d..497238417 100644
--- a/src/pubkey/dh/dh.h
+++ b/src/pubkey/dh/dh.h
@@ -24,7 +24,7 @@ class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey
std::string algo_name() const { return "DH"; }
MemoryVector<byte> public_value() const;
- u32bit max_input_bits() const { return group_p().bits(); }
+ size_t max_input_bits() const { return group_p().bits(); }
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; }
@@ -80,7 +80,7 @@ class BOTAN_DLL DH_KA_Operation : public PK_Ops::Key_Agreement
public:
DH_KA_Operation(const DH_PrivateKey& key);
- SecureVector<byte> agree(const byte w[], u32bit w_len);
+ SecureVector<byte> agree(const byte w[], size_t w_len);
private:
const BigInt& p;
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp
index d714bc154..7f0160b6b 100644
--- a/src/pubkey/dl_group/dl_group.cpp
+++ b/src/pubkey/dl_group/dl_group.cpp
@@ -44,7 +44,7 @@ DL_Group::DL_Group(const std::string& type)
* DL_Group Constructor
*/
DL_Group::DL_Group(RandomNumberGenerator& rng,
- PrimeType type, u32bit pbits, u32bit qbits)
+ PrimeType type, size_t pbits, size_t qbits)
{
if(pbits < 512)
throw Invalid_Argument("DL_Group: prime size " + to_string(pbits) +
@@ -90,7 +90,7 @@ DL_Group::DL_Group(RandomNumberGenerator& rng,
* DL_Group Constructor
*/
DL_Group::DL_Group(RandomNumberGenerator& rng,
- const MemoryRegion<byte>& seed, u32bit pbits, u32bit qbits)
+ const MemoryRegion<byte>& seed, size_t pbits, size_t qbits)
{
if(!generate_dsa_primes(rng,
global_state().algorithm_factory(),
@@ -321,7 +321,7 @@ BigInt DL_Group::make_dsa_generator(const BigInt& p, const BigInt& q)
BOTAN_ASSERT(e > 0, "q does not divide p, invalid group");
- for(u32bit i = 0; i != PRIME_TABLE_SIZE; ++i)
+ for(size_t i = 0; i != PRIME_TABLE_SIZE; ++i)
{
g = power_mod(PRIMES[i], e, p);
if(g > 1)
diff --git a/src/pubkey/dl_group/dl_group.h b/src/pubkey/dl_group/dl_group.h
index 885ccd2f9..bfc2c04e5 100644
--- a/src/pubkey/dl_group/dl_group.h
+++ b/src/pubkey/dl_group/dl_group.h
@@ -122,7 +122,7 @@ class BOTAN_DLL DL_Group
* the value determined according to pbits.
*/
DL_Group(RandomNumberGenerator& rng, PrimeType type,
- u32bit pbits, u32bit qbits = 0);
+ size_t pbits, size_t qbits = 0);
/**
* Create a DSA group with a given seed.
@@ -132,7 +132,7 @@ class BOTAN_DLL DL_Group
* @param qbits the desired bit size of the prime q.
*/
DL_Group(RandomNumberGenerator& rng, const MemoryRegion<byte>& seed,
- u32bit pbits = 1024, u32bit qbits = 0);
+ size_t pbits = 1024, size_t qbits = 0);
/**
* Create a DL group. The prime q will be determined according to p.
diff --git a/src/pubkey/dlies/dlies.cpp b/src/pubkey/dlies/dlies.cpp
index 80cf60ae3..7b890b5ef 100644
--- a/src/pubkey/dlies/dlies.cpp
+++ b/src/pubkey/dlies/dlies.cpp
@@ -16,7 +16,7 @@ namespace Botan {
DLIES_Encryptor::DLIES_Encryptor(const PK_Key_Agreement_Key& key,
KDF* kdf_obj,
MessageAuthenticationCode* mac_obj,
- u32bit mac_kl) :
+ size_t mac_kl) :
ka(key, "Raw"),
kdf(kdf_obj),
mac(mac_obj),
@@ -34,7 +34,7 @@ DLIES_Encryptor::~DLIES_Encryptor()
/*
* DLIES Encryption
*/
-SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length,
+SecureVector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
RandomNumberGenerator&) const
{
if(length > maximum_input_size())
@@ -49,7 +49,7 @@ SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length,
SecureVector<byte> vz = my_key;
vz += ka.derive_key(0, other_key).bits_of();
- const u32bit K_LENGTH = length + mac_keylen;
+ const size_t K_LENGTH = length + mac_keylen;
OctetString K = kdf->derive_key(K_LENGTH, vz);
if(K.length() != K_LENGTH)
@@ -60,7 +60,7 @@ SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length,
mac->set_key(K.begin(), mac_keylen);
mac->update(C, length);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t j = 0; j != 8; ++j)
mac->update(0);
mac->final(C + length);
@@ -79,7 +79,7 @@ void DLIES_Encryptor::set_other_key(const MemoryRegion<byte>& ok)
/*
* Return the max size, in bytes, of a message
*/
-u32bit DLIES_Encryptor::maximum_input_size() const
+size_t DLIES_Encryptor::maximum_input_size() const
{
return 32;
}
@@ -90,7 +90,7 @@ u32bit DLIES_Encryptor::maximum_input_size() const
DLIES_Decryptor::DLIES_Decryptor(const PK_Key_Agreement_Key& key,
KDF* kdf_obj,
MessageAuthenticationCode* mac_obj,
- u32bit mac_kl) :
+ size_t mac_kl) :
ka(key, "Raw"),
kdf(kdf_obj),
mac(mac_obj),
@@ -108,12 +108,12 @@ DLIES_Decryptor::~DLIES_Decryptor()
/*
* DLIES Decryption
*/
-SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], u32bit length) const
+SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], size_t length) const
{
if(length < my_key.size() + mac->OUTPUT_LENGTH)
throw Decoding_Error("DLIES decryption: ciphertext is too short");
- const u32bit CIPHER_LEN = length - my_key.size() - mac->OUTPUT_LENGTH;
+ const size_t CIPHER_LEN = length - my_key.size() - mac->OUTPUT_LENGTH;
SecureVector<byte> v(msg, my_key.size());
SecureVector<byte> C(msg + my_key.size(), CIPHER_LEN);
@@ -122,14 +122,14 @@ SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], u32bit length) const
SecureVector<byte> vz(msg, my_key.size());
vz += ka.derive_key(0, v).bits_of();
- const u32bit K_LENGTH = C.size() + mac_keylen;
+ const size_t K_LENGTH = C.size() + mac_keylen;
OctetString K = kdf->derive_key(K_LENGTH, vz);
if(K.length() != K_LENGTH)
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
mac->set_key(K.begin(), mac_keylen);
mac->update(C);
- for(u32bit j = 0; j != 8; ++j)
+ for(size_t j = 0; j != 8; ++j)
mac->update(0);
SecureVector<byte> T2 = mac->final();
if(T != T2)
diff --git a/src/pubkey/dlies/dlies.h b/src/pubkey/dlies/dlies.h
index ad8f36b40..8e5c05852 100644
--- a/src/pubkey/dlies/dlies.h
+++ b/src/pubkey/dlies/dlies.h
@@ -23,22 +23,22 @@ class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
DLIES_Encryptor(const PK_Key_Agreement_Key&,
KDF* kdf,
MessageAuthenticationCode* mac,
- u32bit mac_key_len = 20);
+ size_t mac_key_len = 20);
~DLIES_Encryptor();
void set_other_key(const MemoryRegion<byte>&);
private:
- SecureVector<byte> enc(const byte[], u32bit,
+ SecureVector<byte> enc(const byte[], size_t,
RandomNumberGenerator&) const;
- u32bit maximum_input_size() const;
+ size_t maximum_input_size() const;
SecureVector<byte> other_key, my_key;
PK_Key_Agreement ka;
KDF* kdf;
MessageAuthenticationCode* mac;
- u32bit mac_keylen;
+ size_t mac_keylen;
};
/**
@@ -50,19 +50,19 @@ class BOTAN_DLL DLIES_Decryptor : public PK_Decryptor
DLIES_Decryptor(const PK_Key_Agreement_Key&,
KDF* kdf,
MessageAuthenticationCode* mac,
- u32bit mac_key_len = 20);
+ size_t mac_key_len = 20);
~DLIES_Decryptor();
private:
- SecureVector<byte> dec(const byte[], u32bit) const;
+ SecureVector<byte> dec(const byte[], size_t) const;
SecureVector<byte> my_key;
PK_Key_Agreement ka;
KDF* kdf;
MessageAuthenticationCode* mac;
- u32bit mac_keylen;
+ size_t mac_keylen;
};
}
diff --git a/src/pubkey/dsa/dsa.cpp b/src/pubkey/dsa/dsa.cpp
index a3917b3d7..5e511840f 100644
--- a/src/pubkey/dsa/dsa.cpp
+++ b/src/pubkey/dsa/dsa.cpp
@@ -74,7 +74,7 @@ DSA_Signature_Operation::DSA_Signature_Operation(const DSA_PrivateKey& dsa) :
}
SecureVector<byte>
-DSA_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
rng.add_entropy(msg, msg_len);
@@ -108,8 +108,8 @@ DSA_Verification_Operation::DSA_Verification_Operation(const DSA_PublicKey& dsa)
mod_q = Modular_Reducer(dsa.group_q());
}
-bool DSA_Verification_Operation::verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len)
+bool DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len)
{
const BigInt& q = mod_q.get_modulus();
diff --git a/src/pubkey/dsa/dsa.h b/src/pubkey/dsa/dsa.h
index 65b6edd98..a41a8432c 100644
--- a/src/pubkey/dsa/dsa.h
+++ b/src/pubkey/dsa/dsa.h
@@ -24,9 +24,9 @@ class BOTAN_DLL DSA_PublicKey : public virtual DL_Scheme_PublicKey
std::string algo_name() const { return "DSA"; }
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; }
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return group_q().bytes(); }
- u32bit max_input_bits() const { return group_q().bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return group_q().bytes(); }
+ size_t max_input_bits() const { return group_q().bits(); }
DSA_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits) :
@@ -65,11 +65,11 @@ class BOTAN_DLL DSA_Signature_Operation : public PK_Ops::Signature
public:
DSA_Signature_Operation(const DSA_PrivateKey& dsa);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return q.bytes(); }
- u32bit max_input_bits() const { return q.bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return q.bytes(); }
+ size_t max_input_bits() const { return q.bits(); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const BigInt& q;
@@ -86,14 +86,14 @@ class BOTAN_DLL DSA_Verification_Operation : public PK_Ops::Verification
public:
DSA_Verification_Operation(const DSA_PublicKey& dsa);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return q.bytes(); }
- u32bit max_input_bits() const { return q.bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return q.bytes(); }
+ size_t max_input_bits() const { return q.bits(); }
bool with_recovery() const { return false; }
- bool verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len);
+ bool verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len);
private:
const BigInt& q;
const BigInt& y;
diff --git a/src/pubkey/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp
index c1b969103..f27185e84 100644
--- a/src/pubkey/ec_dompar/ec_dompar.cpp
+++ b/src/pubkey/ec_dompar/ec_dompar.cpp
@@ -96,10 +96,10 @@ EC_Domain_Params::DER_encode(EC_Domain_Params_Encoding form) const
{
if(form == EC_DOMPAR_ENC_EXPLICIT)
{
- u32bit ecpVers1 = 1;
+ const u32bit ecpVers1 = 1;
OID curve_type("1.2.840.10045.1.1");
- const u32bit p_bytes = curve.get_p().bytes();
+ const size_t p_bytes = curve.get_p().bytes();
return DER_Encoder()
.start_cons(SEQUENCE)
diff --git a/src/pubkey/ecdh/ecdh.cpp b/src/pubkey/ecdh/ecdh.cpp
index 2c78b65a6..656644370 100644
--- a/src/pubkey/ecdh/ecdh.cpp
+++ b/src/pubkey/ecdh/ecdh.cpp
@@ -20,7 +20,7 @@ ECDH_KA_Operation::ECDH_KA_Operation(const ECDH_PrivateKey& key) :
key.private_value();
}
-SecureVector<byte> ECDH_KA_Operation::agree(const byte w[], u32bit w_len)
+SecureVector<byte> ECDH_KA_Operation::agree(const byte w[], size_t w_len)
{
PointGFp point = OS2ECP(w, w_len, curve);
diff --git a/src/pubkey/ecdh/ecdh.h b/src/pubkey/ecdh/ecdh.h
index f0872c5cc..301bb1591 100644
--- a/src/pubkey/ecdh/ecdh.h
+++ b/src/pubkey/ecdh/ecdh.h
@@ -48,7 +48,7 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey
* @return maximum number of input bits
*/
- u32bit max_input_bits() const { return domain().get_order().bits(); }
+ size_t max_input_bits() const { return domain().get_order().bits(); }
/**
* @return public point value
@@ -94,7 +94,7 @@ class BOTAN_DLL ECDH_KA_Operation : public PK_Ops::Key_Agreement
public:
ECDH_KA_Operation(const ECDH_PrivateKey& key);
- SecureVector<byte> agree(const byte w[], u32bit w_len);
+ SecureVector<byte> agree(const byte w[], size_t w_len);
private:
const CurveGFp& curve;
const BigInt& cofactor;
diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp
index 2522fa9f3..9a3510c33 100644
--- a/src/pubkey/ecdsa/ecdsa.cpp
+++ b/src/pubkey/ecdsa/ecdsa.cpp
@@ -33,7 +33,7 @@ ECDSA_Signature_Operation::ECDSA_Signature_Operation(const ECDSA_PrivateKey& ecd
}
SecureVector<byte>
-ECDSA_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+ECDSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
rng.add_entropy(msg, msg_len);
@@ -69,8 +69,8 @@ ECDSA_Verification_Operation::ECDSA_Verification_Operation(const ECDSA_PublicKey
{
}
-bool ECDSA_Verification_Operation::verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len)
+bool ECDSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len)
{
if(sig_len != order.bytes()*2)
return false;
diff --git a/src/pubkey/ecdsa/ecdsa.h b/src/pubkey/ecdsa/ecdsa.h
index 7e7d85ab8..6d62a168d 100644
--- a/src/pubkey/ecdsa/ecdsa.h
+++ b/src/pubkey/ecdsa/ecdsa.h
@@ -47,11 +47,11 @@ class BOTAN_DLL ECDSA_PublicKey : public virtual EC_PublicKey
* This is the bitlength of the order of the base point.
* @result the maximum number of input bits
*/
- u32bit max_input_bits() const { return domain().get_order().bits(); }
+ size_t max_input_bits() const { return domain().get_order().bits(); }
- u32bit message_parts() const { return 2; }
+ size_t message_parts() const { return 2; }
- u32bit message_part_size() const
+ size_t message_part_size() const
{ return domain().get_order().bytes(); }
protected:
@@ -99,12 +99,12 @@ class BOTAN_DLL ECDSA_Signature_Operation : public PK_Ops::Signature
public:
ECDSA_Signature_Operation(const ECDSA_PrivateKey& ecdsa);
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return order.bytes(); }
- u32bit max_input_bits() const { return order.bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return order.bytes(); }
+ size_t max_input_bits() const { return order.bits(); }
private:
const PointGFp& base_point;
@@ -121,14 +121,14 @@ class BOTAN_DLL ECDSA_Verification_Operation : public PK_Ops::Verification
public:
ECDSA_Verification_Operation(const ECDSA_PublicKey& ecdsa);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return order.bytes(); }
- u32bit max_input_bits() const { return order.bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return order.bytes(); }
+ size_t max_input_bits() const { return order.bits(); }
bool with_recovery() const { return false; }
- bool verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len);
+ bool verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len);
private:
const PointGFp& base_point;
const PointGFp& public_point;
diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp
index 58336b1b1..6d15aed79 100644
--- a/src/pubkey/elgamal/elgamal.cpp
+++ b/src/pubkey/elgamal/elgamal.cpp
@@ -77,7 +77,7 @@ ElGamal_Encryption_Operation::ElGamal_Encryption_Operation(const ElGamal_PublicK
}
SecureVector<byte>
-ElGamal_Encryption_Operation::encrypt(const byte msg[], u32bit msg_len,
+ElGamal_Encryption_Operation::encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt& p = mod_p.get_modulus();
@@ -110,11 +110,11 @@ ElGamal_Decryption_Operation::ElGamal_Decryption_Operation(const ElGamal_Private
}
SecureVector<byte>
-ElGamal_Decryption_Operation::decrypt(const byte msg[], u32bit msg_len)
+ElGamal_Decryption_Operation::decrypt(const byte msg[], size_t msg_len)
{
const BigInt& p = mod_p.get_modulus();
- const u32bit p_bytes = p.bytes();
+ const size_t p_bytes = p.bytes();
if(msg_len != 2 * p_bytes)
throw Invalid_Argument("ElGamal decryption: Invalid message");
diff --git a/src/pubkey/elgamal/elgamal.h b/src/pubkey/elgamal/elgamal.h
index f9b52c7b8..383a4160b 100644
--- a/src/pubkey/elgamal/elgamal.h
+++ b/src/pubkey/elgamal/elgamal.h
@@ -25,7 +25,7 @@ class BOTAN_DLL ElGamal_PublicKey : public virtual DL_Scheme_PublicKey
std::string algo_name() const { return "ElGamal"; }
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; }
- u32bit max_input_bits() const { return (group_p().bits() - 1); }
+ size_t max_input_bits() const { return (group_p().bits() - 1); }
ElGamal_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits) :
@@ -61,11 +61,11 @@ class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
class BOTAN_DLL ElGamal_Encryption_Operation : public PK_Ops::Encryption
{
public:
- u32bit max_input_bits() const { return mod_p.get_modulus().bits() - 1; }
+ size_t max_input_bits() const { return mod_p.get_modulus().bits() - 1; }
ElGamal_Encryption_Operation(const ElGamal_PublicKey& key);
- SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
+ SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
@@ -79,11 +79,11 @@ class BOTAN_DLL ElGamal_Encryption_Operation : public PK_Ops::Encryption
class BOTAN_DLL ElGamal_Decryption_Operation : public PK_Ops::Decryption
{
public:
- u32bit max_input_bits() const { return mod_p.get_modulus().bits() - 1; }
+ size_t max_input_bits() const { return mod_p.get_modulus().bits() - 1; }
ElGamal_Decryption_Operation(const ElGamal_PrivateKey& key);
- SecureVector<byte> decrypt(const byte msg[], u32bit msg_len);
+ SecureVector<byte> decrypt(const byte msg[], size_t msg_len);
private:
Fixed_Exponent_Power_Mod powermod_x_p;
Modular_Reducer mod_p;
diff --git a/src/pubkey/gost_3410/gost_3410.cpp b/src/pubkey/gost_3410/gost_3410.cpp
index 50878634b..61693e01f 100644
--- a/src/pubkey/gost_3410/gost_3410.cpp
+++ b/src/pubkey/gost_3410/gost_3410.cpp
@@ -20,7 +20,7 @@ MemoryVector<byte> GOST_3410_PublicKey::x509_subject_public_key() const
const BigInt& x = public_point().get_affine_x();
const BigInt& y = public_point().get_affine_y();
- u32bit part_size = std::max(x.bytes(), y.bytes());
+ size_t part_size = std::max(x.bytes(), y.bytes());
MemoryVector<byte> bits(2*part_size);
@@ -28,7 +28,7 @@ MemoryVector<byte> GOST_3410_PublicKey::x509_subject_public_key() const
y.binary_encode(&bits[2*part_size - y.bytes()]);
// Keys are stored in little endian format (WTF)
- for(u32bit i = 0; i != part_size / 2; ++i)
+ for(size_t i = 0; i != part_size / 2; ++i)
{
std::swap(bits[i], bits[part_size-1-i]);
std::swap(bits[part_size+i], bits[2*part_size-1-i]);
@@ -61,10 +61,10 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
SecureVector<byte> bits;
BER_Decoder(key_bits).decode(bits, OCTET_STRING);
- const u32bit part_size = bits.size() / 2;
+ const size_t part_size = bits.size() / 2;
// Keys are stored in little endian format (WTF)
- for(u32bit i = 0; i != part_size / 2; ++i)
+ for(size_t i = 0; i != part_size / 2; ++i)
{
std::swap(bits[i], bits[part_size-1-i]);
std::swap(bits[part_size+i], bits[2*part_size-1-i]);
@@ -81,7 +81,7 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
namespace {
-BigInt decode_le(const byte msg[], u32bit msg_len)
+BigInt decode_le(const byte msg[], size_t msg_len)
{
SecureVector<byte> msg_le(msg, msg_len);
@@ -103,7 +103,7 @@ GOST_3410_Signature_Operation::GOST_3410_Signature_Operation(
}
SecureVector<byte>
-GOST_3410_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+GOST_3410_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
BigInt k;
@@ -142,8 +142,8 @@ GOST_3410_Verification_Operation::GOST_3410_Verification_Operation(const GOST_34
{
}
-bool GOST_3410_Verification_Operation::verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len)
+bool GOST_3410_Verification_Operation::verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len)
{
if(sig_len != order.bytes()*2)
return false;
diff --git a/src/pubkey/gost_3410/gost_3410.h b/src/pubkey/gost_3410/gost_3410.h
index 9d6a15386..4fb7b42c3 100644
--- a/src/pubkey/gost_3410/gost_3410.h
+++ b/src/pubkey/gost_3410/gost_3410.h
@@ -53,11 +53,11 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
* @result the maximum number of input bits
*/
- u32bit max_input_bits() const { return domain().get_order().bits(); }
+ size_t max_input_bits() const { return domain().get_order().bits(); }
- u32bit message_parts() const { return 2; }
+ size_t message_parts() const { return 2; }
- u32bit message_part_size() const
+ size_t message_part_size() const
{ return domain().get_order().bytes(); }
protected:
@@ -105,11 +105,11 @@ class BOTAN_DLL GOST_3410_Signature_Operation : public PK_Ops::Signature
public:
GOST_3410_Signature_Operation(const GOST_3410_PrivateKey& gost_3410);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return order.bytes(); }
- u32bit max_input_bits() const { return order.bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return order.bytes(); }
+ size_t max_input_bits() const { return order.bits(); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
@@ -126,14 +126,14 @@ class BOTAN_DLL GOST_3410_Verification_Operation : public PK_Ops::Verification
public:
GOST_3410_Verification_Operation(const GOST_3410_PublicKey& gost);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return order.bytes(); }
- u32bit max_input_bits() const { return order.bits(); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return order.bytes(); }
+ size_t max_input_bits() const { return order.bits(); }
bool with_recovery() const { return false; }
- bool verify(const byte msg[], u32bit msg_len,
- const byte sig[], u32bit sig_len);
+ bool verify(const byte msg[], size_t msg_len,
+ const byte sig[], size_t sig_len);
private:
const PointGFp& base_point;
const PointGFp& public_point;
diff --git a/src/pubkey/if_algo/if_algo.h b/src/pubkey/if_algo/if_algo.h
index d0a1ec197..b6683d30e 100644
--- a/src/pubkey/if_algo/if_algo.h
+++ b/src/pubkey/if_algo/if_algo.h
@@ -43,7 +43,7 @@ class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key
*/
const BigInt& get_e() const { return e; }
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
protected:
IF_Scheme_PublicKey() {}
diff --git a/src/pubkey/nr/nr.cpp b/src/pubkey/nr/nr.cpp
index 244a397ee..61cf7eb3f 100644
--- a/src/pubkey/nr/nr.cpp
+++ b/src/pubkey/nr/nr.cpp
@@ -80,7 +80,7 @@ NR_Signature_Operation::NR_Signature_Operation(const NR_PrivateKey& nr) :
}
SecureVector<byte>
-NR_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+NR_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
rng.add_entropy(msg, msg_len);
@@ -119,7 +119,7 @@ NR_Verification_Operation::NR_Verification_Operation(const NR_PublicKey& nr) :
}
SecureVector<byte>
-NR_Verification_Operation::verify_mr(const byte msg[], u32bit msg_len)
+NR_Verification_Operation::verify_mr(const byte msg[], size_t msg_len)
{
const BigInt& q = mod_q.get_modulus();
diff --git a/src/pubkey/nr/nr.h b/src/pubkey/nr/nr.h
index cd12001ad..0d426fb3a 100644
--- a/src/pubkey/nr/nr.h
+++ b/src/pubkey/nr/nr.h
@@ -25,9 +25,9 @@ class BOTAN_DLL NR_PublicKey : public virtual DL_Scheme_PublicKey
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; }
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return group_q().bytes(); }
- u32bit max_input_bits() const { return (group_q().bits() - 1); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return group_q().bytes(); }
+ size_t max_input_bits() const { return (group_q().bits() - 1); }
NR_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits);
@@ -63,11 +63,11 @@ class BOTAN_DLL NR_Signature_Operation : public PK_Ops::Signature
public:
NR_Signature_Operation(const NR_PrivateKey& nr);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return q.bytes(); }
- u32bit max_input_bits() const { return (q.bits() - 1); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return q.bytes(); }
+ size_t max_input_bits() const { return (q.bits() - 1); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const BigInt& q;
@@ -84,13 +84,13 @@ class BOTAN_DLL NR_Verification_Operation : public PK_Ops::Verification
public:
NR_Verification_Operation(const NR_PublicKey& nr);
- u32bit message_parts() const { return 2; }
- u32bit message_part_size() const { return q.bytes(); }
- u32bit max_input_bits() const { return (q.bits() - 1); }
+ size_t message_parts() const { return 2; }
+ size_t message_part_size() const { return q.bytes(); }
+ size_t max_input_bits() const { return (q.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len);
+ SecureVector<byte> verify_mr(const byte msg[], size_t msg_len);
private:
const BigInt& q;
const BigInt& y;
diff --git a/src/pubkey/pk_keys.h b/src/pubkey/pk_keys.h
index 8f086c617..770949b59 100644
--- a/src/pubkey/pk_keys.h
+++ b/src/pubkey/pk_keys.h
@@ -47,19 +47,19 @@ class BOTAN_DLL Public_Key
* Find out the number of message parts supported by this scheme.
* @return number of message parts
*/
- virtual u32bit message_parts() const { return 1; }
+ virtual size_t message_parts() const { return 1; }
/**
* Find out the message part size supported by this scheme/key.
* @return size of the message parts in bits
*/
- virtual u32bit message_part_size() const { return 0; }
+ virtual size_t message_part_size() const { return 0; }
/**
* Get the maximum message size in bits supported by this public key.
* @return maximum message size in bits
*/
- virtual u32bit max_input_bits() const = 0;
+ virtual size_t max_input_bits() const = 0;
/**
* @return X.509 AlgorithmIdentifier for this key
diff --git a/src/pubkey/pk_ops.h b/src/pubkey/pk_ops.h
index b15a8d8cd..51543cd33 100644
--- a/src/pubkey/pk_ops.h
+++ b/src/pubkey/pk_ops.h
@@ -21,9 +21,9 @@ namespace PK_Ops {
class BOTAN_DLL Encryption
{
public:
- virtual u32bit max_input_bits() const = 0;
+ virtual size_t max_input_bits() const = 0;
- virtual SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
+ virtual SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng) = 0;
virtual ~Encryption() {}
@@ -35,10 +35,10 @@ class BOTAN_DLL Encryption
class BOTAN_DLL Decryption
{
public:
- virtual u32bit max_input_bits() const = 0;
+ virtual size_t max_input_bits() const = 0;
virtual SecureVector<byte> decrypt(const byte msg[],
- u32bit msg_len) = 0;
+ size_t msg_len) = 0;
virtual ~Decryption() {}
};
@@ -53,19 +53,19 @@ class BOTAN_DLL Signature
* Find out the number of message parts supported by this scheme.
* @return number of message parts
*/
- virtual u32bit message_parts() const { return 1; }
+ virtual size_t message_parts() const { return 1; }
/**
* Find out the message part size supported by this scheme/key.
* @return size of the message parts
*/
- virtual u32bit message_part_size() const { return 0; }
+ virtual size_t message_part_size() const { return 0; }
/**
* Get the maximum message size in bits supported by this public key.
* @return maximum message in bits
*/
- virtual u32bit max_input_bits() const = 0;
+ virtual size_t max_input_bits() const = 0;
/*
* Perform a signature operation
@@ -73,7 +73,7 @@ class BOTAN_DLL Signature
* @param msg_len the length of msg in bytes
* @param rng a random number generator
*/
- virtual SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ virtual SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng) = 0;
virtual ~Signature() {}
@@ -89,19 +89,19 @@ class BOTAN_DLL Verification
* Get the maximum message size in bits supported by this public key.
* @return maximum message in bits
*/
- virtual u32bit max_input_bits() const = 0;
+ virtual size_t max_input_bits() const = 0;
/**
* Find out the number of message parts supported by this scheme.
* @return number of message parts
*/
- virtual u32bit message_parts() const { return 1; }
+ virtual size_t message_parts() const { return 1; }
/**
* Find out the message part size supported by this scheme/key.
* @return size of the message parts
*/
- virtual u32bit message_part_size() const { return 0; }
+ virtual size_t message_part_size() const { return 0; }
/**
* @return boolean specifying if this key type supports message
@@ -117,8 +117,8 @@ class BOTAN_DLL Verification
* @param sig_len the length of sig in bytes
* @returns if signature is a valid one for message
*/
- virtual bool verify(const byte[], u32bit,
- const byte[], u32bit)
+ virtual bool verify(const byte[], size_t,
+ const byte[], size_t)
{
throw Invalid_State("Message recovery required");
}
@@ -131,7 +131,7 @@ class BOTAN_DLL Verification
* @returns recovered message
*/
virtual SecureVector<byte> verify_mr(const byte[],
- u32bit)
+ size_t)
{
throw Invalid_State("Message recovery not supported");
}
@@ -151,7 +151,7 @@ class BOTAN_DLL Key_Agreement
* @param w_len the length of w in bytes
* @returns the agreed key
*/
- virtual SecureVector<byte> agree(const byte w[], u32bit w_len) = 0;
+ virtual SecureVector<byte> agree(const byte w[], size_t w_len) = 0;
virtual ~Key_Agreement() {}
};
diff --git a/src/pubkey/pkcs8.cpp b/src/pubkey/pkcs8.cpp
index 415aed790..4a43f4402 100644
--- a/src/pubkey/pkcs8.cpp
+++ b/src/pubkey/pkcs8.cpp
@@ -77,9 +77,9 @@ SecureVector<byte> PKCS8_decode(DataSource& source, const User_Interface& ui,
if(!is_encrypted)
key = key_data;
- const u32bit MAX_TRIES = 3;
+ const size_t MAX_TRIES = 3;
- u32bit tries = 0;
+ size_t tries = 0;
while(true)
{
try {
diff --git a/src/pubkey/pubkey.cpp b/src/pubkey/pubkey.cpp
index 3b7d81fb2..a5ec60df3 100644
--- a/src/pubkey/pubkey.cpp
+++ b/src/pubkey/pubkey.cpp
@@ -46,7 +46,7 @@ PK_Encryptor_EME::PK_Encryptor_EME(const Public_Key& key,
*/
SecureVector<byte>
PK_Encryptor_EME::enc(const byte msg[],
- u32bit length,
+ size_t length,
RandomNumberGenerator& rng) const
{
SecureVector<byte> message;
@@ -64,7 +64,7 @@ PK_Encryptor_EME::enc(const byte msg[],
/*
* Return the max size, in bytes, of a message
*/
-u32bit PK_Encryptor_EME::maximum_input_size() const
+size_t PK_Encryptor_EME::maximum_input_size() const
{
if(!eme)
return (op->max_input_bits() / 8);
@@ -98,7 +98,7 @@ PK_Decryptor_EME::PK_Decryptor_EME(const Private_Key& key,
* Decrypt a message
*/
SecureVector<byte> PK_Decryptor_EME::dec(const byte msg[],
- u32bit length) const
+ size_t length) const
{
try {
SecureVector<byte> decrypted = op->decrypt(msg, length);
@@ -149,7 +149,7 @@ PK_Signer::PK_Signer(const Private_Key& key,
/*
* Sign a message
*/
-SecureVector<byte> PK_Signer::sign_message(const byte msg[], u32bit length,
+SecureVector<byte> PK_Signer::sign_message(const byte msg[], size_t length,
RandomNumberGenerator& rng)
{
update(msg, length);
@@ -159,7 +159,7 @@ SecureVector<byte> PK_Signer::sign_message(const byte msg[], u32bit length,
/*
* Add more to the message to be signed
*/
-void PK_Signer::update(const byte in[], u32bit length)
+void PK_Signer::update(const byte in[], size_t length)
{
emsa->update(in, length);
}
@@ -180,7 +180,7 @@ bool PK_Signer::self_test_signature(const MemoryRegion<byte>& msg,
if(msg.size() > recovered.size())
{
- u32bit extra_0s = msg.size() - recovered.size();
+ size_t extra_0s = msg.size() - recovered.size();
for(size_t i = 0; i != extra_0s; ++i)
if(msg[i] != 0)
@@ -217,10 +217,10 @@ SecureVector<byte> PK_Signer::signature(RandomNumberGenerator& rng)
{
if(plain_sig.size() % op->message_parts())
throw Encoding_Error("PK_Signer: strange signature size found");
- const u32bit SIZE_OF_PART = plain_sig.size() / op->message_parts();
+ const size_t SIZE_OF_PART = plain_sig.size() / op->message_parts();
std::vector<BigInt> sig_parts(op->message_parts());
- for(u32bit j = 0; j != sig_parts.size(); ++j)
+ for(size_t j = 0; j != sig_parts.size(); ++j)
sig_parts[j].binary_decode(&plain_sig[SIZE_OF_PART*j], SIZE_OF_PART);
return DER_Encoder()
@@ -271,8 +271,8 @@ void PK_Verifier::set_input_format(Signature_Format format)
/*
* Verify a message
*/
-bool PK_Verifier::verify_message(const byte msg[], u32bit msg_length,
- const byte sig[], u32bit sig_length)
+bool PK_Verifier::verify_message(const byte msg[], size_t msg_length,
+ const byte sig[], size_t sig_length)
{
update(msg, msg_length);
return check_signature(sig, sig_length);
@@ -281,7 +281,7 @@ bool PK_Verifier::verify_message(const byte msg[], u32bit msg_length,
/*
* Append to the message
*/
-void PK_Verifier::update(const byte in[], u32bit length)
+void PK_Verifier::update(const byte in[], size_t length)
{
emsa->update(in, length);
}
@@ -289,7 +289,7 @@ void PK_Verifier::update(const byte in[], u32bit length)
/*
* Check a signature
*/
-bool PK_Verifier::check_signature(const byte sig[], u32bit length)
+bool PK_Verifier::check_signature(const byte sig[], size_t length)
{
try {
if(sig_format == IEEE_1363)
@@ -299,7 +299,7 @@ bool PK_Verifier::check_signature(const byte sig[], u32bit length)
BER_Decoder decoder(sig, length);
BER_Decoder ber_sig = decoder.start_cons(SEQUENCE);
- u32bit count = 0;
+ size_t count = 0;
SecureVector<byte> real_sig;
while(ber_sig.more_items())
{
@@ -326,7 +326,7 @@ bool PK_Verifier::check_signature(const byte sig[], u32bit length)
* Verify a signature
*/
bool PK_Verifier::validate_signature(const MemoryRegion<byte>& msg,
- const byte sig[], u32bit sig_len)
+ const byte sig[], size_t sig_len)
{
if(op->with_recovery())
{
@@ -366,9 +366,9 @@ PK_Key_Agreement::PK_Key_Agreement(const PK_Key_Agreement_Key& key,
kdf = (kdf_name == "Raw") ? 0 : get_kdf(kdf_name);
}
-SymmetricKey PK_Key_Agreement::derive_key(u32bit key_len, const byte in[],
- u32bit in_len, const byte params[],
- u32bit params_len) const
+SymmetricKey PK_Key_Agreement::derive_key(size_t key_len, const byte in[],
+ size_t in_len, const byte params[],
+ size_t params_len) const
{
SecureVector<byte> z = op->agree(in, in_len);
diff --git a/src/pubkey/pubkey.h b/src/pubkey/pubkey.h
index 2ea60fc86..cd813dc65 100644
--- a/src/pubkey/pubkey.h
+++ b/src/pubkey/pubkey.h
@@ -45,7 +45,7 @@ class BOTAN_DLL PK_Encryptor
* @param rng the random number source to use
* @return encrypted message
*/
- SecureVector<byte> encrypt(const byte in[], u32bit length,
+ SecureVector<byte> encrypt(const byte in[], size_t length,
RandomNumberGenerator& rng) const
{
return enc(in, length, rng);
@@ -67,7 +67,7 @@ class BOTAN_DLL PK_Encryptor
* Return the maximum allowed message size in bytes.
* @return maximum message size in bytes
*/
- virtual u32bit maximum_input_size() const = 0;
+ virtual size_t maximum_input_size() const = 0;
PK_Encryptor() {}
virtual ~PK_Encryptor() {}
@@ -75,7 +75,7 @@ class BOTAN_DLL PK_Encryptor
PK_Encryptor(const PK_Encryptor&) {}
PK_Encryptor& operator=(const PK_Encryptor&) { return *this; }
- virtual SecureVector<byte> enc(const byte[], u32bit,
+ virtual SecureVector<byte> enc(const byte[], size_t,
RandomNumberGenerator&) const = 0;
};
@@ -91,7 +91,7 @@ class BOTAN_DLL PK_Decryptor
* @param length the length of the above byte array
* @return decrypted message
*/
- SecureVector<byte> decrypt(const byte in[], u32bit length) const
+ SecureVector<byte> decrypt(const byte in[], size_t length) const
{
return dec(in, length);
}
@@ -112,7 +112,7 @@ class BOTAN_DLL PK_Decryptor
PK_Decryptor(const PK_Decryptor&) {}
PK_Decryptor& operator=(const PK_Decryptor&) { return *this; }
- virtual SecureVector<byte> dec(const byte[], u32bit) const = 0;
+ virtual SecureVector<byte> dec(const byte[], size_t) const = 0;
};
/**
@@ -130,7 +130,7 @@ class BOTAN_DLL PK_Signer
* @param rng the rng to use
* @return signature
*/
- SecureVector<byte> sign_message(const byte in[], u32bit length,
+ SecureVector<byte> sign_message(const byte in[], size_t length,
RandomNumberGenerator& rng);
/**
@@ -154,7 +154,7 @@ class BOTAN_DLL PK_Signer
* @param in the message part to add as a byte array
* @param length the length of the above byte array
*/
- void update(const byte in[], u32bit length);
+ void update(const byte in[], size_t length);
/**
* Add a message part.
@@ -219,8 +219,8 @@ class BOTAN_DLL PK_Verifier
* @param sig_length the length of the above byte array sig
* @return true if the signature is valid
*/
- bool verify_message(const byte msg[], u32bit msg_length,
- const byte sig[], u32bit sig_length);
+ bool verify_message(const byte msg[], size_t msg_length,
+ const byte sig[], size_t sig_length);
/**
* Verify a signature.
* @param msg the message that the signature belongs to
@@ -247,7 +247,7 @@ class BOTAN_DLL PK_Verifier
* @param msg_part the new message part as a byte array
* @param length the length of the above byte array
*/
- void update(const byte msg_part[], u32bit length);
+ void update(const byte msg_part[], size_t length);
/**
* Add a message part of the message corresponding to the
@@ -264,7 +264,7 @@ class BOTAN_DLL PK_Verifier
* @param length the length of the above byte array
* @return true if the signature is valid, false otherwise
*/
- bool check_signature(const byte sig[], u32bit length);
+ bool check_signature(const byte sig[], size_t length);
/**
* Check the signature of the buffered message, i.e. the one build
@@ -299,7 +299,7 @@ class BOTAN_DLL PK_Verifier
PK_Verifier& operator=(const PK_Verifier&) { return *this; }
bool validate_signature(const MemoryRegion<byte>& msg,
- const byte sig[], u32bit sig_len);
+ const byte sig[], size_t sig_len);
PK_Ops::Verification* op;
EMSA* emsa;
@@ -321,11 +321,11 @@ class BOTAN_DLL PK_Key_Agreement
* @param params extra derivation params
* @param params_len the length of params in bytes
*/
- SymmetricKey derive_key(u32bit key_len,
+ SymmetricKey derive_key(size_t key_len,
const byte in[],
- u32bit in_len,
+ size_t in_len,
const byte params[],
- u32bit params_len) const;
+ size_t params_len) const;
/*
* Perform Key Agreement Operation
@@ -335,10 +335,10 @@ class BOTAN_DLL PK_Key_Agreement
* @param params extra derivation params
* @param params_len the length of params in bytes
*/
- SymmetricKey derive_key(u32bit key_len,
+ SymmetricKey derive_key(size_t key_len,
const MemoryRegion<byte>& in,
const byte params[],
- u32bit params_len) const
+ size_t params_len) const
{
return derive_key(key_len, &in[0], in.size(),
params, params_len);
@@ -351,8 +351,8 @@ class BOTAN_DLL PK_Key_Agreement
* @param in_len the length of in in bytes
* @param params extra derivation params
*/
- SymmetricKey derive_key(u32bit key_len,
- const byte in[], u32bit in_len,
+ SymmetricKey derive_key(size_t key_len,
+ const byte in[], size_t in_len,
const std::string& params = "") const
{
return derive_key(key_len, in, in_len,
@@ -366,7 +366,7 @@ class BOTAN_DLL PK_Key_Agreement
* @param in the other parties key
* @param params extra derivation params
*/
- SymmetricKey derive_key(u32bit key_len,
+ SymmetricKey derive_key(size_t key_len,
const MemoryRegion<byte>& in,
const std::string& params = "") const
{
@@ -398,7 +398,7 @@ class BOTAN_DLL PK_Key_Agreement
class BOTAN_DLL PK_Encryptor_EME : public PK_Encryptor
{
public:
- u32bit maximum_input_size() const;
+ size_t maximum_input_size() const;
/**
* Construct an instance.
@@ -410,7 +410,7 @@ class BOTAN_DLL PK_Encryptor_EME : public PK_Encryptor
~PK_Encryptor_EME() { delete op; delete eme; }
private:
- SecureVector<byte> enc(const byte[], u32bit,
+ SecureVector<byte> enc(const byte[], size_t,
RandomNumberGenerator& rng) const;
PK_Ops::Encryption* op;
@@ -433,7 +433,7 @@ class BOTAN_DLL PK_Decryptor_EME : public PK_Decryptor
~PK_Decryptor_EME() { delete op; delete eme; }
private:
- SecureVector<byte> dec(const byte[], u32bit) const;
+ SecureVector<byte> dec(const byte[], size_t) const;
PK_Ops::Decryption* op;
const EME* eme;
diff --git a/src/pubkey/pubkey_enums.cpp b/src/pubkey/pubkey_enums.cpp
index 327107dd1..90d835814 100644
--- a/src/pubkey/pubkey_enums.cpp
+++ b/src/pubkey/pubkey_enums.cpp
@@ -31,7 +31,7 @@ void decode(BER_Decoder& source, Key_Constraints& key_usage)
obj.value[obj.value.size()-1] &= mask;
u16bit usage = 0;
- for(u32bit j = 1; j != obj.value.size(); ++j)
+ for(size_t j = 1; j != obj.value.size(); ++j)
usage = (obj.value[j] << 8) | usage;
key_usage = Key_Constraints(usage);
diff --git a/src/pubkey/rsa/rsa.cpp b/src/pubkey/rsa/rsa.cpp
index 54c8fed0b..40c3968af 100644
--- a/src/pubkey/rsa/rsa.cpp
+++ b/src/pubkey/rsa/rsa.cpp
@@ -18,7 +18,7 @@ namespace Botan {
* Create a RSA private key
*/
RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng,
- u32bit bits, u32bit exp)
+ size_t bits, size_t exp)
{
if(bits < 512)
throw Invalid_Argument(algo_name() + ": Can't make a key that is only " +
@@ -87,7 +87,7 @@ BigInt RSA_Private_Operation::private_op(const BigInt& m) const
}
SecureVector<byte>
-RSA_Private_Operation::sign(const byte msg[], u32bit msg_len,
+RSA_Private_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
/* We don't check signatures against powermod_e_n here because
@@ -104,7 +104,7 @@ RSA_Private_Operation::sign(const byte msg[], u32bit msg_len,
* RSA Decryption Operation
*/
SecureVector<byte>
-RSA_Private_Operation::decrypt(const byte msg[], u32bit msg_len)
+RSA_Private_Operation::decrypt(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
BigInt x = blinder.unblind(private_op(blinder.blind(m)));
diff --git a/src/pubkey/rsa/rsa.h b/src/pubkey/rsa/rsa.h
index f7700e08c..dddecdbed 100644
--- a/src/pubkey/rsa/rsa.h
+++ b/src/pubkey/rsa/rsa.h
@@ -80,7 +80,7 @@ class BOTAN_DLL RSA_PrivateKey : public RSA_PublicKey,
* @param exp the public exponent to be used
*/
RSA_PrivateKey(RandomNumberGenerator& rng,
- u32bit bits, u32bit exp = 65537);
+ size_t bits, size_t exp = 65537);
};
/**
@@ -92,12 +92,12 @@ class BOTAN_DLL RSA_Private_Operation : public PK_Ops::Signature,
public:
RSA_Private_Operation(const RSA_PrivateKey& rsa);
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
- SecureVector<byte> decrypt(const byte msg[], u32bit msg_len);
+ SecureVector<byte> decrypt(const byte msg[], size_t msg_len);
private:
BigInt private_op(const BigInt& m) const;
@@ -121,17 +121,17 @@ class BOTAN_DLL RSA_Public_Operation : public PK_Ops::Verification,
n(rsa.get_n()), powermod_e_n(rsa.get_e(), rsa.get_n())
{}
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
+ SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
return BigInt::encode_1363(public_op(m), n.bytes());
}
- SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len)
+ SecureVector<byte> verify_mr(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(public_op(m));
diff --git a/src/pubkey/rw/rw.cpp b/src/pubkey/rw/rw.cpp
index a9ca8eae7..5f58d8e88 100644
--- a/src/pubkey/rw/rw.cpp
+++ b/src/pubkey/rw/rw.cpp
@@ -17,7 +17,7 @@ namespace Botan {
* Create a Rabin-Williams private key
*/
RW_PrivateKey::RW_PrivateKey(RandomNumberGenerator& rng,
- u32bit bits, u32bit exp)
+ size_t bits, size_t exp)
{
if(bits < 512)
throw Invalid_Argument(algo_name() + ": Can't make a key that is only " +
@@ -71,7 +71,7 @@ RW_Signature_Operation::RW_Signature_Operation(const RW_PrivateKey& rw) :
}
SecureVector<byte>
-RW_Signature_Operation::sign(const byte msg[], u32bit msg_len,
+RW_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
if(!blinder.initialized())
@@ -102,7 +102,7 @@ RW_Signature_Operation::sign(const byte msg[], u32bit msg_len,
}
SecureVector<byte>
-RW_Verification_Operation::verify_mr(const byte msg[], u32bit msg_len)
+RW_Verification_Operation::verify_mr(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
diff --git a/src/pubkey/rw/rw.h b/src/pubkey/rw/rw.h
index 24f4ffab6..b8d92eb3a 100644
--- a/src/pubkey/rw/rw.h
+++ b/src/pubkey/rw/rw.h
@@ -54,7 +54,7 @@ class BOTAN_DLL RW_PrivateKey : public RW_PublicKey,
const BigInt& n = 0) :
IF_Scheme_PrivateKey(rng, p, q, e, d, n) {}
- RW_PrivateKey(RandomNumberGenerator& rng, u32bit bits, u32bit = 2);
+ RW_PrivateKey(RandomNumberGenerator& rng, size_t bits, size_t = 2);
bool check_key(RandomNumberGenerator& rng, bool) const;
};
@@ -67,9 +67,9 @@ class BOTAN_DLL RW_Signature_Operation : public PK_Ops::Signature
public:
RW_Signature_Operation(const RW_PrivateKey& rw);
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
- SecureVector<byte> sign(const byte msg[], u32bit msg_len,
+ SecureVector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const BigInt& n;
@@ -92,10 +92,10 @@ class BOTAN_DLL RW_Verification_Operation : public PK_Ops::Verification
n(rw.get_n()), powermod_e_n(rw.get_e(), rw.get_n())
{}
- u32bit max_input_bits() const { return (n.bits() - 1); }
+ size_t max_input_bits() const { return (n.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> verify_mr(const byte msg[], u32bit msg_len);
+ SecureVector<byte> verify_mr(const byte msg[], size_t msg_len);
private:
const BigInt& n;
diff --git a/src/pubkey/workfactor.cpp b/src/pubkey/workfactor.cpp
index f15c64783..a4d670c82 100644
--- a/src/pubkey/workfactor.cpp
+++ b/src/pubkey/workfactor.cpp
@@ -14,7 +14,7 @@ namespace Botan {
/*
* Choose the exponent size for a DL group
*/
-u32bit dl_work_factor(u32bit bits)
+size_t dl_work_factor(size_t bits)
{
#if 0
/*
@@ -34,16 +34,14 @@ u32bit dl_work_factor(u32bit bits)
return 190;
return 256;
#else
- const u32bit MIN_ESTIMATE = 64;
+ const size_t MIN_ESTIMATE = 64;
const double log_x = bits / 1.44;
const double strength =
2.76 * std::pow(log_x, 1.0/3.0) * std::pow(std::log(log_x), 2.0/3.0);
- if(strength > MIN_ESTIMATE)
- return static_cast<u32bit>(strength);
- return MIN_ESTIMATE;
+ return std::max<size_t>(strength, MIN_ESTIMATE);
#endif
}
diff --git a/src/pubkey/workfactor.h b/src/pubkey/workfactor.h
index c4fc3baa7..bd1a43298 100644
--- a/src/pubkey/workfactor.h
+++ b/src/pubkey/workfactor.h
@@ -17,7 +17,7 @@ namespace Botan {
* @param prime_group_size size of the group in bits
* @return estimated security level for this group
*/
-u32bit dl_work_factor(u32bit prime_group_size);
+size_t dl_work_factor(size_t prime_group_size);
}