Skip to content

Conversation

@sebastian-carpenter
Copy link
Contributor

@sebastian-carpenter sebastian-carpenter commented Nov 21, 2025

This mainly contains testing for encoding / decoding RSA and RSASSA-PSS keys to / from pki.

Found some bugs and fixed them:

  • RSASSA-PSS key params are not encoded to DER when using pki encoding. Copied some code from the spki encoding section for a fix (altered it slightly for different offsets).
  • WolfProvider returns digest names that do not match those of OSSL. Made a mapping function based on a wolfcrypt enum.

Addendum:

  • When doing the encoding test the created der was then decoded with ossl and wp. Changed test_rsa_decode_pkcs8_evp_pkey to allow decoding ctx to be specified. Now decoding can be done with ossl and wp, or just ossl.

Copy link
Contributor

@SparkiDev SparkiDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does wp_rsa_import have a parameter with a string that is the wrong name form?
We have places we set mdName to something explicitly and they can be changed but the import should be the same as

test/test_rsa.c Outdated
static int test_rsa_encode_pkcs8_evp_pkey(const unsigned char *p, long len)
{
int err = 0;
PKCS8_PRIV_KEY_INFO* p8inf1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialise these four pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now initialized to NULL

case WC_HASH_TYPE_SHA3_384:
case WC_HASH_TYPE_SHA3_512:
case WC_HASH_TYPE_BLAKE2B:
case WC_HASH_TYPE_BLAKE2S:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing SHA512-224 and SHA512-256

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added both types and several others. Wrapped new additions in ifdef's

{
int ok = 1;
OSSL_PARAM* p;
const char *ossl_digest;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialise to NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initalized to NULL and changed name to osslDigest

@sebastian-carpenter
Copy link
Contributor Author

Why does wp_rsa_import have a parameter with a string that is the wrong name form? We have places we set mdName to something explicitly and they can be changed but the import should be the same as

comment seems cut off so I took my best guess. I didn't do anything to wp_rsa_import so I'm thinking this is meant to refer to wp_digest_to_ossl_digest. Previously the parameter was ossl_digest so I changed it to osslDigest in the rebase.

As for why this functions exists: When you get parameters from wolfProvider the md and mgf should match what OpenSSL uses for their digest names. I didn't edit what the md and mgf were set to in wolfProvider since it seems like that could cause issues in wolfCrypt (though I'm not certain).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants