RSA example fails on psa_sign_hash returning -133

I have one problem report and some related questions:

Problem report:

When executing the RSA sampe provided with SDK 2.1.0 on the nRD5340DK board the psa_sign_hash function fails with -133 (PSA_ERROR_NOT_PERMITTED). 

The explanation PSA_ERROR_NOT_PERMITTED informs me that a policy is preventing the operation. But as I am using a unmodified sample code. I cannot see which policy change I should have caused. Can you help finding the cause of this behavior?

Questions:

1) I have a requirement to implement RSA OAEP(SHA1) public key encryption using 3072 bit keys. The CryptoCell on the nRF5340 has a upper limit of 2048 bit keys. The question is, how can I implement the required encryption operation? Is using mbed_tsl directly an option or is the 2048 bit key limit also imposed on this API?

2) When attempting to do RSA OAEP(SHA1) using a supposedly supported 2048 bit key, this fails with return code -147 (PSA_ERROR_HARDWARE_FAILURE). There are no sample code performing RSA public key encryption using the CryptoCell, is this operation not supported?

Parents
  • Hi,

    Can you share the lines of code (or sample) you use to do RSA OAEP?
    (Use Insert->Code to insert code)

    1) I have a requirement to implement RSA OAEP(SHA1) public key encryption using 3072 bit keys. The CryptoCell on the nRF5340 has a upper limit of 2048 bit keys. The question is, how can I implement the required encryption operation? Is using mbed_tsl directly an option or is the 2048 bit key limit also imposed on this API?

    For a quick look, I were not able to figure out what the Mbed TLS key limit would be.
    From our Driver configurations and supported features:
    "If a specific cryptographic feature is not supported by a PSA driver but the algorithm is configured to be used, then Built-in Mbed TLS will be enabled to ensure the feature is available."

    So you can use Mbed TLS for this from the PSA API.
    Using the Mbed TLS API directly is also an option, but I recommend trying the PSA API first.
    Can you try to use Mbed TLS to do the same operation, and see if it works that way?

    2) When attempting to do RSA OAEP(SHA1) using a supposedly supported 2048 bit key, this fails with return code -147 (PSA_ERROR_HARDWARE_FAILURE). There are no sample code performing RSA public key encryption using the CryptoCell, is this operation not supported?

    Which function returns this error?

    Do you get the same error for 1024?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd

    We want to use the CryptoCell, so our requirement has been lowered to the supported 2048 bit keys.

    I have used the code sample from the nRFSDK 2.1.0 called RSA that performs RSA signature and signature verification.

    As described this sample fails at my end, when using the nRF5340DK board with error -133.

    I have attached the sample including my enhancements to perform RSA encryption.

    Per default, encryption is tested. Signature can be tested by uncommenting the line:

    #define TEST_RSA_ENCRYPTION (1)
    The test shows:
    1) RSA signature/verification fails with -133.
    2) RSA key generation using keys above 1024 bits hangs the program.
    3) RSA encryption using key size 1024 fails with -133.

    We need to perform a 2048 bit RSA OEAP operation, which should be supported according to the documentation / nRF5340 datasheet. 

    I appreciate your effort, hope you are able to help solving this issue.

    Regards Tonny

    rsa_encrypt_or_sign_test.zip

  • To start, I will test our rsa sample.

    I only changed the size from 1024 to 2048, and i t seems that it is psa_export_public_key fails with -147.
    If I remove psa_export_public_key and the anything which use the public key, the sample runs without error.

    I have looked a bit at why the encryption is NOT_PERMITTED, but have not found out why this is.

    I will look some more into this and return with more information on Monday.

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd

    If you remove the psa_export_public_key, and related then you are not doing public key encryption using a public (only) key. 

    The method psa_asymmetric_encrypt is intended to use a public key without the private part.

    This is the purpose of asymmetric cryptographyso this approach will not work.

Reply Children
No Data
Related