VirtualBox

Ignore:
Timestamp:
Aug 12, 2020 4:09:12 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139865
Message:

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

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
1 added
10 deleted
19 edited

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf

    r80721 r85718  
    77#  buffer overflow or integer overflow.
    88#
    9 #  Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
     9#  Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
     10#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
    1011#  SPDX-License-Identifier: BSD-2-Clause-Patent
    1112#
     
    2425# The following information is for reference only and not required by the build tools.
    2526#
    26 #  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
     27#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64 RISCV64
    2728#
    2829
    2930[Sources]
    3031  InternalCryptLib.h
    31   Hash/CryptMd4.c
    3232  Hash/CryptMd5.c
    3333  Hash/CryptSha1.c
     
    3535  Hash/CryptSha512.c
    3636  Hash/CryptSm3.c
    37   Hmac/CryptHmacMd5.c
    38   Hmac/CryptHmacSha1.c
    3937  Hmac/CryptHmacSha256.c
    4038  Kdf/CryptHkdf.c
    4139  Cipher/CryptAes.c
    42   Cipher/CryptTdes.c
    43   Cipher/CryptArc4.c
    4440  Pk/CryptRsaBasic.c
    4541  Pk/CryptRsaExt.c
     
    5955  SysCall/TimerWrapper.c
    6056  SysCall/BaseMemAllocation.c
     57  SysCall/inet_pton.c
    6158
    6259[Sources.Ia32]
     
    7067
    7168[Sources.AARCH64]
     69  Rand/CryptRand.c
     70
     71[Sources.RISCV64]
    7272  Rand/CryptRand.c
    7373
     
    102102  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
    103103  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
     104  GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
    104105
    105106  XCODE:*_*_*_CC_FLAGS = -std=c99
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Cipher/CryptAes.c

    r80721 r85718  
    7676    return FALSE;
    7777  }
    78   return TRUE;
    79 }
    80 
    81 /**
    82   Performs AES encryption on a data buffer of the specified size in ECB mode.
    83 
    84   This function performs AES encryption on data buffer pointed by Input, of specified
    85   size of InputSize, in ECB mode.
    86   InputSize must be multiple of block size (16 bytes). This function does not perform
    87   padding. Caller must perform padding, if necessary, to ensure valid input data size.
    88   AesContext should be already correctly initialized by AesInit(). Behavior with
    89   invalid AES context is undefined.
    90 
    91   If AesContext is NULL, then return FALSE.
    92   If Input is NULL, then return FALSE.
    93   If InputSize is not multiple of block size (16 bytes), then return FALSE.
    94   If Output is NULL, then return FALSE.
    95 
    96   @param[in]   AesContext  Pointer to the AES context.
    97   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.
    98   @param[in]   InputSize   Size of the Input buffer in bytes.
    99   @param[out]  Output      Pointer to a buffer that receives the AES encryption output.
    100 
    101   @retval TRUE   AES encryption succeeded.
    102   @retval FALSE  AES encryption failed.
    103 
    104 **/
    105 BOOLEAN
    106 EFIAPI
    107 AesEcbEncrypt (
    108   IN   VOID         *AesContext,
    109   IN   CONST UINT8  *Input,
    110   IN   UINTN        InputSize,
    111   OUT  UINT8        *Output
    112   )
    113 {
    114   AES_KEY  *AesKey;
    115 
    116   //
    117   // Check input parameters.
    118   //
    119   if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {
    120     return FALSE;
    121   }
    122 
    123   AesKey = (AES_KEY *) AesContext;
    124 
    125   //
    126   // Perform AES data encryption with ECB mode (block-by-block)
    127   //
    128   while (InputSize > 0) {
    129     AES_ecb_encrypt (Input, Output, AesKey, AES_ENCRYPT);
    130     Input     += AES_BLOCK_SIZE;
    131     Output    += AES_BLOCK_SIZE;
    132     InputSize -= AES_BLOCK_SIZE;
    133   }
    134 
    135   return TRUE;
    136 }
    137 
    138 /**
    139   Performs AES decryption on a data buffer of the specified size in ECB mode.
    140 
    141   This function performs AES decryption on data buffer pointed by Input, of specified
    142   size of InputSize, in ECB mode.
    143   InputSize must be multiple of block size (16 bytes). This function does not perform
    144   padding. Caller must perform padding, if necessary, to ensure valid input data size.
    145   AesContext should be already correctly initialized by AesInit(). Behavior with
    146   invalid AES context is undefined.
    147 
    148   If AesContext is NULL, then return FALSE.
    149   If Input is NULL, then return FALSE.
    150   If InputSize is not multiple of block size (16 bytes), then return FALSE.
    151   If Output is NULL, then return FALSE.
    152 
    153   @param[in]   AesContext  Pointer to the AES context.
    154   @param[in]   Input       Pointer to the buffer containing the data to be decrypted.
    155   @param[in]   InputSize   Size of the Input buffer in bytes.
    156   @param[out]  Output      Pointer to a buffer that receives the AES decryption output.
    157 
    158   @retval TRUE   AES decryption succeeded.
    159   @retval FALSE  AES decryption failed.
    160 
    161 **/
    162 BOOLEAN
    163 EFIAPI
    164 AesEcbDecrypt (
    165   IN   VOID         *AesContext,
    166   IN   CONST UINT8  *Input,
    167   IN   UINTN        InputSize,
    168   OUT  UINT8        *Output
    169   )
    170 {
    171   AES_KEY  *AesKey;
    172 
    173   //
    174   // Check input parameters.
    175   //
    176   if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {
    177     return FALSE;
    178   }
    179 
    180   AesKey = (AES_KEY *) AesContext;
    181 
    182   //
    183   // Perform AES data decryption with ECB mode (block-by-block)
    184   //
    185   while (InputSize > 0) {
    186     AES_ecb_encrypt (Input, Output, AesKey + 1, AES_DECRYPT);
    187     Input     += AES_BLOCK_SIZE;
    188     Output    += AES_BLOCK_SIZE;
    189     InputSize -= AES_BLOCK_SIZE;
    190   }
    191 
    19278  return TRUE;
    19379}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Cipher/CryptAesNull.c

    r80721 r85718  
    4545  IN   CONST UINT8  *Key,
    4646  IN   UINTN        KeyLength
    47   )
    48 {
    49   ASSERT (FALSE);
    50   return FALSE;
    51 }
    52 
    53 /**
    54   Performs AES encryption on a data buffer of the specified size in ECB mode.
    55 
    56   Return FALSE to indicate this interface is not supported.
    57 
    58   @param[in]   AesContext  Pointer to the AES context.
    59   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.
    60   @param[in]   InputSize   Size of the Input buffer in bytes.
    61   @param[out]  Output      Pointer to a buffer that receives the AES encryption output.
    62 
    63   @retval FALSE  This interface is not supported.
    64 
    65 **/
    66 BOOLEAN
    67 EFIAPI
    68 AesEcbEncrypt (
    69   IN   VOID         *AesContext,
    70   IN   CONST UINT8  *Input,
    71   IN   UINTN        InputSize,
    72   OUT  UINT8        *Output
    73   )
    74 {
    75   ASSERT (FALSE);
    76   return FALSE;
    77 }
    78 
    79 /**
    80   Performs AES decryption on a data buffer of the specified size in ECB mode.
    81 
    82   Return FALSE to indicate this interface is not supported.
    83 
    84   @param[in]   AesContext  Pointer to the AES context.
    85   @param[in]   Input       Pointer to the buffer containing the data to be decrypted.
    86   @param[in]   InputSize   Size of the Input buffer in bytes.
    87   @param[out]  Output      Pointer to a buffer that receives the AES decryption output.
    88 
    89   @retval FALSE  This interface is not supported.
    90 
    91 **/
    92 BOOLEAN
    93 EFIAPI
    94 AesEcbDecrypt (
    95   IN   VOID         *AesContext,
    96   IN   CONST UINT8  *Input,
    97   IN   UINTN        InputSize,
    98   OUT  UINT8        *Output
    9947  )
    10048{
  • 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.
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c

    r80721 r85718  
    22  HMAC-SHA256 Wrapper Implementation which does not provide real capabilities.
    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
     
    88
    99#include "InternalCryptLib.h"
    10 
    11 /**
    12   Retrieves the size, in bytes, of the context buffer required for HMAC-SHA256 operations.
    13   (NOTE: This API is deprecated.
    14          Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context operations.)
    15 
    16   Return zero to indicate this interface is not supported.
    17 
    18   @retval  0   This interface is not supported.
    19 
    20 **/
    21 UINTN
    22 EFIAPI
    23 HmacSha256GetContextSize (
    24   VOID
    25   )
    26 {
    27   ASSERT (FALSE);
    28   return 0;
    29 }
    3010
    3111/**
     
    6646
    6747/**
    68   Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SHA256 context for
    69   subsequent use.
     48  Set user-supplied key for subsequent use. It must be done before any
     49  calling to HmacSha256Update().
    7050
    7151  Return FALSE to indicate this interface is not supported.
    7252
    73   @param[out]  HmacSha256Context  Pointer to HMAC-SHA256 context being initialized.
     53  @param[out]  HmacSha256Context  Pointer to HMAC-SHA256 context.
    7454  @param[in]   Key                Pointer to the user-supplied key.
    7555  @param[in]   KeySize            Key size in bytes.
     
    8060BOOLEAN
    8161EFIAPI
    82 HmacSha256Init (
     62HmacSha256SetKey (
    8363  OUT  VOID         *HmacSha256Context,
    8464  IN   CONST UINT8  *Key,
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf

    r80721 r85718  
    77#  buffer overflow or integer overflow.
    88#
    9 #  Note: MD4 Digest functions,
    10 #  HMAC-MD5 functions, HMAC-SHA1/SHA256 functions, AES/TDES/ARC4 functions, RSA external
     9#  Note:
     10#  HMAC-SHA256 functions, AES functions, RSA external
    1111#  functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, X.509
    1212#  certificate handler functions, authenticode signature verification functions,
     
    1414#  supported in this instance.
    1515#
    16 #  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
     16#  Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
    1717#  SPDX-License-Identifier: BSD-2-Clause-Patent
    1818#
     
    3636[Sources]
    3737  InternalCryptLib.h
    38   Hash/CryptMd4Null.c
    3938  Hash/CryptMd5.c
    4039  Hash/CryptSha1.c
     
    4241  Hash/CryptSm3.c
    4342  Hash/CryptSha512.c
    44   Hmac/CryptHmacMd5Null.c
    45   Hmac/CryptHmacSha1Null.c
    4643  Hmac/CryptHmacSha256Null.c
    4744  Kdf/CryptHkdfNull.c
    4845  Cipher/CryptAesNull.c
    49   Cipher/CryptTdesNull.c
    50   Cipher/CryptArc4Null.c
    5146  Pk/CryptRsaBasic.c
    5247  Pk/CryptRsaExtNull.c
     
    9792  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
    9893  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
     94  GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
    9995
    10096  XCODE:*_*_*_CC_FLAGS = -std=c99
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.uni

    r80721 r85718  
    77// buffer overflow or integer overflow.
    88//
    9 // Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/
    10 // TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions,
     9// Note: AES
     10// functions, RSA external functions, PKCS#7 SignedData sign functions,
    1111// Diffie-Hellman functions, X.509 certificate handler functions, authenticode
    1212// signature verification functions, PEM handler functions, and pseudorandom number
    1313// generator functions are not supported in this instance.
    1414//
    15 // Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
     15// Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
    1616//
    1717// SPDX-License-Identifier: BSD-2-Clause-Patent
     
    2222#string STR_MODULE_ABSTRACT             #language en-US "Cryptographic Library Instance for PEIM"
    2323
    24 #string STR_MODULE_DESCRIPTION          #language en-US "Caution: This module requires additional review when modified. This library will have external input - signature. This external input must be validated carefully to avoid security issues such as buffer overflow or integer overflow. Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/ TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, X.509 certificate handler functions, authenticode signature verification functions, PEM handler functions, and pseudorandom number generator functions are not supported in this instance."
     24#string STR_MODULE_DESCRIPTION          #language en-US "Caution: This module requires additional review when modified. This library will have external input - signature. This external input must be validated carefully to avoid security issues such as buffer overflow or integer overflow. Note: AES functions, RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, X.509 certificate handler functions, authenticode signature verification functions, PEM handler functions, and pseudorandom number generator functions are not supported in this instance."
    2525
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c

    r80721 r85718  
    22  PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation over OpenSSL.
    33
    4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
    55SPDX-License-Identifier: BSD-2-Clause-Patent
    66
     
    8383  //
    8484  // Add possible block-cipher descriptor for PEM data decryption.
    85   // NOTE: Only support most popular ciphers (3DES, AES) for the encrypted PEM.
     85  // NOTE: Only support most popular ciphers AES for the encrypted PEM.
    8686  //
    87   if (EVP_add_cipher (EVP_des_ede3_cbc ()) == 0) {
    88     return FALSE;
    89   }
    9087  if (EVP_add_cipher (EVP_aes_128_cbc ()) == 0) {
    9188    return FALSE;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c

    r80721 r85718  
    1313#include <openssl/x509v3.h>
    1414#include <openssl/pkcs7.h>
     15
     16/**
     17  Check the contents of PKCS7 is not data.
     18
     19  It is copied from PKCS7_type_is_other() in pk7_doit.c.
     20
     21  @param[in] P7 Pointer to the location at which the PKCS7 is located.
     22
     23  @retval TRUE  If the type is others.
     24  @retval FALSE If the type is expected.
     25**/
     26STATIC
     27BOOLEAN
     28Pkcs7TypeIsOther (
     29  IN PKCS7 *P7
     30  )
     31{
     32  BOOLEAN Others;
     33  INTN    Nid = OBJ_obj2nid (P7->type);
     34
     35  switch (Nid) {
     36    case NID_pkcs7_data:
     37    case NID_pkcs7_signed:
     38    case NID_pkcs7_enveloped:
     39    case NID_pkcs7_signedAndEnveloped:
     40    case NID_pkcs7_encrypted:
     41      Others = FALSE;
     42      break;
     43    default:
     44      Others = TRUE;
     45  }
     46
     47  return Others;
     48}
     49
     50/**
     51  Get the ASN.1 string for the PKCS7.
     52
     53  It is copied from PKCS7_get_octet_string() in pk7_doit.c.
     54
     55  @param[in] P7 Pointer to the location at which the PKCS7 is located.
     56
     57  @return ASN1_OCTET_STRING ASN.1 string.
     58**/
     59STATIC
     60ASN1_OCTET_STRING*
     61Pkcs7GetOctetString (
     62  IN PKCS7 *P7
     63  )
     64{
     65  if (PKCS7_type_is_data (P7)) {
     66    return P7->d.data;
     67  }
     68
     69  if (Pkcs7TypeIsOther(P7) && (P7->d.other != NULL) &&
     70      (P7->d.other->type == V_ASN1_OCTET_STRING)) {
     71    return P7->d.other->value.octet_string;
     72  }
     73
     74  return NULL;
     75}
    1576
    1677/**
     
    99160    // Retrieve the attached content in PKCS7 signedData
    100161    //
    101     OctStr = Pkcs7->d.sign->contents->d.data;
     162    OctStr = Pkcs7GetOctetString (Pkcs7->d.sign->contents);
     163    if (OctStr == NULL) {
     164      goto _Exit;
     165    }
     166
    102167    if ((OctStr->length > 0) && (OctStr->data != NULL)) {
    103168      *ContentSize = OctStr->length;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c

    r80721 r85718  
    88  4) RsaPkcs1Verify
    99
    10 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
     10Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
    1111SPDX-License-Identifier: BSD-2-Clause-Patent
    1212
     
    251251  If MessageHash is NULL, then return FALSE.
    252252  If Signature is NULL, then return FALSE.
    253   If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
     253  If HashSize is not equal to the size of MD5, SHA-1, SHA-256, SHA-384 or SHA-512 digest, then return FALSE.
    254254
    255255  @param[in]  RsaContext   Pointer to RSA context for signature verification.
     
    289289  //
    290290  // Determine the message digest algorithm according to digest size.
    291   //   Only MD5, SHA-1 or SHA-256 algorithm is supported.
     291  //   Only MD5, SHA-1, SHA-256, SHA-384 or SHA-512 algorithm is supported.
    292292  //
    293293  switch (HashSize) {
     
    302302  case SHA256_DIGEST_SIZE:
    303303    DigestType = NID_sha256;
     304    break;
     305
     306  case SHA384_DIGEST_SIZE:
     307    DigestType = NID_sha384;
     308    break;
     309
     310  case SHA512_DIGEST_SIZE:
     311    DigestType = NID_sha512;
    304312    break;
    305313
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c

    r80721 r85718  
    88  4) RsaPkcs1Sign
    99
    10 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
     10Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
    1111SPDX-License-Identifier: BSD-2-Clause-Patent
    1212
     
    277277  If RsaContext is NULL, then return FALSE.
    278278  If MessageHash is NULL, then return FALSE.
    279   If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
     279  If HashSize is not equal to the size of MD5, SHA-1, SHA-256, SHA-384 or SHA-512 digest, then return FALSE.
    280280  If SigSize is large enough but Signature is NULL, then return FALSE.
    281281
     
    327327  //
    328328  // Determine the message digest algorithm according to digest size.
    329   //   Only MD5, SHA-1 or SHA-256 algorithm is supported.
     329  //   Only MD5, SHA-1, SHA-256, SHA-384 or SHA-512 algorithm is supported.
    330330  //
    331331  switch (HashSize) {
     
    340340  case SHA256_DIGEST_SIZE:
    341341    DigestType = NID_sha256;
     342    break;
     343
     344  case SHA384_DIGEST_SIZE:
     345    DigestType = NID_sha384;
     346    break;
     347
     348  case SHA512_DIGEST_SIZE:
     349    DigestType = NID_sha512;
    342350    break;
    343351
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c

    r80721 r85718  
    22  X.509 Certificate Handler Wrapper Implementation over OpenSSL.
    33
    4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
    55SPDX-License-Identifier: BSD-2-Clause-Patent
    66
     
    6161
    6262  If X509Stack is NULL, then return FALSE.
     63  If this interface is not supported, then return FALSE.
    6364
    6465  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.
    6566                              On output, pointer to the X509 stack object with new
    6667                              inserted X509 certificate.
    67   @param           ...        A list of DER-encoded single certificate data followed
     68  @param[in]       Args       VA_LIST marker for the variable argument list.
     69                              A list of DER-encoded single certificate data followed
    6870                              by certificate size. A NULL terminates the list. The
    6971                              pairs are the arguments to X509ConstructCertificate().
     
    7173  @retval     TRUE            The X509 stack construction succeeded.
    7274  @retval     FALSE           The construction operation failed.
     75  @retval     FALSE           This interface is not supported.
    7376
    7477**/
    7578BOOLEAN
    7679EFIAPI
    77 X509ConstructCertificateStack (
    78   IN OUT  UINT8  **X509Stack,
    79   ...
     80X509ConstructCertificateStackV (
     81  IN OUT  UINT8    **X509Stack,
     82  IN      VA_LIST  Args
    8083  )
    8184{
     
    8588  STACK_OF(X509)  *CertStack;
    8689  BOOLEAN         Status;
    87   VA_LIST         Args;
    8890  UINTN           Index;
    8991
     
    107109    }
    108110  }
    109 
    110   VA_START (Args, X509Stack);
    111111
    112112  for (Index = 0; ; Index++) {
     
    146146  }
    147147
    148   VA_END (Args);
    149 
    150148  if (!Status) {
    151149    sk_X509_pop_free (CertStack, X509_free);
     
    155153
    156154  return Status;
     155}
     156
     157/**
     158  Construct a X509 stack object from a list of DER-encoded certificate data.
     159
     160  If X509Stack is NULL, then return FALSE.
     161
     162  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.
     163                              On output, pointer to the X509 stack object with new
     164                              inserted X509 certificate.
     165  @param           ...        A list of DER-encoded single certificate data followed
     166                              by certificate size. A NULL terminates the list. The
     167                              pairs are the arguments to X509ConstructCertificate().
     168
     169  @retval     TRUE            The X509 stack construction succeeded.
     170  @retval     FALSE           The construction operation failed.
     171
     172**/
     173BOOLEAN
     174EFIAPI
     175X509ConstructCertificateStack (
     176  IN OUT  UINT8  **X509Stack,
     177  ...
     178  )
     179{
     180  VA_LIST  Args;
     181  BOOLEAN  Result;
     182
     183  VA_START (Args, X509Stack);
     184  Result = X509ConstructCertificateStackV (X509Stack, Args);
     185  VA_END (Args);
     186  return Result;
    157187}
    158188
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c

    r80721 r85718  
    33  real capabilities.
    44
    5 Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
     5Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.<BR>
    66SPDX-License-Identifier: BSD-2-Clause-Patent
    77
     
    2828  IN   UINTN        CertSize,
    2929  OUT  UINT8        **SingleX509Cert
     30  )
     31{
     32  ASSERT (FALSE);
     33  return FALSE;
     34}
     35
     36/**
     37  Construct a X509 stack object from a list of DER-encoded certificate data.
     38
     39  If X509Stack is NULL, then return FALSE.
     40  If this interface is not supported, then return FALSE.
     41
     42  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.
     43                              On output, pointer to the X509 stack object with new
     44                              inserted X509 certificate.
     45  @param[in]       Args       VA_LIST marker for the variable argument list.
     46                              A list of DER-encoded single certificate data followed
     47                              by certificate size. A NULL terminates the list. The
     48                              pairs are the arguments to X509ConstructCertificate().
     49
     50  @retval     TRUE            The X509 stack construction succeeded.
     51  @retval     FALSE           The construction operation failed.
     52  @retval     FALSE           This interface is not supported.
     53
     54**/
     55BOOLEAN
     56EFIAPI
     57X509ConstructCertificateStackV (
     58  IN OUT  UINT8    **X509Stack,
     59  IN      VA_LIST  Args
    3060  )
    3161{
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf

    r80721 r85718  
    77#  buffer overflow or integer overflow.
    88#
    9 #  Note: MD4 Digest functions, SHA-384 Digest functions, SHA-512 Digest functions,
    10 #  HMAC-MD5 functions, HMAC-SHA1/SHA256 functions, AES/TDES/ARC4 functions, RSA external
     9#  Note: SHA-384 Digest functions, SHA-512 Digest functions,
     10#  HMAC-SHA256 functions, AES functions, RSA external
    1111#  functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and
    1212#  authenticode signature verification functions are not supported in this instance.
    1313#
    14 #  Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
     14#  Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
     15#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
    1516#  SPDX-License-Identifier: BSD-2-Clause-Patent
    1617#
     
    3536[Sources]
    3637  InternalCryptLib.h
    37   Hash/CryptMd4Null.c
    3838  Hash/CryptMd5.c
    3939  Hash/CryptSha1.c
     
    4141  Hash/CryptSm3.c
    4242  Hash/CryptSha512Null.c
    43   Hmac/CryptHmacMd5Null.c
    44   Hmac/CryptHmacSha1Null.c
    4543  Hmac/CryptHmacSha256Null.c
    4644  Kdf/CryptHkdfNull.c
    4745  Cipher/CryptAesNull.c
    48   Cipher/CryptTdesNull.c
    49   Cipher/CryptArc4Null.c
    5046  Pk/CryptRsaBasic.c
    5147  Pk/CryptRsaExtNull.c
     
    7672
    7773[Sources.AARCH64]
     74  Rand/CryptRand.c
     75
     76[Sources.RISCV64]
    7877  Rand/CryptRand.c
    7978
     
    108107  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
    109108  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
     109  GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
    110110
    111111  XCODE:*_*_*_CC_FLAGS = -std=c99
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.uni

    r80721 r85718  
    77// buffer overflow or integer overflow.
    88//
    9 // Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/
    10 // TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions,
     9// Note: AES
     10// functions, RSA external functions, PKCS#7 SignedData sign functions,
    1111// Diffie-Hellman functions, and authenticode signature verification functions are
    1212// not supported in this instance.
    1313//
    14 // Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
     14// Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
    1515//
    1616// SPDX-License-Identifier: BSD-2-Clause-Patent
     
    2121#string STR_MODULE_ABSTRACT             #language en-US "Cryptographic Library Instance for DXE_RUNTIME_DRIVER"
    2222
    23 #string STR_MODULE_DESCRIPTION          #language en-US "Caution: This module requires additional review when modified. This library will have external input - signature. This external input must be validated carefully to avoid security issues such as buffer overflow or integer overflow. Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/ TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and authenticode signature verification functions are not supported in this instance."
     23#string STR_MODULE_DESCRIPTION          #language en-US "Caution: This module requires additional review when modified. This library will have external input - signature. This external input must be validated carefully to avoid security issues such as buffer overflow or integer overflow. Note: AES functions, RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and authenticode signature verification functions are not supported in this instance."
    2424
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf

    r80721 r85718  
    77#  buffer overflow or integer overflow.
    88#
    9 #  Note: MD4 Digest functions, SHA-384 Digest functions, SHA-512 Digest functions,
    10 #  HMAC-MD5 functions, HMAC-SHA1 functions, TDES/ARC4 functions, RSA external
    11 #  functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and
     9#  Note: SHA-384 Digest functions, SHA-512 Digest functions,
     10#  RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and
    1211#  authenticode signature verification functions are not supported in this instance.
    1312#
    14 #  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
     13#  Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
    1514#  SPDX-License-Identifier: BSD-2-Clause-Patent
    1615#
     
    3534[Sources]
    3635  InternalCryptLib.h
    37   Hash/CryptMd4Null.c
    3836  Hash/CryptMd5.c
    3937  Hash/CryptSha1.c
     
    4139  Hash/CryptSm3.c
    4240  Hash/CryptSha512Null.c
    43   Hmac/CryptHmacMd5Null.c
    44   Hmac/CryptHmacSha1Null.c
    4541  Hmac/CryptHmacSha256.c
    4642  Kdf/CryptHkdfNull.c
    4743  Cipher/CryptAes.c
    48   Cipher/CryptTdesNull.c
    49   Cipher/CryptArc4Null.c
    5044  Pk/CryptRsaBasic.c
    5145  Pk/CryptRsaExtNull.c
     
    10599  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
    106100  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
     101  GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.uni

    r80721 r85718  
    77// buffer overflow or integer overflow.
    88//
    9 // Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/
    10 // TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions,
     9// Note: AES
     10// functions, RSA external functions, PKCS#7 SignedData sign functions,
    1111// Diffie-Hellman functions, and authenticode signature verification functions are
    1212// not supported in this instance.
    1313//
    14 // Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
     14// Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
    1515//
    1616// SPDX-License-Identifier: BSD-2-Clause-Patent
     
    2121#string STR_MODULE_ABSTRACT             #language en-US "Cryptographic Library Instance for SMM driver"
    2222
    23 #string STR_MODULE_DESCRIPTION          #language en-US "Caution: This module requires additional review when modified. This library will have external input - signature. This external input must be validated carefully to avoid security issues such as buffer overflow or integer overflow. Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/ TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and authenticode signature verification functions are not supported in this instance."
     23#string STR_MODULE_DESCRIPTION          #language en-US "Caution: This module requires additional review when modified. This library will have external input - signature. This external input must be validated carefully to avoid security issues such as buffer overflow or integer overflow. Note: AES functions, RSA external functions, PKCS#7 SignedData sign functions, Diffie-Hellman functions, and authenticode signature verification functions are not supported in this instance."
    2424
  • trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c

    r80721 r85718  
    116116//
    117117
     118char *strchr(const char *str, int ch)
     119{
     120  return ScanMem8 (str, AsciiStrSize (str), (UINT8)ch);
     121}
     122
    118123/* Scan a string for the last occurrence of a character */
    119124char *strrchr (const char *str, int c)
Note: See TracChangeset for help on using the changeset viewer.

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