Support custom signing routines in SignaturePrivateKey#424
Conversation
This enables support for signing with non-extractable private keys (e.g. TPM-bound).
|
Hi @rcombs, thanks for submitting this. Just to confirm I understand the architecture correctly:
I would prefer to handle this a little more systematically, in the sense of not having an alternative path for functions like this as opposed to other keys. For example, we could have signing always be a function, and supply a default function when constructing a key from bytes. In line with #425, it would also be good to push most of the complexity here into the Given those considerations, how about an approach something like the following:
From the caller's perspective, you would just from The main drawback that occurs to me is that we end up exposing what are currently some internal interfaces. But we're going to have to expose that sort of thing anyway if we're going to allow this sort of runtime adaptation. |
|
Your understanding is correct, yes. I considered having all keys use a I went with this route largely to try to keep the API change as small as possible (this doesn't introduce any API incompatibility with existing code). The API-wise, I think the change proposed here should be compatible with any future architecture change moving more of the implementation down into the |
|
Picking this back up -- This looks fine to me for what it does. It needs tests, and I would prefer that serialization failed instead of succeeded with invalid data. But I'll add that in a follow-on. |
|
Follow-on is #462 |
PR #424 added std::function usage but missed the include directive. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix time-sensitive certificate test The "Test Certificate notBefore status" test had a certificate with notBefore = 2026-03-08, which is now in the past, causing the test to fail. Replace with a certificate that has notBefore = 2099-01-01 to ensure the test remains valid for decades. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add missing #include <functional> to crypto.h PR #424 added std::function usage but missed the include directive. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix PQ cipher suite preprocessor guard typo The switch case for MLKEM cipher suites used #if !defined(P256_SHA256) which is always true. This should be #if defined(WITH_PQ) to match the cipher definitions above. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix interop code to use all_supported_cipher_suites The array was renamed from all_supported_suites to all_supported_cipher_suites but the interop code wasn't updated. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This enables support for signing with non-extractable private keys (e.g. TPM-bound).