Skip to content

TLS handshake fails for 4096 bit CA on ESP32s3 #6108

@PaulMartinsen

Description

@PaulMartinsen

Version

5.5.4

Description

wolfSSL_connect fails connecting to a server that supplies a certificate signed by a certificate authority that use a 4096 bit RSA key when running on ESP32s3 hardware (no hardware acceleration). The same connection completes successfully when running on:

  • Windows 11 x64,
  • ESP32 using a certificate signed by a certificate authority that uses a 2048 bit key.

The failure occurs when ParseCertRelative in asn.c calls ConfirmSignature, which returns ASN_SIG_CONFIRM_E along the following path:

  1. ConfirmSignature
  2. wc_RsaSSL_VerifyInline
  3. RsaPrivateDecryptEx
  4. wc_RsaFunction_ex
  5. wc_RsaFunctionSync
  6. wc_RsaFunctionSync (line 2797 in case RSA_PUBLIC_DECRYPT, RSA_PUBLIC_ENCRYPT) when it calls mp_exptmod_nct.

wc_RsaFunctionSync returns MP_EXPTMOD_E when mp_exptmod_nct fails, which gets translated into ASN_SIG_CONFIRM_E further up the call-stack.

mp_exptmod_nct returns MP_VAL when it fails the test with m->used = 128 and r->size = 193:

int sp_exptmod_nct(const sp_int* b, const sp_int* e, const sp_int* m, sp_int* r)
{
    // ....
    else if (m->used * 2 >= r->size) {
        err = MP_VAL;
    // ....
   return err;
}

When running on Windows with the same trust chain, m->used = 128 and r->size = 257 (so it doesn't fail).

I attached my user_settings.zip configuration file. Notably, I'm not using hardware acceleration for this test.

Is there some configuration I need to enable to support 4096 bit keys on embedded devices, or is this a bug or a known library limitation?

@gojimmypi

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions