]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add interfaces to several library instances of BaseCryptLib.
authortye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 18 Jul 2012 09:32:05 +0000 (09:32 +0000)
committertye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 18 Jul 2012 09:32:05 +0000 (09:32 +0000)
Signed-off-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13539 6f19259b-4bc3-4df7-8a09-765794883524

42 files changed:
CryptoPkg/Include/Library/BaseCryptLib.h
CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
CryptoPkg/Library/BaseCryptLib/Cipher/CryptAesNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdesNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
CryptoPkg/Library/BaseCryptLib/Pem/CryptPemNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticodeNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptDhNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Sign.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7SignNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExtNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/Rand/CryptRandNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/BaseCryptLibRuntimeCryptProtocol.inf
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptAesNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptArc4Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptTdesNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd4Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd5Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptSha1Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacMd5Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacSha1Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/InternalCryptLib.h [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pem/CryptPemNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptAuthenticodeNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptDhNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptPkcs7SignNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptPkcs7VerifyNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptRsaExtNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptX509Null.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Rand/CryptRandNull.c [new file with mode: 0644]
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/RuntimeDxeIpfCryptLib.c

index ffd83ada66855cffd77f7c519bd56a0fffd520e8..decca54eac5c54b6a619fbcaaa10061e05bdef51 100644 (file)
@@ -69,7 +69,10 @@ typedef enum {
 /**\r
   Retrieves the size, in bytes, of the context buffer required for MD4 hash operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for MD4 hash operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -83,11 +86,13 @@ Md4GetContextSize (
   subsequent use.\r
 \r
   If Md4Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  Md4Context  Pointer to MD4 context being initialized.\r
 \r
   @retval TRUE   MD4 context initialization succeeded.\r
   @retval FALSE  MD4 context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -101,12 +106,14 @@ Md4Init (
 \r
   If Md4Context is NULL, then return FALSE.\r
   If NewMd4Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  Md4Context     Pointer to MD4 context being copied.\r
   @param[out] NewMd4Context  Pointer to new MD4 context.\r
 \r
   @retval TRUE   MD4 context copy succeeded.\r
   @retval FALSE  MD4 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -125,6 +132,7 @@ Md4Duplicate (
   by Md4Final(). Behavior with invalid context is undefined.\r
 \r
   If Md4Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Md4Context  Pointer to the MD4 context.\r
   @param[in]       Data        Pointer to the buffer containing the data to be hashed.\r
@@ -132,6 +140,7 @@ Md4Duplicate (
 \r
   @retval TRUE   MD4 data digest succeeded.\r
   @retval FALSE  MD4 data digest failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -153,6 +162,7 @@ Md4Update (
 \r
   If Md4Context is NULL, then return FALSE.\r
   If HashValue is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Md4Context  Pointer to the MD4 context.\r
   @param[out]      HashValue   Pointer to a buffer that receives the MD4 digest\r
@@ -160,6 +170,7 @@ Md4Update (
 \r
   @retval TRUE   MD4 digest computation succeeded.\r
   @retval FALSE  MD4 digest computation failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -172,7 +183,10 @@ Md4Final (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for MD5 hash operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -186,11 +200,13 @@ Md5GetContextSize (
   subsequent use.\r
 \r
   If Md5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  Md5Context  Pointer to MD5 context being initialized.\r
 \r
   @retval TRUE   MD5 context initialization succeeded.\r
   @retval FALSE  MD5 context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -204,12 +220,14 @@ Md5Init (
 \r
   If Md5Context is NULL, then return FALSE.\r
   If NewMd5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  Md5Context     Pointer to MD5 context being copied.\r
   @param[out] NewMd5Context  Pointer to new MD5 context.\r
 \r
   @retval TRUE   MD5 context copy succeeded.\r
   @retval FALSE  MD5 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -228,6 +246,7 @@ Md5Duplicate (
   by Md5Final(). Behavior with invalid context is undefined.\r
 \r
   If Md5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Md5Context  Pointer to the MD5 context.\r
   @param[in]       Data        Pointer to the buffer containing the data to be hashed.\r
@@ -235,6 +254,7 @@ Md5Duplicate (
 \r
   @retval TRUE   MD5 data digest succeeded.\r
   @retval FALSE  MD5 data digest failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -256,6 +276,7 @@ Md5Update (
 \r
   If Md5Context is NULL, then return FALSE.\r
   If HashValue is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Md5Context  Pointer to the MD5 context.\r
   @param[out]      HashValue   Pointer to a buffer that receives the MD5 digest\r
@@ -263,6 +284,7 @@ Md5Update (
 \r
   @retval TRUE   MD5 digest computation succeeded.\r
   @retval FALSE  MD5 digest computation failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -275,7 +297,10 @@ Md5Final (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for SHA-1 hash operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -289,11 +314,13 @@ Sha1GetContextSize (
   subsequent use.\r
 \r
   If Sha1Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  Sha1Context  Pointer to SHA-1 context being initialized.\r
 \r
   @retval TRUE   SHA-1 context initialization succeeded.\r
   @retval FALSE  SHA-1 context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -307,12 +334,14 @@ Sha1Init (
 \r
   If Sha1Context is NULL, then return FALSE.\r
   If NewSha1Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  Sha1Context     Pointer to SHA-1 context being copied.\r
   @param[out] NewSha1Context  Pointer to new SHA-1 context.\r
 \r
   @retval TRUE   SHA-1 context copy succeeded.\r
   @retval FALSE  SHA-1 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -331,6 +360,7 @@ Sha1Duplicate (
   by Sha1Final(). Behavior with invalid context is undefined.\r
 \r
   If Sha1Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Sha1Context  Pointer to the SHA-1 context.\r
   @param[in]       Data         Pointer to the buffer containing the data to be hashed.\r
@@ -338,6 +368,7 @@ Sha1Duplicate (
 \r
   @retval TRUE   SHA-1 data digest succeeded.\r
   @retval FALSE  SHA-1 data digest failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -359,6 +390,7 @@ Sha1Update (
 \r
   If Sha1Context is NULL, then return FALSE.\r
   If HashValue is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Sha1Context  Pointer to the SHA-1 context.\r
   @param[out]      HashValue    Pointer to a buffer that receives the SHA-1 digest\r
@@ -366,6 +398,7 @@ Sha1Update (
 \r
   @retval TRUE   SHA-1 digest computation succeeded.\r
   @retval FALSE  SHA-1 digest computation failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -410,12 +443,14 @@ Sha256Init (
 \r
   If Sha256Context is NULL, then return FALSE.\r
   If NewSha256Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  Sha256Context     Pointer to SHA-256 context being copied.\r
   @param[out] NewSha256Context  Pointer to new SHA-256 context.\r
 \r
   @retval TRUE   SHA-256 context copy succeeded.\r
   @retval FALSE  SHA-256 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -486,7 +521,10 @@ Sha256Final (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for HMAC-MD5 operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for HMAC-MD5 operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -500,6 +538,7 @@ HmacMd5GetContextSize (
   subsequent use.\r
 \r
   If HmacMd5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  HmacMd5Context  Pointer to HMAC-MD5 context being initialized.\r
   @param[in]   Key             Pointer to the user-supplied key.\r
@@ -507,6 +546,7 @@ HmacMd5GetContextSize (
 \r
   @retval TRUE   HMAC-MD5 context initialization succeeded.\r
   @retval FALSE  HMAC-MD5 context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -522,12 +562,14 @@ HmacMd5Init (
 \r
   If HmacMd5Context is NULL, then return FALSE.\r
   If NewHmacMd5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  HmacMd5Context     Pointer to HMAC-MD5 context being copied.\r
   @param[out] NewHmacMd5Context  Pointer to new HMAC-MD5 context.\r
 \r
   @retval TRUE   HMAC-MD5 context copy succeeded.\r
   @retval FALSE  HMAC-MD5 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -546,6 +588,7 @@ HmacMd5Duplicate (
   finalized by HmacMd5Final(). Behavior with invalid context is undefined.\r
 \r
   If HmacMd5Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  HmacMd5Context  Pointer to the HMAC-MD5 context.\r
   @param[in]       Data            Pointer to the buffer containing the data to be digested.\r
@@ -553,6 +596,7 @@ HmacMd5Duplicate (
 \r
   @retval TRUE   HMAC-MD5 data digest succeeded.\r
   @retval FALSE  HMAC-MD5 data digest failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -574,6 +618,7 @@ HmacMd5Update (
 \r
   If HmacMd5Context is NULL, then return FALSE.\r
   If HashValue is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  HmacMd5Context  Pointer to the HMAC-MD5 context.\r
   @param[out]      HashValue       Pointer to a buffer that receives the HMAC-MD5 digest\r
@@ -581,6 +626,7 @@ HmacMd5Update (
 \r
   @retval TRUE   HMAC-MD5 digest computation succeeded.\r
   @retval FALSE  HMAC-MD5 digest computation failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -593,7 +639,10 @@ HmacMd5Final (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for HMAC-SHA1 operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -607,6 +656,7 @@ HmacSha1GetContextSize (
   subsequent use.\r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  HmacSha1Context  Pointer to HMAC-SHA1 context being initialized.\r
   @param[in]   Key              Pointer to the user-supplied key.\r
@@ -614,6 +664,7 @@ HmacSha1GetContextSize (
 \r
   @retval TRUE   HMAC-SHA1 context initialization succeeded.\r
   @retval FALSE  HMAC-SHA1 context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -629,12 +680,14 @@ HmacSha1Init (
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
   If NewHmacSha1Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  HmacSha1Context     Pointer to HMAC-SHA1 context being copied.\r
   @param[out] NewHmacSha1Context  Pointer to new HMAC-SHA1 context.\r
 \r
   @retval TRUE   HMAC-SHA1 context copy succeeded.\r
   @retval FALSE  HMAC-SHA1 context copy failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -653,6 +706,7 @@ HmacSha1Duplicate (
   be finalized by HmacSha1Final(). Behavior with invalid context is undefined.\r
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  HmacSha1Context Pointer to the HMAC-SHA1 context.\r
   @param[in]       Data            Pointer to the buffer containing the data to be digested.\r
@@ -660,6 +714,7 @@ HmacSha1Duplicate (
 \r
   @retval TRUE   HMAC-SHA1 data digest succeeded.\r
   @retval FALSE  HMAC-SHA1 data digest failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -681,6 +736,7 @@ HmacSha1Update (
 \r
   If HmacSha1Context is NULL, then return FALSE.\r
   If HashValue is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  HmacSha1Context  Pointer to the HMAC-SHA1 context.\r
   @param[out]      HashValue        Pointer to a buffer that receives the HMAC-SHA1 digest\r
@@ -688,6 +744,7 @@ HmacSha1Update (
 \r
   @retval TRUE   HMAC-SHA1 digest computation succeeded.\r
   @retval FALSE  HMAC-SHA1 digest computation failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -705,7 +762,10 @@ HmacSha1Final (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for TDES operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for TDES operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -728,6 +788,7 @@ TdesGetContextSize (
   If TdesContext is NULL, then return FALSE.\r
   If Key is NULL, then return FALSE.\r
   If KeyLength is not valid, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  TdesContext  Pointer to TDES context being initialized.\r
   @param[in]   Key          Pointer to the user-supplied TDES key.\r
@@ -735,6 +796,7 @@ TdesGetContextSize (
 \r
   @retval TRUE   TDES context initialization succeeded.\r
   @retval FALSE  TDES context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -759,6 +821,7 @@ TdesInit (
   If Input is NULL, then return FALSE.\r
   If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -767,6 +830,7 @@ TdesInit (
 \r
   @retval TRUE   TDES encryption succeeded.\r
   @retval FALSE  TDES encryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -792,6 +856,7 @@ TdesEcbEncrypt (
   If Input is NULL, then return FALSE.\r
   If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be decrypted.\r
@@ -800,6 +865,7 @@ TdesEcbEncrypt (
 \r
   @retval TRUE   TDES decryption succeeded.\r
   @retval FALSE  TDES decryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -827,6 +893,7 @@ TdesEcbDecrypt (
   If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
   If Ivec is NULL, then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -836,6 +903,7 @@ TdesEcbDecrypt (
 \r
   @retval TRUE   TDES encryption succeeded.\r
   @retval FALSE  TDES encryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -864,6 +932,7 @@ TdesCbcEncrypt (
   If InputSize is not multiple of block size (8 bytes), then return FALSE.\r
   If Ivec is NULL, then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -873,6 +942,7 @@ TdesCbcEncrypt (
 \r
   @retval TRUE   TDES decryption succeeded.\r
   @retval FALSE  TDES decryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -888,7 +958,10 @@ TdesCbcDecrypt (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for AES operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for AES operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -908,6 +981,7 @@ AesGetContextSize (
   If AesContext is NULL, then return FALSE.\r
   If Key is NULL, then return FALSE.\r
   If KeyLength is not valid, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  AesContext  Pointer to AES context being initialized.\r
   @param[in]   Key         Pointer to the user-supplied AES key.\r
@@ -915,6 +989,7 @@ AesGetContextSize (
 \r
   @retval TRUE   AES context initialization succeeded.\r
   @retval FALSE  AES context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -939,6 +1014,7 @@ AesInit (
   If Input is NULL, then return FALSE.\r
   If InputSize is not multiple of block size (16 bytes), then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -947,6 +1023,7 @@ AesInit (
 \r
   @retval TRUE   AES encryption succeeded.\r
   @retval FALSE  AES encryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -972,6 +1049,7 @@ AesEcbEncrypt (
   If Input is NULL, then return FALSE.\r
   If InputSize is not multiple of block size (16 bytes), then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be decrypted.\r
@@ -980,6 +1058,7 @@ AesEcbEncrypt (
 \r
   @retval TRUE   AES decryption succeeded.\r
   @retval FALSE  AES decryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1007,6 +1086,7 @@ AesEcbDecrypt (
   If InputSize is not multiple of block size (16 bytes), then return FALSE.\r
   If Ivec is NULL, then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -1016,6 +1096,7 @@ AesEcbDecrypt (
 \r
   @retval TRUE   AES encryption succeeded.\r
   @retval FALSE  AES encryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1044,6 +1125,7 @@ AesCbcEncrypt (
   If InputSize is not multiple of block size (16 bytes), then return FALSE.\r
   If Ivec is NULL, then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -1053,6 +1135,7 @@ AesCbcEncrypt (
 \r
   @retval TRUE   AES decryption succeeded.\r
   @retval FALSE  AES decryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1068,7 +1151,10 @@ AesCbcDecrypt (
 /**\r
   Retrieves the size, in bytes, of the context buffer required for ARC4 operations.\r
 \r
+  If this interface is not supported, then return zero.\r
+\r
   @return  The size, in bytes, of the context buffer required for ARC4 operations.\r
+  @retval  0   This interface is not supported.\r
 \r
 **/\r
 UINTN\r
@@ -1087,6 +1173,7 @@ Arc4GetContextSize (
   If Arc4Context is NULL, then return FALSE.\r
   If Key is NULL, then return FALSE.\r
   If KeySize does not in the range of [5, 256] bytes, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  Arc4Context  Pointer to ARC4 context being initialized.\r
   @param[in]   Key          Pointer to the user-supplied ARC4 key.\r
@@ -1094,6 +1181,7 @@ Arc4GetContextSize (
 \r
   @retval TRUE   ARC4 context initialization succeeded.\r
   @retval FALSE  ARC4 context initialization failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1115,6 +1203,7 @@ Arc4Init (
   If Arc4Context is NULL, then return FALSE.\r
   If Input is NULL, then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   Arc4Context  Pointer to the ARC4 context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -1123,6 +1212,7 @@ Arc4Init (
 \r
   @retval TRUE   ARC4 encryption succeeded.\r
   @retval FALSE  ARC4 encryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1145,6 +1235,7 @@ Arc4Encrypt (
   If Arc4Context is NULL, then return FALSE.\r
   If Input is NULL, then return FALSE.\r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]   Arc4Context  Pointer to the ARC4 context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be decrypted.\r
@@ -1153,6 +1244,7 @@ Arc4Encrypt (
 \r
   @retval TRUE   ARC4 decryption succeeded.\r
   @retval FALSE  ARC4 decryption failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1173,11 +1265,13 @@ Arc4Decrypt (
   should be already correctly initialized by ARC4Init().\r
 \r
   If Arc4Context is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
 \r
   @retval TRUE   ARC4 reset succeeded.\r
   @retval FALSE  ARC4 reset failed.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1262,6 +1356,7 @@ RsaSetKey (
   If RsaContext is NULL, then return FALSE.\r
   If BnSize is NULL, then return FALSE.\r
   If BnSize is large enough but BigNumber is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  RsaContext  Pointer to RSA context being set.\r
   @param[in]       KeyTag      Tag of RSA key component being set.\r
@@ -1272,6 +1367,7 @@ RsaSetKey (
   @retval  TRUE   RSA key component was retrieved successfully.\r
   @retval  FALSE  Invalid RSA key component tag.\r
   @retval  FALSE  BnSize is too small.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1294,6 +1390,7 @@ RsaGetKey (
   initialized by RandomSeed().\r
 \r
   If RsaContext is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  RsaContext           Pointer to RSA context being set.\r
   @param[in]       ModulusLength        Length of RSA modulus N in bits.\r
@@ -1302,6 +1399,7 @@ RsaGetKey (
 \r
   @retval  TRUE   RSA key component was generated successfully.\r
   @retval  FALSE  Invalid RSA key component tag.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1323,11 +1421,13 @@ RsaGenerateKey (
   - Whether d*e = 1  mod lcm(p-1,q-1)\r
 \r
   If RsaContext is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  RsaContext  Pointer to RSA context to check.\r
 \r
   @retval  TRUE   RSA key components are valid.\r
   @retval  FALSE  RSA key components are not valid.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1348,6 +1448,7 @@ RsaCheckKey (
   If MessageHash is NULL, then return FALSE.\r
   If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
   If SigSize is large enough but Signature is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]      RsaContext   Pointer to RSA context for signature generation.\r
   @param[in]      MessageHash  Pointer to octet message hash to be signed.\r
@@ -1359,6 +1460,7 @@ RsaCheckKey (
   @retval  TRUE   Signature successfully generated in PKCS1-v1_5.\r
   @retval  FALSE  Signature generation failed.\r
   @retval  FALSE  SigSize is too small.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1403,6 +1505,10 @@ RsaPkcs1Verify (
 /**\r
   Retrieve the RSA Private Key from the password-protected PEM key data.\r
 \r
+  If PemData is NULL, then return FALSE.\r
+  If RsaContext is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
   @param[in]  PemData      Pointer to the PEM-encoded key data to be retrieved.\r
   @param[in]  PemSize      Size of the PEM key data in bytes.\r
   @param[in]  Password     NULL-terminated passphrase used for encrypted PEM key data.\r
@@ -1410,11 +1516,10 @@ RsaPkcs1Verify (
                            RSA private key component. Use RsaFree() function to free the\r
                            resource.\r
 \r
-  If PemData is NULL, then return FALSE.\r
-  If RsaContext is NULL, then return FALSE.\r
-\r
   @retval  TRUE   RSA Private Key was retrieved successfully.\r
   @retval  FALSE  Invalid PEM key data or incorrect password.\r
+  @retval  FALSE  This interface is not supported.\r
+  \r
 \r
 **/\r
 BOOLEAN\r
@@ -1429,17 +1534,19 @@ RsaGetPrivateKeyFromPem (
 /**\r
   Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r
 \r
+  If Cert is NULL, then return FALSE.\r
+  If RsaContext is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
   @param[in]  Cert         Pointer to the DER-encoded X509 certificate.\r
   @param[in]  CertSize     Size of the X509 certificate in bytes.\r
   @param[out] RsaContext   Pointer to new-generated RSA context which contain the retrieved\r
                            RSA public key component. Use RsaFree() function to free the\r
                            resource.\r
 \r
-  If Cert is NULL, then return FALSE.\r
-  If RsaContext is NULL, then return FALSE.\r
-\r
   @retval  TRUE   RSA Public Key was retrieved successfully.\r
   @retval  FALSE  Fail to retrieve RSA public key from X509 certificate.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1453,18 +1560,20 @@ RsaGetPublicKeyFromX509 (
 /**\r
   Retrieve the subject bytes from one X.509 certificate.\r
 \r
+  If Cert is NULL, then return FALSE.\r
+  If SubjectSize is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
   @param[in]      Cert         Pointer to the DER-encoded X509 certificate.\r
   @param[in]      CertSize     Size of the X509 certificate in bytes.\r
   @param[out]     CertSubject  Pointer to the retrieved certificate subject bytes.\r
   @param[in, out] SubjectSize  The size in bytes of the CertSubject buffer on input,\r
                                and the size of buffer returned CertSubject on output.\r
 \r
-  If Cert is NULL, then return FALSE.\r
-  If SubjectSize is NULL, then return FALSE.\r
-\r
   @retval  TRUE   The certificate subject retrieved successfully.\r
   @retval  FALSE  Invalid certificate, or the SubjectSize is too small for the result.\r
                   The SubjectSize will be updated with the required size.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1479,17 +1588,19 @@ X509GetSubjectName (
 /**\r
   Verify one X509 certificate was issued by the trusted CA.\r
 \r
+  If Cert is NULL, then return FALSE.\r
+  If CACert is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
   @param[in]      Cert         Pointer to the DER-encoded X509 certificate to be verified.\r
   @param[in]      CertSize     Size of the X509 certificate in bytes.\r
   @param[in]      CACert       Pointer to the DER-encoded trusted CA certificate.\r
   @param[in]      CACertSize   Size of the CA Certificate in bytes.\r
 \r
-  If Cert is NULL, then return FALSE.\r
-  If CACert is NULL, then return FALSE.\r
-\r
   @retval  TRUE   The certificate was issued by the trusted CA.\r
   @retval  FALSE  Invalid certificate or the certificate was not issued by the given\r
                   trusted CA.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1506,6 +1617,7 @@ X509VerifyCert (
 \r
   If Cert is NULL, then return FALSE.\r
   If SingleX509Cert is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  Cert            Pointer to the DER-encoded certificate data.\r
   @param[in]  CertSize        The size of certificate data in bytes.\r
@@ -1513,6 +1625,7 @@ X509VerifyCert (
 \r
   @retval     TRUE            The X509 object generation succeeded.\r
   @retval     FALSE           The operation failed.\r
+  @retval     FALSE           This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1527,6 +1640,7 @@ X509ConstructCertificate (
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r
   If X509Stack is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  X509Stack  On input, pointer to an existing X509 stack object.\r
                               On output, pointer to the X509 stack object with new\r
@@ -1537,6 +1651,7 @@ X509ConstructCertificate (
                                  \r
   @retval     TRUE            The X509 stack construction succeeded.\r
   @retval     FALSE           The construction operation failed.\r
+  @retval     FALSE           This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1549,7 +1664,7 @@ X509ConstructCertificateStack (
 /**\r
   Release the specified X509 object.\r
 \r
-  If X509Cert is NULL, then return FALSE.\r
+  If the interface is not supported, then ASSERT().\r
 \r
   @param[in]  X509Cert  Pointer to the X509 object to be released.\r
 \r
@@ -1563,7 +1678,7 @@ X509Free (
 /**\r
   Release the specified X509 stack object.\r
 \r
-  If X509Stack is NULL, then return FALSE.\r
+  If the interface is not supported, then ASSERT().\r
 \r
   @param[in]  X509Stack  Pointer to the X509 stack object to be released.\r
 \r
@@ -1581,6 +1696,7 @@ X509StackFree (
 \r
   If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r
   return FALSE. If P7Length overflow, then return FAlSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
   @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
@@ -1593,6 +1709,7 @@ X509StackFree (
 \r
   @retval  TRUE            The operation is finished successfully.\r
   @retval  FALSE           Error occurs during the operation.\r
+  @retval  FALSE           This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1609,6 +1726,8 @@ Pkcs7GetSigners (
 /**\r
   Wrap function to use free() to free allocated memory for certificates.\r
 \r
+  If this interface is not supported, then ASSERT().\r
+\r
   @param[in]  Certs        Pointer to the certificates to be freed.\r
 \r
 **/\r
@@ -1623,6 +1742,8 @@ Pkcs7FreeSigners (
   Syntax Standard, version 1.5". This interface is only intended to be used for\r
   application to perform PKCS#7 functionality validation.\r
 \r
+  If this interface is not supported, then return FALSE.\r
+\r
   @param[in]  PrivateKey       Pointer to the PEM-formatted private key data for\r
                                data signing.\r
   @param[in]  PrivateKeySize   Size of the PEM private key data in bytes.\r
@@ -1639,6 +1760,7 @@ Pkcs7FreeSigners (
 \r
   @retval     TRUE             PKCS#7 data signing succeeded.\r
   @retval     FALSE            PKCS#7 data signing failed.\r
+  @retval     FALSE            This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1662,6 +1784,7 @@ Pkcs7Sign (
 \r
   If P7Data, TrustedCert or InData is NULL, then return FALSE.\r
   If P7Length, CertLength or DataLength overflow, then return FAlSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
   @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
@@ -1673,6 +1796,7 @@ Pkcs7Sign (
 \r
   @retval  TRUE  The specified PKCS#7 signed data is valid.\r
   @retval  FALSE Invalid PKCS#7 signed data.\r
+  @retval  FALSE This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1692,6 +1816,7 @@ Pkcs7Verify (
 \r
   If AuthData is NULL, then return FALSE.\r
   If ImageHash is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  AuthData     Pointer to the Authenticode Signature retrieved from signed\r
                            PE/COFF image to be verified.\r
@@ -1706,6 +1831,7 @@ Pkcs7Verify (
 \r
   @retval  TRUE   The specified Authenticode Signature is valid.\r
   @retval  FALSE  Invalid Authenticode Signature.\r
+  @retval  FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1728,6 +1854,7 @@ AuthenticodeVerify (
 \r
   @return  Pointer to the Diffie-Hellman Context that has been initialized.\r
            If the allocations fails, DhNew() returns NULL.\r
+           If the interface is not supported, DhNew() returns NULL.\r
 \r
 **/\r
 VOID *\r
@@ -1739,7 +1866,7 @@ DhNew (
 /**\r
   Release the specified DH context.\r
 \r
-  If DhContext is NULL, then return FALSE.\r
+  If the interface is not supported, then ASSERT().\r
 \r
   @param[in]  DhContext  Pointer to the DH context to be released.\r
 \r
@@ -1761,6 +1888,7 @@ DhFree (
 \r
   If DhContext is NULL, then return FALSE.\r
   If Prime is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  DhContext    Pointer to the DH context.\r
   @param[in]       Generator    Value of generator.\r
@@ -1770,6 +1898,7 @@ DhFree (
   @retval TRUE   DH pamameter generation succeeded.\r
   @retval FALSE  Value of Generator is not supported.\r
   @retval FALSE  PRNG fails to generate random prime number with PrimeLength.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1789,6 +1918,7 @@ DhGenerateParameter (
 \r
   If DhContext is NULL, then return FALSE.\r
   If Prime is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  DhContext    Pointer to the DH context.\r
   @param[in]       Generator    Value of generator.\r
@@ -1800,6 +1930,7 @@ DhGenerateParameter (
   @retval FALSE  Value of Generator is not suitable for the Prime.\r
   @retval FALSE  Value of Prime is not a prime number.\r
   @retval FALSE  Value of Prime is not a safe prime number.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1822,6 +1953,7 @@ DhSetParameter (
   If DhContext is NULL, then return FALSE.\r
   If PublicKeySize is NULL, then return FALSE.\r
   If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  DhContext      Pointer to the DH context.\r
   @param[out]      PublicKey      Pointer to the buffer to receive generated public key.\r
@@ -1831,6 +1963,7 @@ DhSetParameter (
   @retval TRUE   DH public key generation succeeded.\r
   @retval FALSE  DH public key generation failed.\r
   @retval FALSE  PublicKeySize is not large enough.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1851,6 +1984,7 @@ DhGenerateKey (
   If PeerPublicKey is NULL, then return FALSE.\r
   If KeySize is NULL, then return FALSE.\r
   If KeySize is large enough but Key is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  DhContext          Pointer to the DH context.\r
   @param[in]       PeerPublicKey      Pointer to the peer's public key.\r
@@ -1862,6 +1996,7 @@ DhGenerateKey (
   @retval TRUE   DH exchanged key generation succeeded.\r
   @retval FALSE  DH exchanged key generation failed.\r
   @retval FALSE  KeySize is not large enough.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1884,6 +2019,7 @@ DhComputeKey (
   This function sets up the seed value for the pseudorandom number generator.\r
   If Seed is not NULL, then the seed passed in is used.\r
   If Seed is NULL, then default seed is used.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in]  Seed      Pointer to seed value.\r
                         If NULL, default seed is used.\r
@@ -1892,6 +2028,7 @@ DhComputeKey (
 \r
   @retval TRUE   Pseudorandom number generator has enough entropy for random generation.\r
   @retval FALSE  Pseudorandom number generator does not have enough entropy for random generation.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1905,12 +2042,14 @@ RandomSeed (
   Generates a pseudorandom byte stream of the specified size.\r
 \r
   If Output is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[out]  Output  Pointer to buffer to receive random value.\r
   @param[in]   Size    Size of randome bytes to generate.\r
 \r
   @retval TRUE   Pseudorandom byte stream generated successfully.\r
   @retval FALSE  Pseudorandom number generator fails to generate due to lack of entropy.\r
+  @retval FALSE  This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
index 3b4e69632849bb764eb24c4d4fd81a9d94ce05f2..5bb782927860608e0fb89c4f29d2152e3b308a38 100644 (file)
@@ -21,9 +21,9 @@
   INF_VERSION                    = 0x00010005\r
   BASE_NAME                      = BaseCryptLib\r
   FILE_GUID                      = be3bb803-91b6-4da0-bd91-a8b21c18ca5d\r
-  MODULE_TYPE                    = BASE\r
+  MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = BaseCryptLib\r
+  LIBRARY_CLASS                  = BaseCryptLib|DXE_DRIVER DXE_CORE UEFI_APPLICATION UEFI_DRIVER\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
   Cipher/CryptAes.c\r
   Cipher/CryptTdes.c\r
   Cipher/CryptArc4.c\r
-  Pk/CryptRsa.c\r
-  Pk/CryptPkcs7.c\r
+  Pk/CryptRsaBasic.c\r
+  Pk/CryptRsaExt.c\r
+  Pk/CryptPkcs7Sign.c\r
+  Pk/CryptPkcs7Verify.c\r
   Pk/CryptDh.c\r
   Pk/CryptX509.c\r
   Pk/CryptAuthenticode.c\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Cipher/CryptAesNull.c b/CryptoPkg/Library/BaseCryptLib/Cipher/CryptAesNull.c
new file mode 100644 (file)
index 0000000..074b072
--- /dev/null
@@ -0,0 +1,165 @@
+/** @file\r
+  AES Wrapper Implementation which does not provide real capabilities.  \r
+  \r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for AES operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AesGetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory as AES context for subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  AesContext  Pointer to AES context being initialized.\r
+  @param[in]   Key         Pointer to the user-supplied AES key.\r
+  @param[in]   KeyLength   Length of AES key in bits.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesInit (\r
+  OUT  VOID         *AesContext,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeyLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES encryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+  \r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES encryption output.\r
+  \r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesEcbEncrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES decryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be decrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES decryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesEcbDecrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES encryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[in]   Ivec        Pointer to initialization vector.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesCbcEncrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES decryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[in]   Ivec        Pointer to initialization vector.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesCbcDecrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{  \r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4Null.c b/CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4Null.c
new file mode 100644 (file)
index 0000000..1275e20
--- /dev/null
@@ -0,0 +1,130 @@
+/** @file \r
+  ARC4 Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for ARC4 operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Arc4GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory as ARC4 context for subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Arc4Context  Pointer to ARC4 context being initialized.\r
+  @param[in]   Key          Pointer to the user-supplied ARC4 key.\r
+  @param[in]   KeySize      Size of ARC4 key in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Init (\r
+  OUT  VOID         *Arc4Context,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs ARC4 encryption on a data buffer of the specified size.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
+  @param[in]       Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]       InputSize    Size of the Input buffer in bytes.\r
+  @param[out]      Output       Pointer to a buffer that receives the ARC4 encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Encrypt (\r
+  IN OUT  VOID         *Arc4Context,\r
+  IN      CONST UINT8  *Input,\r
+  IN      UINTN        InputSize,\r
+  OUT     UINT8        *Output\r
+  )\r
+{ \r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs ARC4 decryption on a data buffer of the specified size.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
+  @param[in]       Input        Pointer to the buffer containing the data to be decrypted.\r
+  @param[in]       InputSize    Size of the Input buffer in bytes.\r
+  @param[out]      Output       Pointer to a buffer that receives the ARC4 decryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Decrypt (\r
+  IN OUT  VOID   *Arc4Context,\r
+  IN      UINT8  *Input,\r
+  IN      UINTN  InputSize,\r
+  OUT     UINT8  *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Resets the ARC4 context to the initial state.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Reset (\r
+  IN OUT  VOID  *Arc4Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdesNull.c b/CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdesNull.c
new file mode 100644 (file)
index 0000000..cec33b6
--- /dev/null
@@ -0,0 +1,166 @@
+/** @file\r
+  TDES Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for TDES operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+TdesGetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory as TDES context for subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  TdesContext  Pointer to TDES context being initialized.\r
+  @param[in]   Key          Pointer to the user-supplied TDES key.\r
+  @param[in]   KeyLength    Length of TDES key in bits.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesInit (\r
+  OUT  VOID         *TdesContext,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeyLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES encryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesEcbEncrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES decryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be decrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES decryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesEcbDecrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES encryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[in]   Ivec         Pointer to initialization vector.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesCbcEncrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES decryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[in]   Ivec         Pointer to initialization vector.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesCbcDecrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c
new file mode 100644 (file)
index 0000000..fc634fd
--- /dev/null
@@ -0,0 +1,124 @@
+/** @file\r
+  MD4 Digest Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for MD4 hash\r
+  operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Md4GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by Md4Context as MD4 hash context for\r
+  subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Md4Context  Pointer to MD4 context being initialized.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Init (\r
+  OUT  VOID  *Md4Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing MD4 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Md4Context     Pointer to MD4 context being copied.\r
+  @param[out] NewMd4Context  Pointer to new MD4 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Duplicate (\r
+  IN   CONST VOID  *Md4Context,\r
+  OUT  VOID        *NewMd4Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates MD4 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Md4Context  Pointer to the MD4 context.\r
+  @param[in]       Data        Pointer to the buffer containing the data to be hashed.\r
+  @param[in]       DataSize    Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Update (\r
+  IN OUT  VOID        *Md4Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the MD4 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[in, out]  Md4Context  Pointer to the MD4 context.\r
+  @param[out]      HashValue   Pointer to a buffer that receives the MD4 digest\r
+                               value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Final (\r
+  IN OUT  VOID   *Md4Context,\r
+  OUT     UINT8  *HashValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c
new file mode 100644 (file)
index 0000000..b4bdde0
--- /dev/null
@@ -0,0 +1,127 @@
+/** @file\r
+  HMAC-MD5 Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for HMAC-MD5 operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+HmacMd5GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for\r
+  subsequent use. \r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[out]  HmacMd5Context  Pointer to HMAC-MD5 context being initialized.\r
+  @param[in]   Key             Pointer to the user-supplied key.\r
+  @param[in]   KeySize         Key size in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Init (\r
+  OUT  VOID         *HmacMd5Context,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing HMAC-MD5 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  HmacMd5Context     Pointer to HMAC-MD5 context being copied.\r
+  @param[out] NewHmacMd5Context  Pointer to new HMAC-MD5 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Duplicate (\r
+  IN   CONST VOID  *HmacMd5Context,\r
+  OUT  VOID        *NewHmacMd5Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates HMAC-MD5 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  HmacMd5Context  Pointer to the HMAC-MD5 context.\r
+  @param[in]       Data            Pointer to the buffer containing the data to be digested.\r
+  @param[in]       DataSize        Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Update (\r
+  IN OUT  VOID        *HmacMd5Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the HMAC-MD5 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  HmacMd5Context  Pointer to the HMAC-MD5 context.\r
+  @param[out]      HmacValue       Pointer to a buffer that receives the HMAC-MD5 digest\r
+                                   value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Final (\r
+  IN OUT  VOID   *HmacMd5Context,\r
+  OUT     UINT8  *HmacValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c
new file mode 100644 (file)
index 0000000..b31d0d1
--- /dev/null
@@ -0,0 +1,127 @@
+/** @file\r
+  HMAC-SHA1 Wrapper Implementation which does not provide real capabilities.  \r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+HmacSha1GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for\r
+  subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[out]  HmacSha1Context  Pointer to HMAC-SHA1 context being initialized.\r
+  @param[in]   Key              Pointer to the user-supplied key.\r
+  @param[in]   KeySize          Key size in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Init (\r
+  OUT  VOID         *HmacSha1Context,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing HMAC-SHA1 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  HmacSha1Context     Pointer to HMAC-SHA1 context being copied.\r
+  @param[out] NewHmacSha1Context  Pointer to new HMAC-SHA1 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Duplicate (\r
+  IN   CONST VOID  *HmacSha1Context,\r
+  OUT  VOID        *NewHmacSha1Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates HMAC-SHA1 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[in, out]  HmacSha1Context Pointer to the HMAC-SHA1 context.\r
+  @param[in]       Data            Pointer to the buffer containing the data to be digested.\r
+  @param[in]       DataSize        Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Update (\r
+  IN OUT  VOID        *HmacSha1Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the HMAC-SHA1 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[in, out]  HmacSha1Context  Pointer to the HMAC-SHA1 context.\r
+  @param[out]      HmacValue        Pointer to a buffer that receives the HMAC-SHA1 digest\r
+                                    value (20 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Final (\r
+  IN OUT  VOID   *HmacSha1Context,\r
+  OUT     UINT8  *HmacValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
index e60c17ece0426a7d22765a7e5a9bbf2f5514c761..fae54e650e3366791460b27271d04518dde6d22c 100644 (file)
@@ -6,6 +6,12 @@
 #  This external input must be validated carefully to avoid security issue like\r
 #  buffer overflow, integer overflow.\r
 #\r
+#  Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/\r
+#  TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions,\r
+#  Diffie-Hellman functions, X.509 certificate handler functions, authenticode\r
+#  signature verification functions, PEM handler functions, pseudorandom number\r
+#  generator functions are not supported in this instance.\r
+#\r
 #  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -23,7 +29,7 @@
   FILE_GUID                      = 9a2a4375-194c-4e97-9f67-547ec98d96ca\r
   MODULE_TYPE                    = PEIM\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = BaseCryptLib|PEIM PEI_CORE SEC\r
+  LIBRARY_CLASS                  = BaseCryptLib|PEIM PEI_CORE\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
 \r
 [Sources]\r
+  Hash/CryptMd4Null.c\r
   Hash/CryptMd5.c\r
   Hash/CryptSha1.c\r
   Hash/CryptSha256.c\r
-  Pk/CryptRsa.c\r
+  Hmac/CryptHmacMd5Null.c\r
+  Hmac/CryptHmacSha1Null.c\r
+  Cipher/CryptAesNull.c\r
+  Cipher/CryptTdesNull.c\r
+  Cipher/CryptArc4Null.c\r
+\r
+  Pk/CryptRsaBasic.c\r
+  Pk/CryptRsaExtNull.c\r
+  Pk/CryptPkcs7SignNull.c\r
+  Pk/CryptPkcs7Verify.c\r
+\r
+  Pk/CryptDhNull.c\r
+  Pk/CryptX509Null.c\r
+  Pk/CryptAuthenticodeNull.c\r
+  Pem/CryptPemNull.c\r
+\r
+  Rand/CryptRandNull.c\r
 \r
   SysCall/CrtWrapper.c\r
   SysCall/BaseMemAllocation.c\r
 \r
+\r
 [Sources.Ia32]\r
   SysCall/Ia32/MathMultS64x64.c     | MSFT\r
   SysCall/Ia32/MathDivU64x64.c      | MSFT\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pem/CryptPemNull.c b/CryptoPkg/Library/BaseCryptLib/Pem/CryptPemNull.c
new file mode 100644 (file)
index 0000000..8c9e4f0
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation which does\r
+  not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieve the RSA Private Key from the password-protected PEM key data.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  PemData      Pointer to the PEM-encoded key data to be retrieved.\r
+  @param[in]  PemSize      Size of the PEM key data in bytes.\r
+  @param[in]  Password     NULL-terminated passphrase used for encrypted PEM key data.\r
+  @param[out] RsaContext   Pointer to new-generated RSA context which contain the retrieved\r
+                           RSA private key component. Use RsaFree() function to free the\r
+                           resource.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetPrivateKeyFromPem (\r
+  IN   CONST UINT8  *PemData,\r
+  IN   UINTN        PemSize,\r
+  IN   CONST CHAR8  *Password,\r
+  OUT  VOID         **RsaContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticodeNull.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticodeNull.c
new file mode 100644 (file)
index 0000000..5554486
--- /dev/null
@@ -0,0 +1,51 @@
+/** @file\r
+  Authenticode Portable Executable Signature Verification which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows\r
+  Authenticode Portable Executable Signature Format".\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  AuthData     Pointer to the Authenticode Signature retrieved from signed\r
+                           PE/COFF image to be verified.\r
+  @param[in]  DataSize     Size of the Authenticode Signature in bytes.\r
+  @param[in]  TrustedCert  Pointer to a trusted/root certificate encoded in DER, which\r
+                           is used for certificate chain verification.\r
+  @param[in]  CertSize     Size of the trusted certificate in bytes.\r
+  @param[in]  ImageHash    Pointer to the original image file hash value. The procudure\r
+                           for calculating the image hash value is described in Authenticode\r
+                           specification.\r
+  @param[in]  HashSize     Size of Image hash value in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AuthenticodeVerify (\r
+  IN  CONST UINT8  *AuthData,\r
+  IN  UINTN        DataSize,\r
+  IN  CONST UINT8  *TrustedCert,\r
+  IN  UINTN        CertSize,\r
+  IN  CONST UINT8  *ImageHash,\r
+  IN  UINTN        HashSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptDhNull.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptDhNull.c
new file mode 100644 (file)
index 0000000..35045db
--- /dev/null
@@ -0,0 +1,156 @@
+/** @file\r
+  Diffie-Hellman Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r
+\r
+  @return  Pointer to the Diffie-Hellman Context that has been initialized.\r
+           If the interface is not supported, DhNew() returns NULL.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+DhNew (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Release the specified DH context.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  DhContext  Pointer to the DH context to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DhFree (\r
+  IN  VOID  *DhContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Generates DH parameter.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext    Pointer to the DH context.\r
+  @param[in]       Generator    Value of generator.\r
+  @param[in]       PrimeLength  Length in bits of prime to be generated.\r
+  @param[out]      Prime        Pointer to the buffer to receive the generated prime number.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhGenerateParameter (\r
+  IN OUT  VOID   *DhContext,\r
+  IN      UINTN  Generator,\r
+  IN      UINTN  PrimeLength,\r
+  OUT     UINT8  *Prime\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Sets generator and prime parameters for DH.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext    Pointer to the DH context.\r
+  @param[in]       Generator    Value of generator.\r
+  @param[in]       PrimeLength  Length in bits of prime to be generated.\r
+  @param[in]       Prime        Pointer to the prime number.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhSetParameter (\r
+  IN OUT  VOID         *DhContext,\r
+  IN      UINTN        Generator,\r
+  IN      UINTN        PrimeLength,\r
+  IN      CONST UINT8  *Prime\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE; \r
+}\r
+\r
+/**\r
+  Generates DH public key.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext      Pointer to the DH context.\r
+  @param[out]      PublicKey      Pointer to the buffer to receive generated public key.\r
+  @param[in, out]  PublicKeySize  On input, the size of PublicKey buffer in bytes.\r
+                                  On output, the size of data returned in PublicKey buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhGenerateKey (\r
+  IN OUT  VOID   *DhContext,\r
+  OUT     UINT8  *PublicKey,\r
+  IN OUT  UINTN  *PublicKeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Computes exchanged common key.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext          Pointer to the DH context.\r
+  @param[in]       PeerPublicKey      Pointer to the peer's public key.\r
+  @param[in]       PeerPublicKeySize  Size of peer's public key in bytes.\r
+  @param[out]      Key                Pointer to the buffer to receive generated key.\r
+  @param[in, out]  KeySize            On input, the size of Key buffer in bytes.\r
+                                      On output, the size of data returned in Key buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhComputeKey (\r
+  IN OUT  VOID         *DhContext,\r
+  IN      CONST UINT8  *PeerPublicKey,\r
+  IN      UINTN        PeerPublicKeySize,\r
+  OUT     UINT8        *Key,\r
+  IN OUT  UINTN        *KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Sign.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Sign.c
new file mode 100644 (file)
index 0000000..b275ab8
--- /dev/null
@@ -0,0 +1,197 @@
+/** @file\r
+  PKCS#7 SignedData Sign Wrapper Implementation over OpenSSL.\r
+\r
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+#include <openssl/objects.h>\r
+#include <openssl/x509.h>\r
+#include <openssl/pkcs7.h>\r
+\r
+\r
+/**\r
+  Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r
+  Syntax Standard, version 1.5". This interface is only intended to be used for\r
+  application to perform PKCS#7 functionality validation.\r
+\r
+  @param[in]  PrivateKey       Pointer to the PEM-formatted private key data for\r
+                               data signing.\r
+  @param[in]  PrivateKeySize   Size of the PEM private key data in bytes.\r
+  @param[in]  KeyPassword      NULL-terminated passphrase used for encrypted PEM\r
+                               key data.\r
+  @param[in]  InData           Pointer to the content to be signed.\r
+  @param[in]  InDataSize       Size of InData in bytes.\r
+  @param[in]  SignCert         Pointer to signer's DER-encoded certificate to sign with.\r
+  @param[in]  OtherCerts       Pointer to an optional additional set of certificates to\r
+                               include in the PKCS#7 signedData (e.g. any intermediate\r
+                               CAs in the chain).\r
+  @param[out] SignedData       Pointer to output PKCS#7 signedData.\r
+  @param[out] SignedDataSize   Size of SignedData in bytes.\r
+\r
+  @retval     TRUE             PKCS#7 data signing succeeded.\r
+  @retval     FALSE            PKCS#7 data signing failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Sign (\r
+  IN   CONST UINT8  *PrivateKey,\r
+  IN   UINTN        PrivateKeySize,\r
+  IN   CONST UINT8  *KeyPassword,\r
+  IN   UINT8        *InData,\r
+  IN   UINTN        InDataSize,\r
+  IN   UINT8        *SignCert,\r
+  IN   UINT8        *OtherCerts      OPTIONAL,\r
+  OUT  UINT8        **SignedData,\r
+  OUT  UINTN        *SignedDataSize\r
+  )\r
+{\r
+  BOOLEAN   Status;\r
+  EVP_PKEY  *Key;\r
+  BIO       *DataBio;\r
+  PKCS7     *Pkcs7;\r
+  UINT8     *RsaContext;\r
+  UINT8     *P7Data;\r
+  UINTN     P7DataSize;\r
+  UINT8     *Tmp;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (PrivateKey == NULL || KeyPassword == NULL || InData == NULL ||\r
+    SignCert == NULL || SignedData == NULL || SignedDataSize == NULL || InDataSize > INT_MAX) {\r
+    return FALSE;\r
+  }\r
+\r
+  RsaContext = NULL;\r
+  Key        = NULL;\r
+  Pkcs7      = NULL;\r
+  DataBio    = NULL;\r
+  Status     = FALSE;\r
+\r
+  //\r
+  // Retrieve RSA private key from PEM data.\r
+  //\r
+  Status = RsaGetPrivateKeyFromPem (\r
+             PrivateKey,\r
+             PrivateKeySize,\r
+             (CONST CHAR8 *) KeyPassword,\r
+             (VOID **) &RsaContext\r
+             );\r
+  if (!Status) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Register & Initialize necessary digest algorithms and PRNG for PKCS#7 Handling\r
+  //\r
+  EVP_add_digest (EVP_md5());\r
+  EVP_add_digest (EVP_sha1());\r
+  EVP_add_digest (EVP_sha256());\r
+  RandomSeed (NULL, 0);\r
+\r
+  //\r
+  // Construct OpenSSL EVP_PKEY for private key.\r
+  //\r
+  Key = EVP_PKEY_new ();\r
+  if (Key == NULL) {\r
+    Status = FALSE;\r
+    goto _Exit;\r
+  }\r
+  Key->save_type = EVP_PKEY_RSA;\r
+  Key->type      = EVP_PKEY_type (EVP_PKEY_RSA);\r
+  Key->pkey.rsa  = (RSA *) RsaContext;\r
+\r
+  //\r
+  // Convert the data to be signed to BIO format. \r
+  //\r
+  DataBio = BIO_new (BIO_s_mem ());\r
+  BIO_write (DataBio, InData, (int) InDataSize);\r
+\r
+  //\r
+  // Create the PKCS#7 signedData structure.\r
+  //\r
+  Pkcs7 = PKCS7_sign (\r
+            (X509 *) SignCert,\r
+            Key,\r
+            (STACK_OF(X509) *) OtherCerts,\r
+            DataBio,\r
+            PKCS7_BINARY | PKCS7_NOATTR | PKCS7_DETACHED\r
+            );\r
+  if (Pkcs7 == NULL) {\r
+    Status = FALSE;\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Convert PKCS#7 signedData structure into DER-encoded buffer.\r
+  //\r
+  P7DataSize = i2d_PKCS7 (Pkcs7, NULL);\r
+  if (P7DataSize <= 19) {\r
+    Status = FALSE;\r
+    goto _Exit;\r
+  }\r
+\r
+  P7Data     = malloc (P7DataSize);\r
+  if (P7Data == NULL) {\r
+    Status = FALSE;\r
+    goto _Exit;\r
+  }\r
+\r
+  Tmp        = P7Data;\r
+  P7DataSize = i2d_PKCS7 (Pkcs7, (unsigned char **) &Tmp);\r
+\r
+  //\r
+  // Strip ContentInfo to content only for signeddata. The data be trimmed off\r
+  // is totally 19 bytes.\r
+  //\r
+  *SignedDataSize = P7DataSize - 19;\r
+  *SignedData     = malloc (*SignedDataSize);\r
+  if (*SignedData == NULL) {\r
+    Status = FALSE;\r
+    OPENSSL_free (P7Data);\r
+    goto _Exit;\r
+  }\r
+\r
+  CopyMem (*SignedData, P7Data + 19, *SignedDataSize);\r
+  \r
+  OPENSSL_free (P7Data);\r
+\r
+  Status = TRUE;\r
+\r
+_Exit:\r
+  //\r
+  // Release Resources\r
+  //\r
+  if (RsaContext != NULL) {\r
+    RsaFree (RsaContext);\r
+    if (Key != NULL) {\r
+      Key->pkey.rsa = NULL;\r
+    }\r
+  }\r
+\r
+  if (Key != NULL) {\r
+    EVP_PKEY_free (Key);\r
+  }\r
+\r
+  if (DataBio != NULL) {\r
+    BIO_free (DataBio);\r
+  }\r
+\r
+  if (Pkcs7 != NULL) {\r
+    PKCS7_free (Pkcs7);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7SignNull.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7SignNull.c
new file mode 100644 (file)
index 0000000..539bb6b
--- /dev/null
@@ -0,0 +1,59 @@
+/** @file\r
+  PKCS#7 SignedData Sign Wrapper Implementation which does not provide real\r
+  capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r
+  Syntax Standard, version 1.5". This interface is only intended to be used for\r
+  application to perform PKCS#7 functionality validation.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  PrivateKey       Pointer to the PEM-formatted private key data for\r
+                               data signing.\r
+  @param[in]  PrivateKeySize   Size of the PEM private key data in bytes.\r
+  @param[in]  KeyPassword      NULL-terminated passphrase used for encrypted PEM\r
+                               key data.\r
+  @param[in]  InData           Pointer to the content to be signed.\r
+  @param[in]  InDataSize       Size of InData in bytes.\r
+  @param[in]  SignCert         Pointer to signer's DER-encoded certificate to sign with.\r
+  @param[in]  OtherCerts       Pointer to an optional additional set of certificates to\r
+                               include in the PKCS#7 signedData (e.g. any intermediate\r
+                               CAs in the chain).\r
+  @param[out] SignedData       Pointer to output PKCS#7 signedData.\r
+  @param[out] SignedDataSize   Size of SignedData in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Sign (\r
+  IN   CONST UINT8  *PrivateKey,\r
+  IN   UINTN        PrivateKeySize,\r
+  IN   CONST UINT8  *KeyPassword,\r
+  IN   UINT8        *InData,\r
+  IN   UINTN        InDataSize,\r
+  IN   UINT8        *SignCert,\r
+  IN   UINT8        *OtherCerts      OPTIONAL,\r
+  OUT  UINT8        **SignedData,\r
+  OUT  UINTN        *SignedDataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
new file mode 100644 (file)
index 0000000..24f4c03
--- /dev/null
@@ -0,0 +1,577 @@
+/** @file\r
+  PKCS#7 SignedData Verification Wrapper Implementation over OpenSSL.\r
+\r
+  Caution: This module requires additional review when modified.\r
+  This library will have external input - signature (e.g. UEFI Authenticated\r
+  Variable). It may by input in SMM mode.\r
+  This external input must be validated carefully to avoid security issue like\r
+  buffer overflow, integer overflow.\r
+\r
+  WrapPkcs7Data(), Pkcs7GetSigners(), Pkcs7Verify() will get UEFI Authenticated\r
+  Variable and will do basic check for data structure.\r
+\r
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+#include <openssl/objects.h>\r
+#include <openssl/x509.h>\r
+#include <openssl/pkcs7.h>\r
+\r
+UINT8 mOidValue[9] = { 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02 };\r
+\r
+/**\r
+  Verification callback function to override any existing callbacks in OpenSSL\r
+  for intermediate certificate supports.\r
+\r
+  @param[in]  Status   Original status before calling this callback.\r
+  @param[in]  Context  X509 store context.\r
+\r
+  @retval     1        Current X509 certificate is verified successfully.\r
+  @retval     0        Verification failed.\r
+\r
+**/\r
+int\r
+X509VerifyCb (\r
+  IN int            Status,\r
+  IN X509_STORE_CTX *Context\r
+  )\r
+{\r
+  X509_OBJECT  *Obj;\r
+  INTN         Error;\r
+  INTN         Index;\r
+  INTN         Count;\r
+\r
+  Obj   = NULL;\r
+  Error = (INTN) X509_STORE_CTX_get_error (Context);\r
+\r
+  //\r
+  // X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT and X509_V_ERR_UNABLE_TO_GET_ISSUER_\r
+  // CERT_LOCALLY mean a X509 certificate is not self signed and its issuer\r
+  // can not be found in X509_verify_cert of X509_vfy.c.\r
+  // In order to support intermediate certificate node, we override the\r
+  // errors if the certification is obtained from X509 store, i.e. it is\r
+  // a trusted ceritifcate node that is enrolled by user.\r
+  // Besides,X509_V_ERR_CERT_UNTRUSTED and X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE\r
+  // are also ignored to enable such feature.\r
+  //\r
+  if ((Error == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT) ||\r
+      (Error == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY)) {\r
+    Obj = (X509_OBJECT *) malloc (sizeof (X509_OBJECT));\r
+    if (Obj == NULL) {\r
+      return 0;\r
+    }\r
+\r
+    Obj->type      = X509_LU_X509;\r
+    Obj->data.x509 = Context->current_cert;\r
+\r
+    CRYPTO_w_lock (CRYPTO_LOCK_X509_STORE);\r
+\r
+    if (X509_OBJECT_retrieve_match (Context->ctx->objs, Obj)) {\r
+      Status = 1;\r
+    } else {\r
+      //\r
+      // If any certificate in the chain is enrolled as trusted certificate,\r
+      // pass the certificate verification.\r
+      //\r
+      if (Error == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) {\r
+        Count = (INTN) sk_X509_num (Context->chain);\r
+        for (Index = 0; Index < Count; Index++) {\r
+          Obj->data.x509 = sk_X509_value (Context->chain, (int) Index);\r
+          if (X509_OBJECT_retrieve_match (Context->ctx->objs, Obj)) {\r
+            Status = 1;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    CRYPTO_w_unlock (CRYPTO_LOCK_X509_STORE);\r
+  }\r
+\r
+  if ((Error == X509_V_ERR_CERT_UNTRUSTED) ||\r
+      (Error == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE)) {\r
+    Status = 1;\r
+  }\r
+\r
+  if (Obj != NULL) {\r
+    OPENSSL_free (Obj);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Check input P7Data is a wrapped ContentInfo structure or not. If not construct\r
+  a new structure to wrap P7Data.\r
+\r
+  Caution: This function may receive untrusted input.\r
+  UEFI Authenticated Variable is external input, so this function will do basic\r
+  check for PKCS#7 data structure.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[out] WrapFlag     If TRUE P7Data is a ContentInfo structure, otherwise\r
+                           return FALSE.\r
+  @param[out] WrapData     If return status of this function is TRUE: \r
+                           1) when WrapFlag is TRUE, pointer to P7Data.\r
+                           2) when WrapFlag is FALSE, pointer to a new ContentInfo\r
+                           structure. It's caller's responsibility to free this\r
+                           buffer.\r
+  @param[out] WrapDataSize Length of ContentInfo structure in bytes.\r
+\r
+  @retval     TRUE         The operation is finished successfully.\r
+  @retval     FALSE        The operation is failed due to lack of resources.\r
+\r
+**/\r
+BOOLEAN\r
+WrapPkcs7Data (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT BOOLEAN      *WrapFlag,\r
+  OUT UINT8        **WrapData,\r
+  OUT UINTN        *WrapDataSize\r
+  )\r
+{\r
+  BOOLEAN          Wrapped;\r
+  UINT8            *SignedData;\r
+\r
+  //\r
+  // Check whether input P7Data is a wrapped ContentInfo structure or not.\r
+  //\r
+  Wrapped = FALSE;\r
+  if ((P7Data[4] == 0x06) && (P7Data[5] == 0x09)) {\r
+    if (CompareMem (P7Data + 6, mOidValue, sizeof (mOidValue)) == 0) {\r
+      if ((P7Data[15] == 0xA0) && (P7Data[16] == 0x82)) {\r
+        Wrapped = TRUE;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (Wrapped) {\r
+    *WrapData     = (UINT8 *) P7Data;\r
+    *WrapDataSize = P7Length;\r
+  } else {\r
+    //\r
+    // Wrap PKCS#7 signeddata to a ContentInfo structure - add a header in 19 bytes.\r
+    //\r
+    *WrapDataSize = P7Length + 19;\r
+    *WrapData     = malloc (*WrapDataSize);\r
+    if (*WrapData == NULL) {\r
+      *WrapFlag = Wrapped;\r
+      return FALSE;\r
+    }\r
+\r
+    SignedData = *WrapData;\r
+\r
+    //\r
+    // Part1: 0x30, 0x82.\r
+    //\r
+    SignedData[0] = 0x30;\r
+    SignedData[1] = 0x82;\r
+\r
+    //\r
+    // Part2: Length1 = P7Length + 19 - 4, in big endian.\r
+    //\r
+    SignedData[2] = (UINT8) (((UINT16) (*WrapDataSize - 4)) >> 8);\r
+    SignedData[3] = (UINT8) (((UINT16) (*WrapDataSize - 4)) & 0xff);\r
+\r
+    //\r
+    // Part3: 0x06, 0x09.\r
+    //\r
+    SignedData[4] = 0x06;\r
+    SignedData[5] = 0x09;\r
+\r
+    //\r
+    // Part4: OID value -- 0x2A 0x86 0x48 0x86 0xF7 0x0D 0x01 0x07 0x02.\r
+    //\r
+    CopyMem (SignedData + 6, mOidValue, sizeof (mOidValue));\r
+\r
+    //\r
+    // Part5: 0xA0, 0x82.\r
+    //\r
+    SignedData[15] = 0xA0;\r
+    SignedData[16] = 0x82;\r
+\r
+    //\r
+    // Part6: Length2 = P7Length, in big endian.\r
+    //\r
+    SignedData[17] = (UINT8) (((UINT16) P7Length) >> 8);\r
+    SignedData[18] = (UINT8) (((UINT16) P7Length) & 0xff);\r
+\r
+    //\r
+    // Part7: P7Data.\r
+    //\r
+    CopyMem (SignedData + 19, P7Data, P7Length);\r
+  }\r
+\r
+  *WrapFlag = Wrapped;\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r
+  return FALSE. If P7Length overflow, then return FAlSE.\r
+\r
+  Caution: This function may receive untrusted input.\r
+  UEFI Authenticated Variable is external input, so this function will do basic\r
+  check for PKCS#7 data structure.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[out] CertStack    Pointer to Signer's certificates retrieved from P7Data.\r
+                           It's caller's responsiblity to free the buffer.\r
+  @param[out] StackLength  Length of signer's certificates in bytes.\r
+  @param[out] TrustedCert  Pointer to a trusted certificate from Signer's certificates.\r
+                           It's caller's responsiblity to free the buffer.\r
+  @param[out] CertLength   Length of the trusted certificate in bytes.\r
+\r
+  @retval  TRUE            The operation is finished successfully.\r
+  @retval  FALSE           Error occurs during the operation.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7GetSigners (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT UINT8        **CertStack,\r
+  OUT UINTN        *StackLength,\r
+  OUT UINT8        **TrustedCert,\r
+  OUT UINTN        *CertLength\r
+  )\r
+{\r
+  PKCS7            *Pkcs7;\r
+  BOOLEAN          Status;\r
+  UINT8            *SignedData;\r
+  UINT8            *Temp;\r
+  UINTN            SignedDataSize;\r
+  BOOLEAN          Wrapped;\r
+  STACK_OF(X509)   *Stack;\r
+  UINT8            Index;\r
+  UINT8            *CertBuf;\r
+  UINT8            *OldBuf;\r
+  UINTN            BufferSize;\r
+  UINTN            OldSize;\r
+  UINT8            *SingleCert;\r
+  UINTN            SingleCertSize;\r
+\r
+  if ((P7Data == NULL) || (CertStack == NULL) || (StackLength == NULL) ||\r
+      (TrustedCert == NULL) || (CertLength == NULL) || (P7Length > INT_MAX)) {\r
+    return FALSE;\r
+  }\r
+  \r
+  Status = WrapPkcs7Data (P7Data, P7Length, &Wrapped, &SignedData, &SignedDataSize);\r
+  if (!Status) {\r
+    return Status;\r
+  }\r
+\r
+  Status     = FALSE;\r
+  Pkcs7      = NULL;\r
+  Stack      = NULL;\r
+  CertBuf    = NULL;\r
+  OldBuf     = NULL;\r
+  SingleCert = NULL;\r
+\r
+  //\r
+  // Retrieve PKCS#7 Data (DER encoding)\r
+  //\r
+  if (SignedDataSize > INT_MAX) {\r
+    goto _Exit;\r
+  }\r
+\r
+  Temp = SignedData;\r
+  Pkcs7 = d2i_PKCS7 (NULL, (const unsigned char **) &Temp, (int) SignedDataSize);\r
+  if (Pkcs7 == NULL) {\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Check if it's PKCS#7 Signed Data (for Authenticode Scenario)\r
+  //\r
+  if (!PKCS7_type_is_signed (Pkcs7)) {\r
+    goto _Exit;\r
+  }\r
+\r
+  Stack = PKCS7_get0_signers(Pkcs7, NULL, PKCS7_BINARY);\r
+  if (Stack == NULL) {\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Convert CertStack to buffer in following format:\r
+  // UINT8  CertNumber;\r
+  // UINT32 Cert1Length;\r
+  // UINT8  Cert1[];\r
+  // UINT32 Cert2Length;\r
+  // UINT8  Cert2[];\r
+  // ...\r
+  // UINT32 CertnLength;\r
+  // UINT8  Certn[];\r
+  //\r
+  BufferSize = sizeof (UINT8);\r
+  OldSize    = BufferSize;\r
+  \r
+  for (Index = 0; ; Index++) {\r
+    Status = X509PopCertificate (Stack, &SingleCert, &SingleCertSize);\r
+    if (!Status) {\r
+      break;\r
+    }\r
+\r
+    OldSize    = BufferSize;\r
+    OldBuf     = CertBuf;\r
+    BufferSize = OldSize + SingleCertSize + sizeof (UINT32);\r
+    CertBuf    = malloc (BufferSize);\r
+\r
+    if (CertBuf == NULL) {\r
+      goto _Exit;\r
+    }\r
+\r
+    if (OldBuf != NULL) {\r
+      CopyMem (CertBuf, OldBuf, OldSize);\r
+      free (OldBuf);\r
+      OldBuf = NULL;\r
+    }\r
+\r
+    WriteUnaligned32 ((UINT32 *) (CertBuf + OldSize), (UINT32) SingleCertSize);\r
+    CopyMem (CertBuf + OldSize + sizeof (UINT32), SingleCert, SingleCertSize);\r
+\r
+    free (SingleCert);\r
+    SingleCert = NULL;\r
+  }\r
+\r
+  if (CertBuf != NULL) {\r
+    //\r
+    // Update CertNumber.\r
+    //\r
+    CertBuf[0] = Index;\r
+\r
+    *CertLength = BufferSize - OldSize - sizeof (UINT32);\r
+    *TrustedCert = malloc (*CertLength);\r
+    if (*TrustedCert == NULL) {\r
+      goto _Exit;\r
+    }\r
+\r
+    CopyMem (*TrustedCert, CertBuf + OldSize + sizeof (UINT32), *CertLength);\r
+    *CertStack   = CertBuf;\r
+    *StackLength = BufferSize;\r
+    Status = TRUE;\r
+  } \r
+\r
+_Exit:\r
+  //\r
+  // Release Resources\r
+  //\r
+  if (!Wrapped) {\r
+    free (SignedData);\r
+  }\r
+\r
+  if (Pkcs7 != NULL) {\r
+    PKCS7_free (Pkcs7);\r
+  }\r
+\r
+  if (Stack != NULL) {\r
+    sk_X509_pop_free(Stack, X509_free);\r
+  }\r
+\r
+  if (SingleCert !=  NULL) {\r
+    free (SingleCert);\r
+  }\r
+\r
+  if (!Status && (CertBuf != NULL)) {\r
+    free (CertBuf);\r
+    *CertStack = NULL;\r
+  }\r
+\r
+  if (OldBuf != NULL) {\r
+    free (OldBuf);\r
+  }\r
+  \r
+  return Status;\r
+}\r
+\r
+/**\r
+  Wrap function to use free() to free allocated memory for certificates.\r
+\r
+  @param[in]  Certs        Pointer to the certificates to be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Pkcs7FreeSigners (\r
+  IN  UINT8        *Certs\r
+  )\r
+{\r
+  if (Certs == NULL) {\r
+    return;\r
+  }\r
+\r
+  free (Certs);\r
+}\r
+\r
+/**\r
+  Verifies the validility of a PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  If P7Data, TrustedCert or InData is NULL, then return FALSE.\r
+  If P7Length, CertLength or DataLength overflow, then return FAlSE.\r
+\r
+  Caution: This function may receive untrusted input.\r
+  UEFI Authenticated Variable is external input, so this function will do basic\r
+  check for PKCS#7 data structure.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[in]  TrustedCert  Pointer to a trusted/root certificate encoded in DER, which\r
+                           is used for certificate chain verification.\r
+  @param[in]  CertLength   Length of the trusted certificate in bytes.\r
+  @param[in]  InData       Pointer to the content to be verified.\r
+  @param[in]  DataLength   Length of InData in bytes.\r
+\r
+  @retval  TRUE  The specified PKCS#7 signed data is valid.\r
+  @retval  FALSE Invalid PKCS#7 signed data.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Verify (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  IN  CONST UINT8  *TrustedCert,\r
+  IN  UINTN        CertLength,\r
+  IN  CONST UINT8  *InData,\r
+  IN  UINTN        DataLength\r
+  )\r
+{\r
+  PKCS7       *Pkcs7;\r
+  BIO         *CertBio;\r
+  BIO         *DataBio;\r
+  BOOLEAN     Status;\r
+  X509        *Cert;\r
+  X509_STORE  *CertStore;\r
+  UINT8       *SignedData;\r
+  UINT8       *Temp;\r
+  UINTN       SignedDataSize;\r
+  BOOLEAN     Wrapped;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (P7Data == NULL || TrustedCert == NULL || InData == NULL || \r
+    P7Length > INT_MAX || CertLength > INT_MAX || DataLength > INT_MAX) {\r
+    return FALSE;\r
+  }\r
+  \r
+  Pkcs7     = NULL;\r
+  CertBio   = NULL;\r
+  DataBio   = NULL;\r
+  Cert      = NULL;\r
+  CertStore = NULL;\r
+\r
+  //\r
+  // Register & Initialize necessary digest algorithms for PKCS#7 Handling\r
+  //\r
+  EVP_add_digest (EVP_md5());\r
+  EVP_add_digest (EVP_sha1());\r
+  EVP_add_digest_alias (SN_sha1WithRSAEncryption, SN_sha1WithRSA);\r
+  EVP_add_digest (EVP_sha256());\r
+\r
+  Status = WrapPkcs7Data (P7Data, P7Length, &Wrapped, &SignedData, &SignedDataSize);\r
+  if (!Status) {\r
+    return Status;\r
+  }\r
+\r
+  Status = FALSE;\r
+  \r
+  //\r
+  // Retrieve PKCS#7 Data (DER encoding)\r
+  //\r
+  if (SignedDataSize > INT_MAX) {\r
+    goto _Exit;\r
+  }\r
+\r
+  Temp = SignedData;\r
+  Pkcs7 = d2i_PKCS7 (NULL, (const unsigned char **) &Temp, (int) SignedDataSize);\r
+  if (Pkcs7 == NULL) {\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Check if it's PKCS#7 Signed Data (for Authenticode Scenario)\r
+  //\r
+  if (!PKCS7_type_is_signed (Pkcs7)) {\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Read DER-encoded root certificate and Construct X509 Certificate\r
+  //\r
+  CertBio = BIO_new (BIO_s_mem ());\r
+  BIO_write (CertBio, TrustedCert, (int)CertLength);\r
+  if (CertBio == NULL) {\r
+    goto _Exit;\r
+  }\r
+  Cert = d2i_X509_bio (CertBio, NULL);\r
+  if (Cert == NULL) {\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Setup X509 Store for trusted certificate\r
+  //\r
+  CertStore = X509_STORE_new ();\r
+  if (CertStore == NULL) {\r
+    goto _Exit;\r
+  }\r
+  if (!(X509_STORE_add_cert (CertStore, Cert))) {\r
+    goto _Exit;\r
+  }\r
+\r
+  //\r
+  // Register customized X509 verification callback function to support\r
+  // trusted intermediate certificate anchor.\r
+  //\r
+  CertStore->verify_cb = X509VerifyCb;\r
+\r
+  //\r
+  // For generic PKCS#7 handling, InData may be NULL if the content is present\r
+  // in PKCS#7 structure. So ignore NULL checking here.\r
+  //\r
+  DataBio = BIO_new (BIO_s_mem ());\r
+  BIO_write (DataBio, InData, (int)DataLength);\r
+\r
+  //\r
+  // Verifies the PKCS#7 signedData structure\r
+  //\r
+  Status = (BOOLEAN) PKCS7_verify (Pkcs7, NULL, CertStore, DataBio, NULL, PKCS7_BINARY);\r
+\r
+_Exit:\r
+  //\r
+  // Release Resources\r
+  //\r
+  BIO_free (DataBio);\r
+  BIO_free (CertBio);\r
+  X509_free (Cert);\r
+  X509_STORE_free (CertStore);\r
+  PKCS7_free (Pkcs7);\r
+\r
+  if (!Wrapped) {\r
+    OPENSSL_free (SignedData);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyNull.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyNull.c
new file mode 100644 (file)
index 0000000..9a4c77a
--- /dev/null
@@ -0,0 +1,100 @@
+/** @file\r
+  PKCS#7 SignedData Verification Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[out] CertStack    Pointer to Signer's certificates retrieved from P7Data.\r
+                           It's caller's responsiblity to free the buffer.\r
+  @param[out] StackLength  Length of signer's certificates in bytes.\r
+  @param[out] TrustedCert  Pointer to a trusted certificate from Signer's certificates.\r
+                           It's caller's responsiblity to free the buffer.\r
+  @param[out] CertLength   Length of the trusted certificate in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7GetSigners (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT UINT8        **CertStack,\r
+  OUT UINTN        *StackLength,\r
+  OUT UINT8        **TrustedCert,\r
+  OUT UINTN        *CertLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Wrap function to use free() to free allocated memory for certificates.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+  \r
+  @param[in]  Certs        Pointer to the certificates to be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Pkcs7FreeSigners (\r
+  IN  UINT8        *Certs\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Verifies the validility of a PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[in]  TrustedCert  Pointer to a trusted/root certificate encoded in DER, which\r
+                           is used for certificate chain verification.\r
+  @param[in]  CertLength   Length of the trusted certificate in bytes.\r
+  @param[in]  InData       Pointer to the content to be verified.\r
+  @param[in]  DataLength   Length of InData in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Verify (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  IN  CONST UINT8  *TrustedCert,\r
+  IN  UINTN        CertLength,\r
+  IN  CONST UINT8  *InData,\r
+  IN  UINTN        DataLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c
new file mode 100644 (file)
index 0000000..6bf95de
--- /dev/null
@@ -0,0 +1,319 @@
+/** @file\r
+  RSA Asymmetric Cipher Wrapper Implementation over OpenSSL.\r
+\r
+  This file implements following APIs which provide basic capabilities for RSA:\r
+  1) RsaNew\r
+  2) RsaFree\r
+  3) RsaSetKey\r
+  4) RsaPkcs1Verify\r
+\r
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+#include <openssl/rsa.h>\r
+#include <openssl/err.h>\r
+\r
+\r
+/**\r
+  Allocates and initializes one RSA context for subsequent use.\r
+\r
+  @return  Pointer to the RSA context that has been initialized.\r
+           If the allocations fails, RsaNew() returns NULL.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+RsaNew (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Allocates & Initializes RSA Context by OpenSSL RSA_new()\r
+  //\r
+  return (VOID *)RSA_new ();\r
+}\r
+\r
+/**\r
+  Release the specified RSA context.\r
+\r
+  @param[in]  RsaContext  Pointer to the RSA context to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+RsaFree (\r
+  IN  VOID  *RsaContext\r
+  )\r
+{\r
+  //\r
+  // Free OpenSSL RSA Context\r
+  //\r
+  RSA_free ((RSA *)RsaContext);\r
+}\r
+\r
+/**\r
+  Sets the tag-designated key component into the established RSA context.\r
+\r
+  This function sets the tag-designated RSA key component into the established\r
+  RSA context from the user-specified non-negative integer (octet string format\r
+  represented in RSA PKCS#1).\r
+  If BigNumber is NULL, then the specified key componenet in RSA context is cleared.\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+\r
+  @param[in, out]  RsaContext  Pointer to RSA context being set.\r
+  @param[in]       KeyTag      Tag of RSA key component being set.\r
+  @param[in]       BigNumber   Pointer to octet integer buffer.\r
+                               If NULL, then the specified key componenet in RSA\r
+                               context is cleared.\r
+  @param[in]       BnSize      Size of big number buffer in bytes.\r
+                               If BigNumber is NULL, then it is ignored.\r
+\r
+  @retval  TRUE   RSA key component was set successfully.\r
+  @retval  FALSE  Invalid RSA key component tag.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaSetKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  IN      CONST UINT8  *BigNumber,\r
+  IN      UINTN        BnSize\r
+  )\r
+{\r
+  RSA  *RsaKey;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (RsaContext == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  RsaKey = (RSA *)RsaContext;\r
+  //\r
+  // Set RSA Key Components by converting octet string to OpenSSL BN representation.\r
+  // NOTE: For RSA public key (used in signature verification), only public components\r
+  //       (N, e) are needed.\r
+  //\r
+  switch (KeyTag) {\r
+\r
+  //\r
+  // RSA Public Modulus (N)\r
+  //\r
+  case RsaKeyN:\r
+    if (RsaKey->n != NULL) {\r
+      BN_free (RsaKey->n);\r
+    }\r
+    RsaKey->n = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->n = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->n);\r
+    break;\r
+\r
+  //\r
+  // RSA Public Exponent (e)\r
+  //\r
+  case RsaKeyE:\r
+    if (RsaKey->e != NULL) {\r
+      BN_free (RsaKey->e);\r
+    }\r
+    RsaKey->e = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->e = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->e);\r
+    break;\r
+\r
+  //\r
+  // RSA Private Exponent (d)\r
+  //\r
+  case RsaKeyD:\r
+    if (RsaKey->d != NULL) {\r
+      BN_free (RsaKey->d);\r
+    }\r
+    RsaKey->d = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->d = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->d);\r
+    break;\r
+\r
+  //\r
+  // RSA Secret Prime Factor of Modulus (p)\r
+  //\r
+  case RsaKeyP:\r
+    if (RsaKey->p != NULL) {\r
+      BN_free (RsaKey->p);\r
+    }\r
+    RsaKey->p = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->p = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->p);\r
+    break;\r
+\r
+  //\r
+  // RSA Secret Prime Factor of Modules (q)\r
+  //\r
+  case RsaKeyQ:\r
+    if (RsaKey->q != NULL) {\r
+      BN_free (RsaKey->q);\r
+    }\r
+    RsaKey->q = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->q = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->q);\r
+    break;\r
+\r
+  //\r
+  // p's CRT Exponent (== d mod (p - 1))\r
+  //\r
+  case RsaKeyDp:\r
+    if (RsaKey->dmp1 != NULL) {\r
+      BN_free (RsaKey->dmp1);\r
+    }\r
+    RsaKey->dmp1 = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->dmp1 = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->dmp1);\r
+    break;\r
+\r
+  //\r
+  // q's CRT Exponent (== d mod (q - 1))\r
+  //\r
+  case RsaKeyDq:\r
+    if (RsaKey->dmq1 != NULL) {\r
+      BN_free (RsaKey->dmq1);\r
+    }\r
+    RsaKey->dmq1 = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->dmq1 = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->dmq1);\r
+    break;\r
+\r
+  //\r
+  // The CRT Coefficient (== 1/q mod p)\r
+  //\r
+  case RsaKeyQInv:\r
+    if (RsaKey->iqmp != NULL) {\r
+      BN_free (RsaKey->iqmp);\r
+    }\r
+    RsaKey->iqmp = NULL;\r
+    if (BigNumber == NULL) {\r
+      break;\r
+    }\r
+    RsaKey->iqmp = BN_bin2bn (BigNumber, (UINT32) BnSize, RsaKey->iqmp);\r
+    break;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r
+  RSA PKCS#1.\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+  If MessageHash is NULL, then return FALSE.\r
+  If Signature is NULL, then return FALSE.\r
+  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
+\r
+  @param[in]  RsaContext   Pointer to RSA context for signature verification.\r
+  @param[in]  MessageHash  Pointer to octet message hash to be checked.\r
+  @param[in]  HashSize     Size of the message hash in bytes.\r
+  @param[in]  Signature    Pointer to RSA PKCS1-v1_5 signature to be verified.\r
+  @param[in]  SigSize      Size of signature in bytes.\r
+\r
+  @retval  TRUE   Valid signature encoded in PKCS1-v1_5.\r
+  @retval  FALSE  Invalid signature or invalid RSA context.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaPkcs1Verify (\r
+  IN  VOID         *RsaContext,\r
+  IN  CONST UINT8  *MessageHash,\r
+  IN  UINTN        HashSize,\r
+  IN  UINT8        *Signature,\r
+  IN  UINTN        SigSize\r
+  )\r
+{\r
+  INTN     Length;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (RsaContext == NULL || MessageHash == NULL || Signature == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  \r
+  //\r
+  // Check for unsupported hash size:\r
+  //    Only MD5, SHA-1 or SHA-256 digest size is supported\r
+  //\r
+  if (HashSize != MD5_DIGEST_SIZE && HashSize != SHA1_DIGEST_SIZE && HashSize != SHA256_DIGEST_SIZE) {\r
+    return FALSE;\r
+  }\r
+  \r
+  //\r
+  // RSA PKCS#1 Signature Decoding using OpenSSL RSA Decryption with Public Key\r
+  //\r
+  Length = RSA_public_decrypt (\r
+             (UINT32) SigSize,\r
+             Signature,\r
+             Signature,\r
+             RsaContext,\r
+             RSA_PKCS1_PADDING\r
+             );\r
+\r
+  //\r
+  // Invalid RSA Key or PKCS#1 Padding Checking Failed (if Length < 0)\r
+  // NOTE: Length should be the addition of HashSize and some DER value.\r
+  //       Ignore more strict length checking here.\r
+  //\r
+  if (Length < (INTN) HashSize) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Validate the MessageHash and Decoded Signature\r
+  // NOTE: The decoded Signature should be the DER encoding of the DigestInfo value\r
+  //       DigestInfo ::= SEQUENCE {\r
+  //           digestAlgorithm AlgorithmIdentifier\r
+  //           digest OCTET STRING\r
+  //       }\r
+  //       Then Memory Comparing should skip the DER value of the underlying SEQUENCE\r
+  //       type and AlgorithmIdentifier.\r
+  //\r
+  if (CompareMem (MessageHash, Signature + Length - HashSize, HashSize) == 0) {\r
+    //\r
+    // Valid RSA PKCS#1 Signature\r
+    //\r
+    return TRUE;\r
+  } else {\r
+    //\r
+    // Failed to verification\r
+    //\r
+    return FALSE;\r
+  }\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c
new file mode 100644 (file)
index 0000000..67d8826
--- /dev/null
@@ -0,0 +1,432 @@
+/** @file\r
+  RSA Asymmetric Cipher Wrapper Implementation over OpenSSL.\r
+\r
+  This file implements following APIs which provide more capabilities for RSA:\r
+  1) RsaGetKey\r
+  2) RsaGenerateKey\r
+  3) RsaCheckKey\r
+  4) RsaPkcs1Sign\r
+\r
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+#include <openssl/rsa.h>\r
+#include <openssl/err.h>\r
+\r
+//\r
+// ASN.1 value for Hash Algorithm ID with the Distringuished Encoding Rules (DER)\r
+// Refer to Section 9.2 of PKCS#1 v2.1\r
+//                           \r
+CONST UINT8  Asn1IdMd5[] = {\r
+  0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,\r
+  0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10\r
+  };\r
+\r
+CONST UINT8  Asn1IdSha1[] = {\r
+  0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,\r
+  0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14\r
+  };\r
+\r
+CONST UINT8  Asn1IdSha256[] = {\r
+  0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,\r
+  0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,\r
+  0x00, 0x04, 0x20\r
+  };\r
+\r
+/**\r
+  Gets the tag-designated RSA key component from the established RSA context.\r
+\r
+  This function retrieves the tag-designated RSA key component from the\r
+  established RSA context as a non-negative integer (octet string format\r
+  represented in RSA PKCS#1).\r
+  If specified key component has not been set or has been cleared, then returned\r
+  BnSize is set to 0.\r
+  If the BigNumber buffer is too small to hold the contents of the key, FALSE\r
+  is returned and BnSize is set to the required buffer size to obtain the key.\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+  If BnSize is NULL, then return FALSE.\r
+  If BnSize is large enough but BigNumber is NULL, then return FALSE.\r
+\r
+  @param[in, out]  RsaContext  Pointer to RSA context being set.\r
+  @param[in]       KeyTag      Tag of RSA key component being set.\r
+  @param[out]      BigNumber   Pointer to octet integer buffer.\r
+  @param[in, out]  BnSize      On input, the size of big number buffer in bytes.\r
+                               On output, the size of data returned in big number buffer in bytes.\r
+\r
+  @retval  TRUE   RSA key component was retrieved successfully.\r
+  @retval  FALSE  Invalid RSA key component tag.\r
+  @retval  FALSE  BnSize is too small.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  OUT     UINT8        *BigNumber,\r
+  IN OUT  UINTN        *BnSize\r
+  )\r
+{\r
+  RSA    *RsaKey;\r
+  BIGNUM *BnKey;\r
+  UINTN  Size;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (RsaContext == NULL || BnSize == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  RsaKey  = (RSA *) RsaContext;\r
+  Size    = *BnSize;\r
+  *BnSize = 0;\r
+\r
+  switch (KeyTag) {\r
+\r
+  //\r
+  // RSA Public Modulus (N)\r
+  //\r
+  case RsaKeyN:\r
+    if (RsaKey->n == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->n;\r
+    break;\r
+\r
+  //\r
+  // RSA Public Exponent (e)\r
+  //\r
+  case RsaKeyE:\r
+    if (RsaKey->e == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->e;\r
+    break;\r
+\r
+  //\r
+  // RSA Private Exponent (d)\r
+  //\r
+  case RsaKeyD:\r
+    if (RsaKey->d == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->d;\r
+    break;\r
+\r
+  //\r
+  // RSA Secret Prime Factor of Modulus (p)\r
+  //\r
+  case RsaKeyP:\r
+    if (RsaKey->p == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->p;\r
+    break;\r
+\r
+  //\r
+  // RSA Secret Prime Factor of Modules (q)\r
+  //\r
+  case RsaKeyQ:\r
+    if (RsaKey->q == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->q;\r
+    break;\r
+\r
+  //\r
+  // p's CRT Exponent (== d mod (p - 1))\r
+  //\r
+  case RsaKeyDp:\r
+    if (RsaKey->dmp1 == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->dmp1;\r
+    break;\r
+\r
+  //\r
+  // q's CRT Exponent (== d mod (q - 1))\r
+  //\r
+  case RsaKeyDq:\r
+    if (RsaKey->dmq1 == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->dmq1;\r
+    break;\r
+\r
+  //\r
+  // The CRT Coefficient (== 1/q mod p)\r
+  //\r
+  case RsaKeyQInv:\r
+    if (RsaKey->iqmp == NULL) {\r
+      return TRUE;\r
+    }\r
+    BnKey = RsaKey->iqmp;\r
+    break;\r
+\r
+  default:\r
+    return FALSE;\r
+  }\r
+\r
+  *BnSize = Size;\r
+  Size    = BN_num_bytes (BnKey);\r
+\r
+  if (*BnSize < Size) {\r
+    *BnSize = Size;\r
+    return FALSE;\r
+  }\r
+\r
+  if (BigNumber == NULL) {\r
+    return FALSE;\r
+  }\r
+  *BnSize = BN_bn2bin (BnKey, BigNumber) ;\r
+  \r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Generates RSA key components.\r
+\r
+  This function generates RSA key components. It takes RSA public exponent E and\r
+  length in bits of RSA modulus N as input, and generates all key components.\r
+  If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.\r
+\r
+  Before this function can be invoked, pseudorandom number generator must be correctly\r
+  initialized by RandomSeed().\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+\r
+  @param[in, out]  RsaContext           Pointer to RSA context being set.\r
+  @param[in]       ModulusLength        Length of RSA modulus N in bits.\r
+  @param[in]       PublicExponent       Pointer to RSA public exponent.\r
+  @param[in]       PublicExponentSize   Size of RSA public exponent buffer in bytes. \r
+\r
+  @retval  TRUE   RSA key component was generated successfully.\r
+  @retval  FALSE  Invalid RSA key component tag.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGenerateKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      UINTN        ModulusLength,\r
+  IN      CONST UINT8  *PublicExponent,\r
+  IN      UINTN        PublicExponentSize\r
+  )\r
+{\r
+  BIGNUM   *KeyE;\r
+  BOOLEAN  RetVal;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (RsaContext == NULL) {\r
+    return FALSE;\r
+  }\r
+  \r
+  KeyE = BN_new ();\r
+  if (PublicExponent == NULL) {\r
+    BN_set_word (KeyE, 0x10001);\r
+  } else {\r
+    BN_bin2bn (PublicExponent, (UINT32) PublicExponentSize, KeyE);\r
+  }\r
+\r
+  RetVal = FALSE;\r
+  if (RSA_generate_key_ex ((RSA *) RsaContext, (UINT32) ModulusLength, KeyE, NULL) == 1) {\r
+   RetVal = TRUE;\r
+  }\r
+\r
+  BN_free (KeyE);\r
+  return RetVal;\r
+}\r
+\r
+/**\r
+  Validates key components of RSA context.\r
+\r
+  This function validates key compoents of RSA context in following aspects:\r
+  - Whether p is a prime\r
+  - Whether q is a prime\r
+  - Whether n = p * q\r
+  - Whether d*e = 1  mod lcm(p-1,q-1)\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+\r
+  @param[in]  RsaContext  Pointer to RSA context to check.\r
+\r
+  @retval  TRUE   RSA key components are valid.\r
+  @retval  FALSE  RSA key components are not valid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaCheckKey (\r
+  IN  VOID  *RsaContext\r
+  )\r
+{\r
+  UINTN  Reason;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (RsaContext == NULL) {\r
+    return FALSE;\r
+  }\r
+  \r
+  if  (RSA_check_key ((RSA *) RsaContext) != 1) {\r
+    Reason = ERR_GET_REASON (ERR_peek_last_error ());\r
+    if (Reason == RSA_R_P_NOT_PRIME ||\r
+        Reason == RSA_R_Q_NOT_PRIME ||\r
+        Reason == RSA_R_N_DOES_NOT_EQUAL_P_Q ||\r
+        Reason == RSA_R_D_E_NOT_CONGRUENT_TO_1) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Performs the PKCS1-v1_5 encoding methods defined in RSA PKCS #1.\r
+\r
+  @param  Message      Message buffer to be encoded.\r
+  @param  MessageSize  Size of message buffer in bytes.\r
+  @param  DigestInfo   Pointer to buffer of digest info for output.\r
+\r
+  @return  Size of DigestInfo in bytes.\r
+\r
+**/  \r
+UINTN\r
+DigestInfoEncoding (\r
+  IN   CONST UINT8  *Message,\r
+  IN   UINTN        MessageSize,\r
+  OUT  UINT8        *DigestInfo\r
+  )\r
+{\r
+  CONST UINT8  *HashDer;\r
+  UINTN        DerSize;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (Message == NULL || DigestInfo == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // The original message length is used to determine the hash algorithm since\r
+  // message is digest value hashed by the specified algorithm.\r
+  //\r
+  switch (MessageSize) {\r
+  case MD5_DIGEST_SIZE:\r
+    HashDer = Asn1IdMd5;\r
+    DerSize = sizeof (Asn1IdMd5);\r
+    break;\r
+  \r
+  case SHA1_DIGEST_SIZE:\r
+    HashDer = Asn1IdSha1;\r
+    DerSize = sizeof (Asn1IdSha1);\r
+    break;\r
+   \r
+  case SHA256_DIGEST_SIZE:\r
+    HashDer = Asn1IdSha256;\r
+    DerSize = sizeof (Asn1IdSha256);\r
+    break;\r
+  \r
+  default:\r
+    return FALSE;\r
+  }\r
+\r
+  CopyMem (DigestInfo, HashDer, DerSize);\r
+  CopyMem (DigestInfo + DerSize, Message, MessageSize);\r
+\r
+  return (DerSize + MessageSize);\r
+}\r
+\r
+/**\r
+  Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r
+\r
+  This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in\r
+  RSA PKCS#1.\r
+  If the Signature buffer is too small to hold the contents of signature, FALSE\r
+  is returned and SigSize is set to the required buffer size to obtain the signature.\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+  If MessageHash is NULL, then return FALSE.\r
+  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
+  If SigSize is large enough but Signature is NULL, then return FALSE.\r
+\r
+  @param[in]       RsaContext   Pointer to RSA context for signature generation.\r
+  @param[in]       MessageHash  Pointer to octet message hash to be signed.\r
+  @param[in]       HashSize     Size of the message hash in bytes.\r
+  @param[out]      Signature    Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r
+  @param[in, out]  SigSize      On input, the size of Signature buffer in bytes.\r
+                                On output, the size of data returned in Signature buffer in bytes.\r
+\r
+  @retval  TRUE   Signature successfully generated in PKCS1-v1_5.\r
+  @retval  FALSE  Signature generation failed.\r
+  @retval  FALSE  SigSize is too small.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaPkcs1Sign (\r
+  IN      VOID         *RsaContext,\r
+  IN      CONST UINT8  *MessageHash,\r
+  IN      UINTN        HashSize,\r
+  OUT     UINT8        *Signature,\r
+  IN OUT  UINTN        *SigSize\r
+  )\r
+{\r
+  RSA      *Rsa;\r
+  UINTN    Size;\r
+  INTN     ReturnVal;\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (RsaContext == NULL || MessageHash == NULL ||\r
+    (HashSize != MD5_DIGEST_SIZE && HashSize != SHA1_DIGEST_SIZE && HashSize != SHA256_DIGEST_SIZE)) {\r
+    return FALSE;\r
+  }\r
+\r
+  Rsa = (RSA *) RsaContext;\r
+  Size = BN_num_bytes (Rsa->n);\r
+\r
+  if (*SigSize < Size) {\r
+    *SigSize = Size;\r
+    return FALSE;\r
+  }\r
+\r
+  if (Signature == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  Size = DigestInfoEncoding (MessageHash, HashSize, Signature);\r
+\r
+  ReturnVal = RSA_private_encrypt (\r
+                (UINT32) Size,\r
+                Signature,\r
+                Signature,\r
+                Rsa,\r
+                RSA_PKCS1_PADDING\r
+                );\r
+\r
+  if (ReturnVal < (INTN) Size) {\r
+    return FALSE;\r
+  }\r
+\r
+  *SigSize = (UINTN)ReturnVal;\r
+  return TRUE;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExtNull.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExtNull.c
new file mode 100644 (file)
index 0000000..e44cdde
--- /dev/null
@@ -0,0 +1,125 @@
+/** @file\r
+  RSA Asymmetric Cipher Wrapper Implementation over OpenSSL.\r
+\r
+  This file does not provide real capabilities for following APIs in RSA handling:\r
+  1) RsaGetKey\r
+  2) RsaGenerateKey\r
+  3) RsaCheckKey\r
+  4) RsaPkcs1Sign\r
+\r
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Gets the tag-designated RSA key component from the established RSA context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  RsaContext  Pointer to RSA context being set.\r
+  @param[in]       KeyTag      Tag of RSA key component being set.\r
+  @param[out]      BigNumber   Pointer to octet integer buffer.\r
+  @param[in, out]  BnSize      On input, the size of big number buffer in bytes.\r
+                               On output, the size of data returned in big number buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  OUT     UINT8        *BigNumber,\r
+  IN OUT  UINTN        *BnSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Generates RSA key components.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  RsaContext           Pointer to RSA context being set.\r
+  @param[in]       ModulusLength        Length of RSA modulus N in bits.\r
+  @param[in]       PublicExponent       Pointer to RSA public exponent.\r
+  @param[in]       PublicExponentSize   Size of RSA public exponent buffer in bytes. \r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGenerateKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      UINTN        ModulusLength,\r
+  IN      CONST UINT8  *PublicExponent,\r
+  IN      UINTN        PublicExponentSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Validates key components of RSA context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  RsaContext  Pointer to RSA context to check.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaCheckKey (\r
+  IN  VOID  *RsaContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]       RsaContext   Pointer to RSA context for signature generation.\r
+  @param[in]       MessageHash  Pointer to octet message hash to be signed.\r
+  @param[in]       HashSize     Size of the message hash in bytes.\r
+  @param[out]      Signature    Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r
+  @param[in, out]  SigSize      On input, the size of Signature buffer in bytes.\r
+                                On output, the size of data returned in Signature buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaPkcs1Sign (\r
+  IN      VOID         *RsaContext,\r
+  IN      CONST UINT8  *MessageHash,\r
+  IN      UINTN        HashSize,\r
+  OUT     UINT8        *Signature,\r
+  IN OUT  UINTN        *SigSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c
new file mode 100644 (file)
index 0000000..5dbddca
--- /dev/null
@@ -0,0 +1,180 @@
+/** @file\r
+  X.509 Certificate Handler Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Construct a X509 object from DER-encoded certificate data.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Cert            Pointer to the DER-encoded certificate data.\r
+  @param[in]  CertSize        The size of certificate data in bytes.\r
+  @param[out] SingleX509Cert  The generated X509 object.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificate (\r
+  IN   CONST UINT8  *Cert,\r
+  IN   UINTN        CertSize,\r
+  OUT  UINT8        **SingleX509Cert\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Construct a X509 stack object from a list of DER-encoded certificate data.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  X509Stack  On input, pointer to an existing X509 stack object.\r
+                              On output, pointer to the X509 stack object with new\r
+                              inserted X509 certificate.\r
+  @param           ...        A list of DER-encoded single certificate data followed\r
+                              by certificate size. A NULL terminates the list. The\r
+                              pairs are the arguments to X509ConstructCertificate().\r
+                                 \r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificateStack (\r
+  IN OUT  UINT8  **X509Stack,\r
+  ...  \r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Release the specified X509 object.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  X509Cert  Pointer to the X509 object to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+X509Free (\r
+  IN  VOID  *X509Cert\r
+  )\r
+{ \r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Release the specified X509 stack object.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  X509Stack  Pointer to the X509 stack object to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+X509StackFree (\r
+  IN  VOID  *X509Stack\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Retrieve the subject bytes from one X.509 certificate.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]      Cert         Pointer to the DER-encoded X509 certificate.\r
+  @param[in]      CertSize     Size of the X509 certificate in bytes.\r
+  @param[out]     CertSubject  Pointer to the retrieved certificate subject bytes.\r
+  @param[in, out] SubjectSize  The size in bytes of the CertSubject buffer on input,\r
+                               and the size of buffer returned CertSubject on output.\r
+\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509GetSubjectName (\r
+  IN      CONST UINT8  *Cert,\r
+  IN      UINTN        CertSize,\r
+  OUT     UINT8        *CertSubject,\r
+  IN OUT  UINTN        *SubjectSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Cert         Pointer to the DER-encoded X509 certificate.\r
+  @param[in]  CertSize     Size of the X509 certificate in bytes.\r
+  @param[out] RsaContext   Pointer to new-generated RSA context which contain the retrieved\r
+                           RSA public key component. Use RsaFree() function to free the\r
+                           resource.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetPublicKeyFromX509 (\r
+  IN   CONST UINT8  *Cert,\r
+  IN   UINTN        CertSize,\r
+  OUT  VOID         **RsaContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Verify one X509 certificate was issued by the trusted CA.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]      Cert         Pointer to the DER-encoded X509 certificate to be verified.\r
+  @param[in]      CertSize     Size of the X509 certificate in bytes.\r
+  @param[in]      CACert       Pointer to the DER-encoded trusted CA certificate.\r
+  @param[in]      CACertSize   Size of the CA Certificate in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509VerifyCert (\r
+  IN  CONST UINT8  *Cert,\r
+  IN  UINTN        CertSize,\r
+  IN  CONST UINT8  *CACert,\r
+  IN  UINTN        CACertSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandNull.c b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandNull.c
new file mode 100644 (file)
index 0000000..8838e22
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file\r
+  Pseudorandom Number Generator Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+\r
+/**\r
+  Sets up the seed value for the pseudorandom number generator.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Seed      Pointer to seed value.\r
+                        If NULL, default seed is used.\r
+  @param[in]  SeedSize  Size of seed value.\r
+                        If Seed is NULL, this parameter is ignored.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RandomSeed (\r
+  IN  CONST  UINT8  *Seed  OPTIONAL,\r
+  IN  UINTN         SeedSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Generates a pseudorandom byte stream of the specified size.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Output  Pointer to buffer to receive random value.\r
+  @param[in]   Size    Size of randome bytes to generate.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RandomBytes (\r
+  OUT  UINT8  *Output,\r
+  IN   UINTN  Size\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
index f864efcd562e2b2413314a4d5802075d44fbdb3f..535ad514c6b67beeea05c71054ca465002df58e8 100644 (file)
@@ -6,6 +6,11 @@
 #  This external input must be validated carefully to avoid security issue like\r
 #  buffer overflow, integer overflow.\r
 #\r
+#  Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/\r
+#  TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions,\r
+#  Diffie-Hellman functions, authenticode signature verification functions are\r
+#  not supported in this instance.\r
+#\r
 #  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -23,7 +28,7 @@
   FILE_GUID                      = 78189cc0-727d-46a4-84ea-f7dd860de64a\r
   MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = BaseCryptLib\r
+  LIBRARY_CLASS                  = BaseCryptLib|DXE_RUNTIME_DRIVER\r
   CONSTRUCTOR                    = RuntimeCryptLibConstructor\r
 \r
 #\r
 #\r
 \r
 [Sources]\r
+  Hash/CryptMd4Null.c\r
   Hash/CryptMd5.c\r
   Hash/CryptSha1.c\r
   Hash/CryptSha256.c\r
-  Pk/CryptRsa.c\r
-  Pk/CryptPkcs7.c\r
+  Hmac/CryptHmacMd5Null.c\r
+  Hmac/CryptHmacSha1Null.c\r
+  Cipher/CryptAesNull.c\r
+  Cipher/CryptTdesNull.c\r
+  Cipher/CryptArc4Null.c\r
+  Pk/CryptRsaBasic.c\r
+  Pk/CryptRsaExtNull.c\r
+  Pk/CryptPkcs7SignNull.c\r
+  Pk/CryptPkcs7Verify.c \r
+  Pk/CryptDhNull.c\r
   Pk/CryptX509.c\r
+  Pk/CryptAuthenticodeNull.c\r
   Pem/CryptPem.c\r
 \r
   SysCall/CrtWrapper.c\r
index ac3494a20cc7740ff3f900510e81a5b4051bd468..cdbe3ac8b220696677f4235a3479d51c3e17dfd8 100644 (file)
@@ -1,20 +1,16 @@
 ## @file\r
 #  Cryptographic Library Instance for SMM driver.\r
 #\r
-#  This library instance uses ConstantTimeClock.c thus does not provide\r
-#  functionality for following APIs which need system time support:\r
-#  1) RsaGenerateKey\r
-#  2) RsaCheckKey\r
-#  3) RsaPkcs1Sign\r
-#  4) Pkcs7Sign\r
-#  5) DhGenerateParameter\r
-#  6) DhGenerateKey\r
-#\r
 #  Caution: This module requires additional review when modified.\r
 #  This library will have external input - signature.\r
 #  This external input must be validated carefully to avoid security issue like\r
 #  buffer overflow, integer overflow.\r
 #\r
+#  Note: MD4 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, AES/\r
+#  TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign functions,\r
+#  Diffie-Hellman functions, authenticode signature verification functions are\r
+#  not supported in this instance.\r
+#\r
 #  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 \r
 [Sources]\r
+  Hash/CryptMd4Null.c\r
   Hash/CryptMd5.c\r
   Hash/CryptSha1.c\r
   Hash/CryptSha256.c\r
-  Pk/CryptRsa.c\r
-  Pk/CryptPkcs7.c\r
+  Hmac/CryptHmacMd5Null.c\r
+  Hmac/CryptHmacSha1Null.c\r
+  Cipher/CryptAesNull.c\r
+  Cipher/CryptTdesNull.c\r
+  Cipher/CryptArc4Null.c\r
+  Pk/CryptRsaBasic.c\r
+  Pk/CryptRsaExtNull.c\r
+  Pk/CryptPkcs7SignNull.c\r
+  Pk/CryptPkcs7Verify.c\r
+  Pk/CryptDhNull.c\r
   Pk/CryptX509.c\r
+  Pk/CryptAuthenticodeNull.c\r
   Pem/CryptPem.c\r
 \r
   SysCall/CrtWrapper.c\r
index 0f1b0eb093059ef200d6ee6e42d5020c697c9906..8ef2d4182aa58f4e23021bd9152fdbeb59d58f32 100644 (file)
@@ -2,7 +2,14 @@
 #  Cryptographic Library Instance based on Runtime Crypt Protocol.\r
 #  This instance will be only used by the Authenticated Variable driver for IPF.\r
 #\r
-#  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Note: MD4/MD5/SHA1 Digest functions, HMAC-MD5 functions, HMAC-SHA1 functions, \r
+#  AES/TDES/ARC4 functions, RSA external functions, PKCS#7 SignedData sign/verify\r
+#  functions, Diffie-Hellman functions, X.509 certificate handler functions,\r
+#  authenticode signature verification functions, PEM handler functions,\r
+#  pseudorandom number generator functions, Sha256Duplicate() are not supported\r
+#  in this instance.\r
+#\r
+#  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
 [Sources]\r
   RuntimeDxeIpfCryptLib.c\r
 \r
+  Hash/CryptMd4Null.c\r
+  Hash/CryptMd5Null.c\r
+  Hash/CryptSha1Null.c\r
+  Hmac/CryptHmacMd5Null.c\r
+  Hmac/CryptHmacSha1Null.c\r
+  Cipher/CryptAesNull.c\r
+  Cipher/CryptTdesNull.c\r
+  Cipher/CryptArc4Null.c\r
+  Pk/CryptRsaExtNull.c\r
+  Pk/CryptPkcs7SignNull.c\r
+  Pk/CryptPkcs7VerifyNull.c\r
+  Pk/CryptDhNull.c\r
+  Pk/CryptX509Null.c\r
+  Pk/CryptAuthenticodeNull.c\r
+  Pem/CryptPemNull.c\r
+  Rand/CryptRandNull.c\r
+\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   CryptoPkg/CryptoPkg.dec\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptAesNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptAesNull.c
new file mode 100644 (file)
index 0000000..074b072
--- /dev/null
@@ -0,0 +1,165 @@
+/** @file\r
+  AES Wrapper Implementation which does not provide real capabilities.  \r
+  \r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for AES operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AesGetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory as AES context for subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  AesContext  Pointer to AES context being initialized.\r
+  @param[in]   Key         Pointer to the user-supplied AES key.\r
+  @param[in]   KeyLength   Length of AES key in bits.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesInit (\r
+  OUT  VOID         *AesContext,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeyLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES encryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+  \r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES encryption output.\r
+  \r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesEcbEncrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES decryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be decrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES decryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesEcbDecrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES encryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[in]   Ivec        Pointer to initialization vector.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesCbcEncrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs AES decryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   AesContext  Pointer to the AES context.\r
+  @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize   Size of the Input buffer in bytes.\r
+  @param[in]   Ivec        Pointer to initialization vector.\r
+  @param[out]  Output      Pointer to a buffer that receives the AES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesCbcDecrypt (\r
+  IN   VOID         *AesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{  \r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptArc4Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptArc4Null.c
new file mode 100644 (file)
index 0000000..1275e20
--- /dev/null
@@ -0,0 +1,130 @@
+/** @file \r
+  ARC4 Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for ARC4 operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Arc4GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory as ARC4 context for subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Arc4Context  Pointer to ARC4 context being initialized.\r
+  @param[in]   Key          Pointer to the user-supplied ARC4 key.\r
+  @param[in]   KeySize      Size of ARC4 key in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Init (\r
+  OUT  VOID         *Arc4Context,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs ARC4 encryption on a data buffer of the specified size.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
+  @param[in]       Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]       InputSize    Size of the Input buffer in bytes.\r
+  @param[out]      Output       Pointer to a buffer that receives the ARC4 encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Encrypt (\r
+  IN OUT  VOID         *Arc4Context,\r
+  IN      CONST UINT8  *Input,\r
+  IN      UINTN        InputSize,\r
+  OUT     UINT8        *Output\r
+  )\r
+{ \r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs ARC4 decryption on a data buffer of the specified size.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
+  @param[in]       Input        Pointer to the buffer containing the data to be decrypted.\r
+  @param[in]       InputSize    Size of the Input buffer in bytes.\r
+  @param[out]      Output       Pointer to a buffer that receives the ARC4 decryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Decrypt (\r
+  IN OUT  VOID   *Arc4Context,\r
+  IN      UINT8  *Input,\r
+  IN      UINTN  InputSize,\r
+  OUT     UINT8  *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Resets the ARC4 context to the initial state.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Arc4Reset (\r
+  IN OUT  VOID  *Arc4Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptTdesNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Cipher/CryptTdesNull.c
new file mode 100644 (file)
index 0000000..cec33b6
--- /dev/null
@@ -0,0 +1,166 @@
+/** @file\r
+  TDES Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for TDES operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+TdesGetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory as TDES context for subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  TdesContext  Pointer to TDES context being initialized.\r
+  @param[in]   Key          Pointer to the user-supplied TDES key.\r
+  @param[in]   KeyLength    Length of TDES key in bits.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesInit (\r
+  OUT  VOID         *TdesContext,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeyLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES encryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesEcbEncrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES decryption on a data buffer of the specified size in ECB mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be decrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES decryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesEcbDecrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES encryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[in]   Ivec         Pointer to initialization vector.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesCbcEncrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Performs TDES decryption on a data buffer of the specified size in CBC mode.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   TdesContext  Pointer to the TDES context.\r
+  @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
+  @param[in]   InputSize    Size of the Input buffer in bytes.\r
+  @param[in]   Ivec         Pointer to initialization vector.\r
+  @param[out]  Output       Pointer to a buffer that receives the TDES encryption output.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TdesCbcDecrypt (\r
+  IN   VOID         *TdesContext,\r
+  IN   CONST UINT8  *Input,\r
+  IN   UINTN        InputSize,\r
+  IN   CONST UINT8  *Ivec,\r
+  OUT  UINT8        *Output\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd4Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd4Null.c
new file mode 100644 (file)
index 0000000..fc634fd
--- /dev/null
@@ -0,0 +1,124 @@
+/** @file\r
+  MD4 Digest Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for MD4 hash\r
+  operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Md4GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by Md4Context as MD4 hash context for\r
+  subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Md4Context  Pointer to MD4 context being initialized.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Init (\r
+  OUT  VOID  *Md4Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing MD4 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Md4Context     Pointer to MD4 context being copied.\r
+  @param[out] NewMd4Context  Pointer to new MD4 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Duplicate (\r
+  IN   CONST VOID  *Md4Context,\r
+  OUT  VOID        *NewMd4Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates MD4 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Md4Context  Pointer to the MD4 context.\r
+  @param[in]       Data        Pointer to the buffer containing the data to be hashed.\r
+  @param[in]       DataSize    Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Update (\r
+  IN OUT  VOID        *Md4Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the MD4 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[in, out]  Md4Context  Pointer to the MD4 context.\r
+  @param[out]      HashValue   Pointer to a buffer that receives the MD4 digest\r
+                               value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md4Final (\r
+  IN OUT  VOID   *Md4Context,\r
+  OUT     UINT8  *HashValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd5Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptMd5Null.c
new file mode 100644 (file)
index 0000000..b9283d1
--- /dev/null
@@ -0,0 +1,125 @@
+/** @file\r
+  MD5 Digest Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Md5GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r
+  subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Md5Context  Pointer to MD5 context being initialized.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md5Init (\r
+  OUT  VOID  *Md5Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing MD5 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Md5Context     Pointer to MD5 context being copied.\r
+  @param[out] NewMd5Context  Pointer to new MD5 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md5Duplicate (\r
+  IN   CONST VOID  *Md5Context,\r
+  OUT  VOID        *NewMd5Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates MD5 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Md5Context  Pointer to the MD5 context.\r
+  @param[in]       Data        Pointer to the buffer containing the data to be hashed.\r
+  @param[in]       DataSize    Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md5Update (\r
+  IN OUT  VOID        *Md5Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the MD5 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Md5Context  Pointer to the MD5 context.\r
+  @param[out]      HashValue   Pointer to a buffer that receives the MD5 digest\r
+                               value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Md5Final (\r
+  IN OUT  VOID   *Md5Context,\r
+  OUT     UINT8  *HashValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptSha1Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hash/CryptSha1Null.c
new file mode 100644 (file)
index 0000000..7054365
--- /dev/null
@@ -0,0 +1,125 @@
+/** @file\r
+  SHA-1 Digest Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @return  The size, in bytes, of the context buffer required for SHA-1 hash operations.\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Sha1GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;  \r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r
+  subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+  \r
+  @param[out]  Sha1Context  Pointer to SHA-1 context being initialized.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha1Init (\r
+  OUT  VOID  *Sha1Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing SHA-1 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Sha1Context     Pointer to SHA-1 context being copied.\r
+  @param[out] NewSha1Context  Pointer to new SHA-1 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha1Duplicate (\r
+  IN   CONST VOID  *Sha1Context,\r
+  OUT  VOID        *NewSha1Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates SHA-1 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Sha1Context  Pointer to the SHA-1 context.\r
+  @param[in]       Data         Pointer to the buffer containing the data to be hashed.\r
+  @param[in]       DataSize     Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha1Update (\r
+  IN OUT  VOID        *Sha1Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the SHA-1 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  Sha1Context  Pointer to the SHA-1 context.\r
+  @param[out]      HashValue    Pointer to a buffer that receives the SHA-1 digest\r
+                                value (20 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha1Final (\r
+  IN OUT  VOID   *Sha1Context,\r
+  OUT     UINT8  *HashValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacMd5Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacMd5Null.c
new file mode 100644 (file)
index 0000000..b4bdde0
--- /dev/null
@@ -0,0 +1,127 @@
+/** @file\r
+  HMAC-MD5 Wrapper Implementation which does not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for HMAC-MD5 operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+HmacMd5GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for\r
+  subsequent use. \r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[out]  HmacMd5Context  Pointer to HMAC-MD5 context being initialized.\r
+  @param[in]   Key             Pointer to the user-supplied key.\r
+  @param[in]   KeySize         Key size in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Init (\r
+  OUT  VOID         *HmacMd5Context,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing HMAC-MD5 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  HmacMd5Context     Pointer to HMAC-MD5 context being copied.\r
+  @param[out] NewHmacMd5Context  Pointer to new HMAC-MD5 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Duplicate (\r
+  IN   CONST VOID  *HmacMd5Context,\r
+  OUT  VOID        *NewHmacMd5Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates HMAC-MD5 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  HmacMd5Context  Pointer to the HMAC-MD5 context.\r
+  @param[in]       Data            Pointer to the buffer containing the data to be digested.\r
+  @param[in]       DataSize        Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Update (\r
+  IN OUT  VOID        *HmacMd5Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the HMAC-MD5 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  HmacMd5Context  Pointer to the HMAC-MD5 context.\r
+  @param[out]      HmacValue       Pointer to a buffer that receives the HMAC-MD5 digest\r
+                                   value (16 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacMd5Final (\r
+  IN OUT  VOID   *HmacMd5Context,\r
+  OUT     UINT8  *HmacValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacSha1Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Hmac/CryptHmacSha1Null.c
new file mode 100644 (file)
index 0000000..b31d0d1
--- /dev/null
@@ -0,0 +1,127 @@
+/** @file\r
+  HMAC-SHA1 Wrapper Implementation which does not provide real capabilities.  \r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations.\r
+\r
+  Return zero to indicate this interface is not supported.\r
+\r
+  @retval  0   This interface is not supported.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+HmacSha1GetContextSize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for\r
+  subsequent use.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[out]  HmacSha1Context  Pointer to HMAC-SHA1 context being initialized.\r
+  @param[in]   Key              Pointer to the user-supplied key.\r
+  @param[in]   KeySize          Key size in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Init (\r
+  OUT  VOID         *HmacSha1Context,\r
+  IN   CONST UINT8  *Key,\r
+  IN   UINTN        KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Makes a copy of an existing HMAC-SHA1 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  HmacSha1Context     Pointer to HMAC-SHA1 context being copied.\r
+  @param[out] NewHmacSha1Context  Pointer to new HMAC-SHA1 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Duplicate (\r
+  IN   CONST VOID  *HmacSha1Context,\r
+  OUT  VOID        *NewHmacSha1Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Digests the input data and updates HMAC-SHA1 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[in, out]  HmacSha1Context Pointer to the HMAC-SHA1 context.\r
+  @param[in]       Data            Pointer to the buffer containing the data to be digested.\r
+  @param[in]       DataSize        Size of Data buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Update (\r
+  IN OUT  VOID        *HmacSha1Context,\r
+  IN      CONST VOID  *Data,\r
+  IN      UINTN       DataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Completes computation of the HMAC-SHA1 digest value.\r
+\r
+  Return FALSE to indicate this interface is not supported.  \r
+\r
+  @param[in, out]  HmacSha1Context  Pointer to the HMAC-SHA1 context.\r
+  @param[out]      HmacValue        Pointer to a buffer that receives the HMAC-SHA1 digest\r
+                                    value (20 bytes).\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+HmacSha1Final (\r
+  IN OUT  VOID   *HmacSha1Context,\r
+  OUT     UINT8  *HmacValue\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/InternalCryptLib.h b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/InternalCryptLib.h
new file mode 100644 (file)
index 0000000..998100d
--- /dev/null
@@ -0,0 +1,33 @@
+/** @file  \r
+  Internal include file for BaseCryptLibRuntimeCryptProtocol.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __INTERNAL_CRYPT_LIB_H__\r
+#define __INTERNAL_CRYPT_LIB_H__\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseCryptLib.h>\r
+\r
+//\r
+// Environment Setting for OpenSSL-based UEFI Crypto Library.\r
+//\r
+#ifndef OPENSSL_SYSNAME_UWIN\r
+#define OPENSSL_SYSNAME_UWIN\r
+#endif\r
+\r
+\r
+#endif\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pem/CryptPemNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pem/CryptPemNull.c
new file mode 100644 (file)
index 0000000..8c9e4f0
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation which does\r
+  not provide real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Retrieve the RSA Private Key from the password-protected PEM key data.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  PemData      Pointer to the PEM-encoded key data to be retrieved.\r
+  @param[in]  PemSize      Size of the PEM key data in bytes.\r
+  @param[in]  Password     NULL-terminated passphrase used for encrypted PEM key data.\r
+  @param[out] RsaContext   Pointer to new-generated RSA context which contain the retrieved\r
+                           RSA private key component. Use RsaFree() function to free the\r
+                           resource.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetPrivateKeyFromPem (\r
+  IN   CONST UINT8  *PemData,\r
+  IN   UINTN        PemSize,\r
+  IN   CONST CHAR8  *Password,\r
+  OUT  VOID         **RsaContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptAuthenticodeNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptAuthenticodeNull.c
new file mode 100644 (file)
index 0000000..5554486
--- /dev/null
@@ -0,0 +1,51 @@
+/** @file\r
+  Authenticode Portable Executable Signature Verification which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows\r
+  Authenticode Portable Executable Signature Format".\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  AuthData     Pointer to the Authenticode Signature retrieved from signed\r
+                           PE/COFF image to be verified.\r
+  @param[in]  DataSize     Size of the Authenticode Signature in bytes.\r
+  @param[in]  TrustedCert  Pointer to a trusted/root certificate encoded in DER, which\r
+                           is used for certificate chain verification.\r
+  @param[in]  CertSize     Size of the trusted certificate in bytes.\r
+  @param[in]  ImageHash    Pointer to the original image file hash value. The procudure\r
+                           for calculating the image hash value is described in Authenticode\r
+                           specification.\r
+  @param[in]  HashSize     Size of Image hash value in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AuthenticodeVerify (\r
+  IN  CONST UINT8  *AuthData,\r
+  IN  UINTN        DataSize,\r
+  IN  CONST UINT8  *TrustedCert,\r
+  IN  UINTN        CertSize,\r
+  IN  CONST UINT8  *ImageHash,\r
+  IN  UINTN        HashSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptDhNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptDhNull.c
new file mode 100644 (file)
index 0000000..35045db
--- /dev/null
@@ -0,0 +1,156 @@
+/** @file\r
+  Diffie-Hellman Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r
+\r
+  @return  Pointer to the Diffie-Hellman Context that has been initialized.\r
+           If the interface is not supported, DhNew() returns NULL.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+DhNew (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Release the specified DH context.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  DhContext  Pointer to the DH context to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DhFree (\r
+  IN  VOID  *DhContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Generates DH parameter.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext    Pointer to the DH context.\r
+  @param[in]       Generator    Value of generator.\r
+  @param[in]       PrimeLength  Length in bits of prime to be generated.\r
+  @param[out]      Prime        Pointer to the buffer to receive the generated prime number.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhGenerateParameter (\r
+  IN OUT  VOID   *DhContext,\r
+  IN      UINTN  Generator,\r
+  IN      UINTN  PrimeLength,\r
+  OUT     UINT8  *Prime\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Sets generator and prime parameters for DH.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext    Pointer to the DH context.\r
+  @param[in]       Generator    Value of generator.\r
+  @param[in]       PrimeLength  Length in bits of prime to be generated.\r
+  @param[in]       Prime        Pointer to the prime number.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhSetParameter (\r
+  IN OUT  VOID         *DhContext,\r
+  IN      UINTN        Generator,\r
+  IN      UINTN        PrimeLength,\r
+  IN      CONST UINT8  *Prime\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE; \r
+}\r
+\r
+/**\r
+  Generates DH public key.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext      Pointer to the DH context.\r
+  @param[out]      PublicKey      Pointer to the buffer to receive generated public key.\r
+  @param[in, out]  PublicKeySize  On input, the size of PublicKey buffer in bytes.\r
+                                  On output, the size of data returned in PublicKey buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhGenerateKey (\r
+  IN OUT  VOID   *DhContext,\r
+  OUT     UINT8  *PublicKey,\r
+  IN OUT  UINTN  *PublicKeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Computes exchanged common key.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  DhContext          Pointer to the DH context.\r
+  @param[in]       PeerPublicKey      Pointer to the peer's public key.\r
+  @param[in]       PeerPublicKeySize  Size of peer's public key in bytes.\r
+  @param[out]      Key                Pointer to the buffer to receive generated key.\r
+  @param[in, out]  KeySize            On input, the size of Key buffer in bytes.\r
+                                      On output, the size of data returned in Key buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+DhComputeKey (\r
+  IN OUT  VOID         *DhContext,\r
+  IN      CONST UINT8  *PeerPublicKey,\r
+  IN      UINTN        PeerPublicKeySize,\r
+  OUT     UINT8        *Key,\r
+  IN OUT  UINTN        *KeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptPkcs7SignNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptPkcs7SignNull.c
new file mode 100644 (file)
index 0000000..539bb6b
--- /dev/null
@@ -0,0 +1,59 @@
+/** @file\r
+  PKCS#7 SignedData Sign Wrapper Implementation which does not provide real\r
+  capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r
+  Syntax Standard, version 1.5". This interface is only intended to be used for\r
+  application to perform PKCS#7 functionality validation.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  PrivateKey       Pointer to the PEM-formatted private key data for\r
+                               data signing.\r
+  @param[in]  PrivateKeySize   Size of the PEM private key data in bytes.\r
+  @param[in]  KeyPassword      NULL-terminated passphrase used for encrypted PEM\r
+                               key data.\r
+  @param[in]  InData           Pointer to the content to be signed.\r
+  @param[in]  InDataSize       Size of InData in bytes.\r
+  @param[in]  SignCert         Pointer to signer's DER-encoded certificate to sign with.\r
+  @param[in]  OtherCerts       Pointer to an optional additional set of certificates to\r
+                               include in the PKCS#7 signedData (e.g. any intermediate\r
+                               CAs in the chain).\r
+  @param[out] SignedData       Pointer to output PKCS#7 signedData.\r
+  @param[out] SignedDataSize   Size of SignedData in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Sign (\r
+  IN   CONST UINT8  *PrivateKey,\r
+  IN   UINTN        PrivateKeySize,\r
+  IN   CONST UINT8  *KeyPassword,\r
+  IN   UINT8        *InData,\r
+  IN   UINTN        InDataSize,\r
+  IN   UINT8        *SignCert,\r
+  IN   UINT8        *OtherCerts      OPTIONAL,\r
+  OUT  UINT8        **SignedData,\r
+  OUT  UINTN        *SignedDataSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptPkcs7VerifyNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptPkcs7VerifyNull.c
new file mode 100644 (file)
index 0000000..9a4c77a
--- /dev/null
@@ -0,0 +1,100 @@
+/** @file\r
+  PKCS#7 SignedData Verification Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[out] CertStack    Pointer to Signer's certificates retrieved from P7Data.\r
+                           It's caller's responsiblity to free the buffer.\r
+  @param[out] StackLength  Length of signer's certificates in bytes.\r
+  @param[out] TrustedCert  Pointer to a trusted certificate from Signer's certificates.\r
+                           It's caller's responsiblity to free the buffer.\r
+  @param[out] CertLength   Length of the trusted certificate in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7GetSigners (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT UINT8        **CertStack,\r
+  OUT UINTN        *StackLength,\r
+  OUT UINT8        **TrustedCert,\r
+  OUT UINTN        *CertLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Wrap function to use free() to free allocated memory for certificates.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+  \r
+  @param[in]  Certs        Pointer to the certificates to be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Pkcs7FreeSigners (\r
+  IN  UINT8        *Certs\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Verifies the validility of a PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[in]  TrustedCert  Pointer to a trusted/root certificate encoded in DER, which\r
+                           is used for certificate chain verification.\r
+  @param[in]  CertLength   Length of the trusted certificate in bytes.\r
+  @param[in]  InData       Pointer to the content to be verified.\r
+  @param[in]  DataLength   Length of InData in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Verify (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  IN  CONST UINT8  *TrustedCert,\r
+  IN  UINTN        CertLength,\r
+  IN  CONST UINT8  *InData,\r
+  IN  UINTN        DataLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptRsaExtNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptRsaExtNull.c
new file mode 100644 (file)
index 0000000..e44cdde
--- /dev/null
@@ -0,0 +1,125 @@
+/** @file\r
+  RSA Asymmetric Cipher Wrapper Implementation over OpenSSL.\r
+\r
+  This file does not provide real capabilities for following APIs in RSA handling:\r
+  1) RsaGetKey\r
+  2) RsaGenerateKey\r
+  3) RsaCheckKey\r
+  4) RsaPkcs1Sign\r
+\r
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Gets the tag-designated RSA key component from the established RSA context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  RsaContext  Pointer to RSA context being set.\r
+  @param[in]       KeyTag      Tag of RSA key component being set.\r
+  @param[out]      BigNumber   Pointer to octet integer buffer.\r
+  @param[in, out]  BnSize      On input, the size of big number buffer in bytes.\r
+                               On output, the size of data returned in big number buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  OUT     UINT8        *BigNumber,\r
+  IN OUT  UINTN        *BnSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Generates RSA key components.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  RsaContext           Pointer to RSA context being set.\r
+  @param[in]       ModulusLength        Length of RSA modulus N in bits.\r
+  @param[in]       PublicExponent       Pointer to RSA public exponent.\r
+  @param[in]       PublicExponentSize   Size of RSA public exponent buffer in bytes. \r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGenerateKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      UINTN        ModulusLength,\r
+  IN      CONST UINT8  *PublicExponent,\r
+  IN      UINTN        PublicExponentSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Validates key components of RSA context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  RsaContext  Pointer to RSA context to check.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaCheckKey (\r
+  IN  VOID  *RsaContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]       RsaContext   Pointer to RSA context for signature generation.\r
+  @param[in]       MessageHash  Pointer to octet message hash to be signed.\r
+  @param[in]       HashSize     Size of the message hash in bytes.\r
+  @param[out]      Signature    Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r
+  @param[in, out]  SigSize      On input, the size of Signature buffer in bytes.\r
+                                On output, the size of data returned in Signature buffer in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaPkcs1Sign (\r
+  IN      VOID         *RsaContext,\r
+  IN      CONST UINT8  *MessageHash,\r
+  IN      UINTN        HashSize,\r
+  OUT     UINT8        *Signature,\r
+  IN OUT  UINTN        *SigSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptX509Null.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Pk/CryptX509Null.c
new file mode 100644 (file)
index 0000000..5dbddca
--- /dev/null
@@ -0,0 +1,180 @@
+/** @file\r
+  X.509 Certificate Handler Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Construct a X509 object from DER-encoded certificate data.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Cert            Pointer to the DER-encoded certificate data.\r
+  @param[in]  CertSize        The size of certificate data in bytes.\r
+  @param[out] SingleX509Cert  The generated X509 object.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificate (\r
+  IN   CONST UINT8  *Cert,\r
+  IN   UINTN        CertSize,\r
+  OUT  UINT8        **SingleX509Cert\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Construct a X509 stack object from a list of DER-encoded certificate data.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in, out]  X509Stack  On input, pointer to an existing X509 stack object.\r
+                              On output, pointer to the X509 stack object with new\r
+                              inserted X509 certificate.\r
+  @param           ...        A list of DER-encoded single certificate data followed\r
+                              by certificate size. A NULL terminates the list. The\r
+                              pairs are the arguments to X509ConstructCertificate().\r
+                                 \r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificateStack (\r
+  IN OUT  UINT8  **X509Stack,\r
+  ...  \r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Release the specified X509 object.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  X509Cert  Pointer to the X509 object to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+X509Free (\r
+  IN  VOID  *X509Cert\r
+  )\r
+{ \r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Release the specified X509 stack object.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  X509Stack  Pointer to the X509 stack object to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+X509StackFree (\r
+  IN  VOID  *X509Stack\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Retrieve the subject bytes from one X.509 certificate.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]      Cert         Pointer to the DER-encoded X509 certificate.\r
+  @param[in]      CertSize     Size of the X509 certificate in bytes.\r
+  @param[out]     CertSubject  Pointer to the retrieved certificate subject bytes.\r
+  @param[in, out] SubjectSize  The size in bytes of the CertSubject buffer on input,\r
+                               and the size of buffer returned CertSubject on output.\r
+\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509GetSubjectName (\r
+  IN      CONST UINT8  *Cert,\r
+  IN      UINTN        CertSize,\r
+  OUT     UINT8        *CertSubject,\r
+  IN OUT  UINTN        *SubjectSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Cert         Pointer to the DER-encoded X509 certificate.\r
+  @param[in]  CertSize     Size of the X509 certificate in bytes.\r
+  @param[out] RsaContext   Pointer to new-generated RSA context which contain the retrieved\r
+                           RSA public key component. Use RsaFree() function to free the\r
+                           resource.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaGetPublicKeyFromX509 (\r
+  IN   CONST UINT8  *Cert,\r
+  IN   UINTN        CertSize,\r
+  OUT  VOID         **RsaContext\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Verify one X509 certificate was issued by the trusted CA.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]      Cert         Pointer to the DER-encoded X509 certificate to be verified.\r
+  @param[in]      CertSize     Size of the X509 certificate in bytes.\r
+  @param[in]      CACert       Pointer to the DER-encoded trusted CA certificate.\r
+  @param[in]      CACertSize   Size of the CA Certificate in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509VerifyCert (\r
+  IN  CONST UINT8  *Cert,\r
+  IN  UINTN        CertSize,\r
+  IN  CONST UINT8  *CACert,\r
+  IN  UINTN        CACertSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
diff --git a/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Rand/CryptRandNull.c b/CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/Rand/CryptRandNull.c
new file mode 100644 (file)
index 0000000..8838e22
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file\r
+  Pseudorandom Number Generator Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+\r
+/**\r
+  Sets up the seed value for the pseudorandom number generator.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Seed      Pointer to seed value.\r
+                        If NULL, default seed is used.\r
+  @param[in]  SeedSize  Size of seed value.\r
+                        If Seed is NULL, this parameter is ignored.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RandomSeed (\r
+  IN  CONST  UINT8  *Seed  OPTIONAL,\r
+  IN  UINTN         SeedSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Generates a pseudorandom byte stream of the specified size.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[out]  Output  Pointer to buffer to receive random value.\r
+  @param[in]   Size    Size of randome bytes to generate.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RandomBytes (\r
+  OUT  UINT8  *Output,\r
+  IN   UINTN  Size\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
index 2a1da855c66178d8d1134e3b539a7d1145ea70a8..68abc893fd14b67daeb1ff801a2e0ae9131e719e 100644 (file)
@@ -217,6 +217,29 @@ Sha256Init (
 }\r
 \r
 \r
+/**\r
+  Makes a copy of an existing SHA-256 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Sha256Context     Pointer to SHA-256 context being copied.\r
+  @param[out] NewSha256Context  Pointer to new SHA-256 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha256Duplicate (\r
+  IN   CONST VOID  *Sha256Context,\r
+  OUT  VOID        *NewSha256Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+\r
 /**\r
   Performs SHA-256 digest on a data buffer of the specified length. This function can\r
   be called multiple times to compute the digest of long or discontinuous data streams.\r
@@ -277,9 +300,9 @@ Sha256Final (
 }\r
 \r
 /**\r
-  Allocates and Initializes one RSA Context for subsequent use.\r
+  Allocates and initializes one RSA context for subsequent use.\r
 \r
-  @return  Pointer to the RSA Context that has been initialized.\r
+  @return  Pointer to the RSA context that has been initialized.\r
            If the allocations fails, RsaNew() returns NULL.\r
 \r
 **/\r
@@ -297,7 +320,7 @@ RsaNew (
 }\r
 \r
 /**\r
-  Release the specified RSA Context.\r
+  Release the specified RSA context.\r
 \r
   @param[in]  RsaContext  Pointer to the RSA context to be released.\r
 \r
@@ -316,35 +339,41 @@ RsaFree (
 }\r
 \r
 /**\r
-  Sets the tag-designated RSA key component into the established RSA context from\r
-  the user-specified nonnegative integer (octet string format represented in RSA\r
-  PKCS#1).\r
+  Sets the tag-designated key component into the established RSA context.\r
+\r
+  This function sets the tag-designated RSA key component into the established\r
+  RSA context from the user-specified non-negative integer (octet string format\r
+  represented in RSA PKCS#1).\r
+  If BigNumber is NULL, then the specified key componenet in RSA context is cleared.\r
 \r
   If RsaContext is NULL, then return FALSE.\r
 \r
   @param[in, out]  RsaContext  Pointer to RSA context being set.\r
   @param[in]       KeyTag      Tag of RSA key component being set.\r
   @param[in]       BigNumber   Pointer to octet integer buffer.\r
-  @param[in]       BnLength    Length of big number buffer in bytes.\r
+                               If NULL, then the specified key componenet in RSA\r
+                               context is cleared.\r
+  @param[in]       BnSize      Size of big number buffer in bytes.\r
+                               If BigNumber is NULL, then it is ignored.\r
 \r
-  @return  TRUE   RSA key component was set successfully.\r
-  @return  FALSE  Invalid RSA key component tag.\r
+  @retval  TRUE   RSA key component was set successfully.\r
+  @retval  FALSE  Invalid RSA key component tag.\r
 \r
 **/\r
 BOOLEAN\r
 EFIAPI\r
 RsaSetKey (\r
-  IN OUT VOID         *RsaContext,\r
-  IN     RSA_KEY_TAG  KeyTag,\r
-  IN     CONST UINT8  *BigNumber,\r
-  IN     UINTN        BnLength\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  IN      CONST UINT8  *BigNumber,\r
+  IN      UINTN        BnSize\r
   )\r
 {\r
   if (!InternalIsCryptServiveAvailable ()) {\r
     return FALSE;\r
   }\r
 \r
-  return mCryptProtocol->RsaSetKey (RsaContext, KeyTag, BigNumber, BnLength);\r
+  return mCryptProtocol->RsaSetKey (RsaContext, KeyTag, BigNumber, BnSize);\r
 }\r
 \r
 /**\r
@@ -354,16 +383,16 @@ RsaSetKey (
   If RsaContext is NULL, then return FALSE.\r
   If MessageHash is NULL, then return FALSE.\r
   If Signature is NULL, then return FALSE.\r
-  If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
+  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
 \r
   @param[in]  RsaContext   Pointer to RSA context for signature verification.\r
   @param[in]  MessageHash  Pointer to octet message hash to be checked.\r
-  @param[in]  HashLength   Length of the message hash in bytes.\r
+  @param[in]  HashSize     Size of the message hash in bytes.\r
   @param[in]  Signature    Pointer to RSA PKCS1-v1_5 signature to be verified.\r
-  @param[in]  SigLength    Length of signature in bytes.\r
+  @param[in]  SigSize      Size of signature in bytes.\r
 \r
-  @return  TRUE   Valid signature encoded in PKCS1-v1_5.\r
-  @return  FALSE  Invalid signature or invalid RSA context.\r
+  @retval  TRUE   Valid signature encoded in PKCS1-v1_5.\r
+  @retval  FALSE  Invalid signature or invalid RSA context.\r
 \r
 **/\r
 BOOLEAN\r
@@ -371,9 +400,9 @@ EFIAPI
 RsaPkcs1Verify (\r
   IN  VOID         *RsaContext,\r
   IN  CONST UINT8  *MessageHash,\r
-  IN  UINTN        HashLength,\r
+  IN  UINTN        HashSize,\r
   IN  UINT8        *Signature,\r
-  IN  UINTN        SigLength\r
+  IN  UINTN        SigSize\r
   )\r
 {\r
   if (!InternalIsCryptServiveAvailable ()) {\r
@@ -383,8 +412,8 @@ RsaPkcs1Verify (
   return mCryptProtocol->RsaPkcs1Verify (\r
                            RsaContext,\r
                            MessageHash,\r
-                           HashLength,\r
+                           HashSize,\r
                            Signature,\r
-                           SigLength\r
+                           SigSize\r
                            );\r
 }\r