VirtualBox

Ignore:
Timestamp:
Aug 12, 2020 4:09:12 PM (4 years ago)
Author:
vboxsync
Message:

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c

    r80721 r85718  
    22  HMAC-SHA256 Wrapper Implementation over OpenSSL.
    33
    4 Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>
    55SPDX-License-Identifier: BSD-2-Clause-Patent
    66
     
    1010#include <openssl/hmac.h>
    1111
    12 //
    13 // NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h
    14 //       #define HMAC_MAX_MD_CBLOCK_SIZE     144
    15 //
    16 #define HMAC_SHA256_CTX_SIZE    (sizeof(void *) * 4 + sizeof(unsigned int) + \
    17                              sizeof(unsigned char) * 144)
    18 
    19 /**
    20   Retrieves the size, in bytes, of the context buffer required for HMAC-SHA256 operations.
    21   (NOTE: This API is deprecated.
    22          Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context operations.)
    23 
    24   @return  The size, in bytes, of the context buffer required for HMAC-SHA256 operations.
    25 
    26 **/
    27 UINTN
    28 EFIAPI
    29 HmacSha256GetContextSize (
    30   VOID
    31   )
    32 {
    33   //
    34   // Retrieves the OpenSSL HMAC-SHA256 Context Size
    35   // NOTE: HMAC_CTX object was made opaque in openssl-1.1.x, here we just use the
    36   //       fixed size as a workaround to make this API work for compatibility.
    37   //       We should retire HmacSha256GetContextSize() in future, and use HmacSha256New()
    38   //       and HmacSha256Free() for context allocation and release.
    39   //
    40   return (UINTN)HMAC_SHA256_CTX_SIZE;
    41 }
    42 
    4312/**
    4413  Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.
     
    7948
    8049/**
    81   Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SHA256 context for
    82   subsequent use.
    83 
    84   If HmacSha256Context is NULL, then return FALSE.
    85 
    86   @param[out]  HmacSha256Context  Pointer to HMAC-SHA256 context being initialized.
     50  Set user-supplied key for subsequent use. It must be done before any
     51  calling to HmacSha256Update().
     52
     53  If HmacSha256Context is NULL, then return FALSE.
     54
     55  @param[out]  HmacSha256Context  Pointer to HMAC-SHA256 context.
    8756  @param[in]   Key                Pointer to the user-supplied key.
    8857  @param[in]   KeySize            Key size in bytes.
    8958
    90   @retval TRUE   HMAC-SHA256 context initialization succeeded.
    91   @retval FALSE  HMAC-SHA256 context initialization failed.
    92 
    93 **/
    94 BOOLEAN
    95 EFIAPI
    96 HmacSha256Init (
     59  @retval TRUE   The Key is set successfully.
     60  @retval FALSE  The Key is set unsuccessfully.
     61
     62**/
     63BOOLEAN
     64EFIAPI
     65HmacSha256SetKey (
    9766  OUT  VOID         *HmacSha256Context,
    9867  IN   CONST UINT8  *Key,
     
    10776  }
    10877
    109   //
    110   // OpenSSL HMAC-SHA256 Context Initialization
    111   //
    112   memset(HmacSha256Context, 0, HMAC_SHA256_CTX_SIZE);
    113   if (HMAC_CTX_reset ((HMAC_CTX *)HmacSha256Context) != 1) {
    114     return FALSE;
    115   }
    11678  if (HMAC_Init_ex ((HMAC_CTX *)HmacSha256Context, Key, (UINT32) KeySize, EVP_sha256(), NULL) != 1) {
    11779    return FALSE;
     
    160122  This function performs HMAC-SHA256 digest on a data buffer of the specified size.
    161123  It can be called multiple times to compute the digest of long or discontinuous data streams.
    162   HMAC-SHA256 context should be already correctly initialized by HmacSha256Init(), and should not
    163   be finalized by HmacSha256Final(). Behavior with invalid context is undefined.
     124  HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
     125  by HmacSha256Final(). Behavior with invalid context is undefined.
    164126
    165127  If HmacSha256Context is NULL, then return FALSE.
     
    211173  the specified memory. After this function has been called, the HMAC-SHA256 context cannot
    212174  be used again.
    213   HMAC-SHA256 context should be already correctly initialized by HmacSha256Init(), and should
    214   not be finalized by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.
     175  HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
     176  by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.
    215177
    216178  If HmacSha256Context is NULL, then return FALSE.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette