Hello.
Whether I correctly understand that below approach should protect the reference AES-128 key against the side channel attack due to usage of the mask? I use a bit outdated API but it doesn't matter, I get the correct results.
uint32_t coreClockHz = CLOCK_GetFreq(kCLOCK_CoreSysClk);
status_t result = PUF_Init(PUF, PUF_DISCHARGE_TIME_MS, coreClockHz);
if (result != kStatus_Success) return result;
result = PUF_Start(PUF, ac_buffer, ac_size);
if (result != kStatus_Success) {
PUF_Deinit(PUF, PUF_DISCHARGE_TIME_MS, coreClockHz);
}
__attribute__((aligned(4)))
uint8_t user_key[16] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
__attribute__((aligned(4)))
uint8_t keyCode[52] = {0x00};
result = PUF_SetUserKey(PUF, kPUF_KeyIndex_00, user_key, sizeof(user_key), keyCode, sizeof(keyCode));
if (result != kStatus_Success) {
PUF_Deinit(PUF, PUF_DISCHARGE_TIME_MS, coreClockHz);
}
hashcrypt_handle_t hch;
hch.keySize = kHASHCRYPT_Aes128;
hch.keyType = kHASHCRYPT_SecretKey;
result = PUF_GetHwKey(PUF, keyCode, 52, kPUF_KeySlot0, 0x01000001);
if (result != kStatus_Success) {
PUF_Deinit(PUF, PUF_DISCHARGE_TIME_MS, coreClockHz);
}
uint8_t pt[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t ct[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
result = HASHCRYPT_AES_EncryptEcb(HASHCRYPT, &hch, pt, ct, 16);
At least key bytes at positions 0, 3, 4, 7... should be protected?