aboutsummaryrefslogtreecommitdiffstats
path: root/src/pbkdf
diff options
context:
space:
mode:
Diffstat (limited to 'src/pbkdf')
-rw-r--r--src/pbkdf/pbkdf2/pbkdf2.cpp7
-rw-r--r--src/pbkdf/pgps2k/pgp_s2k.cpp2
2 files changed, 5 insertions, 4 deletions
diff --git a/src/pbkdf/pbkdf2/pbkdf2.cpp b/src/pbkdf/pbkdf2/pbkdf2.cpp
index d234fa7f0..b1c7b2e07 100644
--- a/src/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/pbkdf/pbkdf2/pbkdf2.cpp
@@ -37,22 +37,23 @@ OctetString PKCS5_PBKDF2::derive_key(u32bit key_len,
byte* T = &key[0];
+ SecureVector<byte> U(mac->OUTPUT_LENGTH);
+
u32bit counter = 1;
while(key_len)
{
u32bit T_size = std::min(mac->OUTPUT_LENGTH, key_len);
- SecureVector<byte> U(mac->OUTPUT_LENGTH);
mac->update(salt, salt_size);
for(u32bit j = 0; j != 4; ++j)
mac->update(get_byte(j, counter));
- mac->final(U);
+ mac->final(&U[0]);
xor_buf(T, U, T_size);
for(u32bit j = 1; j != iterations; ++j)
{
mac->update(U);
- mac->final(U);
+ mac->final(&U[0]);
xor_buf(T, U, T_size);
}
diff --git a/src/pbkdf/pgps2k/pgp_s2k.cpp b/src/pbkdf/pgps2k/pgp_s2k.cpp
index db18adaf1..8ad8592c4 100644
--- a/src/pbkdf/pgps2k/pgp_s2k.cpp
+++ b/src/pbkdf/pgps2k/pgp_s2k.cpp
@@ -46,7 +46,7 @@ OctetString OpenPGP_S2K::derive_key(u32bit key_len,
}
hash_buf = hash->final();
- key.copy(generated, hash_buf, hash->OUTPUT_LENGTH);
+ key.copy(generated, &hash_buf[0], hash->OUTPUT_LENGTH);
generated += hash->OUTPUT_LENGTH;
++pass;
}