aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pbkdf/pbkdf.h6
-rw-r--r--src/pbkdf/pbkdf1/pbkdf1.cpp10
-rw-r--r--src/pbkdf/pbkdf1/pbkdf1.h6
-rw-r--r--src/pbkdf/pbkdf2/pbkdf2.cpp14
-rw-r--r--src/pbkdf/pbkdf2/pbkdf2.h6
-rw-r--r--src/pbkdf/pgps2k/pgp_s2k.cpp14
-rw-r--r--src/pbkdf/pgps2k/pgp_s2k.h6
7 files changed, 31 insertions, 31 deletions
diff --git a/src/pbkdf/pbkdf.h b/src/pbkdf/pbkdf.h
index 675330843..91883f9e2 100644
--- a/src/pbkdf/pbkdf.h
+++ b/src/pbkdf/pbkdf.h
@@ -45,10 +45,10 @@ class BOTAN_DLL PBKDF
* @param salt_len length of salt in bytes
* @param iterations the number of iterations to use (use 10K or more)
*/
- virtual OctetString derive_key(u32bit output_len,
+ virtual OctetString derive_key(size_t output_len,
const std::string& passphrase,
- const byte salt[], u32bit salt_len,
- u32bit iterations) const = 0;
+ const byte salt[], size_t salt_len,
+ size_t iterations) const = 0;
PBKDF() {}
virtual ~PBKDF() {}
diff --git a/src/pbkdf/pbkdf1/pbkdf1.cpp b/src/pbkdf/pbkdf1/pbkdf1.cpp
index 20875ebc2..017153557 100644
--- a/src/pbkdf/pbkdf1/pbkdf1.cpp
+++ b/src/pbkdf/pbkdf1/pbkdf1.cpp
@@ -13,10 +13,10 @@ namespace Botan {
/*
* Return a PKCS#5 PBKDF1 derived key
*/
-OctetString PKCS5_PBKDF1::derive_key(u32bit key_len,
+OctetString PKCS5_PBKDF1::derive_key(size_t key_len,
const std::string& passphrase,
- const byte salt[], u32bit salt_size,
- u32bit iterations) const
+ const byte salt[], size_t salt_size,
+ size_t iterations) const
{
if(iterations == 0)
throw Invalid_Argument("PKCS5_PBKDF1: Invalid iteration count");
@@ -28,13 +28,13 @@ OctetString PKCS5_PBKDF1::derive_key(u32bit key_len,
hash->update(salt, salt_size);
SecureVector<byte> key = hash->final();
- for(u32bit j = 1; j != iterations; ++j)
+ for(size_t j = 1; j != iterations; ++j)
{
hash->update(key);
hash->final(&key[0]);
}
- return OctetString(&key[0], std::min<u32bit>(key_len, key.size()));
+ return OctetString(&key[0], std::min<size_t>(key_len, key.size()));
}
}
diff --git a/src/pbkdf/pbkdf1/pbkdf1.h b/src/pbkdf/pbkdf1/pbkdf1.h
index d10536f7e..f8e2dbe69 100644
--- a/src/pbkdf/pbkdf1/pbkdf1.h
+++ b/src/pbkdf/pbkdf1/pbkdf1.h
@@ -46,10 +46,10 @@ class BOTAN_DLL PKCS5_PBKDF1 : public PBKDF
return new PKCS5_PBKDF1(hash->clone());
}
- OctetString derive_key(u32bit output_len,
+ OctetString derive_key(size_t output_len,
const std::string& passphrase,
- const byte salt[], u32bit salt_len,
- u32bit iterations) const;
+ const byte salt[], size_t salt_len,
+ size_t iterations) const;
private:
HashFunction* hash;
};
diff --git a/src/pbkdf/pbkdf2/pbkdf2.cpp b/src/pbkdf/pbkdf2/pbkdf2.cpp
index 88131da01..5002f2ad6 100644
--- a/src/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/pbkdf/pbkdf2/pbkdf2.cpp
@@ -14,10 +14,10 @@ namespace Botan {
/*
* Return a PKCS #5 PBKDF2 derived key
*/
-OctetString PKCS5_PBKDF2::derive_key(u32bit key_len,
+OctetString PKCS5_PBKDF2::derive_key(size_t key_len,
const std::string& passphrase,
- const byte salt[], u32bit salt_size,
- u32bit iterations) const
+ const byte salt[], size_t salt_size,
+ size_t iterations) const
{
if(iterations == 0)
throw Invalid_Argument("PKCS#5 PBKDF2: Invalid iteration count");
@@ -42,15 +42,15 @@ OctetString PKCS5_PBKDF2::derive_key(u32bit key_len,
u32bit counter = 1;
while(key_len)
{
- u32bit T_size = std::min<u32bit>(mac->OUTPUT_LENGTH, key_len);
+ size_t T_size = std::min<size_t>(mac->OUTPUT_LENGTH, key_len);
mac->update(salt, salt_size);
- for(u32bit j = 0; j != 4; ++j)
- mac->update(get_byte(j, counter));
+ mac->update_be(counter);
mac->final(&U[0]);
+
xor_buf(T, U, T_size);
- for(u32bit j = 1; j != iterations; ++j)
+ for(size_t j = 1; j != iterations; ++j)
{
mac->update(U);
mac->final(&U[0]);
diff --git a/src/pbkdf/pbkdf2/pbkdf2.h b/src/pbkdf/pbkdf2/pbkdf2.h
index 8b50b4a67..26392bdad 100644
--- a/src/pbkdf/pbkdf2/pbkdf2.h
+++ b/src/pbkdf/pbkdf2/pbkdf2.h
@@ -29,10 +29,10 @@ class BOTAN_DLL PKCS5_PBKDF2 : public PBKDF
return new PKCS5_PBKDF2(mac->clone());
}
- OctetString derive_key(u32bit output_len,
+ OctetString derive_key(size_t output_len,
const std::string& passphrase,
- const byte salt[], u32bit salt_len,
- u32bit iterations) const;
+ const byte salt[], size_t salt_len,
+ size_t iterations) const;
/**
* Create a PKCS #5 instance using the specified message auth code
diff --git a/src/pbkdf/pgps2k/pgp_s2k.cpp b/src/pbkdf/pgps2k/pgp_s2k.cpp
index 8ad8592c4..98e05073e 100644
--- a/src/pbkdf/pgps2k/pgp_s2k.cpp
+++ b/src/pbkdf/pgps2k/pgp_s2k.cpp
@@ -12,24 +12,24 @@ namespace Botan {
/*
* Derive a key using the OpenPGP S2K algorithm
*/
-OctetString OpenPGP_S2K::derive_key(u32bit key_len,
+OctetString OpenPGP_S2K::derive_key(size_t key_len,
const std::string& passphrase,
- const byte salt_buf[], u32bit salt_size,
- u32bit iterations) const
+ const byte salt_buf[], size_t salt_size,
+ size_t iterations) const
{
SecureVector<byte> key(key_len), hash_buf;
- u32bit pass = 0, generated = 0,
+ size_t pass = 0, generated = 0,
total_size = passphrase.size() + salt_size;
- u32bit to_hash = std::max(iterations, total_size);
+ size_t to_hash = std::max(iterations, total_size);
hash->clear();
while(key_len > generated)
{
- for(u32bit j = 0; j != pass; ++j)
+ for(size_t j = 0; j != pass; ++j)
hash->update(0);
- u32bit left = to_hash;
+ size_t left = to_hash;
while(left >= total_size)
{
hash->update(salt_buf, salt_size);
diff --git a/src/pbkdf/pgps2k/pgp_s2k.h b/src/pbkdf/pgps2k/pgp_s2k.h
index 9fb09af5a..7620a6c84 100644
--- a/src/pbkdf/pgps2k/pgp_s2k.h
+++ b/src/pbkdf/pgps2k/pgp_s2k.h
@@ -36,10 +36,10 @@ class BOTAN_DLL OpenPGP_S2K : public PBKDF
return new OpenPGP_S2K(hash->clone());
}
- OctetString derive_key(u32bit output_len,
+ OctetString derive_key(size_t output_len,
const std::string& passphrase,
- const byte salt[], u32bit salt_len,
- u32bit iterations) const;
+ const byte salt[], size_t salt_len,
+ size_t iterations) const;
private:
HashFunction* hash;
};