You can calculate these coefficients directly by a call to Cy_Crypto_Rsa_CalcCoefs and print it after calculation. You can then store these values in flash by declaring them as const.
Important note: if you use RSA process function once you don’t need to calculate these coefficients before.
Please look into the key data structure for allocation details:
* All fields for the context structure are internal. Firmware never reads or
* writes these values. Firmware allocates the structure and provides the
* address of the structure to the driver in the function calls. Firmware must
* ensure that the defined instance of this structure remains in scope
* while the drive is in use.
* The driver uses this structure to store and manipulate the RSA public key and
* additional coefficients to accelerate RSA calculation.
* RSA key contained from two fields:
* - n - modulus part of the key
* - e - exponent part of the key.
* Other fields are accelerating coefficients and can be calculated by
* \ref Cy_Crypto_Rsa_CalcCoefs.
* \note The <b>modulus</b> and <b>exponent</b> values in the
* \ref cy_stc_crypto_rsa_pub_key_t must also be in little-endian order.<br>
* Use \ref Cy_Crypto_InvertEndianness function to convert to or from
* little-endian order.
/** \cond INTERNAL */
/** The pointer to the modulus part of public key. */
/** The modulus length, in bits, maximum supported size is 2048Bit */
/** The pointer to the exponent part of public key */
/** The exponent length, in bits, maximum supported size is 256Bit */
/** The pointer to the Barrett coefficient. Memory for it should be
allocated by user with size moduloLength + 1. */
/** The pointer to the binary inverse of the modulo. Memory for it
should be allocated by user with size moduloLength. */
/** The pointer to the (2^moduloLength mod modulo). Memory for it should
be allocated by user with size moduloLength */
/** \endcond */
Thanks for the answer, Dheeraj. However, it's exactly because I don't want to do this process that I'm asking how to compute those arrays outside of the firmware.
Is the computation process proprietary?
While your linked example is useful for a how-to generate rsa key pairs, it does not talk about barretCoefPtr, rBarPtr, or inverseModuloPtr.
I just found out that Cypress provides a tool to generate all those tables into a C file. That's exactly what I needed.
"C:\Program Files (x86)\Cypress\PDL\version\security\secure_image\src\scripts\rsa_to_c.py"