3131#include <wolfssl/wolfcrypt/sha.h>
3232#include <wolfssl/wolfcrypt/sha256.h>
3333#include <wolfssl/wolfcrypt/error-crypt.h>
34+ #ifdef NO_INLINE
35+ #include <wolfssl/wolfcrypt/misc.h>
36+ #else
37+ #define WOLFSSL_MISC_INCLUDED
38+ #include <wolfcrypt/src/misc.c>
39+ #endif
3440
3541#if defined(__DCACHE_PRESENT ) && (__DCACHE_PRESENT == 1U ) && defined(DCP_USE_DCACHE ) && (DCP_USE_DCACHE == 1U )
3642#error "DCACHE not supported by this driver. Please undefine DCP_USE_DCACHE."
@@ -205,14 +211,18 @@ int DCPAesInit(Aes *aes)
205211 return 0 ;
206212}
207213
214+ static unsigned char aes_key_aligned [16 ] __attribute__((aligned (0x10 )));
215+
208216void DCPAesFree (Aes * aes )
209217{
218+ dcp_lock ();
219+ ForceZero (aes_key_aligned , sizeof (aes_key_aligned ));
220+ dcp_unlock ();
210221 dcp_free (aes -> handle .channel );
211222 aes -> handle .channel = 0 ;
212223}
213224
214225
215- static unsigned char aes_key_aligned [16 ] __attribute__((aligned (0x10 )));
216226int DCPAesSetKey (Aes * aes , const byte * key , word32 len , const byte * iv ,
217227 int dir )
218228{
@@ -231,8 +241,9 @@ int DCPAesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
231241 return WC_HW_E ;
232242 }
233243 dcp_lock ();
234- memcpy (aes_key_aligned , key , 16 );
244+ XMEMCPY (aes_key_aligned , key , 16 );
235245 status = DCP_AES_SetKey (DCP , & aes -> handle , aes_key_aligned , 16 );
246+ ForceZero (aes_key_aligned , sizeof (aes_key_aligned ));
236247 if (status != kStatus_Success )
237248 status = WC_HW_E ;
238249 else {
0 commit comments