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
  • Hi,

    mokoysh said:
    I test the examples\crypto\nrf_cc310\aes ,the power is 1.6mA.

    I measured ~2 ua with this example. The only change I made was to disable UART logging in sdk_config.h. Did you keep logging enabled?

    mokoysh said:
    And the project had attach

    The attachment included the source files, but I didn't see any actual project files for building the project.

Children
Related