mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
wc_InitRsaKey_Id and wc_InitRsaKey_Label name a key held by a crypto callback device, so the modulus n stays zero in software. Padding read the key size from mp_count_bits(&key->n) and so got 0 bits: - WC_RSA_NO_PAD encrypt returned RSA_PAD_E before the device was called. - WC_RSA_NO_PAD decrypt and verify returned RSA_PAD_E after the device had done the operation. - PSS with a 1024-bit key and SHA-512 picked the wrong default salt length, so signing and wc_RsaPSS_VerifyCheck returned PSS_SALTLEN_E. Add RsaModulusBits, which falls back to wc_RsaEncryptSize when n is not set. That already asks the device with WC_PK_TYPE_RSA_GET_SIZE, and covers other keys held in hardware the same way. Use it wherever padding, unpadding and the PSS salt length need the key size. test_wc_RsaId_CryptoCb runs these operations with a key from wc_InitRsaKey_Id against a device that holds the software key. The PSS half needs only PSS, SHA-512 and the 1024-bit client key, read from certs/1024 or taken from certs_test.h with USE_CERT_BUFFERS_1024, so it also runs in builds without WC_RSA_NO_PADDING, such as the cryptocb-only CI legs. The device does the raw operation in software, so the test needs software RSA, or swdev in a build with WOLF_CRYPTO_CB_ONLY_RSA.