11#include "InternalCryptLib.h"
12#include <mbedtls/hkdf.h>
34 IN mbedtls_md_type_t MdType,
45 const mbedtls_md_info_t *md;
49 (KeySize > INT_MAX) || (SaltSize > INT_MAX) || (InfoSize > INT_MAX) || (OutSize > INT_MAX))
54 md = mbedtls_md_info_from_type (MdType);
57 Ret = mbedtls_hkdf (md, Salt, (UINT32)SaltSize, Key, (UINT32)KeySize, Info, (UINT32)InfoSize, Out, (UINT32)OutSize);
83 IN mbedtls_md_type_t MdType,
92 const mbedtls_md_info_t *md;
96 if ((Key ==
NULL) || (Salt ==
NULL) || (PrkOut ==
NULL) ||
97 (KeySize > INT_MAX) || (SaltSize > INT_MAX) || (PrkOutSize > INT_MAX))
104 case MBEDTLS_MD_SHA256:
107 case MBEDTLS_MD_SHA384:
110 case MBEDTLS_MD_SHA512:
117 if (PrkOutSize != MdSize) {
121 md = mbedtls_md_info_from_type (MdType);
124 Ret = mbedtls_hkdf_extract (md, Salt, (UINT32)SaltSize, Key, (UINT32)KeySize, PrkOut);
150 IN mbedtls_md_type_t MdType,
159 const mbedtls_md_info_t *md;
164 (PrkSize > INT_MAX) || (InfoSize > INT_MAX) || (OutSize > INT_MAX))
170 case MBEDTLS_MD_SHA256:
173 case MBEDTLS_MD_SHA384:
176 case MBEDTLS_MD_SHA512:
183 if (PrkSize != MdSize) {
187 md = mbedtls_md_info_from_type (MdType);
190 Ret = mbedtls_hkdf_expand (md, Prk, (UINT32)PrkSize, Info, (UINT32)InfoSize, Out, (UINT32)OutSize);
227 return HkdfMdExtractAndExpand (MBEDTLS_MD_SHA256, Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize);
255 return HkdfMdExtract (MBEDTLS_MD_SHA256, Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize);
283 return HkdfMdExpand (MBEDTLS_MD_SHA256, Prk, PrkSize, Info, InfoSize, Out, OutSize);
315 return HkdfMdExtractAndExpand (MBEDTLS_MD_SHA384, Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize);
343 return HkdfMdExtract (MBEDTLS_MD_SHA384, Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize);
371 return HkdfMdExpand (MBEDTLS_MD_SHA384, Prk, PrkSize, Info, InfoSize, Out, OutSize);
#define SHA512_DIGEST_SIZE
#define SHA256_DIGEST_SIZE
#define SHA384_DIGEST_SIZE
BOOLEAN EFIAPI HkdfSha256Extract(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, UINTN PrkOutSize)
STATIC BOOLEAN HkdfMdExpand(IN CONST EVP_MD *Md, 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)
STATIC BOOLEAN HkdfMdExtractAndExpand(IN CONST EVP_MD *Md, 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, UINTN PrkOutSize)
STATIC BOOLEAN HkdfMdExtract(IN CONST EVP_MD *Md, IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, 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 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 HkdfSha384Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)