summaryrefslogtreecommitdiff
path: root/CryptoPkg/Library/BaseCryptLib/Hash
diff options
context:
space:
mode:
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-19 05:52:16 +0000
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2012-03-19 05:52:16 +0000
commit16d2c32c4dff7fd8b0ee19e3ba908c0121f6636e (patch)
tree08699467fc6247e7375faf2c419cfd882398ab63 /CryptoPkg/Library/BaseCryptLib/Hash
parentbd0de3963b8e09ccded4b6922d5e6f0146a2f63f (diff)
downloadedk2-platforms-16d2c32c4dff7fd8b0ee19e3ba908c0121f6636e.tar.xz
1. Remove conducting ASSERT in BaseCryptLib.
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
Diffstat (limited to 'CryptoPkg/Library/BaseCryptLib/Hash')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c46
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c46
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c46
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c46
4 files changed, 104 insertions, 80 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
index a5769133ed..31fc4dcea9 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
@@ -1,7 +1,7 @@
/** @file
MD4 Digest Wrapper Implementation over OpenSSL.
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -37,7 +37,7 @@ Md4GetContextSize (
Initializes user-supplied memory pointed by Md4Context as MD4 hash context for
subsequent use.
- If Md4Context is NULL, then ASSERT().
+ If Md4Context is NULL, then return FALSE.
@param[out] Md4Context Pointer to MD4 context being initialized.
@@ -52,9 +52,11 @@ Md4Init (
)
{
//
- // ASSERT if Md4Context is NULL.
+ // Check input parameters.
//
- ASSERT (Md4Context != NULL);
+ if (Md4Context == NULL) {
+ return FALSE;
+ }
//
// OpenSSL MD4 Context Initialization
@@ -65,8 +67,8 @@ Md4Init (
/**
Makes a copy of an existing MD4 context.
- If Md4Context is NULL, then ASSERT().
- If NewMd4Context is NULL, then ASSERT().
+ If Md4Context is NULL, then return FALSE.
+ If NewMd4Context is NULL, then return FALSE.
@param[in] Md4Context Pointer to MD4 context being copied.
@param[out] NewMd4Context Pointer to new MD4 context.
@@ -83,10 +85,11 @@ Md4Duplicate (
)
{
//
- // ASSERT if Md4Context or NewMd4Context is NULL.
+ // Check input parameters.
//
- ASSERT (Md4Context != NULL);
- ASSERT (NewMd4Context != NULL);
+ if (Md4Context == NULL || NewMd4Context == NULL) {
+ return FALSE;
+ }
CopyMem (NewMd4Context, Md4Context, sizeof (MD4_CTX));
@@ -101,7 +104,7 @@ Md4Duplicate (
MD4 context should be already correctly intialized by Md4Init(), and should not be finalized
by Md4Final(). Behavior with invalid context is undefined.
- If Md4Context is NULL, then ASSERT().
+ If Md4Context is NULL, then return FALSE.
@param[in, out] Md4Context Pointer to the MD4 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@@ -120,15 +123,17 @@ Md4Update (
)
{
//
- // ASSERT if Md4Context is NULL
+ // Check input parameters.
//
- ASSERT (Md4Context != NULL);
+ if (Md4Context == NULL) {
+ return FALSE;
+ }
//
- // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL
+ // Check invalid parameters, in case that only DataLength was checked in OpenSSL
//
- if (Data == NULL) {
- ASSERT (DataSize == 0);
+ if (Data == NULL && DataSize != 0) {
+ return FALSE;
}
//
@@ -146,8 +151,8 @@ Md4Update (
MD4 context should be already correctly intialized by Md4Init(), and should not be
finalized by Md4Final(). Behavior with invalid MD4 context is undefined.
- If Md4Context is NULL, then ASSERT().
- If HashValue is NULL, then ASSERT().
+ If Md4Context is NULL, then return FALSE.
+ If HashValue is NULL, then return FALSE.
@param[in, out] Md4Context Pointer to the MD4 context.
@param[out] HashValue Pointer to a buffer that receives the MD4 digest
@@ -165,10 +170,11 @@ Md4Final (
)
{
//
- // ASSERT if Md4Context is NULL or HashValue is NULL
+ // Check input parameters.
//
- ASSERT (Md4Context != NULL);
- ASSERT (HashValue != NULL);
+ if (Md4Context == NULL || HashValue == NULL) {
+ return FALSE;
+ }
//
// OpenSSL MD4 Hash Finalization
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c
index 8d5e6ed89d..1d852c7495 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptMd5.c
@@ -1,7 +1,7 @@
/** @file
MD5 Digest Wrapper Implementation over OpenSSL.
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -39,7 +39,7 @@ Md5GetContextSize (
Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
subsequent use.
- If Md5Context is NULL, then ASSERT().
+ If Md5Context is NULL, then return FALSE.
@param[out] Md5Context Pointer to MD5 context being initialized.
@@ -54,9 +54,11 @@ Md5Init (
)
{
//
- // ASSERT if Md5Context is NULL.
+ // Check input parameters.
//
- ASSERT (Md5Context != NULL);
+ if ((Md5Context == NULL)) {
+ return FALSE;
+ }
//
// OpenSSL MD5 Context Initialization
@@ -67,8 +69,8 @@ Md5Init (
/**
Makes a copy of an existing MD5 context.
- If Md5Context is NULL, then ASSERT().
- If NewMd5Context is NULL, then ASSERT().
+ If Md5Context is NULL, then return FALSE.
+ If NewMd5Context is NULL, then return FALSE.
@param[in] Md5Context Pointer to MD5 context being copied.
@param[out] NewMd5Context Pointer to new MD5 context.
@@ -85,10 +87,11 @@ Md5Duplicate (
)
{
//
- // ASSERT if Md5Context or NewMd5Context is NULL.
+ // Check input parameters.
//
- ASSERT (Md5Context != NULL);
- ASSERT (NewMd5Context != NULL);
+ if (Md5Context == NULL || NewMd5Context == NULL) {
+ return FALSE;
+ }
CopyMem (NewMd5Context, Md5Context, sizeof (MD5_CTX));
@@ -103,7 +106,7 @@ Md5Duplicate (
MD5 context should be already correctly intialized by Md5Init(), and should not be finalized
by Md5Final(). Behavior with invalid context is undefined.
- If Md5Context is NULL, then ASSERT().
+ If Md5Context is NULL, then return FALSE.
@param[in, out] Md5Context Pointer to the MD5 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@@ -122,15 +125,17 @@ Md5Update (
)
{
//
- // ASSERT if Md5Context is NULL
+ // Check input parameters.
//
- ASSERT (Md5Context != NULL);
+ if (Md5Context == NULL) {
+ return FALSE;
+ }
//
- // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL
+ // Check invalid parameters, in case that only DataLength was checked in OpenSSL
//
- if (Data == NULL) {
- ASSERT (DataSize == 0);
+ if (Data == NULL && (DataSize != 0)) {
+ return FALSE;
}
//
@@ -148,8 +153,8 @@ Md5Update (
MD5 context should be already correctly intialized by Md5Init(), and should not be
finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
- If Md5Context is NULL, then ASSERT().
- If HashValue is NULL, then ASSERT().
+ If Md5Context is NULL, then return FALSE.
+ If HashValue is NULL, then return FALSE.
@param[in, out] Md5Context Pointer to the MD5 context.
@param[out] HashValue Pointer to a buffer that receives the MD5 digest
@@ -167,10 +172,11 @@ Md5Final (
)
{
//
- // ASSERT if Md5Context is NULL or HashValue is NULL
+ // Check input parameters.
//
- ASSERT (Md5Context != NULL);
- ASSERT (HashValue != NULL);
+ if (Md5Context == NULL || HashValue == NULL) {
+ return FALSE;
+ }
//
// OpenSSL MD5 Hash Finalization
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c
index 27526bcd40..633028b64e 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha1.c
@@ -1,7 +1,7 @@
/** @file
SHA-1 Digest Wrapper Implementation over OpenSSL.
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -38,7 +38,7 @@ Sha1GetContextSize (
Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
subsequent use.
- If Sha1Context is NULL, then ASSERT().
+ If Sha1Context is NULL, then return FALSE.
@param[out] Sha1Context Pointer to SHA-1 context being initialized.
@@ -53,9 +53,11 @@ Sha1Init (
)
{
//
- // ASSERT if Sha1Context is NULL
+ // Check input parameters.
//
- ASSERT (Sha1Context != NULL);
+ if (Sha1Context == NULL) {
+ return FALSE;
+ }
//
// OpenSSL SHA-1 Context Initialization
@@ -66,8 +68,8 @@ Sha1Init (
/**
Makes a copy of an existing SHA-1 context.
- If Sha1Context is NULL, then ASSERT().
- If NewSha1Context is NULL, then ASSERT().
+ If Sha1Context is NULL, then return FALSE.
+ If NewSha1Context is NULL, then return FALSE.
@param[in] Sha1Context Pointer to SHA-1 context being copied.
@param[out] NewSha1Context Pointer to new SHA-1 context.
@@ -84,10 +86,11 @@ Sha1Duplicate (
)
{
//
- // ASSERT if Sha1Context or NewSha1Context is NULL.
+ // Check input parameters.
//
- ASSERT (Sha1Context != NULL);
- ASSERT (NewSha1Context != NULL);
+ if (Sha1Context == NULL || NewSha1Context == NULL) {
+ return FALSE;
+ }
CopyMem (NewSha1Context, Sha1Context, sizeof (SHA_CTX));
@@ -102,7 +105,7 @@ Sha1Duplicate (
SHA-1 context should be already correctly intialized by Sha1Init(), and should not be finalized
by Sha1Final(). Behavior with invalid context is undefined.
- If Sha1Context is NULL, then ASSERT().
+ If Sha1Context is NULL, then return FALSE.
@param[in, out] Sha1Context Pointer to the SHA-1 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@@ -121,15 +124,17 @@ Sha1Update (
)
{
//
- // ASSERT if Sha1Context is NULL
+ // Check input parameters.
//
- ASSERT (Sha1Context != NULL);
+ if (Sha1Context == NULL) {
+ return FALSE;
+ }
//
- // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL
+ // Check invalid parameters, in case that only DataLength was checked in OpenSSL
//
- if (Data == NULL) {
- ASSERT (DataSize == 0);
+ if (Data == NULL && DataSize != 0) {
+ return FALSE;
}
//
@@ -147,8 +152,8 @@ Sha1Update (
SHA-1 context should be already correctly intialized by Sha1Init(), and should not be
finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
- If Sha1Context is NULL, then ASSERT().
- If HashValue is NULL, then ASSERT().
+ If Sha1Context is NULL, then return FALSE.
+ If HashValue is NULL, then return FALSE.
@param[in, out] Sha1Context Pointer to the SHA-1 context.
@param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
@@ -166,10 +171,11 @@ Sha1Final (
)
{
//
- // ASSERT if Sha1Context is NULL or HashValue is NULL
+ // Check input parameters.
//
- ASSERT (Sha1Context != NULL);
- ASSERT (HashValue != NULL);
+ if (Sha1Context == NULL || HashValue == NULL) {
+ return FALSE;
+ }
//
// OpenSSL SHA-1 Hash Finalization
diff --git a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c
index 3c2f9a1155..ca0cb1aa8c 100644
--- a/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c
+++ b/CryptoPkg/Library/BaseCryptLib/Hash/CryptSha256.c
@@ -1,7 +1,7 @@
/** @file
SHA-256 Digest Wrapper Implementation over OpenSSL.
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -37,7 +37,7 @@ Sha256GetContextSize (
Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
subsequent use.
- If Sha256Context is NULL, then ASSERT().
+ If Sha256Context is NULL, then return FALSE.
@param[out] Sha256Context Pointer to SHA-256 context being initialized.
@@ -52,9 +52,11 @@ Sha256Init (
)
{
//
- // ASSERT if Sha256Context is NULL
+ // Check input parameters.
//
- ASSERT (Sha256Context != NULL);
+ if (Sha256Context == NULL) {
+ return FALSE;
+ }
//
// OpenSSL SHA-256 Context Initialization
@@ -65,8 +67,8 @@ Sha256Init (
/**
Makes a copy of an existing SHA-256 context.
- If Sha256Context is NULL, then ASSERT().
- If NewSha256Context is NULL, then ASSERT().
+ If Sha256Context is NULL, then return FALSE.
+ If NewSha256Context is NULL, then return FALSE.
@param[in] Sha256Context Pointer to SHA-256 context being copied.
@param[out] NewSha256Context Pointer to new SHA-256 context.
@@ -83,10 +85,11 @@ Sha256Duplicate (
)
{
//
- // ASSERT if Sha256Context or NewSha256Context is NULL.
+ // Check input parameters.
//
- ASSERT (Sha256Context != NULL);
- ASSERT (NewSha256Context != NULL);
+ if (Sha256Context == NULL || NewSha256Context == NULL) {
+ return FALSE;
+ }
CopyMem (NewSha256Context, Sha256Context, sizeof (SHA256_CTX));
@@ -101,7 +104,7 @@ Sha256Duplicate (
SHA-256 context should be already correctly intialized by Sha256Init(), and should not be finalized
by Sha256Final(). Behavior with invalid context is undefined.
- If Sha256Context is NULL, then ASSERT().
+ If Sha256Context is NULL, then return FALSE.
@param[in, out] Sha256Context Pointer to the SHA-256 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@@ -120,15 +123,17 @@ Sha256Update (
)
{
//
- // ASSERT if Sha256Context is NULL
+ // Check input parameters.
//
- ASSERT (Sha256Context != NULL);
+ if (Sha256Context == NULL) {
+ return FALSE;
+ }
//
- // ASSERT if invalid parameters, in case that only DataLength was checked in OpenSSL
+ // Check invalid parameters, in case that only DataLength was checked in OpenSSL
//
- if (Data == NULL) {
- ASSERT (DataSize == 0);
+ if (Data == NULL && DataSize != 0) {
+ return FALSE;
}
//
@@ -146,8 +151,8 @@ Sha256Update (
SHA-256 context should be already correctly intialized by Sha256Init(), and should not be
finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.
- If Sha256Context is NULL, then ASSERT().
- If HashValue is NULL, then ASSERT().
+ If Sha256Context is NULL, then return FALSE.
+ If HashValue is NULL, then return FALSE.
@param[in, out] Sha256Context Pointer to the SHA-256 context.
@param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
@@ -165,10 +170,11 @@ Sha256Final (
)
{
//
- // ASSERT if Sha256Context is NULL or HashValue is NULL
+ // Check input parameters.
//
- ASSERT (Sha256Context != NULL);
- ASSERT (HashValue != NULL);
+ if (Sha256Context == NULL || HashValue == NULL) {
+ return FALSE;
+ }
//
// OpenSSL SHA-256 Hash Finalization