-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CryptoPkg: Add Null instance of the BaseCryptLib class
https://bugzilla.tianocore.org/show_bug.cgi?id=2257 Add a Null instance of the BaseCryptLib class. This lib instance can be used as a template for new implementations of the BaseCryptLib class and can also be used to reduce CI build times for build checks that depend on the BaseCryptLib class. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Xiaoyu Lu <xiaoyux.lu@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
- Loading branch information
Showing
29 changed files
with
3,401 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
## @file | ||
# Cryptographic Library Null Instance. | ||
# | ||
# 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. | ||
# | ||
# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR> | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = BaseCryptLibNull | ||
MODULE_UNI_FILE = BaseCryptLibNull.uni | ||
FILE_GUID = ba4b5ba1-0ea1-415a-896c-6caaf32146f3 | ||
MODULE_TYPE = BASE | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = BaseCryptLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 | ||
# | ||
|
||
[Sources] | ||
InternalCryptLib.h | ||
Hash/CryptMd4Null.c | ||
Hash/CryptMd5Null.c | ||
Hash/CryptSha1Null.c | ||
Hash/CryptSha256Null.c | ||
Hash/CryptSha512Null.c | ||
Hash/CryptSm3Null.c | ||
Hmac/CryptHmacMd5Null.c | ||
Hmac/CryptHmacSha1Null.c | ||
Hmac/CryptHmacSha256Null.c | ||
Cipher/CryptAesNull.c | ||
Cipher/CryptTdesNull.c | ||
Cipher/CryptArc4Null.c | ||
Pk/CryptRsaBasicNull.c | ||
Pk/CryptRsaExtNull.c | ||
Pk/CryptPkcs1OaepNull.c | ||
Pk/CryptPkcs5Pbkdf2Null.c | ||
Pk/CryptPkcs7SignNull.c | ||
Pk/CryptPkcs7VerifyNull.c | ||
Pk/CryptPkcs7VerifyEkuNull.c | ||
Pk/CryptDhNull.c | ||
Pk/CryptX509Null.c | ||
Pk/CryptAuthenticodeNull.c | ||
Pk/CryptTsNull.c | ||
Pem/CryptPemNull.c | ||
Rand/CryptRandNull.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
CryptoPkg/CryptoPkg.dec | ||
|
||
[LibraryClasses] | ||
DebugLib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// /** @file | ||
// Cryptographic Library Null Instance. | ||
// | ||
// 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. | ||
// | ||
// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
// | ||
// **/ | ||
|
||
#string STR_MODULE_ABSTRACT #language en-US "Cryptographic Library Null Instance" | ||
|
||
#string STR_MODULE_DESCRIPTION #language en-US "Caution: This is a null version of your crypto library and SHOULD NOT be used on any product ever." | ||
|
159 changes: 159 additions & 0 deletions
159
CryptoPkg/Library/BaseCryptLibNull/Cipher/CryptAesNull.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/** @file | ||
AES Wrapper Implementation which does not provide real capabilities. | ||
Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "InternalCryptLib.h" | ||
|
||
/** | ||
Retrieves the size, in bytes, of the context buffer required for AES operations. | ||
Return zero to indicate this interface is not supported. | ||
@retval 0 This interface is not supported. | ||
**/ | ||
UINTN | ||
EFIAPI | ||
AesGetContextSize ( | ||
VOID | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return 0; | ||
} | ||
|
||
/** | ||
Initializes user-supplied memory as AES context for subsequent use. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[out] AesContext Pointer to AES context being initialized. | ||
@param[in] Key Pointer to the user-supplied AES key. | ||
@param[in] KeyLength Length of AES key in bits. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
AesInit ( | ||
OUT VOID *AesContext, | ||
IN CONST UINT8 *Key, | ||
IN UINTN KeyLength | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Performs AES encryption on a data buffer of the specified size in ECB mode. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in] AesContext Pointer to the AES context. | ||
@param[in] Input Pointer to the buffer containing the data to be encrypted. | ||
@param[in] InputSize Size of the Input buffer in bytes. | ||
@param[out] Output Pointer to a buffer that receives the AES encryption output. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
AesEcbEncrypt ( | ||
IN VOID *AesContext, | ||
IN CONST UINT8 *Input, | ||
IN UINTN InputSize, | ||
OUT UINT8 *Output | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Performs AES decryption on a data buffer of the specified size in ECB mode. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in] AesContext Pointer to the AES context. | ||
@param[in] Input Pointer to the buffer containing the data to be decrypted. | ||
@param[in] InputSize Size of the Input buffer in bytes. | ||
@param[out] Output Pointer to a buffer that receives the AES decryption output. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
AesEcbDecrypt ( | ||
IN VOID *AesContext, | ||
IN CONST UINT8 *Input, | ||
IN UINTN InputSize, | ||
OUT UINT8 *Output | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Performs AES encryption on a data buffer of the specified size in CBC mode. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in] AesContext Pointer to the AES context. | ||
@param[in] Input Pointer to the buffer containing the data to be encrypted. | ||
@param[in] InputSize Size of the Input buffer in bytes. | ||
@param[in] Ivec Pointer to initialization vector. | ||
@param[out] Output Pointer to a buffer that receives the AES encryption output. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
AesCbcEncrypt ( | ||
IN VOID *AesContext, | ||
IN CONST UINT8 *Input, | ||
IN UINTN InputSize, | ||
IN CONST UINT8 *Ivec, | ||
OUT UINT8 *Output | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Performs AES decryption on a data buffer of the specified size in CBC mode. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in] AesContext Pointer to the AES context. | ||
@param[in] Input Pointer to the buffer containing the data to be encrypted. | ||
@param[in] InputSize Size of the Input buffer in bytes. | ||
@param[in] Ivec Pointer to initialization vector. | ||
@param[out] Output Pointer to a buffer that receives the AES encryption output. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
AesCbcDecrypt ( | ||
IN VOID *AesContext, | ||
IN CONST UINT8 *Input, | ||
IN UINTN InputSize, | ||
IN CONST UINT8 *Ivec, | ||
OUT UINT8 *Output | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} |
124 changes: 124 additions & 0 deletions
124
CryptoPkg/Library/BaseCryptLibNull/Cipher/CryptArc4Null.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/** @file | ||
ARC4 Wrapper Implementation which does not provide real capabilities. | ||
Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "InternalCryptLib.h" | ||
|
||
/** | ||
Retrieves the size, in bytes, of the context buffer required for ARC4 operations. | ||
Return zero to indicate this interface is not supported. | ||
@retval 0 This interface is not supported. | ||
**/ | ||
UINTN | ||
EFIAPI | ||
Arc4GetContextSize ( | ||
VOID | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return 0; | ||
} | ||
|
||
/** | ||
Initializes user-supplied memory as ARC4 context for subsequent use. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[out] Arc4Context Pointer to ARC4 context being initialized. | ||
@param[in] Key Pointer to the user-supplied ARC4 key. | ||
@param[in] KeySize Size of ARC4 key in bytes. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
Arc4Init ( | ||
OUT VOID *Arc4Context, | ||
IN CONST UINT8 *Key, | ||
IN UINTN KeySize | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Performs ARC4 encryption on a data buffer of the specified size. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in, out] Arc4Context Pointer to the ARC4 context. | ||
@param[in] Input Pointer to the buffer containing the data to be encrypted. | ||
@param[in] InputSize Size of the Input buffer in bytes. | ||
@param[out] Output Pointer to a buffer that receives the ARC4 encryption output. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
Arc4Encrypt ( | ||
IN OUT VOID *Arc4Context, | ||
IN CONST UINT8 *Input, | ||
IN UINTN InputSize, | ||
OUT UINT8 *Output | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Performs ARC4 decryption on a data buffer of the specified size. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in, out] Arc4Context Pointer to the ARC4 context. | ||
@param[in] Input Pointer to the buffer containing the data to be decrypted. | ||
@param[in] InputSize Size of the Input buffer in bytes. | ||
@param[out] Output Pointer to a buffer that receives the ARC4 decryption output. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
Arc4Decrypt ( | ||
IN OUT VOID *Arc4Context, | ||
IN UINT8 *Input, | ||
IN UINTN InputSize, | ||
OUT UINT8 *Output | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} | ||
|
||
/** | ||
Resets the ARC4 context to the initial state. | ||
Return FALSE to indicate this interface is not supported. | ||
@param[in, out] Arc4Context Pointer to the ARC4 context. | ||
@retval FALSE This interface is not supported. | ||
**/ | ||
BOOLEAN | ||
EFIAPI | ||
Arc4Reset ( | ||
IN OUT VOID *Arc4Context | ||
) | ||
{ | ||
ASSERT (FALSE); | ||
return FALSE; | ||
} |
Oops, something went wrong.