From 98f41cbf141d1e514184025ee7dab734ae31ac2e Mon Sep 17 00:00:00 2001 From: Bhavik Ameta Date: Mon, 24 Aug 2015 19:45:41 +0530 Subject: [PATCH] sw_services:xilsecure: Removing NULL checking asserts on input buffer locations to correct assert failures Removing NULL checking asserts for the data buffers where 0x00 is a possible location. This will resolve the assert failures in xilsecure. Signed-off-by: Bhavik Ameta Acked-by: Srikanth Vemula --- lib/sw_services/xilsecure/src/xsecure_aes.c | 7 ------- lib/sw_services/xilsecure/src/xsecure_rsa.c | 12 ++---------- lib/sw_services/xilsecure/src/xsecure_sha.c | 5 +---- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/lib/sw_services/xilsecure/src/xsecure_aes.c b/lib/sw_services/xilsecure/src/xsecure_aes.c index 0dca89b2..4022b1a7 100644 --- a/lib/sw_services/xilsecure/src/xsecure_aes.c +++ b/lib/sw_services/xilsecure/src/xsecure_aes.c @@ -91,7 +91,6 @@ s32 XSecure_AesInitialize(XSecure_Aes *InstancePtr, XCsuDma *CsuDmaPtr, /* Assert validates the input arguments */ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(CsuDmaPtr != NULL); - Xil_AssertNonvoid(Iv != NULL); InstancePtr->BaseAddress = XSECURE_CSU_AES_BASE; InstancePtr->CsuDmaPtr = CsuDmaPtr; @@ -278,8 +277,6 @@ void XSecure_AesEncrypt(XSecure_Aes *InstancePtr, u8 *Dst, const u8 *Src, { /* Assert validates the input arguments */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(Dst != NULL); - Xil_AssertVoid(Src != NULL); Xil_AssertVoid(Len != (u32)0x0); u32 SssCfg = 0U; @@ -348,8 +345,6 @@ static u32 XSecure_AesDecryptBlk(XSecure_Aes *InstancePtr, u8 *Dst, { /* Assert validates the input arguments */ Xil_AssertNonvoid(InstancePtr != NULL); - Xil_AssertNonvoid(Dst != NULL); - Xil_AssertNonvoid(Src != NULL); Xil_AssertNonvoid(Tag != NULL); volatile u32 Status = 0U; @@ -557,8 +552,6 @@ u32 XSecure_AesDecrypt(XSecure_Aes *InstancePtr, u8 *Dst, const u8 *Src, { /* Assert validates the input arguments */ Xil_AssertNonvoid(InstancePtr != NULL); - Xil_AssertNonvoid(Dst != NULL); - Xil_AssertNonvoid(Src != NULL); u32 SssCfg = 0x0U; volatile u32 Status=0x0U; diff --git a/lib/sw_services/xilsecure/src/xsecure_rsa.c b/lib/sw_services/xilsecure/src/xsecure_rsa.c index df48fd1c..41041a89 100644 --- a/lib/sw_services/xilsecure/src/xsecure_rsa.c +++ b/lib/sw_services/xilsecure/src/xsecure_rsa.c @@ -138,7 +138,6 @@ static void XSecure_RsaWriteMem(XSecure_Rsa *InstancePtr, u32* WrData, { /* Assert validates the input arguments */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(WrData != NULL); u32 Index = 0U; u32 DataOffset = 0U; @@ -211,7 +210,6 @@ static void XSecure_RsaGetData(XSecure_Rsa *InstancePtr, u32 *RdData) { /* Assert validates the input arguments */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(RdData != NULL); u32 Index = 0U; u32 DataOffset = 0U; @@ -385,17 +383,11 @@ END: * Match the decrypted data with expected data * * @param Signature is the pointer to RSA signature for data to be - * authenticated + * authenticated * @param Hash is the pointer to expected hash data * @param HashLen is the length of Hash used. * - * @return 0 if RSA match succeeded - * 1 if character 1 of padding does not match - * 2 if character 2 of padding does not match - * 3 if FF padding scheme does not match - * 4 if character after FF padding does not match - * 5 T_padding for given SHA algorithm does not match - * 6 if the output hash does not match + * @return XST_SUCCESS if decryption was successful. * * @note None * diff --git a/lib/sw_services/xilsecure/src/xsecure_sha.c b/lib/sw_services/xilsecure/src/xsecure_sha.c index fbbeb253..961b03dc 100644 --- a/lib/sw_services/xilsecure/src/xsecure_sha.c +++ b/lib/sw_services/xilsecure/src/xsecure_sha.c @@ -116,7 +116,6 @@ void XSecure_Sha3Padd(XSecure_Sha3 *InstancePtr, u8 *Dst, u32 MsgLen) { /* Assert validates the input arguments */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(Dst != NULL); memset(Dst, 0, MsgLen); Dst[0] = 0x1U; @@ -177,7 +176,6 @@ void XSecure_Sha3Update(XSecure_Sha3 *InstancePtr, const u8 *Data, { /* Asserts validate the input arguments */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(Data != NULL); Xil_AssertVoid(Size != (u32)0x00U); InstancePtr->Sha3Len += Size; @@ -272,7 +270,7 @@ void XSecure_Sha3Finish(XSecure_Sha3 *InstancePtr, u8 *Hash) * Calculate SHA-3 Digest on the given input data * * @param InstancePtr is a pointer to the XSecure_Sha3 instance. - * @param In is the pointer to the input data for hashing + * @param In is the pointer to the input data for hashing * @param Size of the input data * @param Out is the pointer to location where resulting hash will be * written. @@ -287,7 +285,6 @@ void XSecure_Sha3Digest(XSecure_Sha3 *InstancePtr, const u8 *In, const u32 Size, { /* Asserts validate the input arguments */ Xil_AssertVoid(InstancePtr != NULL); - Xil_AssertVoid(In != NULL); Xil_AssertVoid(Size != (u32)0x00U); Xil_AssertVoid(Out != NULL);