You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For my project I wanted SHA256 support and the random number generator. In the harmony configurator I enabled hardware support for both my requirements.
I looked in to the documentation and found the following:
RNG
#define RANDOM_BYTE_SZ 32
int ret;
CRYPT_RNG_CTX mcRng;
byte out[RANDOM_BYTE_SZ];
ret = CRYPT_RNG_Initialize(&mcRng);
ret = CRYPT_RNG_BlockGenerate(&mcRng, out, RANDOM_BYTE_SZ);
The initialize function fails with error code -209 (DRBG_CONT_FIPS_E).
But the initialize function tries to preform a sha256 operations with fails which I will mention below.
The initialize function fails with error code -245 (ASYNC_OP_E).
After going line by line with the debugger I stumbled on the while-wait loop that times out in pic32mz-crypt.c Pic32Crypto()
/* Software Reset the Crypto Engine */
CECON = 1 << 6;
while (CECON);
/* Clear the interrupt flags */
CEINTSRC = 0xF;
/* Run the engine */
CEBDPADDR = (unsigned int)KVA_TO_PA(&bd);
CEINTEN = 0x07; /* enable DMA Packet Completion Interrupt */
/* input swap, enable BD fetch and start DMA */
#if PIC32_NO_OUT_SWAP
CECON = 0x25;
#else
CECON = 0xa5; /* bit 7 = enable out swap */
#endif
/* wait for operation to complete */
while (CEINTSRCbits.PKTIF == 0 && --timeout > 0) {};
/* Clear the interrupt flags */
CEINTSRC = 0xF;
/* check for errors */
if (CESTATbits.ERROP || timeout <= 0) {
#if 0
printf("PIC32 Crypto: ERROP %x, ERRPHASE %x, TIMEOUT %s\n",
CESTATbits.ERROP, CESTATbits.ERRPHASE, timeout <= 0 ? "yes" : "no");
#endif
ret = ASYNC_OP_E;
}
the CEINTSRCbits.PKTIF seems to be never set to 1.
I looked up what this function does and compared it with the PIC32MZ datasheet and this function seems to enable al the right registers.
Maybe I forgot to setup/initialize something in the project but I can't find anything in the Harmony documentation files.
The text was updated successfully, but these errors were encountered:
In the harmony configurator I forgot to enable the RNG peripheral, after enabling the peripheral the crypto library generated the random numbers I wanted.
But this let me to the peripheral disable bits in plib_clk.c CLK_Initialize() where I found that harmony never enabled the crypto engine peripheral after clearing bit PMD7<22> everything started working.
Harmony generated:
PMD7 = 0xffefffef;
Clearing the PMD7<22> bit:
PMD7 = 0xffafffef;
But there is no way to enable the crypto engine in the harmony configurator as there is no crypto peripheral node to add, like how you add the RNG peripheral node.
For my project I wanted SHA256 support and the random number generator. In the harmony configurator I enabled hardware support for both my requirements.
I looked in to the documentation and found the following:
The initialize function fails with error code -209 (DRBG_CONT_FIPS_E).
But the initialize function tries to preform a sha256 operations with fails which I will mention below.
The initialize function fails with error code -245 (ASYNC_OP_E).
After going line by line with the debugger I stumbled on the while-wait loop that times out in
pic32mz-crypt.c Pic32Crypto()
the
CEINTSRCbits.PKTIF
seems to be never set to 1.I looked up what this function does and compared it with the PIC32MZ datasheet and this function seems to enable al the right registers.
Maybe I forgot to setup/initialize something in the project but I can't find anything in the Harmony documentation files.
The text was updated successfully, but these errors were encountered: