]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Remove conducting ASSERT in BaseCryptLib.
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 19 Mar 2012 05:52:16 +0000 (05:52 +0000)
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 19 Mar 2012 05:52:16 +0000 (05:52 +0000)
Signed-off-by: sfu5
Reviewed-by: qianouyang
Reviewed-by: gdong1
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13110 6f19259b-4bc3-4df7-8a09-765794883524

21 files changed:
CryptoPkg/CryptRuntimeDxe/CryptRuntime.c
CryptoPkg/CryptRuntimeDxe/CryptRuntime.h
CryptoPkg/Include/Library/BaseCryptLib.h
CryptoPkg/Include/Protocol/RuntimeCrypt.h
CryptoPkg/Library/BaseCryptLib/Cipher/CryptAes.c
CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4.c
CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdes.c
CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c
CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c
CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c
CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptDh.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptRsa.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/RuntimeDxeIpfCryptLib.c

index ff20da49e9f62a1009315d4c1714a33eb4e4a537..75d89648e4368454e94fc75ecca5bcbd8cffebcf 100644 (file)
@@ -2,7 +2,7 @@
   Runtime Cryptographic Driver Implementation, which produce one crypto\r
   protocol.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -53,7 +53,7 @@ RuntimeCryptSha256GetContextSize (
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 Context being initialized.\r
 \r
@@ -74,7 +74,7 @@ RuntimeCryptSha256Init (
   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
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -100,8 +100,8 @@ RuntimeCryptSha256Update (
   Completes SHA-256 hash computation and retrieves the digest value into the specified\r
   memory. After this function has been called, the SHA-256 context cannot be used again.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 context\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -157,7 +157,7 @@ RuntimeCryptRsaFree (
   the user-specified nonnegative integer (octet string format represented in RSA\r
   PKCS#1).\r
 \r
-  If RsaContext is NULL, then ASSERT().\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
@@ -184,10 +184,10 @@ RuntimeCryptRsaSetKey (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\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 HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, 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
index 312d7b49e157a4509c3164436d129cb1507129ee..86476450f449916097fe353ebc4a96e0a1a67d87 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file of Runtime Cryptographic Driver.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -41,7 +41,7 @@ RuntimeCryptSha256GetContextSize (
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 Context being initialized.\r
 \r
@@ -60,7 +60,7 @@ RuntimeCryptSha256Init (
   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
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -84,8 +84,8 @@ RuntimeCryptSha256Update (
   Completes SHA-256 hash computation and retrieves the digest value into the specified\r
   memory. After this function has been called, the SHA-256 context cannot be used again.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 context\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -133,7 +133,7 @@ RuntimeCryptRsaFree (
   the user-specified nonnegative integer (octet string format represented in RSA\r
   PKCS#1).\r
 \r
-  If RsaContext is NULL, then ASSERT().\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
@@ -158,10 +158,10 @@ RuntimeCryptRsaSetKey (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\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 HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, 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
index 0745e9316d4f8d73e0fda25c16f89eed0f4dce73..69b9a888f2395ea514fd1e666ab81f19ea253798 100644 (file)
@@ -4,7 +4,7 @@
   primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI security\r
   functionality enabling.\r
 \r
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -82,7 +82,7 @@ Md4GetContextSize (
   Initializes user-supplied memory pointed by Md4Context as MD4 hash context for\r
   subsequent use.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
+  If Md4Context is NULL, then return FALSE.\r
 \r
   @param[out]  Md4Context  Pointer to MD4 context being initialized.\r
 \r
@@ -99,8 +99,8 @@ Md4Init (
 /**\r
   Makes a copy of an existing MD4 context.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
-  If NewMd4Context is NULL, then ASSERT().\r
+  If Md4Context is NULL, then return FALSE.\r
+  If NewMd4Context is NULL, then return FALSE.\r
 \r
   @param[in]  Md4Context     Pointer to MD4 context being copied.\r
   @param[out] NewMd4Context  Pointer to new MD4 context.\r
@@ -124,7 +124,7 @@ Md4Duplicate (
   MD4 context should be already correctly intialized by Md4Init(), and should not be finalized\r
   by Md4Final(). Behavior with invalid context is undefined.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
+  If Md4Context is NULL, 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
@@ -151,8 +151,8 @@ Md4Update (
   MD4 context should be already correctly intialized by Md4Init(), and should not be\r
   finalized by Md4Final(). Behavior with invalid MD4 context is undefined.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Md4Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -185,7 +185,7 @@ Md5GetContextSize (
   Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r
   subsequent use.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
+  If Md5Context is NULL, then return FALSE.\r
 \r
   @param[out]  Md5Context  Pointer to MD5 context being initialized.\r
 \r
@@ -202,8 +202,8 @@ Md5Init (
 /**\r
   Makes a copy of an existing MD5 context.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
-  If NewMd5Context is NULL, then ASSERT().\r
+  If Md5Context is NULL, then return FALSE.\r
+  If NewMd5Context is NULL, then return FALSE.\r
 \r
   @param[in]  Md5Context     Pointer to MD5 context being copied.\r
   @param[out] NewMd5Context  Pointer to new MD5 context.\r
@@ -227,7 +227,7 @@ Md5Duplicate (
   MD5 context should be already correctly intialized by Md5Init(), and should not be finalized\r
   by Md5Final(). Behavior with invalid context is undefined.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
+  If Md5Context is NULL, 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
@@ -254,8 +254,8 @@ Md5Update (
   MD5 context should be already correctly intialized by Md5Init(), and should not be\r
   finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Md5Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -288,7 +288,7 @@ Sha1GetContextSize (
   Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r
   subsequent use.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
+  If Sha1Context is NULL, then return FALSE.\r
 \r
   @param[out]  Sha1Context  Pointer to SHA-1 context being initialized.\r
 \r
@@ -305,8 +305,8 @@ Sha1Init (
 /**\r
   Makes a copy of an existing SHA-1 context.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
-  If NewSha1Context is NULL, then ASSERT().\r
+  If Sha1Context is NULL, then return FALSE.\r
+  If NewSha1Context is NULL, 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
@@ -330,7 +330,7 @@ Sha1Duplicate (
   SHA-1 context should be already correctly intialized by Sha1Init(), and should not be finalized\r
   by Sha1Final(). Behavior with invalid context is undefined.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
+  If Sha1Context is NULL, 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
@@ -357,8 +357,8 @@ Sha1Update (
   SHA-1 context should be already correctly intialized by Sha1Init(), and should not be\r
   finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha1Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -391,7 +391,7 @@ Sha256GetContextSize (
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[out]  Sha256Context  Pointer to SHA-256 context being initialized.\r
 \r
@@ -408,8 +408,8 @@ Sha256Init (
 /**\r
   Makes a copy of an existing SHA-256 context.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If NewSha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If NewSha256Context is NULL, 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
@@ -433,7 +433,7 @@ Sha256Duplicate (
   SHA-256 context should be already correctly intialized by Sha256Init(), and should not be finalized\r
   by Sha256Final(). Behavior with invalid context is undefined.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -460,8 +460,8 @@ Sha256Update (
   SHA-256 context should be already correctly intialized by Sha256Init(), and should not be\r
   finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -499,7 +499,7 @@ HmacMd5GetContextSize (
   Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for\r
   subsequent use.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, 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
@@ -520,8 +520,8 @@ HmacMd5Init (
 /**\r
   Makes a copy of an existing HMAC-MD5 context.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
-  If NewHmacMd5Context is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, then return FALSE.\r
+  If NewHmacMd5Context is NULL, 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
@@ -545,7 +545,7 @@ HmacMd5Duplicate (
   HMAC-MD5 context should be already correctly intialized by HmacMd5Init(), and should not be\r
   finalized by HmacMd5Final(). Behavior with invalid context is undefined.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, 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
@@ -572,8 +572,8 @@ HmacMd5Update (
   HMAC-MD5 context should be already correctly intialized by HmacMd5Init(), and should not be\r
   finalized by HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -606,7 +606,7 @@ HmacSha1GetContextSize (
   Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for\r
   subsequent use.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, 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
@@ -627,8 +627,8 @@ HmacSha1Init (
 /**\r
   Makes a copy of an existing HMAC-SHA1 context.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
-  If NewHmacSha1Context is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, then return FALSE.\r
+  If NewHmacSha1Context is NULL, 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
@@ -652,7 +652,7 @@ HmacSha1Duplicate (
   HMAC-SHA1 context should be already correctly intialized by HmacSha1Init(), and should not\r
   be finalized by HmacSha1Final(). Behavior with invalid context is undefined.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, 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
@@ -679,8 +679,8 @@ HmacSha1Update (
   HMAC-SHA1 context should be already correctly intialized by HmacSha1Init(), and should\r
   not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -725,9 +725,9 @@ TdesGetContextSize (
   KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security)\r
   KeyLength = 192  Keying option 3: K1 != K2 != K3 (Strongest)\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Key is NULL, then ASSERT().\r
-  If KeyLength is not valid, then ASSERT().\r
+  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
 \r
   @param[out]  TdesContext  Pointer to TDES context being initialized.\r
   @param[in]   Key          Pointer to the user-supplied TDES key.\r
@@ -755,10 +755,10 @@ TdesInit (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -788,10 +788,10 @@ TdesEcbEncrypt (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be decrypted.\r
@@ -822,11 +822,11 @@ TdesEcbDecrypt (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -859,11 +859,11 @@ TdesCbcEncrypt (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -905,9 +905,9 @@ AesGetContextSize (
   operations.\r
   There are 3 options for key length, 128 bits, 192 bits, and 256 bits.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Key is NULL, then ASSERT().\r
-  If KeyLength is not valid, then ASSERT().\r
+  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
 \r
   @param[out]  AesContext  Pointer to AES context being initialized.\r
   @param[in]   Key         Pointer to the user-supplied AES key.\r
@@ -935,10 +935,10 @@ AesInit (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -968,10 +968,10 @@ AesEcbEncrypt (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be decrypted.\r
@@ -1002,11 +1002,11 @@ AesEcbDecrypt (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -1039,11 +1039,11 @@ AesCbcEncrypt (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -1084,9 +1084,9 @@ Arc4GetContextSize (
   In addtion, it sets up all ARC4 key materials for subsequent encryption and decryption\r
   operations.\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
-  If Key is NULL, then ASSERT().\r
-  If KeySize does not in the range of [5, 256] bytes, then ASSERT().\r
+  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
 \r
   @param[out]  Arc4Context  Pointer to ARC4 context being initialized.\r
   @param[in]   Key          Pointer to the user-supplied ARC4 key.\r
@@ -1112,9 +1112,9 @@ Arc4Init (
   Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r
   invalid ARC4 context is undefined.\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If Arc4Context is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  If Output is NULL, 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
@@ -1142,9 +1142,9 @@ Arc4Encrypt (
   Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r
   invalid ARC4 context is undefined.\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If Arc4Context is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  If Output is NULL, 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
@@ -1172,7 +1172,7 @@ Arc4Decrypt (
   Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context\r
   should be already correctly initialized by ARC4Init().\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
+  If Arc4Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
 \r
@@ -1206,7 +1206,7 @@ RsaNew (
 /**\r
   Release the specified RSA context.\r
 \r
-  If RsaContext is NULL, then ASSERT().\r
+  If RsaContext is NULL, then return FALSE.\r
 \r
   @param[in]  RsaContext  Pointer to the RSA context to be released.\r
 \r
@@ -1225,7 +1225,7 @@ RsaFree (
   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 ASSERT().\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
@@ -1259,9 +1259,9 @@ RsaSetKey (
   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 ASSERT().\r
-  If BnSize is NULL, then ASSERT().\r
-  If BnSize is large enough but BigNumber is NULL, then ASSERT().\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
@@ -1293,7 +1293,7 @@ RsaGetKey (
   Before this function can be invoked, pseudorandom number generator must be correctly\r
   initialized by RandomSeed().\r
 \r
-  If RsaContext is NULL, then ASSERT().\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
@@ -1322,7 +1322,7 @@ RsaGenerateKey (
   - Whether n = p * q\r
   - Whether d*e = 1  mod lcm(p-1,q-1)\r
 \r
-  If RsaContext is NULL, then ASSERT().\r
+  If RsaContext is NULL, then return FALSE.\r
 \r
   @param[in]  RsaContext  Pointer to RSA context to check.\r
 \r
@@ -1344,10 +1344,10 @@ RsaCheckKey (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\r
-  If SigSize is large enough but Signature is NULL, then ASSERT().\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
@@ -1375,10 +1375,10 @@ RsaPkcs1Sign (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then ASSERT().\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, 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
@@ -1410,8 +1410,8 @@ RsaPkcs1Verify (
                            RSA private key component. Use RsaFree() function to free the\r
                            resource.\r
 \r
-  If PemData is NULL, then ASSERT().\r
-  If RsaContext is NULL, then ASSERT().\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
@@ -1435,8 +1435,8 @@ RsaGetPrivateKeyFromPem (
                            RSA public key component. Use RsaFree() function to free the\r
                            resource.\r
 \r
-  If Cert is NULL, then ASSERT().\r
-  If RsaContext is NULL, then ASSERT().\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
@@ -1459,8 +1459,8 @@ RsaGetPublicKeyFromX509 (
   @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 ASSERT().\r
-  If SubjectSize is NULL, then ASSERT().\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
@@ -1484,8 +1484,8 @@ X509GetSubjectName (
   @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 ASSERT().\r
-  If CACert is NULL, then ASSERT().\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
@@ -1504,8 +1504,8 @@ X509VerifyCert (
 /**\r
   Construct a X509 object from DER-encoded certificate data.\r
 \r
-  If Cert is NULL, then ASSERT().\r
-  If SingleX509Cert is NULL, then ASSERT().\r
+  If Cert is NULL, then return FALSE.\r
+  If SingleX509Cert is NULL, 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
@@ -1526,7 +1526,7 @@ X509ConstructCertificate (
 /**\r
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r
-  If X509Stack is NULL, then ASSERT().\r
+  If X509Stack is NULL, 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
@@ -1549,7 +1549,7 @@ X509ConstructCertificateStack (
 /**\r
   Release the specified X509 object.\r
 \r
-  If X509Cert is NULL, then ASSERT().\r
+  If X509Cert is NULL, then return FALSE.\r
 \r
   @param[in]  X509Cert  Pointer to the X509 object to be released.\r
 \r
@@ -1563,7 +1563,7 @@ X509Free (
 /**\r
   Release the specified X509 stack object.\r
 \r
-  If X509Stack is NULL, then ASSERT().\r
+  If X509Stack is NULL, then return FALSE.\r
 \r
   @param[in]  X509Stack  Pointer to the X509 stack object to be released.\r
 \r
@@ -1615,7 +1615,7 @@ Pkcs7Sign (
   Verifies the validility of a PKCS#7 signed data as described in "PKCS #7: Cryptographic\r
   Message Syntax Standard".\r
 \r
-  If P7Data is NULL, then ASSERT().\r
+  If P7Data is NULL, then return FALSE.\r
 \r
   @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
   @param[in]  P7Size       Size of the PKCS#7 message in bytes.\r
@@ -1644,8 +1644,8 @@ Pkcs7Verify (
   Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows\r
   Authenticode Portable Executable Signature Format".\r
 \r
-  If AuthData is NULL, then ASSERT().\r
-  If ImageHash is NULL, then ASSERT().\r
+  If AuthData is NULL, then return FALSE.\r
+  If ImageHash is NULL, then return FALSE.\r
 \r
   @param[in]  AuthData     Pointer to the Authenticode Signature retrieved from signed\r
                            PE/COFF image to be verified.\r
@@ -1693,7 +1693,7 @@ DhNew (
 /**\r
   Release the specified DH context.\r
 \r
-  If DhContext is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
 \r
   @param[in]  DhContext  Pointer to the DH context to be released.\r
 \r
@@ -1713,8 +1713,8 @@ DhFree (
   Before this function can be invoked, pseudorandom number generator must be correctly\r
   initialized by RandomSeed().\r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If Prime is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
+  If Prime is NULL, then return FALSE.\r
 \r
   @param[in, out]  DhContext    Pointer to the DH context.\r
   @param[in]       Generator    Value of generator.\r
@@ -1741,8 +1741,8 @@ DhGenerateParameter (
   Given generator g, and prime number p, this function and sets DH\r
   context accordingly.\r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If Prime is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
+  If Prime is NULL, then return FALSE.\r
 \r
   @param[in, out]  DhContext    Pointer to the DH context.\r
   @param[in]       Generator    Value of generator.\r
@@ -1773,9 +1773,9 @@ DhSetParameter (
   If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r
   PublicKeySize is set to the required buffer size to obtain the public key.\r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If PublicKeySize is NULL, then ASSERT().\r
-  If PublicKeySize is large enough but PublicKey is NULL, then ASSERT().\r
+  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
 \r
   @param[in, out]  DhContext      Pointer to the DH context.\r
   @param[out]      PublicKey      Pointer to the buffer to receive generated public key.\r
@@ -1801,10 +1801,10 @@ DhGenerateKey (
   Given peer's public key, this function computes the exchanged common key, based on its own\r
   context including value of prime modulus and random secret exponent. \r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If PeerPublicKey is NULL, then ASSERT().\r
-  If KeySize is NULL, then ASSERT().\r
-  If KeySize is large enough but Key is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in, out]  DhContext          Pointer to the DH context.\r
   @param[in]       PeerPublicKey      Pointer to the peer's public key.\r
@@ -1858,7 +1858,7 @@ RandomSeed (
 /**\r
   Generates a pseudorandom byte stream of the specified size.\r
 \r
-  If Output is NULL, then ASSERT().\r
+  If Output is NULL, 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
index bb97d9102e2c81cf9e115a23a3633e6dd20c050b..bb03a622e9f5064af3676b72b1e815a16d4e4c33 100644 (file)
@@ -3,7 +3,7 @@
   Only limited crypto primitives (SHA-256 and RSA) are provided for runtime\r
   authenticated variable service.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -44,7 +44,7 @@ UINTN
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 Context being initialized.\r
 \r
@@ -63,7 +63,7 @@ BOOLEAN
   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
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -87,8 +87,8 @@ BOOLEAN
   Completes SHA-256 hash computation and retrieves the digest value into the specified\r
   memory. After this function has been called, the SHA-256 context cannot be used again.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 context\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -136,7 +136,7 @@ VOID
   the user-specified nonnegative integer (octet string format represented in RSA\r
   PKCS#1).\r
 \r
-  If RsaContext is NULL, then ASSERT().\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
@@ -160,10 +160,10 @@ BOOLEAN
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\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 HashLength 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
index e32063cd9883ba02362ad0e00e19315fa7f9f821..45e4a4392efa18a26916a4a51c73f49b709111fb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   AES Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -42,9 +42,9 @@ AesGetContextSize (
   operations.\r
   There are 3 options for key length, 128 bits, 192 bits, and 256 bits.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Key is NULL, then ASSERT().\r
-  If KeyLength is not valid, then ASSERT().\r
+  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
 \r
   @param[out]  AesContext  Pointer to AES context being initialized.\r
   @param[in]   Key         Pointer to the user-supplied AES key.\r
@@ -64,12 +64,12 @@ AesInit (
 {\r
   AES_KEY  *AesKey;\r
 \r
-  ASSERT (AesContext != NULL);\r
   //\r
-  // AES Key Checking\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Key != NULL);\r
-  ASSERT ((KeyLength == 128) || (KeyLength == 192) || (KeyLength == 256));\r
+  if (AesContext == NULL || Key == NULL || (KeyLength != 128 && KeyLength != 192 && KeyLength != 256)) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // Initialize AES encryption & decryption key schedule.\r
@@ -94,10 +94,10 @@ AesInit (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -118,12 +118,14 @@ AesEcbEncrypt (
   )\r
 {\r
   AES_KEY  *AesKey;\r
-  \r
-  ASSERT (AesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);\r
-  ASSERT (Output != NULL);\r
 \r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {\r
+    return FALSE;\r
+  }\r
+  \r
   AesKey = (AES_KEY *) AesContext;\r
 \r
   //\r
@@ -149,10 +151,10 @@ AesEcbEncrypt (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be decrypted.\r
@@ -173,11 +175,13 @@ AesEcbDecrypt (
   )\r
 {\r
   AES_KEY  *AesKey;\r
-  \r
-  ASSERT (AesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);\r
-  ASSERT (Output != NULL);\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   AesKey = (AES_KEY *) AesContext;\r
 \r
@@ -205,11 +209,11 @@ AesEcbDecrypt (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -234,11 +238,12 @@ AesCbcEncrypt (
   AES_KEY  *AesKey;\r
   UINT8    IvecBuffer[AES_BLOCK_SIZE];\r
 \r
-  ASSERT (AesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);\r
-  ASSERT (Ivec != NULL);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   AesKey = (AES_KEY *) AesContext;\r
   CopyMem (IvecBuffer, Ivec, AES_BLOCK_SIZE);\r
@@ -262,11 +267,11 @@ AesCbcEncrypt (
   AesContext should be already correctly initialized by AesInit(). Behavior with\r
   invalid AES context is undefined.\r
 \r
-  If AesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (16 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If AesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   AesContext  Pointer to the AES context.\r
   @param[in]   Input       Pointer to the buffer containing the data to be encrypted.\r
@@ -290,12 +295,13 @@ AesCbcDecrypt (
 {\r
   AES_KEY  *AesKey;\r
   UINT8    IvecBuffer[AES_BLOCK_SIZE];\r
-  \r
-  ASSERT (AesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);\r
-  ASSERT (Ivec != NULL);\r
-  ASSERT (Output != NULL);\r
+\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   AesKey = (AES_KEY *) AesContext;\r
   CopyMem (IvecBuffer, Ivec, AES_BLOCK_SIZE);\r
index fa8fd963dddb8172e549605f405d6e39e335d41b..69214181373ec6ee7b1df948da28c2bbfbbff672 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   ARC4 Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -42,9 +42,9 @@ Arc4GetContextSize (
   In addtion, it sets up all ARC4 key materials for subsequent encryption and decryption\r
   operations.\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
-  If Key is NULL, then ASSERT().\r
-  If KeySize does not in the range of [5, 256] bytes, then ASSERT().\r
+  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
 \r
   @param[out]  Arc4Context  Pointer to ARC4 context being initialized.\r
   @param[in]   Key          Pointer to the user-supplied ARC4 key.\r
@@ -64,9 +64,12 @@ Arc4Init (
 {\r
   RC4_KEY  *Rc4Key;\r
 \r
-  ASSERT (Arc4Context != NULL);\r
-  ASSERT (Key != NULL);\r
-  ASSERT ((KeySize >= 5) && (KeySize <= 256));\r
+  //\r
+  // Check input parameters.\r
+  //  \r
+  if (Arc4Context == NULL || Key == NULL || (KeySize < 5 || KeySize > 256)) {\r
+    return FALSE;\r
+  }\r
 \r
   Rc4Key = (RC4_KEY *) Arc4Context;\r
 \r
@@ -85,9 +88,9 @@ Arc4Init (
   Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r
   invalid ARC4 context is undefined.\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If Arc4Context is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  If Output is NULL, then return FALSE.\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
@@ -109,9 +112,12 @@ Arc4Encrypt (
 {\r
   RC4_KEY  *Rc4Key;\r
 \r
-  ASSERT (Arc4Context != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (Arc4Context == NULL || Input == NULL || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Rc4Key = (RC4_KEY *) Arc4Context;\r
 \r
@@ -128,9 +134,9 @@ Arc4Encrypt (
   Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r
   invalid ARC4 context is undefined.\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If Arc4Context is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  If Output is NULL, then return FALSE.\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
@@ -152,9 +158,12 @@ Arc4Decrypt (
 {\r
   RC4_KEY  *Rc4Key;\r
 \r
-  ASSERT (Arc4Context != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (Arc4Context == NULL || Input == NULL || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Rc4Key = (RC4_KEY *) Arc4Context;\r
 \r
@@ -171,7 +180,7 @@ Arc4Decrypt (
   Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context\r
   should be already correctly initialized by ARC4Init().\r
 \r
-  If Arc4Context is NULL, then ASSERT().\r
+  If Arc4Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Arc4Context  Pointer to the ARC4 context.\r
 \r
@@ -187,8 +196,13 @@ Arc4Reset (
 {\r
   RC4_KEY  *Rc4Key;\r
 \r
-  ASSERT (Arc4Context != NULL);\r
-\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (Arc4Context == NULL) {\r
+    return FALSE;\r
+  }\r
+  \r
   Rc4Key = (RC4_KEY *) Arc4Context;\r
 \r
   CopyMem (Rc4Key, Rc4Key + 1, sizeof(RC4_KEY));\r
index 5535ab368650d5f2c517c404c639949323028a11..8213718b42642f89ec75451d5daa0278533561e5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TDES Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -44,9 +44,9 @@ TdesGetContextSize (
   KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security)\r
   KeyLength = 192  Keying option 3: K1 != K2 != K3 (Strongest)\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Key is NULL, then ASSERT().\r
-  If KeyLength is not valid, then ASSERT().\r
+  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
 \r
   @param[out]  TdesContext  Pointer to TDES context being initialized.\r
   @param[in]   Key          Pointer to the user-supplied TDES key.\r
@@ -66,9 +66,12 @@ TdesInit (
 {\r
   DES_key_schedule  *KeySchedule;\r
 \r
-  ASSERT (TdesContext != NULL);\r
-  ASSERT (Key != NULL);\r
-  ASSERT ((KeyLength == 64) || (KeyLength == 128) || (KeyLength == 192));\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (TdesContext == NULL || Key == NULL || (KeyLength != 64 && KeyLength != 128 && KeyLength != 192)) {\r
+    return FALSE;\r
+  }\r
 \r
   KeySchedule = (DES_key_schedule *) TdesContext;\r
 \r
@@ -117,10 +120,10 @@ TdesInit (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -142,10 +145,12 @@ TdesEcbEncrypt (
 {\r
   DES_key_schedule  *KeySchedule;\r
 \r
-  ASSERT (TdesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   KeySchedule = (DES_key_schedule *) TdesContext;\r
 \r
@@ -176,10 +181,10 @@ TdesEcbEncrypt (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be decrypted.\r
@@ -201,10 +206,12 @@ TdesEcbDecrypt (
 {\r
   DES_key_schedule  *KeySchedule;\r
 \r
-  ASSERT (TdesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   KeySchedule = (DES_key_schedule *) TdesContext;\r
 \r
@@ -236,11 +243,11 @@ TdesEcbDecrypt (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -265,11 +272,12 @@ TdesCbcEncrypt (
   DES_key_schedule  *KeySchedule;\r
   UINT8             IvecBuffer[TDES_BLOCK_SIZE];\r
 \r
-  ASSERT (TdesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);\r
-  ASSERT (Ivec != NULL);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   KeySchedule = (DES_key_schedule *) TdesContext;\r
   CopyMem (IvecBuffer, Ivec, TDES_BLOCK_SIZE);\r
@@ -299,11 +307,11 @@ TdesCbcEncrypt (
   TdesContext should be already correctly initialized by TdesInit(). Behavior with\r
   invalid TDES context is undefined.\r
 \r
-  If TdesContext is NULL, then ASSERT().\r
-  If Input is NULL, then ASSERT().\r
-  If InputSize is not multiple of block size (8 bytes), then ASSERT().\r
-  If Ivec is NULL, then ASSERT().\r
-  If Output is NULL, then ASSERT().\r
+  If TdesContext is NULL, then return FALSE.\r
+  If Input is NULL, then return FALSE.\r
+  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
 \r
   @param[in]   TdesContext  Pointer to the TDES context.\r
   @param[in]   Input        Pointer to the buffer containing the data to be encrypted.\r
@@ -328,11 +336,12 @@ TdesCbcDecrypt (
   DES_key_schedule  *KeySchedule;\r
   UINT8             IvecBuffer[TDES_BLOCK_SIZE];\r
 \r
-  ASSERT (TdesContext != NULL);\r
-  ASSERT (Input != NULL);\r
-  ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);\r
-  ASSERT (Ivec != NULL);\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   KeySchedule = (DES_key_schedule *) TdesContext;\r
   CopyMem (IvecBuffer, Ivec, TDES_BLOCK_SIZE);\r
index a5769133ed1efb160ef0ed98fc1e5d9bf1036fd2..31fc4dcea9d900d7ab6dade3aac8365b9f90e1b5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MD4 Digest Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -37,7 +37,7 @@ Md4GetContextSize (
   Initializes user-supplied memory pointed by Md4Context as MD4 hash context for\r
   subsequent use.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
+  If Md4Context is NULL, then return FALSE.\r
 \r
   @param[out]  Md4Context  Pointer to MD4 context being initialized.\r
 \r
@@ -52,9 +52,11 @@ Md4Init (
   )\r
 {\r
   //\r
-  // ASSERT if Md4Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md4Context != NULL);\r
+  if (Md4Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL MD4 Context Initialization\r
@@ -65,8 +67,8 @@ Md4Init (
 /**\r
   Makes a copy of an existing MD4 context.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
-  If NewMd4Context is NULL, then ASSERT().\r
+  If Md4Context is NULL, then return FALSE.\r
+  If NewMd4Context is NULL, then return FALSE.\r
 \r
   @param[in]  Md4Context     Pointer to MD4 context being copied.\r
   @param[out] NewMd4Context  Pointer to new MD4 context.\r
@@ -83,10 +85,11 @@ Md4Duplicate (
   )\r
 {\r
   //\r
-  // ASSERT if Md4Context or NewMd4Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md4Context    != NULL);\r
-  ASSERT (NewMd4Context != NULL);\r
+  if (Md4Context == NULL || NewMd4Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   CopyMem (NewMd4Context, Md4Context, sizeof (MD4_CTX));\r
 \r
@@ -101,7 +104,7 @@ Md4Duplicate (
   MD4 context should be already correctly intialized by Md4Init(), and should not be finalized\r
   by Md4Final(). Behavior with invalid context is undefined.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
+  If Md4Context is NULL, 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
@@ -120,15 +123,17 @@ Md4Update (
   )\r
 {\r
   //\r
-  // ASSERT if Md4Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md4Context != NULL);\r
+  if (Md4Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
-  // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
+  // Check invalid parameters, in case that only DataLength was checked in OpenSSL\r
   //\r
-  if (Data == NULL) {\r
-    ASSERT (DataSize == 0);\r
+  if (Data == NULL && DataSize != 0) {\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -146,8 +151,8 @@ Md4Update (
   MD4 context should be already correctly intialized by Md4Init(), and should not be\r
   finalized by Md4Final(). Behavior with invalid MD4 context is undefined.\r
 \r
-  If Md4Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Md4Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -165,10 +170,11 @@ Md4Final (
   )\r
 {\r
   //\r
-  // ASSERT if Md4Context is NULL or HashValue is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md4Context != NULL);\r
-  ASSERT (HashValue  != NULL);\r
+  if (Md4Context == NULL || HashValue == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL MD4 Hash Finalization\r
index 8d5e6ed89d106ad0b642be5af31b118898f80b36..1d852c74951682313bfed192230a1a1c5a1ab130 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MD5 Digest Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -39,7 +39,7 @@ Md5GetContextSize (
   Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r
   subsequent use.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
+  If Md5Context is NULL, then return FALSE.\r
 \r
   @param[out]  Md5Context  Pointer to MD5 context being initialized.\r
 \r
@@ -54,9 +54,11 @@ Md5Init (
   )\r
 {\r
   //\r
-  // ASSERT if Md5Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md5Context != NULL);\r
+  if ((Md5Context == NULL)) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL MD5 Context Initialization\r
@@ -67,8 +69,8 @@ Md5Init (
 /**\r
   Makes a copy of an existing MD5 context.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
-  If NewMd5Context is NULL, then ASSERT().\r
+  If Md5Context is NULL, then return FALSE.\r
+  If NewMd5Context is NULL, then return FALSE.\r
 \r
   @param[in]  Md5Context     Pointer to MD5 context being copied.\r
   @param[out] NewMd5Context  Pointer to new MD5 context.\r
@@ -85,10 +87,11 @@ Md5Duplicate (
   )\r
 {\r
   //\r
-  // ASSERT if Md5Context or NewMd5Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md5Context    != NULL);\r
-  ASSERT (NewMd5Context != NULL);\r
+  if (Md5Context == NULL || NewMd5Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   CopyMem (NewMd5Context, Md5Context, sizeof (MD5_CTX));\r
 \r
@@ -103,7 +106,7 @@ Md5Duplicate (
   MD5 context should be already correctly intialized by Md5Init(), and should not be finalized\r
   by Md5Final(). Behavior with invalid context is undefined.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
+  If Md5Context is NULL, 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
@@ -122,15 +125,17 @@ Md5Update (
   )\r
 {\r
   //\r
-  // ASSERT if Md5Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md5Context != NULL);\r
+  if (Md5Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
-  // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
+  // Check invalid parameters, in case that only DataLength was checked in OpenSSL\r
   //\r
-  if (Data == NULL) {\r
-    ASSERT (DataSize == 0);\r
+  if (Data == NULL && (DataSize != 0)) {\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -148,8 +153,8 @@ Md5Update (
   MD5 context should be already correctly intialized by Md5Init(), and should not be\r
   finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r
 \r
-  If Md5Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Md5Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -167,10 +172,11 @@ Md5Final (
   )\r
 {\r
   //\r
-  // ASSERT if Md5Context is NULL or HashValue is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Md5Context != NULL);\r
-  ASSERT (HashValue  != NULL);\r
+  if (Md5Context == NULL || HashValue == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL MD5 Hash Finalization\r
index 27526bcd404a834a438818dd59cfa285935ec271..633028b64e46d097151f613e6884a0ad8531be1c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SHA-1 Digest Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -38,7 +38,7 @@ Sha1GetContextSize (
   Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r
   subsequent use.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
+  If Sha1Context is NULL, then return FALSE.\r
 \r
   @param[out]  Sha1Context  Pointer to SHA-1 context being initialized.\r
 \r
@@ -53,9 +53,11 @@ Sha1Init (
   )\r
 {\r
   //\r
-  // ASSERT if Sha1Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha1Context != NULL);\r
+  if (Sha1Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL SHA-1 Context Initialization\r
@@ -66,8 +68,8 @@ Sha1Init (
 /**\r
   Makes a copy of an existing SHA-1 context.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
-  If NewSha1Context is NULL, then ASSERT().\r
+  If Sha1Context is NULL, then return FALSE.\r
+  If NewSha1Context is NULL, 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
@@ -84,10 +86,11 @@ Sha1Duplicate (
   )\r
 {\r
   //\r
-  // ASSERT if Sha1Context or NewSha1Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha1Context    != NULL);\r
-  ASSERT (NewSha1Context != NULL);\r
+  if (Sha1Context == NULL || NewSha1Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   CopyMem (NewSha1Context, Sha1Context, sizeof (SHA_CTX));\r
 \r
@@ -102,7 +105,7 @@ Sha1Duplicate (
   SHA-1 context should be already correctly intialized by Sha1Init(), and should not be finalized\r
   by Sha1Final(). Behavior with invalid context is undefined.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
+  If Sha1Context is NULL, 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
@@ -121,15 +124,17 @@ Sha1Update (
   )\r
 {\r
   //\r
-  // ASSERT if Sha1Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha1Context != NULL);\r
+  if (Sha1Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
-  // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
+  // Check invalid parameters, in case that only DataLength was checked in OpenSSL\r
   //\r
-  if (Data == NULL) {\r
-    ASSERT (DataSize == 0);\r
+  if (Data == NULL && DataSize != 0) {\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -147,8 +152,8 @@ Sha1Update (
   SHA-1 context should be already correctly intialized by Sha1Init(), and should not be\r
   finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r
 \r
-  If Sha1Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha1Context is NULL, then return FALSE.\r
+  If HashValue is NULL, 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
@@ -166,10 +171,11 @@ Sha1Final (
   )\r
 {\r
   //\r
-  // ASSERT if Sha1Context is NULL or HashValue is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha1Context != NULL);\r
-  ASSERT (HashValue   != NULL);\r
+  if (Sha1Context == NULL || HashValue == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL SHA-1 Hash Finalization\r
index 3c2f9a11552138df230f29942fc97b31a81b5c0b..ca0cb1aa8ced7f71ccbcf594e622006d69f8dc8a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SHA-256 Digest Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -37,7 +37,7 @@ Sha256GetContextSize (
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[out]  Sha256Context  Pointer to SHA-256 context being initialized.\r
 \r
@@ -52,9 +52,11 @@ Sha256Init (
   )\r
 {\r
   //\r
-  // ASSERT if Sha256Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha256Context != NULL);\r
+  if (Sha256Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL SHA-256 Context Initialization\r
@@ -65,8 +67,8 @@ Sha256Init (
 /**\r
   Makes a copy of an existing SHA-256 context.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If NewSha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If NewSha256Context is NULL, 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
@@ -83,10 +85,11 @@ Sha256Duplicate (
   )\r
 {\r
   //\r
-  // ASSERT if Sha256Context or NewSha256Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha256Context    != NULL);\r
-  ASSERT (NewSha256Context != NULL);\r
+  if (Sha256Context == NULL || NewSha256Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   CopyMem (NewSha256Context, Sha256Context, sizeof (SHA256_CTX));\r
 \r
@@ -101,7 +104,7 @@ Sha256Duplicate (
   SHA-256 context should be already correctly intialized by Sha256Init(), and should not be finalized\r
   by Sha256Final(). Behavior with invalid context is undefined.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -120,15 +123,17 @@ Sha256Update (
   )\r
 {\r
   //\r
-  // ASSERT if Sha256Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha256Context != NULL);\r
+  if (Sha256Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
-  // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
+  // Check invalid parameters, in case that only DataLength was checked in OpenSSL\r
   //\r
-  if (Data == NULL) {\r
-    ASSERT (DataSize == 0);\r
+  if (Data == NULL && DataSize != 0) {\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -146,8 +151,8 @@ Sha256Update (
   SHA-256 context should be already correctly intialized by Sha256Init(), and should not be\r
   finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -165,10 +170,11 @@ Sha256Final (
   )\r
 {\r
   //\r
-  // ASSERT if Sha256Context is NULL or HashValue is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Sha256Context != NULL);\r
-  ASSERT (HashValue     != NULL);\r
+  if (Sha256Context == NULL || HashValue == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL SHA-256 Hash Finalization\r
index 5386072c388eed9824fce4dee96b47239c3cdcd9..0cdab7ac11e5a45b7a070e5ddbee7253a87b50a7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   HMAC-MD5 Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -37,7 +37,7 @@ HmacMd5GetContextSize (
   Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for\r
   subsequent use.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, 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
@@ -56,9 +56,11 @@ HmacMd5Init (
   )\r
 {\r
   //\r
-  // ASSERT if HmacMd5Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacMd5Context != NULL);\r
+  if (HmacMd5Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL HMAC-MD5 Context Initialization\r
@@ -72,8 +74,8 @@ HmacMd5Init (
 /**\r
   Makes a copy of an existing HMAC-MD5 context.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
-  If NewHmacMd5Context is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, then return FALSE.\r
+  If NewHmacMd5Context is NULL, 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
@@ -90,10 +92,11 @@ HmacMd5Duplicate (
   )\r
 {\r
   //\r
-  // ASSERT if HmacMd5Context or NewHmacMd5Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacMd5Context    != NULL);\r
-  ASSERT (NewHmacMd5Context != NULL);\r
+  if (HmacMd5Context == NULL || NewHmacMd5Context == NULL) {\r
+    return FALSE;\r
+  }\r
   \r
   CopyMem (NewHmacMd5Context, HmacMd5Context, sizeof (HMAC_CTX));\r
 \r
@@ -108,7 +111,7 @@ HmacMd5Duplicate (
   HMAC-MD5 context should be already correctly intialized by HmacMd5Init(), and should not be\r
   finalized by HmacMd5Final(). Behavior with invalid context is undefined.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, 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
@@ -127,15 +130,17 @@ HmacMd5Update (
   )\r
 {\r
   //\r
-  // ASSERT if HmacMd5Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacMd5Context != NULL);\r
+  if (HmacMd5Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
-  // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
+  // Check invalid parameters, in case that only DataLength was checked in OpenSSL\r
   //\r
-  if (Data == NULL) {\r
-    ASSERT (DataSize == 0);\r
+  if (Data == NULL && DataSize != 0) {\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -155,8 +160,8 @@ HmacMd5Update (
   HMAC-MD5 context should be already correctly intialized by HmacMd5Init(), and should not be\r
   finalized by HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined.\r
 \r
-  If HmacMd5Context is NULL, then ASSERT().\r
-  If HmacValue is NULL, then ASSERT().\r
+  If HmacMd5Context is NULL, then return FALSE.\r
+  If HmacValue is NULL, then return FALSE.\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
@@ -176,10 +181,11 @@ HmacMd5Final (
   UINT32  Length;\r
 \r
   //\r
-  // ASSERT if HmacMd5Context is NULL or HmacValue is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacMd5Context != NULL);\r
-  ASSERT (HmacValue != NULL);\r
+  if (HmacMd5Context == NULL || HmacValue == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL HMAC-MD5 digest finalization\r
index ff9377c0d2f165c0b19f29f74da5b853dda01c56..58da2f3aecd5eb95cdd7817860d16a979d5e224e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   HMAC-SHA1 Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -37,7 +37,7 @@ HmacSha1GetContextSize (
   Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for\r
   subsequent use.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, 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
@@ -56,9 +56,11 @@ HmacSha1Init (
   )\r
 {\r
   //\r
-  // ASSERT if HmacSha1Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacSha1Context != NULL);\r
+  if (HmacSha1Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL HMAC-SHA1 Context Initialization\r
@@ -72,8 +74,8 @@ HmacSha1Init (
 /**\r
   Makes a copy of an existing HMAC-SHA1 context.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
-  If NewHmacSha1Context is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, then return FALSE.\r
+  If NewHmacSha1Context is NULL, 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
@@ -90,10 +92,11 @@ HmacSha1Duplicate (
   )\r
 {\r
   //\r
-  // ASSERT if HmacSha1Context or NewHmacSha1Context is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacSha1Context    != NULL);\r
-  ASSERT (NewHmacSha1Context != NULL);\r
+  if (HmacSha1Context == NULL || NewHmacSha1Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   CopyMem (NewHmacSha1Context, HmacSha1Context, sizeof (HMAC_CTX));\r
 \r
@@ -108,7 +111,7 @@ HmacSha1Duplicate (
   HMAC-SHA1 context should be already correctly intialized by HmacSha1Init(), and should not\r
   be finalized by HmacSha1Final(). Behavior with invalid context is undefined.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, 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
@@ -127,15 +130,17 @@ HmacSha1Update (
   )\r
 {\r
   //\r
-  // ASSERT if HmacSha1Context is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacSha1Context != NULL);\r
+  if (HmacSha1Context == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
-  // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL\r
+  // Check invalid parameters, in case that only DataLength was checked in OpenSSL\r
   //\r
-  if (Data == NULL) {\r
-    ASSERT (DataSize == 0);\r
+  if (Data == NULL && DataSize != 0) {\r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -155,8 +160,8 @@ HmacSha1Update (
   HMAC-SHA1 context should be already correctly intialized by HmacSha1Init(), and should\r
   not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined.\r
 \r
-  If HmacSha1Context is NULL, then ASSERT().\r
-  If HmacValue is NULL, then ASSERT().\r
+  If HmacSha1Context is NULL, then return FALSE.\r
+  If HmacValue is NULL, then return FALSE.\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
@@ -176,10 +181,11 @@ HmacSha1Final (
   UINT32  Length;\r
 \r
   //\r
-  // ASSERT if HmacSha1Context is NULL or HmacValue is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (HmacSha1Context != NULL);\r
-  ASSERT (HmacValue != NULL);\r
+  if (HmacSha1Context == NULL || HmacValue == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // OpenSSL HMAC-SHA1 digest finalization\r
index 0b37adc33e81ab6c9716c791762dd394dabb716e..2c3a97b2c0f91539d5e3113e96cf9b0fd65ce4d2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -60,8 +60,8 @@ PasswordCallback (
                            RSA private key component. Use RsaFree() function to free the\r
                            resource.\r
 \r
-  If PemData is NULL, then ASSERT().\r
-  If RsaContext is NULL, then ASSERT().\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
@@ -80,11 +80,11 @@ RsaGetPrivateKeyFromPem (
   BIO      *PemBio;\r
 \r
   //\r
-  // ASSERT if PemData is NULL or RsaContext is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (PemData    != NULL);\r
-  ASSERT (RsaContext != NULL);\r
-  ASSERT (PemSize    <= INT_MAX);\r
+  if (PemData == NULL || RsaContext == NULL || PemSize > INT_MAX) {\r
+    return FALSE;\r
+  }\r
 \r
   Status = FALSE;\r
   PemBio = NULL;\r
index 0321b203499fa678b39129881edf8466f5df00a7..a1f8c58e746de62a8ba7db54ca3a034236ca0c4a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Authenticode Portable Executable Signature Verification over OpenSSL.\r
 \r
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 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
@@ -23,8 +23,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows\r
   Authenticode Portable Executable Signature Format".\r
 \r
-  If AuthData is NULL, then ASSERT().\r
-  If ImageHash is NULL, then ASSERT().\r
+  If AuthData is NULL, then return FALSE.\r
+  If ImageHash is NULL, then return FALSE.\r
 \r
   @param[in]  AuthData     Pointer to the Authenticode Signature retrieved from signed\r
                            PE/COFF image to be verified.\r
@@ -60,11 +60,15 @@ AuthenticodeVerify (
   UINTN        ContentSize;\r
 \r
   //\r
-  // ASSERT if Authenticode Signature Data or PE Image Hash is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (AuthData  != NULL);\r
-  ASSERT (ImageHash != NULL);\r
-  ASSERT (DataSize  <= INT_MAX);\r
+  if ((AuthData == NULL) || (TrustedCert == NULL) || (ImageHash == NULL)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if ((DataSize > INT_MAX) || (CertSize > INT_MAX) || (HashSize > INT_MAX)) {\r
+    return FALSE;\r
+  }\r
 \r
   Status       = FALSE;\r
   Pkcs7        = NULL;\r
@@ -96,6 +100,7 @@ AuthenticodeVerify (
   // Retrieve the SEQUENCE data size from ASN.1-encoded SpcIndirectDataContent.\r
   //\r
   Asn1Byte = *(SpcIndirectDataContent + 1);\r
+\r
   if ((Asn1Byte & 0x80) == 0) {\r
     //\r
     // Short Form of Length Encoding\r
@@ -105,9 +110,9 @@ AuthenticodeVerify (
     // Skip the SEQUENCE Tag;\r
     //\r
     SpcIndirectDataContent += 2;\r
-  } else {\r
+  } else if ((Asn1Byte & 0x82) == 0x82) {\r
     //\r
-    // Long Form of Length Encoding (Assume Only two bytes here)\r
+    // Long Form of Length Encoding, only support two bytes.\r
     //\r
     ContentSize  = (UINTN) (*(SpcIndirectDataContent + 2));\r
     ContentSize = (ContentSize << 8) + (UINTN)(*(SpcIndirectDataContent + 3));\r
@@ -115,6 +120,8 @@ AuthenticodeVerify (
     // Skip the SEQUENCE Tag;\r
     //\r
     SpcIndirectDataContent += 4;\r
+  } else {\r
+    goto _Exit;\r
   }\r
 \r
   //\r
index b7e164cf43770dc8a38bf4aca58bd25148ee0db8..20f13469b30f407367557e01e4f1fac16cbf967e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Diffie-Hellman Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -38,7 +38,7 @@ DhNew (
 /**\r
   Release the specified DH context.\r
 \r
-  If DhContext is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
 \r
   @param[in]  DhContext  Pointer to the DH context to be released.\r
 \r
@@ -64,8 +64,8 @@ DhFree (
   Before this function can be invoked, pseudorandom number generator must be correctly\r
   initialized by RandomSeed().\r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If Prime is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
+  If Prime is NULL, then return FALSE.\r
 \r
   @param[in, out]  DhContext    Pointer to the DH context.\r
   @param[in]       Generator    Value of generator.\r
@@ -88,6 +88,13 @@ DhGenerateParameter (
 {\r
   BOOLEAN RetVal;\r
 \r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (DhContext == NULL || Prime == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   if (Generator != DH_GENERATOR_2 && Generator != DH_GENERATOR_5) {\r
     return FALSE;\r
   }\r
@@ -108,8 +115,8 @@ DhGenerateParameter (
   Given generator g, and prime number p, this function and sets DH\r
   context accordingly.\r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If Prime is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
+  If Prime is NULL, then return FALSE.\r
 \r
   @param[in, out]  DhContext    Pointer to the DH context.\r
   @param[in]       Generator    Value of generator.\r
@@ -134,6 +141,13 @@ DhSetParameter (
 {\r
   DH  *Dh;\r
 \r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (DhContext == NULL || Prime == NULL) {\r
+    return FALSE;\r
+  }\r
+  \r
   if (Generator != DH_GENERATOR_2 && Generator != DH_GENERATOR_5) {\r
     return FALSE;\r
   }\r
@@ -156,9 +170,9 @@ DhSetParameter (
   If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r
   PublicKeySize is set to the required buffer size to obtain the public key.\r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If PublicKeySize is NULL, then ASSERT().\r
-  If PublicKeySize is large enough but PublicKey is NULL, then ASSERT().\r
+  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
 \r
   @param[in, out]  DhContext      Pointer to the DH context.\r
   @param[out]      PublicKey      Pointer to the buffer to receive generated public key.\r
@@ -181,6 +195,17 @@ DhGenerateKey (
   BOOLEAN RetVal;\r
   DH      *Dh;\r
 \r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (DhContext == NULL || PublicKeySize == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (PublicKey == NULL && *PublicKeySize != 0) {\r
+    return FALSE;\r
+  }\r
+  \r
   Dh = (DH *) DhContext;\r
   *PublicKeySize = 0;\r
 \r
@@ -199,10 +224,10 @@ DhGenerateKey (
   Given peer's public key, this function computes the exchanged common key, based on its own\r
   context including value of prime modulus and random secret exponent. \r
 \r
-  If DhContext is NULL, then ASSERT().\r
-  If PeerPublicKey is NULL, then ASSERT().\r
-  If KeySize is NULL, then ASSERT().\r
-  If KeySize is large enough but Key is NULL, then ASSERT().\r
+  If DhContext is NULL, then return FALSE.\r
+  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
 \r
   @param[in, out]  DhContext          Pointer to the DH context.\r
   @param[in]       PeerPublicKey      Pointer to the peer's public key.\r
@@ -228,6 +253,17 @@ DhComputeKey (
 {\r
   BIGNUM  *Bn;\r
 \r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (DhContext == NULL || PeerPublicKey == NULL || KeySize == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (Key == NULL && *KeySize != 0) {\r
+    return FALSE;\r
+  }\r
+  \r
   Bn = BN_bin2bn (PeerPublicKey, (UINT32) PeerPublicKeySize, NULL);\r
 \r
   *KeySize = (BOOLEAN) DH_compute_key (Key, Bn, DhContext);\r
index 83f0dfcd5a6de16e39c183b35deb5ee862c7efd2..16176423237958d21f37f3009158765e8ea3a744 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PKCS#7 SignedData Verification Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -150,13 +150,10 @@ Pkcs7Sign (
   //\r
   // Check input parameters.\r
   //\r
-  ASSERT (PrivateKey     != NULL);\r
-  ASSERT (KeyPassword    != NULL);\r
-  ASSERT (InData         != NULL);\r
-  ASSERT (SignCert       != NULL);\r
-  ASSERT (SignedData     != NULL);\r
-  ASSERT (SignedDataSize != NULL);\r
-  ASSERT (InDataSize     <= INT_MAX);\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
@@ -285,7 +282,8 @@ _Exit:
   Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
   in a ContentInfo structure.\r
 \r
-  If P7Data is NULL, then ASSERT().\r
+  If P7Data, TrustedCert or InData is NULL, then return FALSE.\r
+  If P7Length, CertLength or DataLength overflow, 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
@@ -322,15 +320,13 @@ Pkcs7Verify (
   BOOLEAN     Wrapped;\r
 \r
   //\r
-  // ASSERT if any input parameter is invalid.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (P7Data      != NULL);\r
-  ASSERT (TrustedCert != NULL);\r
-  ASSERT (InData      != NULL);\r
-  ASSERT (P7Length    <= INT_MAX);\r
-  ASSERT (CertLength  <= INT_MAX);\r
-  ASSERT (DataLength  <= INT_MAX);\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
   Status    = FALSE;\r
   Pkcs7     = NULL;\r
   CertBio   = NULL;\r
index 0b561c35807eb732882ba8098b04aea504ebb62f..048335318a1a4460f6dd3f883e3549953a5d6b79 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   RSA Asymmetric Cipher Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -60,7 +60,7 @@ RsaNew (
 /**\r
   Release the specified RSA context.\r
 \r
-  If RsaContext is NULL, then ASSERT().\r
+  If RsaContext is NULL, then return FALSE.\r
 \r
   @param[in]  RsaContext  Pointer to the RSA context to be released.\r
 \r
@@ -71,8 +71,6 @@ RsaFree (
   IN  VOID  *RsaContext\r
   )\r
 {\r
-  ASSERT (RsaContext != NULL);\r
-\r
   //\r
   // Free OpenSSL RSA Context\r
   //\r
@@ -87,7 +85,7 @@ RsaFree (
   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 ASSERT().\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
@@ -113,10 +111,11 @@ RsaSetKey (
   RSA  *RsaKey;\r
 \r
   //\r
-  // ASSERT if RsaContext is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (RsaContext != NULL);\r
-\r
+  if (RsaContext == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   RsaKey = (RSA *)RsaContext;\r
   //\r
@@ -256,9 +255,9 @@ RsaSetKey (
   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 ASSERT().\r
-  If BnSize is NULL, then ASSERT().\r
-  If BnSize is large enough but BigNumber is NULL, then ASSERT().\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
@@ -284,8 +283,12 @@ RsaGetKey (
   BIGNUM *BnKey;\r
   UINTN  Size;\r
 \r
-  ASSERT (RsaContext != NULL);\r
-  ASSERT (BnSize != NULL);\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
@@ -385,7 +388,9 @@ RsaGetKey (
     return FALSE;\r
   }\r
 \r
-  ASSERT (BigNumber != NULL);\r
+  if (BigNumber == NULL) {\r
+    return FALSE;\r
+  }\r
   *BnSize = BN_bn2bin (BnKey, BigNumber) ;\r
   \r
   return TRUE;\r
@@ -401,7 +406,7 @@ RsaGetKey (
   Before this function can be invoked, pseudorandom number generator must be correctly\r
   initialized by RandomSeed().\r
 \r
-  If RsaContext is NULL, then ASSERT().\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
@@ -424,8 +429,13 @@ RsaGenerateKey (
   BIGNUM   *KeyE;\r
   BOOLEAN  RetVal;\r
 \r
-  ASSERT (RsaContext != NULL);\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
@@ -451,7 +461,7 @@ RsaGenerateKey (
   - Whether n = p * q\r
   - Whether d*e = 1  mod lcm(p-1,q-1)\r
 \r
-  If RsaContext is NULL, then ASSERT().\r
+  If RsaContext is NULL, then return FALSE.\r
 \r
   @param[in]  RsaContext  Pointer to RSA context to check.\r
 \r
@@ -467,8 +477,13 @@ RsaCheckKey (
 {\r
   UINTN  Reason;\r
 \r
-  ASSERT (RsaContext != NULL);\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
@@ -502,8 +517,12 @@ DigestInfoEncoding (
   CONST UINT8  *HashDer;\r
   UINTN        DerSize;\r
 \r
-  ASSERT (Message != NULL);\r
-  ASSERT (DigestInfo != NULL);\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
@@ -543,10 +562,10 @@ DigestInfoEncoding (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\r
-  If SigSize is large enough but Signature is NULL, then ASSERT().\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
@@ -574,11 +593,13 @@ RsaPkcs1Sign (
   UINTN    Size;\r
   INTN     ReturnVal;\r
 \r
-  ASSERT (RsaContext != NULL);\r
-  ASSERT (MessageHash != NULL);\r
-  ASSERT ((HashSize == MD5_DIGEST_SIZE) ||\r
-          (HashSize == SHA1_DIGEST_SIZE) ||\r
-          (HashSize == SHA256_DIGEST_SIZE));\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
@@ -588,7 +609,9 @@ RsaPkcs1Sign (
     return FALSE;\r
   }\r
 \r
-  ASSERT (Signature != NULL);\r
+  if (Signature == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Size = DigestInfoEncoding (MessageHash, HashSize, Signature);\r
 \r
@@ -612,10 +635,10 @@ RsaPkcs1Sign (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\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
@@ -640,19 +663,21 @@ RsaPkcs1Verify (
   INTN     Length;\r
 \r
   //\r
-  // ASSERT if RsaContext, MessageHash or Signature is NULL\r
+  // Check input parameters.\r
   //\r
-  ASSERT (RsaContext  != NULL);\r
-  ASSERT (MessageHash != NULL);\r
-  ASSERT (Signature   != NULL);\r
+  if (RsaContext == NULL || MessageHash == NULL || Signature == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
+  \r
   //\r
-  // ASSERT if unsupported hash size:\r
+  // Check for unsupported hash size:\r
   //    Only MD5, SHA-1 or SHA-256 digest size is supported\r
   //\r
-  ASSERT ((HashSize == MD5_DIGEST_SIZE) || (HashSize == SHA1_DIGEST_SIZE) ||\r
-          (HashSize == SHA256_DIGEST_SIZE));\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
index 3a5485e002c7c4e60d1a8539359d2cd87fe458c8..153e7106171eeaa83cce35e4814d6c054645deb6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   X.509 Certificate Handler Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -19,8 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 /**\r
   Construct a X509 object from DER-encoded certificate data.\r
 \r
-  If Cert is NULL, then ASSERT().\r
-  If SingleX509Cert is NULL, then ASSERT().\r
+  If Cert is NULL, then return FALSE.\r
+  If SingleX509Cert is NULL, 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
@@ -43,11 +43,11 @@ X509ConstructCertificate (
   BOOLEAN  Status;\r
 \r
   //\r
-  // ASSERT if Cert is NULL or SingleX509Cert is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Cert           != NULL);\r
-  ASSERT (SingleX509Cert != NULL);\r
-  ASSERT (CertSize       <= INT_MAX);\r
+  if (Cert == NULL || SingleX509Cert == NULL || CertSize > INT_MAX) {\r
+    return FALSE;\r
+  }\r
 \r
   Status = FALSE;\r
 \r
@@ -79,7 +79,7 @@ _Exit:
 /**\r
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r
-  If X509Stack is NULL, then ASSERT().\r
+  If X509Stack is NULL, 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
@@ -108,9 +108,11 @@ X509ConstructCertificateStack (
   UINTN           Index;\r
 \r
   //\r
-  // ASSERT if input X509Stack is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (X509Stack != NULL);\r
+  if (X509Stack == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Status = FALSE;\r
 \r
@@ -171,7 +173,7 @@ X509ConstructCertificateStack (
 /**\r
   Release the specified X509 object.\r
 \r
-  If X509Cert is NULL, then ASSERT().\r
+  If X509Cert is NULL, then return FALSE.\r
 \r
   @param[in]  X509Cert  Pointer to the X509 object to be released.\r
 \r
@@ -181,9 +183,14 @@ EFIAPI
 X509Free (\r
   IN  VOID  *X509Cert\r
   )\r
-{\r
-  ASSERT (X509Cert != NULL);\r
-\r
+{ \r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (X509Cert == NULL) {\r
+    return;\r
+  }\r
+  \r
   //\r
   // Free OpenSSL X509 object.\r
   //\r
@@ -193,7 +200,7 @@ X509Free (
 /**\r
   Release the specified X509 stack object.\r
 \r
-  If X509Stack is NULL, then ASSERT().\r
+  If X509Stack is NULL, then return FALSE.\r
 \r
   @param[in]  X509Stack  Pointer to the X509 stack object to be released.\r
 \r
@@ -204,8 +211,13 @@ X509StackFree (
   IN  VOID  *X509Stack\r
   )\r
 {\r
-  ASSERT (X509Stack != NULL);\r
-\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (X509Stack == NULL) {\r
+    return;\r
+  }\r
+  \r
   //\r
   // Free OpenSSL X509 stack object.\r
   //\r
@@ -221,8 +233,8 @@ X509StackFree (
   @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 ASSERT().\r
-  If SubjectSize is NULL, then ASSERT().\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
@@ -243,10 +255,11 @@ X509GetSubjectName (
   X509_NAME  *X509Name;\r
 \r
   //\r
-  // ASSERT if Cert is NULL or SubjectSize is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Cert        != NULL);\r
-  ASSERT (SubjectSize != NULL);\r
+  if (Cert == NULL || SubjectSize == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Status   = FALSE;\r
   X509Cert = NULL;\r
@@ -291,8 +304,8 @@ _Exit:
                            RSA public key component. Use RsaFree() function to free the\r
                            resource.\r
 \r
-  If Cert is NULL, then ASSERT().\r
-  If RsaContext is NULL, then ASSERT().\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
@@ -309,12 +322,13 @@ RsaGetPublicKeyFromX509 (
   BOOLEAN   Status;\r
   EVP_PKEY  *Pkey;\r
   X509      *X509Cert;\r
-\r
+  \r
   //\r
-  // ASSERT if Cert is NULL or RsaContext is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Cert       != NULL);\r
-  ASSERT (RsaContext != NULL);\r
+  if (Cert == NULL || RsaContext == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Status   = FALSE;\r
   Pkey     = NULL;\r
@@ -361,8 +375,8 @@ _Exit:
   @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 ASSERT().\r
-  If CACert is NULL, then ASSERT().\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
@@ -383,12 +397,13 @@ X509VerifyCert (
   X509            *X509CACert;\r
   X509_STORE      *CertStore;\r
   X509_STORE_CTX  CertCtx;\r
-\r
+  \r
   //\r
-  // ASSERT if Cert is NULL or CACert is NULL.\r
+  // Check input parameters.\r
   //\r
-  ASSERT (Cert   != NULL);\r
-  ASSERT (CACert != NULL);\r
+  if (Cert == NULL || CACert == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   Status     = FALSE;\r
   X509Cert   = NULL;\r
index 3ead6d1906fa0142c6865ac7e56122da604e541f..4b275951e83e70988a545b2062f6da282954ca66 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pseudorandom Number Generator Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -59,7 +59,7 @@ RandomSeed (
 /**\r
   Generates a pseudorandom byte stream of the specified size.\r
 \r
-  If Output is NULL, then ASSERT().\r
+  If Output is NULL, 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
@@ -75,7 +75,12 @@ RandomBytes (
   IN   UINTN  Size\r
   )\r
 {\r
-  ASSERT (Output != NULL);\r
+  //\r
+  // Check input parameters.\r
+  //\r
+  if (Output == NULL) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // Generate random data.\r
index 7f893b91df1771f9e81b650fb2e66b4717a4da82..2a1da855c66178d8d1134e3b539a7d1145ea70a8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of The runtime cryptographic library instance (for IPF).\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\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
@@ -195,7 +195,7 @@ Sha256GetContextSize (
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 Context being initialized.\r
 \r
@@ -221,7 +221,7 @@ Sha256Init (
   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
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -251,8 +251,8 @@ Sha256Update (
   Completes SHA-256 hash computation and retrieves the digest value into the specified\r
   memory. After this function has been called, the SHA-256 context cannot be used again.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 context\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -320,7 +320,7 @@ RsaFree (
   the user-specified nonnegative integer (octet string format represented in RSA\r
   PKCS#1).\r
 \r
-  If RsaContext is NULL, then ASSERT().\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
@@ -351,10 +351,10 @@ RsaSetKey (
   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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\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 HashLength 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