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
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
AES 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
|
||||
@@ -42,9 +42,9 @@ AesGetContextSize (
|
||||
operations.
|
||||
There are 3 options for key length, 128 bits, 192 bits, and 256 bits.
|
||||
|
||||
If AesContext is NULL, then ASSERT().
|
||||
If Key is NULL, then ASSERT().
|
||||
If KeyLength is not valid, then ASSERT().
|
||||
If AesContext is NULL, then return FALSE.
|
||||
If Key is NULL, then return FALSE.
|
||||
If KeyLength is not valid, then return FALSE.
|
||||
|
||||
@param[out] AesContext Pointer to AES context being initialized.
|
||||
@param[in] Key Pointer to the user-supplied AES key.
|
||||
@@ -64,12 +64,12 @@ AesInit (
|
||||
{
|
||||
AES_KEY *AesKey;
|
||||
|
||||
ASSERT (AesContext != NULL);
|
||||
//
|
||||
// AES Key Checking
|
||||
// Check input parameters.
|
||||
//
|
||||
ASSERT (Key != NULL);
|
||||
ASSERT ((KeyLength == 128) || (KeyLength == 192) || (KeyLength == 256));
|
||||
if (AesContext == NULL || Key == NULL || (KeyLength != 128 && KeyLength != 192 && KeyLength != 256)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize AES encryption & decryption key schedule.
|
||||
@@ -94,10 +94,10 @@ AesInit (
|
||||
AesContext should be already correctly initialized by AesInit(). Behavior with
|
||||
invalid AES context is undefined.
|
||||
|
||||
If AesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (16 bytes), then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If AesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (16 bytes), then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] AesContext Pointer to the AES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -118,12 +118,14 @@ AesEcbEncrypt (
|
||||
)
|
||||
{
|
||||
AES_KEY *AesKey;
|
||||
|
||||
ASSERT (AesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Output != NULL);
|
||||
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AesKey = (AES_KEY *) AesContext;
|
||||
|
||||
//
|
||||
@@ -149,10 +151,10 @@ AesEcbEncrypt (
|
||||
AesContext should be already correctly initialized by AesInit(). Behavior with
|
||||
invalid AES context is undefined.
|
||||
|
||||
If AesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (16 bytes), then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If AesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (16 bytes), then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] AesContext Pointer to the AES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be decrypted.
|
||||
@@ -173,11 +175,13 @@ AesEcbDecrypt (
|
||||
)
|
||||
{
|
||||
AES_KEY *AesKey;
|
||||
|
||||
ASSERT (AesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Output != NULL);
|
||||
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AesKey = (AES_KEY *) AesContext;
|
||||
|
||||
@@ -205,11 +209,11 @@ AesEcbDecrypt (
|
||||
AesContext should be already correctly initialized by AesInit(). Behavior with
|
||||
invalid AES context is undefined.
|
||||
|
||||
If AesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (16 bytes), then ASSERT().
|
||||
If Ivec is NULL, then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If AesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (16 bytes), then return FALSE.
|
||||
If Ivec is NULL, then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] AesContext Pointer to the AES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -234,11 +238,12 @@ AesCbcEncrypt (
|
||||
AES_KEY *AesKey;
|
||||
UINT8 IvecBuffer[AES_BLOCK_SIZE];
|
||||
|
||||
ASSERT (AesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Ivec != NULL);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AesKey = (AES_KEY *) AesContext;
|
||||
CopyMem (IvecBuffer, Ivec, AES_BLOCK_SIZE);
|
||||
@@ -262,11 +267,11 @@ AesCbcEncrypt (
|
||||
AesContext should be already correctly initialized by AesInit(). Behavior with
|
||||
invalid AES context is undefined.
|
||||
|
||||
If AesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (16 bytes), then ASSERT().
|
||||
If Ivec is NULL, then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If AesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (16 bytes), then return FALSE.
|
||||
If Ivec is NULL, then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] AesContext Pointer to the AES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -290,12 +295,13 @@ AesCbcDecrypt (
|
||||
{
|
||||
AES_KEY *AesKey;
|
||||
UINT8 IvecBuffer[AES_BLOCK_SIZE];
|
||||
|
||||
ASSERT (AesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % AES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Ivec != NULL);
|
||||
ASSERT (Output != NULL);
|
||||
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (AesContext == NULL || Input == NULL || (InputSize % AES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AesKey = (AES_KEY *) AesContext;
|
||||
CopyMem (IvecBuffer, Ivec, AES_BLOCK_SIZE);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
ARC4 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
|
||||
@@ -42,9 +42,9 @@ Arc4GetContextSize (
|
||||
In addtion, it sets up all ARC4 key materials for subsequent encryption and decryption
|
||||
operations.
|
||||
|
||||
If Arc4Context is NULL, then ASSERT().
|
||||
If Key is NULL, then ASSERT().
|
||||
If KeySize does not in the range of [5, 256] bytes, then ASSERT().
|
||||
If Arc4Context is NULL, then return FALSE.
|
||||
If Key is NULL, then return FALSE.
|
||||
If KeySize does not in the range of [5, 256] bytes, then return FALSE.
|
||||
|
||||
@param[out] Arc4Context Pointer to ARC4 context being initialized.
|
||||
@param[in] Key Pointer to the user-supplied ARC4 key.
|
||||
@@ -64,9 +64,12 @@ Arc4Init (
|
||||
{
|
||||
RC4_KEY *Rc4Key;
|
||||
|
||||
ASSERT (Arc4Context != NULL);
|
||||
ASSERT (Key != NULL);
|
||||
ASSERT ((KeySize >= 5) && (KeySize <= 256));
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (Arc4Context == NULL || Key == NULL || (KeySize < 5 || KeySize > 256)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Rc4Key = (RC4_KEY *) Arc4Context;
|
||||
|
||||
@@ -85,9 +88,9 @@ Arc4Init (
|
||||
Arc4Context should be already correctly initialized by Arc4Init(). Behavior with
|
||||
invalid ARC4 context is undefined.
|
||||
|
||||
If Arc4Context is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If Arc4Context is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in, out] Arc4Context Pointer to the ARC4 context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -109,9 +112,12 @@ Arc4Encrypt (
|
||||
{
|
||||
RC4_KEY *Rc4Key;
|
||||
|
||||
ASSERT (Arc4Context != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (Arc4Context == NULL || Input == NULL || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Rc4Key = (RC4_KEY *) Arc4Context;
|
||||
|
||||
@@ -128,9 +134,9 @@ Arc4Encrypt (
|
||||
Arc4Context should be already correctly initialized by Arc4Init(). Behavior with
|
||||
invalid ARC4 context is undefined.
|
||||
|
||||
If Arc4Context is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If Arc4Context is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in, out] Arc4Context Pointer to the ARC4 context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be decrypted.
|
||||
@@ -152,9 +158,12 @@ Arc4Decrypt (
|
||||
{
|
||||
RC4_KEY *Rc4Key;
|
||||
|
||||
ASSERT (Arc4Context != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (Arc4Context == NULL || Input == NULL || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Rc4Key = (RC4_KEY *) Arc4Context;
|
||||
|
||||
@@ -171,7 +180,7 @@ Arc4Decrypt (
|
||||
Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context
|
||||
should be already correctly initialized by ARC4Init().
|
||||
|
||||
If Arc4Context is NULL, then ASSERT().
|
||||
If Arc4Context is NULL, then return FALSE.
|
||||
|
||||
@param[in, out] Arc4Context Pointer to the ARC4 context.
|
||||
|
||||
@@ -187,8 +196,13 @@ Arc4Reset (
|
||||
{
|
||||
RC4_KEY *Rc4Key;
|
||||
|
||||
ASSERT (Arc4Context != NULL);
|
||||
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (Arc4Context == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Rc4Key = (RC4_KEY *) Arc4Context;
|
||||
|
||||
CopyMem (Rc4Key, Rc4Key + 1, sizeof(RC4_KEY));
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
TDES 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
|
||||
@@ -44,9 +44,9 @@ TdesGetContextSize (
|
||||
KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security)
|
||||
KeyLength = 192 Keying option 3: K1 != K2 != K3 (Strongest)
|
||||
|
||||
If TdesContext is NULL, then ASSERT().
|
||||
If Key is NULL, then ASSERT().
|
||||
If KeyLength is not valid, then ASSERT().
|
||||
If TdesContext is NULL, then return FALSE.
|
||||
If Key is NULL, then return FALSE.
|
||||
If KeyLength is not valid, then return FALSE.
|
||||
|
||||
@param[out] TdesContext Pointer to TDES context being initialized.
|
||||
@param[in] Key Pointer to the user-supplied TDES key.
|
||||
@@ -66,9 +66,12 @@ TdesInit (
|
||||
{
|
||||
DES_key_schedule *KeySchedule;
|
||||
|
||||
ASSERT (TdesContext != NULL);
|
||||
ASSERT (Key != NULL);
|
||||
ASSERT ((KeyLength == 64) || (KeyLength == 128) || (KeyLength == 192));
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (TdesContext == NULL || Key == NULL || (KeyLength != 64 && KeyLength != 128 && KeyLength != 192)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeySchedule = (DES_key_schedule *) TdesContext;
|
||||
|
||||
@@ -117,10 +120,10 @@ TdesInit (
|
||||
TdesContext should be already correctly initialized by TdesInit(). Behavior with
|
||||
invalid TDES context is undefined.
|
||||
|
||||
If TdesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (8 bytes), then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If TdesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (8 bytes), then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] TdesContext Pointer to the TDES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -142,10 +145,12 @@ TdesEcbEncrypt (
|
||||
{
|
||||
DES_key_schedule *KeySchedule;
|
||||
|
||||
ASSERT (TdesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeySchedule = (DES_key_schedule *) TdesContext;
|
||||
|
||||
@@ -176,10 +181,10 @@ TdesEcbEncrypt (
|
||||
TdesContext should be already correctly initialized by TdesInit(). Behavior with
|
||||
invalid TDES context is undefined.
|
||||
|
||||
If TdesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (8 bytes), then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If TdesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (8 bytes), then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] TdesContext Pointer to the TDES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be decrypted.
|
||||
@@ -201,10 +206,12 @@ TdesEcbDecrypt (
|
||||
{
|
||||
DES_key_schedule *KeySchedule;
|
||||
|
||||
ASSERT (TdesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeySchedule = (DES_key_schedule *) TdesContext;
|
||||
|
||||
@@ -236,11 +243,11 @@ TdesEcbDecrypt (
|
||||
TdesContext should be already correctly initialized by TdesInit(). Behavior with
|
||||
invalid TDES context is undefined.
|
||||
|
||||
If TdesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (8 bytes), then ASSERT().
|
||||
If Ivec is NULL, then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If TdesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (8 bytes), then return FALSE.
|
||||
If Ivec is NULL, then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] TdesContext Pointer to the TDES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -265,11 +272,12 @@ TdesCbcEncrypt (
|
||||
DES_key_schedule *KeySchedule;
|
||||
UINT8 IvecBuffer[TDES_BLOCK_SIZE];
|
||||
|
||||
ASSERT (TdesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Ivec != NULL);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeySchedule = (DES_key_schedule *) TdesContext;
|
||||
CopyMem (IvecBuffer, Ivec, TDES_BLOCK_SIZE);
|
||||
@@ -299,11 +307,11 @@ TdesCbcEncrypt (
|
||||
TdesContext should be already correctly initialized by TdesInit(). Behavior with
|
||||
invalid TDES context is undefined.
|
||||
|
||||
If TdesContext is NULL, then ASSERT().
|
||||
If Input is NULL, then ASSERT().
|
||||
If InputSize is not multiple of block size (8 bytes), then ASSERT().
|
||||
If Ivec is NULL, then ASSERT().
|
||||
If Output is NULL, then ASSERT().
|
||||
If TdesContext is NULL, then return FALSE.
|
||||
If Input is NULL, then return FALSE.
|
||||
If InputSize is not multiple of block size (8 bytes), then return FALSE.
|
||||
If Ivec is NULL, then return FALSE.
|
||||
If Output is NULL, then return FALSE.
|
||||
|
||||
@param[in] TdesContext Pointer to the TDES context.
|
||||
@param[in] Input Pointer to the buffer containing the data to be encrypted.
|
||||
@@ -328,11 +336,12 @@ TdesCbcDecrypt (
|
||||
DES_key_schedule *KeySchedule;
|
||||
UINT8 IvecBuffer[TDES_BLOCK_SIZE];
|
||||
|
||||
ASSERT (TdesContext != NULL);
|
||||
ASSERT (Input != NULL);
|
||||
ASSERT ((InputSize % TDES_BLOCK_SIZE) == 0);
|
||||
ASSERT (Ivec != NULL);
|
||||
ASSERT (Output != NULL);
|
||||
//
|
||||
// Check input parameters.
|
||||
//
|
||||
if (TdesContext == NULL || Input == NULL || (InputSize % TDES_BLOCK_SIZE) != 0 || Ivec == NULL || Output == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeySchedule = (DES_key_schedule *) TdesContext;
|
||||
CopyMem (IvecBuffer, Ivec, TDES_BLOCK_SIZE);
|
||||
|
Reference in New Issue
Block a user