TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptHkdf.c File Reference
#include "InternalCryptLib.h"
#include <mbedtls/hkdf.h>

Go to the source code of this file.

Functions

STATIC BOOLEAN HkdfMdExtractAndExpand (IN mbedtls_md_type_t MdType, IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
 
STATIC BOOLEAN HkdfMdExtract (IN mbedtls_md_type_t MdType, IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, IN UINTN PrkOutSize)
 
STATIC BOOLEAN HkdfMdExpand (IN mbedtls_md_type_t MdType, IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
 
BOOLEAN EFIAPI HkdfSha256ExtractAndExpand (IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
 
BOOLEAN EFIAPI HkdfSha256Extract (IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, IN UINTN PrkOutSize)
 
BOOLEAN EFIAPI HkdfSha256Expand (IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
 
BOOLEAN EFIAPI HkdfSha384ExtractAndExpand (IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
 
BOOLEAN EFIAPI HkdfSha384Extract (IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, IN UINTN PrkOutSize)
 
BOOLEAN EFIAPI HkdfSha384Expand (IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
 

Detailed Description

HMAC-SHA256 KDF Wrapper Implementation over MbedTLS.

RFC 5869: HMAC-based Extract-and-Expand Key Derivation Function (HKDF)

Copyright (c) 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CryptHkdf.c.

Function Documentation

◆ HkdfMdExpand()

STATIC BOOLEAN HkdfMdExpand ( IN mbedtls_md_type_t  MdType,
IN CONST UINT8 *  Prk,
IN UINTN  PrkSize,
IN CONST UINT8 *  Info,
IN UINTN  InfoSize,
OUT UINT8 *  Out,
IN UINTN  OutSize 
)

Derive HMAC-based Expand Key Derivation Function (HKDF).

Parameters
[in]MdTypeMessage Digest Type.
[in]PrkPointer to the user-supplied key.
[in]PrkSizeKey size in bytes.
[in]InfoPointer to the application specific info.
[in]InfoSizeInfo size in bytes.
[out]OutPointer to buffer to receive hkdf value.
[in]OutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 149 of file CryptHkdf.c.

◆ HkdfMdExtract()

STATIC BOOLEAN HkdfMdExtract ( IN mbedtls_md_type_t  MdType,
IN CONST UINT8 *  Key,
IN UINTN  KeySize,
IN CONST UINT8 *  Salt,
IN UINTN  SaltSize,
OUT UINT8 *  PrkOut,
IN UINTN  PrkOutSize 
)

Derive HMAC-based Extract Key Derivation Function (HKDF).

Parameters
[in]MdTypeMessage Digest Type.
[in]KeyPointer to the user-supplied key.
[in]KeySizeKey size in bytes.
[in]SaltPointer to the salt(non-secret) value.
[in]SaltSizeSalt size in bytes.
[out]PrkOutPointer to buffer to receive hkdf value.
[in]PrkOutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 82 of file CryptHkdf.c.

◆ HkdfMdExtractAndExpand()

STATIC BOOLEAN HkdfMdExtractAndExpand ( IN mbedtls_md_type_t  MdType,
IN CONST UINT8 *  Key,
IN UINTN  KeySize,
IN CONST UINT8 *  Salt,
IN UINTN  SaltSize,
IN CONST UINT8 *  Info,
IN UINTN  InfoSize,
OUT UINT8 *  Out,
IN UINTN  OutSize 
)

Derive HMAC-based Extract-and-Expand Key Derivation Function (HKDF).

Parameters
[in]MdTypeMessage Digest Type.
[in]KeyPointer to the user-supplied key.
[in]KeySizeKey size in bytes.
[in]SaltPointer to the salt(non-secret) value.
[in]SaltSizeSalt size in bytes.
[in]InfoPointer to the application specific info.
[in]InfoSizeInfo size in bytes.
[out]OutPointer to buffer to receive hkdf value.
[in]OutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 33 of file CryptHkdf.c.

◆ HkdfSha256Expand()

BOOLEAN EFIAPI HkdfSha256Expand ( IN CONST UINT8 *  Prk,
IN UINTN  PrkSize,
IN CONST UINT8 *  Info,
IN UINTN  InfoSize,
OUT UINT8 *  Out,
IN UINTN  OutSize 
)

Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF).

Parameters
[in]PrkPointer to the user-supplied key.
[in]PrkSizeKey size in bytes.
[in]InfoPointer to the application specific info.
[in]InfoSizeInfo size in bytes.
[out]OutPointer to buffer to receive hkdf value.
[in]OutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 274 of file CryptHkdf.c.

◆ HkdfSha256Extract()

BOOLEAN EFIAPI HkdfSha256Extract ( IN CONST UINT8 *  Key,
IN UINTN  KeySize,
IN CONST UINT8 *  Salt,
IN UINTN  SaltSize,
OUT UINT8 *  PrkOut,
IN UINTN  PrkOutSize 
)

Derive SHA256 HMAC-based Extract Key Derivation Function (HKDF).

Parameters
[in]KeyPointer to the user-supplied key.
[in]KeySizeKey size in bytes.
[in]SaltPointer to the salt(non-secret) value.
[in]SaltSizeSalt size in bytes.
[out]PrkOutPointer to buffer to receive hkdf value.
[in]PrkOutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 246 of file CryptHkdf.c.

◆ HkdfSha256ExtractAndExpand()

BOOLEAN EFIAPI HkdfSha256ExtractAndExpand ( IN CONST UINT8 *  Key,
IN UINTN  KeySize,
IN CONST UINT8 *  Salt,
IN UINTN  SaltSize,
IN CONST UINT8 *  Info,
IN UINTN  InfoSize,
OUT UINT8 *  Out,
IN UINTN  OutSize 
)

Derive SHA256 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).

Parameters
[in]KeyPointer to the user-supplied key.
[in]KeySizeKey size in bytes.
[in]SaltPointer to the salt(non-secret) value.
[in]SaltSizeSalt size in bytes.
[in]InfoPointer to the application specific info.
[in]InfoSizeInfo size in bytes.
[out]OutPointer to buffer to receive hkdf value.
[in]OutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 216 of file CryptHkdf.c.

◆ HkdfSha384Expand()

BOOLEAN EFIAPI HkdfSha384Expand ( IN CONST UINT8 *  Prk,
IN UINTN  PrkSize,
IN CONST UINT8 *  Info,
IN UINTN  InfoSize,
OUT UINT8 *  Out,
IN UINTN  OutSize 
)

Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF).

Parameters
[in]PrkPointer to the user-supplied key.
[in]PrkSizeKey size in bytes.
[in]InfoPointer to the application specific info.
[in]InfoSizeInfo size in bytes.
[out]OutPointer to buffer to receive hkdf value.
[in]OutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 362 of file CryptHkdf.c.

◆ HkdfSha384Extract()

BOOLEAN EFIAPI HkdfSha384Extract ( IN CONST UINT8 *  Key,
IN UINTN  KeySize,
IN CONST UINT8 *  Salt,
IN UINTN  SaltSize,
OUT UINT8 *  PrkOut,
IN UINTN  PrkOutSize 
)

Derive SHA384 HMAC-based Extract Key Derivation Function (HKDF).

Parameters
[in]KeyPointer to the user-supplied key.
[in]KeySizeKey size in bytes.
[in]SaltPointer to the salt(non-secret) value.
[in]SaltSizeSalt size in bytes.
[out]PrkOutPointer to buffer to receive hkdf value.
[in]PrkOutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 334 of file CryptHkdf.c.

◆ HkdfSha384ExtractAndExpand()

BOOLEAN EFIAPI HkdfSha384ExtractAndExpand ( IN CONST UINT8 *  Key,
IN UINTN  KeySize,
IN CONST UINT8 *  Salt,
IN UINTN  SaltSize,
IN CONST UINT8 *  Info,
IN UINTN  InfoSize,
OUT UINT8 *  Out,
IN UINTN  OutSize 
)

Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).

Parameters
[in]KeyPointer to the user-supplied key.
[in]KeySizeKey size in bytes.
[in]SaltPointer to the salt(non-secret) value.
[in]SaltSizeSalt size in bytes.
[in]InfoPointer to the application specific info.
[in]InfoSizeInfo size in bytes.
[out]OutPointer to buffer to receive hkdf value.
[in]OutSizeSize of hkdf bytes to generate.
Return values
TRUEHkdf generated successfully.
FALSEHkdf generation failed.

Definition at line 304 of file CryptHkdf.c.