CryptoPkg/BaseCryptLib: replace HmacXxxInit API with HmacXxxSetKey

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1792

HmacXxxInit() is supposed to be initialize user supplied buffer as HMAC
context, as well as user supplied key. Currently it has no real use cases.

Due to BZ1792, the user has no way to get correct size of context buffer
after it's fixed, and then cannot make use of HmacXxxInit to initialize
it.

So it's decided to replace it with HmacXxxSetKey to keep the functionality
of supplying a key to HMAC, but drop all other initialization works. The
user can still get HMAC context via HmacXxxNew interface, which hides the
details about the context.

Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
This commit is contained in:
Jian J Wang
2020-01-17 11:05:40 +08:00
committed by mergify[bot]
parent 5cd3d4bc43
commit a23fdff6fb
10 changed files with 84 additions and 105 deletions

View File

@ -65,12 +65,12 @@ HmacSha256Free (
}
/**
Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SHA256 context for
subsequent use.
Set user-supplied key for subsequent use. It must be done before any
calling to HmacSha256Update().
Return FALSE to indicate this interface is not supported.
@param[out] HmacSha256Context Pointer to HMAC-SHA256 context being initialized.
@param[out] HmacSha256Context Pointer to HMAC-SHA256 context.
@param[in] Key Pointer to the user-supplied key.
@param[in] KeySize Key size in bytes.
@ -79,7 +79,7 @@ HmacSha256Free (
**/
BOOLEAN
EFIAPI
HmacSha256Init (
HmacSha256SetKey (
OUT VOID *HmacSha256Context,
IN CONST UINT8 *Key,
IN UINTN KeySize