aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/kdf/prf_x942/prf_x942.cpp
diff options
context:
space:
mode:
authorKai Michaelis <[email protected]>2016-06-01 11:57:42 +0200
committerKai Michaelis <[email protected]>2016-06-01 11:57:42 +0200
commitcf74d1c376df1d9e6400e264a1d059720eeaa059 (patch)
treeac16b3e568c59a710af79020c0fee96887a9c4df /src/lib/kdf/prf_x942/prf_x942.cpp
parent57a3f3272c96a83c5c87c36761caee83982be498 (diff)
make sure kdf labels are always used
Diffstat (limited to 'src/lib/kdf/prf_x942/prf_x942.cpp')
-rw-r--r--src/lib/kdf/prf_x942/prf_x942.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/kdf/prf_x942/prf_x942.cpp b/src/lib/kdf/prf_x942/prf_x942.cpp
index 3830c5775..206cf6ce6 100644
--- a/src/lib/kdf/prf_x942/prf_x942.cpp
+++ b/src/lib/kdf/prf_x942/prf_x942.cpp
@@ -31,15 +31,20 @@ std::vector<byte> encode_x942_int(u32bit n)
size_t X942_PRF::kdf(byte key[], size_t key_len,
const byte secret[], size_t secret_len,
const byte salt[], size_t salt_len,
- const byte[], size_t) const
+ const byte label[], size_t label_len) const
{
std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-160"));
const OID kek_algo(m_key_wrap_oid);
secure_vector<byte> h;
+ secure_vector<byte> in;
size_t offset = 0;
u32bit counter = 1;
+ in.reserve(salt_len + label_len);
+ in += std::make_pair(label,label_len);
+ in += std::make_pair(salt,salt_len);
+
while(offset != key_len && counter)
{
hash->update(secret, secret_len);
@@ -55,7 +60,7 @@ size_t X942_PRF::kdf(byte key[], size_t key_len,
.encode_if(salt_len != 0,
DER_Encoder()
.start_explicit(0)
- .encode(salt, salt_len, OCTET_STRING)
+ .encode(in, OCTET_STRING)
.end_explicit()
)