TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptPkcs5Pbkdf2.c File Reference
#include "InternalCryptLib.h"
#include <openssl/evp.h>
#include <openssl/hmac.h>

Go to the source code of this file.

Functions

BOOLEAN EFIAPI Pkcs5HashPassword (IN UINTN PasswordLength, IN CONST CHAR8 *Password, IN UINTN SaltLength, IN CONST UINT8 *Salt, IN UINTN IterationCount, IN UINTN DigestSize, IN UINTN KeyLength, OUT UINT8 *OutKey)
 

Detailed Description

PBKDF2 Key Derivation Function Wrapper Implementation over OpenSSL.

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

Definition in file CryptPkcs5Pbkdf2.c.

Function Documentation

◆ Pkcs5HashPassword()

BOOLEAN EFIAPI Pkcs5HashPassword ( IN UINTN  PasswordLength,
IN CONST CHAR8 *  Password,
IN UINTN  SaltLength,
IN CONST UINT8 *  Salt,
IN UINTN  IterationCount,
IN UINTN  DigestSize,
IN UINTN  KeyLength,
OUT UINT8 *  OutKey 
)

Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0 password based encryption key derivation function PBKDF2, as specified in RFC 2898.

If Password or Salt or OutKey is NULL, then return FALSE. If the hash algorithm could not be determined, then return FALSE.

Parameters
[in]PasswordLengthLength of input password in bytes.
[in]PasswordPointer to the array for the password.
[in]SaltLengthSize of the Salt in bytes.
[in]SaltPointer to the Salt.
[in]IterationCountNumber of iterations to perform. Its value should be greater than or equal to 1.
[in]DigestSizeSize of the message digest to be used (eg. SHA256_DIGEST_SIZE). NOTE: DigestSize will be used to determine the hash algorithm. Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.
[in]KeyLengthSize of the derived key buffer in bytes.
[out]OutKeyPointer to the output derived key buffer.
Return values
TRUEA key was derived successfully.
FALSEOne of the pointers was NULL or one of the sizes was too large.
FALSEThe hash algorithm could not be determined from the digest size.
FALSEThe key derivation operation failed.

Definition at line 40 of file CryptPkcs5Pbkdf2.c.