crypto: Adapt kdf_t interface to support KDFs with fixed output length

This commit is contained in:
Tobias Brunner
2022-04-14 19:02:56 +02:00
parent 96c7692661
commit 7bde56a9bc
7 changed files with 89 additions and 1 deletions
@@ -71,6 +71,12 @@ METHOD(kdf_t, get_type, key_derivation_function_t,
return KDF_PRF_PLUS;
}
METHOD(kdf_t, get_length, size_t,
private_kdf_t *this)
{
return SIZE_MAX;
}
METHOD(kdf_t, get_bytes, bool,
private_kdf_t *this, size_t out_len, uint8_t *buffer)
{
@@ -162,6 +168,7 @@ kdf_t *botan_kdf_create(key_derivation_function_t algo, va_list args)
INIT(this,
.public = {
.get_type = _get_type,
.get_length = _get_length,
.get_bytes = _get_bytes,
.allocate_bytes = _allocate_bytes,
.set_param = _set_param,
@@ -51,6 +51,12 @@ METHOD(kdf_t, get_type, key_derivation_function_t,
return KDF_PRF_PLUS;
}
METHOD(kdf_t, get_length, size_t,
private_kdf_t *this)
{
return SIZE_MAX;
}
METHOD(kdf_t, get_bytes, bool,
private_kdf_t *this, size_t out_len, uint8_t *buffer)
{
@@ -156,6 +162,7 @@ kdf_t *kdf_prf_plus_create(key_derivation_function_t algo, va_list args)
INIT(this,
.public = {
.get_type = _get_type,
.get_length = _get_length,
.get_bytes = _get_bytes,
.allocate_bytes = _allocate_bytes,
.set_param = _set_param,
@@ -66,6 +66,12 @@ METHOD(kdf_t, get_type, key_derivation_function_t,
return KDF_PRF_PLUS;
}
METHOD(kdf_t, get_length, size_t,
private_kdf_t *this)
{
return SIZE_MAX;
}
METHOD(kdf_t, get_bytes, bool,
private_kdf_t *this, size_t out_len, uint8_t *buffer)
{
@@ -153,6 +159,7 @@ kdf_t *openssl_kdf_create(key_derivation_function_t algo, va_list args)
INIT(this,
.public = {
.get_type = _get_type,
.get_length = _get_length,
.get_bytes = _get_bytes,
.allocate_bytes = _allocate_bytes,
.set_param = _set_param,
@@ -64,6 +64,12 @@ METHOD(kdf_t, get_type, key_derivation_function_t,
return KDF_PRF_PLUS;
}
METHOD(kdf_t, get_length, size_t,
private_kdf_t *this)
{
return SIZE_MAX;
}
METHOD(kdf_t, get_bytes, bool,
private_kdf_t *this, size_t out_len, uint8_t *buffer)
{
@@ -141,6 +147,7 @@ kdf_t *wolfssl_kdf_create(key_derivation_function_t algo, va_list args)
INIT(this,
.public = {
.get_type = _get_type,
.get_length = _get_length,
.get_bytes = _get_bytes,
.allocate_bytes = _allocate_bytes,
.set_param = _set_param,