Mbed-TLS / mbedtls

An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API. Releases are on a varying cadence, typically around 3 - 6 months between releases.
https://www.trustedfirmware.org/projects/mbed-tls/
Other
5.23k stars 2.56k forks source link

Using private key (n,d) make signature, but get failure when use public key(n,e) make verify #6258

Open 840180795github opened 2 years ago

840180795github commented 2 years ago

Summary

 I using private key (n,d) make signature on other third rsa algorithm lib, but get failure when use public key(n,e) make verify under mbedtls lib . But I success make signature and verify using "mbedtls_rsa_rsassa_pkcs1_v15_sign" and "mbedtls_rsa_pkcs1_verify" .  Also  achieve success signature and verify on other third rsa algorithm lib.
  I confirm that the difference only exist  private key format between  the third rsa algorithm lib and mbedtls lib.
  Configure pkcs1_v15 and sha256 on both lib.

System information

Mbed TLS version (number or commit id): mbedtls-2.14.1 Operating system and version: Win10 Configuration (if not default, please attach mbedtls_config.h): Use default configuration Compiler and options (if you used a pre-built binary, please indicate how you obtained it): VS2012 express Additional environment information:

Expected behavior

I using private key (n,d) make signature on other third rsa algorithm lib, and get success when use public key(n,e) make verify under mbedtls lib .

Actual behavior

I using private key (n,d) make signature on other third rsa algorithm lib, but get failure when use public key(n,e) make verify under mbedtls lib .

Steps to reproduce

Using python cryptography do signature with private key (n,d)

Additional information

davidhorstmann-arm commented 2 years ago

Can you please give a summary of the Python code you're using to generate the signature and the C code you're using to verify it so that we can try to reproduce?