PGSC: Add JCE implementation for OpenPGP Smart Card message decryption - #2374
PGSC: Add JCE implementation for OpenPGP Smart Card message decryption#2374vanitasvitae wants to merge 1 commit into
Conversation
|
Hi @vanitasvitae, Before going further, would you mind resyncing the branch onto current main and continuing from there? The earlier state of this PR is already merged, with a review pass on top, so working from current main means you can see what we've changed, and your own commits won't be masked by the ~4000 commits of drift. It also makes anything you need from our side easy to pick up. Worth rebasing rather than merging: a few of the files you touched were adjusted in that review pass, so a rebase will surface those as conflicts you can resolve deliberately, where a merge would quietly take the older versions. One heads-up for when you do, there are some debug leftovers still on the branch: Thank you. |
1fe1ba8 to
44d1110
Compare
|
Hey! I rebased the PR and added some more tests and further progress. I like the changes you applied! |
|
Merged with some revisions - I moved the external public key code under a new package org.bouncycastle.openpgp.api.operator. have a feeling it may serve us well to preserve the bcpg->openpgp->openpgp.api pattern. One thing, with debug, you can now just use: ./gradlew -Prelease.debug=true clean build to do a debug build without having to change the build.gradle file. The new API is now available at https://www.bouncycastle.org/betas as well |
…he release.debug compile switch, single-source the PKESK parsing checks in AbstractPublicKeyDataDecryptorFactory for all the public-key data decryptor factories, carry the external-key session recovery flow in a stack-neutral base class in the new org.bouncycastle.openpgp.api.operator package with the lightweight and JCE external factories in its bc and jcajce subpackages, route the JCE factory's KDF, key unwrap and data decryptors through the configured provider, validate the curve and convert the ephemeral key before fetching the card PIN in the Yubikey callbacks, allow a provider to be passed to the JCE Yubikey decryptor factory provider, and cover the JCE external factory with a software-callback round-trip and malformed-packet regression test, relates to github #2374.
This PR is based on and includes #2339
Inhere, I modified BCs API to allow for message decryption with external secret keys.
On top of that, I introduced
AbstractPublicKeyDataDecryptorFactory.getCryptoCallback()and reworked theBcPublicKeyDataDecryptorFactoryto cleanly separate out PK crypto operations during session-key recovery, for sake of simple delegation to hardware devices in subclasses.Furthermode, the new module
pgscnow contains the initial design of a smart card API for bcpg. It currently supports listing cards, uploading key material and decrypting messages using both a simulated smart card backend, as well as an implementation using the YubiKit library.TODO:
JcaPublicKeyDataDecryptorFactoryJcaExternalPublicKeyDataDecryptorFactoryYubikeyPublicKeyDataDecryptorFactoryto implement both a BC and JCA version.