Skip to content

Only build mbedtls_rsa_deduce_private_exponent when key generation is enabled #669

@gilles-peskine-arm

Description

@gilles-peskine-arm

Since TF-PSA-Crypto 1.0, there is no way to import an RSA private key without the private exponent. We've already done some cleanup (#576), but the now private function mbedtls_rsa_deduce_private_exponent() is still present in the build and used in tests.

mbedtls_rsa_deduce_private_exponent() needs to remain in the code because it's used during key generation. But we don't need it in builds without RSA key generation.

There is test data in test_suite_rsa.data which has key pairs given only by (N, E, Q, P) without D. We should rewrite this test data to have complete RSA key data, in particular with D. Strictly speaking, the goal of this issue is only to add the private exponent to the data; however we might want to move directly to the standard ASN.1 representation of private keys with all the fields.

Goals of this issue:

  • test_suite_rsa.data doesn't have key pairs given only by (N, E, Q, P).
  • In test_suite_rsa.function, mbedtls_rsa_test_fill_context() doesn't try to fill in for a missing D. (Of course, in public keys, only N and E are present.)
  • mbedtls_rsa_deduce_private_exponent is guarded by MBEDTLS_PSA_BUILTIN_WANT_RSA_KEY_PAIR_GENERATE (or MBEDTLS_GENPRIME, which is the legacy symbol with the same meaning).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestsize-sEstimated task size: small (~2d)

Projects

Status

Incoming

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions