Fix EC public key export for provider keys - #13
anurag6569201 wants to merge 1 commit into
Conversation
Source PR: dotnet#133205 Source head: 5656265
⛔ Shipwright · BlockedRecommendation: do not merge PR #13 · Tier
Findings (3)
Fireworks usage: 10,277 input · 709 output · 10,986 total tokens · $0.0027 · 11s · 0 fix iteration(s) Open the Shipwright check for full evidence and the audit bundle. Use |
| *cbD = 0; | ||
|
|
||
| exit: | ||
| if (exportedParameters) OSSL_PARAM_free(exportedParameters); |
There was a problem hiding this comment.
Shipwright · CRITICAL
The fallback path calls OSSL_PARAM_free(exportedParameters) unconditionally at exit, but exportedParameters is only initialized to NULL at declaration and only assigned by EVP_PKEY
Impact: The fallback path calls OSSL_PARAM_free(exportedParameters) unconditionally at exit, but exportedParameters is only initialized to NULL at declaration and only assigned by EVP_PKEY_todata. If EVP_PKEY_todata succeeds but returns a non-NULL pointer, this is fine; however, if the function is entered via the public_key_exported goto after the EVP_PKEY_get_octet_string_param path, exportedParameters remains NULL and OSS…
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
|
|
||
| pubKeyData = (const uint8_t*)publicKeyValue; | ||
|
|
||
| public_key_exported: |
There was a problem hiding this comment.
Shipwright · HIGH
The control flow uses a goto label public_key_exported that is placed after the fallback block, but the label is inside the function and the fallback block is conditionally compile
Impact: The control flow uses a goto label public_key_exported that is placed after the fallback block, but the label is inside the function and the fallback block is conditionally compiled with FEATURE_DISTRO_AGNOSTIC_SSL. On builds without FEATURE_DISTRO_AGNOSTIC_SSL, the fallback block is absent, but the goto public_key_exported from the first path still compiles because the label is present. This creates a confusing con…
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
Most of the explanation for this change is documented as comments in this pull request. However, before:
After:
The general gist of the change is the the PKCS#11 OpenSSL provider does not "materialize" the public key until you go through an
exportKEYMGMT interface:https://github.com/openssl-projects/pkcs11-provider/blob/c7a5c8b62a0ff012b16574f01651254ef7e664ee/src/kmgmt/common.c#L496-L498
Attempting to directly export the public key before this materialization happens results in an error.
We continue to try out existing way first - this is both performance and works in scenarios where a Provider has not implemented KEYMGMT APIs. If it fails, we attempt with EVP_PKEY_todata, which gives us the public key through a KEYMGMT API. It uses the same OSSL_PARAM
OSSL_PKEY_PARAM_PUB_KEYas we were using before, so we can use the same point handling for the existing and fallback way.Contributes to dotnet#133171
Source merge-base:
75cffcef7186a6a0b738f15a98d0b28c6c8e6507Source head:
56562651f2f82b31d86d2869b922ee2e7b9bc834