diff options
Diffstat (limited to 'src/kdf')
-rw-r--r-- | src/kdf/kdf.cpp | 18 | ||||
-rw-r--r-- | src/kdf/kdf.h | 28 | ||||
-rw-r--r-- | src/kdf/kdf1/kdf1.cpp | 6 | ||||
-rw-r--r-- | src/kdf/kdf1/kdf1.h | 6 | ||||
-rw-r--r-- | src/kdf/kdf2/kdf2.cpp | 12 | ||||
-rw-r--r-- | src/kdf/kdf2/kdf2.h | 4 | ||||
-rw-r--r-- | src/kdf/mgf1/mgf1.cpp | 10 | ||||
-rw-r--r-- | src/kdf/mgf1/mgf1.h | 2 | ||||
-rw-r--r-- | src/kdf/ssl_prf/prf_ssl3.cpp | 16 | ||||
-rw-r--r-- | src/kdf/ssl_prf/prf_ssl3.h | 4 | ||||
-rw-r--r-- | src/kdf/tls_prf/prf_tls.cpp | 24 | ||||
-rw-r--r-- | src/kdf/tls_prf/prf_tls.h | 12 | ||||
-rw-r--r-- | src/kdf/x942_prf/prf_x942.cpp | 8 | ||||
-rw-r--r-- | src/kdf/x942_prf/prf_x942.h | 4 |
14 files changed, 77 insertions, 77 deletions
diff --git a/src/kdf/kdf.cpp b/src/kdf/kdf.cpp index 04f44f2f4..6281f753c 100644 --- a/src/kdf/kdf.cpp +++ b/src/kdf/kdf.cpp @@ -12,7 +12,7 @@ namespace Botan { /* * Derive a key */ -SecureVector<byte> KDF::derive_key(u32bit key_len, +SecureVector<byte> KDF::derive_key(size_t key_len, const MemoryRegion<byte>& secret, const std::string& salt) const { @@ -24,9 +24,9 @@ SecureVector<byte> KDF::derive_key(u32bit key_len, /* * Derive a key */ -SecureVector<byte> KDF::derive_key(u32bit key_len, +SecureVector<byte> KDF::derive_key(size_t key_len, const MemoryRegion<byte>& secret, - const byte salt[], u32bit salt_len) const + const byte salt[], size_t salt_len) const { return derive_key(key_len, &secret[0], secret.size(), salt, salt_len); @@ -35,7 +35,7 @@ SecureVector<byte> KDF::derive_key(u32bit key_len, /* * Derive a key */ -SecureVector<byte> KDF::derive_key(u32bit key_len, +SecureVector<byte> KDF::derive_key(size_t key_len, const MemoryRegion<byte>& secret, const MemoryRegion<byte>& salt) const { @@ -46,8 +46,8 @@ SecureVector<byte> KDF::derive_key(u32bit key_len, /* * Derive a key */ -SecureVector<byte> KDF::derive_key(u32bit key_len, - const byte secret[], u32bit secret_len, +SecureVector<byte> KDF::derive_key(size_t key_len, + const byte secret[], size_t secret_len, const std::string& salt) const { return derive_key(key_len, secret, secret_len, @@ -58,9 +58,9 @@ SecureVector<byte> KDF::derive_key(u32bit key_len, /* * Derive a key */ -SecureVector<byte> KDF::derive_key(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte salt[], u32bit salt_len) const +SecureVector<byte> KDF::derive_key(size_t key_len, + const byte secret[], size_t secret_len, + const byte salt[], size_t salt_len) const { return derive(key_len, secret, secret_len, salt, salt_len); } diff --git a/src/kdf/kdf.h b/src/kdf/kdf.h index ecf7f4621..58d59d351 100644 --- a/src/kdf/kdf.h +++ b/src/kdf/kdf.h @@ -25,7 +25,7 @@ class BOTAN_DLL KDF * @param secret the secret input * @param salt a diversifier */ - SecureVector<byte> derive_key(u32bit key_len, + SecureVector<byte> derive_key(size_t key_len, const MemoryRegion<byte>& secret, const std::string& salt = "") const; @@ -35,7 +35,7 @@ class BOTAN_DLL KDF * @param secret the secret input * @param salt a diversifier */ - SecureVector<byte> derive_key(u32bit key_len, + SecureVector<byte> derive_key(size_t key_len, const MemoryRegion<byte>& secret, const MemoryRegion<byte>& salt) const; @@ -46,10 +46,10 @@ class BOTAN_DLL KDF * @param salt a diversifier * @param salt_len size of salt in bytes */ - SecureVector<byte> derive_key(u32bit key_len, + SecureVector<byte> derive_key(size_t key_len, const MemoryRegion<byte>& secret, const byte salt[], - u32bit salt_len) const; + size_t salt_len) const; /** * Derive a key @@ -58,9 +58,9 @@ class BOTAN_DLL KDF * @param secret_len size of secret in bytes * @param salt a diversifier */ - SecureVector<byte> derive_key(u32bit key_len, + SecureVector<byte> derive_key(size_t key_len, const byte secret[], - u32bit secret_len, + size_t secret_len, const std::string& salt = "") const; /** @@ -71,18 +71,18 @@ class BOTAN_DLL KDF * @param salt a diversifier * @param salt_len size of salt in bytes */ - SecureVector<byte> derive_key(u32bit key_len, + SecureVector<byte> derive_key(size_t key_len, const byte secret[], - u32bit secret_len, + size_t secret_len, const byte salt[], - u32bit salt_len) const; + size_t salt_len) const; virtual ~KDF() {} private: virtual SecureVector<byte> - derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte salt[], u32bit salt_len) const = 0; + derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte salt[], size_t salt_len) const = 0; }; /** @@ -91,8 +91,8 @@ class BOTAN_DLL KDF class BOTAN_DLL MGF { public: - virtual void mask(const byte in[], u32bit in_len, - byte out[], u32bit out_len) const = 0; + virtual void mask(const byte in[], size_t in_len, + byte out[], size_t out_len) const = 0; virtual ~MGF() {} }; diff --git a/src/kdf/kdf1/kdf1.cpp b/src/kdf/kdf1/kdf1.cpp index 539d9ed50..f3e4e208f 100644 --- a/src/kdf/kdf1/kdf1.cpp +++ b/src/kdf/kdf1/kdf1.cpp @@ -12,9 +12,9 @@ namespace Botan { /* * KDF1 Key Derivation Mechanism */ -SecureVector<byte> KDF1::derive(u32bit, - const byte secret[], u32bit secret_len, - const byte P[], u32bit P_len) const +SecureVector<byte> KDF1::derive(size_t, + const byte secret[], size_t secret_len, + const byte P[], size_t P_len) const { hash->update(secret, secret_len); hash->update(P, P_len); diff --git a/src/kdf/kdf1/kdf1.h b/src/kdf/kdf1/kdf1.h index 80ea470a9..fd950cd9b 100644 --- a/src/kdf/kdf1/kdf1.h +++ b/src/kdf/kdf1/kdf1.h @@ -19,9 +19,9 @@ namespace Botan { class BOTAN_DLL KDF1 : public KDF { public: - SecureVector<byte> derive(u32bit, - const byte secret[], u32bit secret_len, - const byte P[], u32bit P_len) const; + SecureVector<byte> derive(size_t, + const byte secret[], size_t secret_len, + const byte P[], size_t P_len) const; KDF1(HashFunction* h) : hash(h) {} KDF1(const KDF1& other) : KDF(), hash(other.hash->clone()) {} diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp index 14cc29a31..b10077e35 100644 --- a/src/kdf/kdf2/kdf2.cpp +++ b/src/kdf/kdf2/kdf2.cpp @@ -13,9 +13,9 @@ namespace Botan { /* * KDF2 Key Derivation Mechanism */ -SecureVector<byte> KDF2::derive(u32bit out_len, - const byte secret[], u32bit secret_len, - const byte P[], u32bit P_len) const +SecureVector<byte> KDF2::derive(size_t out_len, + const byte secret[], size_t secret_len, + const byte P[], size_t P_len) const { SecureVector<byte> output; u32bit counter = 1; @@ -23,12 +23,12 @@ SecureVector<byte> KDF2::derive(u32bit out_len, while(out_len && counter) { hash->update(secret, secret_len); - for(u32bit j = 0; j != 4; ++j) - hash->update(get_byte(j, counter)); + for(size_t i = 0; i != 4; ++i) + hash->update(get_byte(i, counter)); hash->update(P, P_len); SecureVector<byte> hash_result = hash->final(); - u32bit added = std::min<u32bit>(hash_result.size(), out_len); + size_t added = std::min(hash_result.size(), out_len); output += std::make_pair(&hash_result[0], added); out_len -= added; diff --git a/src/kdf/kdf2/kdf2.h b/src/kdf/kdf2/kdf2.h index 1f01008c0..f2fd7630d 100644 --- a/src/kdf/kdf2/kdf2.h +++ b/src/kdf/kdf2/kdf2.h @@ -19,8 +19,8 @@ namespace Botan { class BOTAN_DLL KDF2 : public KDF { public: - SecureVector<byte> derive(u32bit, const byte[], u32bit, - const byte[], u32bit) const; + SecureVector<byte> derive(size_t, const byte[], size_t, + const byte[], size_t) const; KDF2(HashFunction* h) : hash(h) {} KDF2(const KDF2& other) : KDF(), hash(other.hash->clone()) {} diff --git a/src/kdf/mgf1/mgf1.cpp b/src/kdf/mgf1/mgf1.cpp index c79ae44bb..6dc028bad 100644 --- a/src/kdf/mgf1/mgf1.cpp +++ b/src/kdf/mgf1/mgf1.cpp @@ -17,19 +17,19 @@ namespace Botan { /* * MGF1 Mask Generation Function */ -void MGF1::mask(const byte in[], u32bit in_len, byte out[], - u32bit out_len) const +void MGF1::mask(const byte in[], size_t in_len, byte out[], + size_t out_len) const { u32bit counter = 0; while(out_len) { hash->update(in, in_len); - for(u32bit j = 0; j != 4; ++j) - hash->update(get_byte(j, counter)); + for(size_t i = 0; i != 4; ++i) + hash->update(get_byte(i, counter)); SecureVector<byte> buffer = hash->final(); - u32bit xored = std::min<u32bit>(buffer.size(), out_len); + size_t xored = std::min<size_t>(buffer.size(), out_len); xor_buf(out, &buffer[0], xored); out += xored; out_len -= xored; diff --git a/src/kdf/mgf1/mgf1.h b/src/kdf/mgf1/mgf1.h index 2f7655fe2..95a2a2bc5 100644 --- a/src/kdf/mgf1/mgf1.h +++ b/src/kdf/mgf1/mgf1.h @@ -19,7 +19,7 @@ namespace Botan { class BOTAN_DLL MGF1 : public MGF { public: - void mask(const byte[], u32bit, byte[], u32bit) const; + void mask(const byte[], size_t, byte[], size_t) const; /** MGF1 constructor: takes ownership of hash diff --git a/src/kdf/ssl_prf/prf_ssl3.cpp b/src/kdf/ssl_prf/prf_ssl3.cpp index 952158378..27afd9744 100644 --- a/src/kdf/ssl_prf/prf_ssl3.cpp +++ b/src/kdf/ssl_prf/prf_ssl3.cpp @@ -20,16 +20,16 @@ namespace { /* * Return the next inner hash */ -OctetString next_hash(u32bit where, u32bit want, +OctetString next_hash(size_t where, size_t want, HashFunction& md5, HashFunction& sha1, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) { BOTAN_ASSERT(want <= md5.OUTPUT_LENGTH, "Desired output too large"); const byte ASCII_A_CHAR = 0x41; - for(u32bit j = 0; j != where + 1; j++) + for(size_t j = 0; j != where + 1; j++) sha1.update(ASCII_A_CHAR + where); sha1.update(secret, secret_len); sha1.update(seed, seed_len); @@ -47,9 +47,9 @@ OctetString next_hash(u32bit where, u32bit want, /* * SSL3 PRF */ -SecureVector<byte> SSL3_PRF::derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) const +SecureVector<byte> SSL3_PRF::derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) const { if(key_len > 416) throw Invalid_Argument("SSL3_PRF: Requested key length is too large"); @@ -62,7 +62,7 @@ SecureVector<byte> SSL3_PRF::derive(u32bit key_len, int counter = 0; while(key_len) { - const u32bit produce = std::min(key_len, md5.OUTPUT_LENGTH); + const size_t produce = std::min<size_t>(key_len, md5.OUTPUT_LENGTH); output = output + next_hash(counter++, produce, md5, sha1, secret, secret_len, seed, seed_len); diff --git a/src/kdf/ssl_prf/prf_ssl3.h b/src/kdf/ssl_prf/prf_ssl3.h index 7d968eda1..1340b149e 100644 --- a/src/kdf/ssl_prf/prf_ssl3.h +++ b/src/kdf/ssl_prf/prf_ssl3.h @@ -18,8 +18,8 @@ namespace Botan { class BOTAN_DLL SSL3_PRF : public KDF { public: - SecureVector<byte> derive(u32bit, const byte[], u32bit, - const byte[], u32bit) const; + SecureVector<byte> derive(size_t, const byte[], size_t, + const byte[], size_t) const; }; } diff --git a/src/kdf/tls_prf/prf_tls.cpp b/src/kdf/tls_prf/prf_tls.cpp index fa4552474..97e952b0a 100644 --- a/src/kdf/tls_prf/prf_tls.cpp +++ b/src/kdf/tls_prf/prf_tls.cpp @@ -20,19 +20,19 @@ namespace { */ void P_hash(MemoryRegion<byte>& output, MessageAuthenticationCode* mac, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) { mac->set_key(secret, secret_len); SecureVector<byte> A(seed, seed_len); - u32bit offset = 0; + size_t offset = 0; while(offset != output.size()) { - const u32bit this_block_len = - std::min<u32bit>(mac->OUTPUT_LENGTH, output.size() - offset); + const size_t this_block_len = + std::min<size_t>(mac->OUTPUT_LENGTH, output.size() - offset); A = mac->process(A); @@ -65,13 +65,13 @@ TLS_PRF::~TLS_PRF() /* * TLS PRF */ -SecureVector<byte> TLS_PRF::derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) const +SecureVector<byte> TLS_PRF::derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) const { SecureVector<byte> output(key_len); - u32bit S1_len = (secret_len + 1) / 2, + size_t S1_len = (secret_len + 1) / 2, S2_len = (secret_len + 1) / 2; const byte* S1 = secret; const byte* S2 = secret + (secret_len - S2_len); @@ -95,9 +95,9 @@ TLS_12_PRF::~TLS_12_PRF() delete hmac; } -SecureVector<byte> TLS_12_PRF::derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) const +SecureVector<byte> TLS_12_PRF::derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) const { SecureVector<byte> output(key_len); diff --git a/src/kdf/tls_prf/prf_tls.h b/src/kdf/tls_prf/prf_tls.h index c7ad81a97..ee1b29df6 100644 --- a/src/kdf/tls_prf/prf_tls.h +++ b/src/kdf/tls_prf/prf_tls.h @@ -20,9 +20,9 @@ namespace Botan { class BOTAN_DLL TLS_PRF : public KDF { public: - SecureVector<byte> derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) const; + SecureVector<byte> derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) const; TLS_PRF(); ~TLS_PRF(); @@ -37,9 +37,9 @@ class BOTAN_DLL TLS_PRF : public KDF class BOTAN_DLL TLS_12_PRF : public KDF { public: - SecureVector<byte> derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) const; + SecureVector<byte> derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte seed[], size_t seed_len) const; TLS_12_PRF(HashFunction* hash); ~TLS_12_PRF(); diff --git a/src/kdf/x942_prf/prf_x942.cpp b/src/kdf/x942_prf/prf_x942.cpp index 35402ad28..966d883b6 100644 --- a/src/kdf/x942_prf/prf_x942.cpp +++ b/src/kdf/x942_prf/prf_x942.cpp @@ -32,9 +32,9 @@ MemoryVector<byte> encode_x942_int(u32bit n) /* * X9.42 PRF */ -SecureVector<byte> X942_PRF::derive(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte salt[], u32bit salt_len) const +SecureVector<byte> X942_PRF::derive(size_t key_len, + const byte secret[], size_t secret_len, + const byte salt[], size_t salt_len) const { SHA_160 hash; const OID kek_algo(key_wrap_oid); @@ -69,7 +69,7 @@ SecureVector<byte> X942_PRF::derive(u32bit key_len, ); SecureVector<byte> digest = hash.final(); - const u32bit needed = std::min(digest.size(), key_len - key.size()); + const size_t needed = std::min(digest.size(), key_len - key.size()); key += std::make_pair(&digest[0], needed); ++counter; diff --git a/src/kdf/x942_prf/prf_x942.h b/src/kdf/x942_prf/prf_x942.h index a5fe9f351..8efc6ea45 100644 --- a/src/kdf/x942_prf/prf_x942.h +++ b/src/kdf/x942_prf/prf_x942.h @@ -18,8 +18,8 @@ namespace Botan { class BOTAN_DLL X942_PRF : public KDF { public: - SecureVector<byte> derive(u32bit, const byte[], u32bit, - const byte[], u32bit) const; + SecureVector<byte> derive(size_t, const byte[], size_t, + const byte[], size_t) const; X942_PRF(const std::string&); private: |