Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Power consumption cannot be reduced after using hardware encryption

Hi   

    Nordic engineer

    Power consumption cannot be reduced after using hardware encryption. Under normal conditions, the device power consumption is 30µA, but after calling aes_cbc_decrypt, it increases to 3.4mA.   SDK is nrf5 17.0.0,how can I reduce power consumption?

   

void aes_cbc_decrypt(uint8_t *in,uint32_t out_len,uint8_t *out,uint8_t *iv,uint8_t *key)
{
    int ret;
	SaSiAesUserContext_t    ContextID;
	SaSiAesUserKeyData_t    keyData;
	SaSi_LibInit();
    ret = SaSi_AesInit(&ContextID,SASI_AES_DECRYPT,SASI_AES_MODE_CBC,SASI_AES_PADDING_NONE);
    
    ret = SaSi_AesSetIv(&ContextID, iv);

    keyData.pKey = key;
    keyData.keySize = 16;
    ret = SaSi_AesSetKey(&ContextID, SASI_AES_USER_KEY, &keyData, sizeof(keyData) );
    uint16_t i=0;
	if(out_len>SASI_AES_BLOCK_SIZE_IN_BYTES)
	{
	    for(i=0 ; i<(out_len/SASI_AES_BLOCK_SIZE_IN_BYTES-1) ; i++)
	    {
	        ret = SaSi_AesBlock(&ContextID,
	   				in+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
	   				SASI_AES_BLOCK_SIZE_IN_BYTES,
	   				out+i*SASI_AES_BLOCK_SIZE_IN_BYTES);
	    }
	}
    uint32_t len=out_len-i*SASI_AES_BLOCK_SIZE_IN_BYTES;
	if(len%SASI_AES_BLOCK_SIZE_IN_BYTES)
	{
		uint8_t temp[32]={0};
		uint32_t cipher_len = ((len+15)/SASI_AES_BLOCK_SIZE_IN_BYTES)*SASI_AES_BLOCK_SIZE_IN_BYTES;
		ret = SaSi_AesFinish(&ContextID,
						cipher_len,
						in+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
						cipher_len,
						temp,
						&cipher_len); 
		memcpy(out+i*SASI_AES_BLOCK_SIZE_IN_BYTES,temp,len);
	}
	else
	{
		ret = SaSi_AesFinish(&ContextID,
							len,
							in+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
							len,
							out+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
							&len);  
	}
	SaSi_AesFree(&ContextID);
	SaSi_LibFini();	    
}

Parents Reply Children
  • Hi,

    Since I'm not able to reproduce this on my end I suggest you try to troubleshoot this more on your side. For example, you can try to build without FPU enabled (Note: this requires you to link in the non-FP variant of the cc310 runtime lib as well). Or you can try find you why you are not measuring -2-3 ua with the examples\crypto\nrf_cc310\aes example.

    mokoysh said:
      I'm sorry to misread the previous information,the project in the folder aes_test\.MDK_Project\AES_TEST.uvprojx.

    I see. I'm on macOS where directories with leading dot (.) like .MDK_Project will appear hidden by default. 

Related