2023-03-31 03:33 AM
I am using the STM32WLE5CC ship on a RAK3172 module.
I am not using the HAL but writing directly to the PKA RAM and registers, to perform a standard Modular Exponention (normal mode) as described in section 22.4.6 of the manual.
The PKA clock has been enabled for normal and sleep mode.
I write the exponent and exponent length, the operand and operand length, and the modulus to the PKA RAM, ensuring I am ending with a 32 bit word set to zero as described by section22.4.1.
I set the PKA Control Register "Start" bit, after ensuring that the "mode" has been set to zero (Montgomery parameter computation then modular exponentiation) and the enable flag is still set.
After setting the start bit in the CR, the "Busy" bit in the status register goes high, as expected.
I poll the status register every 10 microseconds, waiting for it to change - the Busy bit should go to 0 and the PROCENF flag should go high, but it never changes, even after several hours.
I can read back the registers and RAM and they containt he values I expect.
Are there any other clock systems or registers that need to be set for the PKA to operate?
Solved! Go to Solution.
2023-04-12 04:57 AM
Final solution found.
It appears my code was overwriting the exponent with zeros when putting the operand into the PKA RAM. As anything to the power of zero is one, the PKA was producing the right answer for that scenario.
Ensuring the operand did not overrun the exponent means the system is now working as expected.
2023-04-11 08:36 AM
I've got a bit further. I had the wrong size of the operand - it needed to be the same size as the Modulus (in bits), rahter than the size of the base value of the exponent. The operation now completes.
However, the data sheet says the output should be at offset 0x724 in the PKA RAM, but this is always all zeros except the first byte, which contains 0x01. This value is the same regardless of the numbers or the modulus put into the PKA RAM.
If I use the values in the data sheet to do a large number addition or arithmetic multiplication, the operation completes and has the expected values at the expected offset in the PKA RAM offset, so I know the hardware module is turned on and working for some of the operations.
Is there any additional documentation on how to detect errors from the output of the PKA ram to hint at what else I might not be doing correctly?
Are there any known errors in the datasheet for this chipset that have not made it into an errata document?
Is there an example of code showing how to implement a modular exponential operation?
2023-04-12 04:57 AM
Final solution found.
It appears my code was overwriting the exponent with zeros when putting the operand into the PKA RAM. As anything to the power of zero is one, the PKA was producing the right answer for that scenario.
Ensuring the operand did not overrun the exponent means the system is now working as expected.