Class YubikeySmartCardBackend
java.lang.Object
org.bouncycastle.openpgp.smartcard.OpenPGPSmartCardBackend<YubikeyOpenPGPSmartCard>
org.bouncycastle.openpgp.smartcard.yubikey.YubikeySmartCardBackend
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface -
Field Summary
Fields inherited from class OpenPGPSmartCardBackend
SHORTENED_IDENTIFIER_LENGTH, STORED_FINGERPRINT_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionYubikeySmartCardBackend(com.yubico.yubikit.desktop.YubiKitManager yubiKitManager, org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter keyConverter, org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator fingerprintCalculator, YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) -
Method Summary
Modifier and TypeMethodDescriptionaddAllowedCardSerial(Integer number) Nominate a device serial number this backend is permitted to open.bcImpl()org.bouncycastle.openpgp.PGPPublicKeyconvertPublicKey(com.yubico.yubikit.core.keys.PublicKeyValues pkVal, byte[] storedFingerprint, Date creationTime) Convert the key fromPublicKeyValuesinto a barePGPPublicKey, brute-forcing the algorithm id.static YubikeySmartCardBackendstatic YubikeySmartCardBackendcreateInstance(com.yubico.yubikit.desktop.YubiKitManager yubiKitManager, org.bouncycastle.jce.provider.BouncyCastleProvider provider, YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) static YubikeySmartCardBackendcreateInstance(com.yubico.yubikit.desktop.YubiKitManager yubiKitManager, YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) static YubikeySmartCardBackendcreateInstance(YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) getName()Return the name of the backend.jceImpl()JCE-backed decryptor factory provider drawing its cryptographic primitives from the given JCA provider.Return the connected YubiKey devices whose serial number has been allow-listed withaddAllowedCardSerial(Integer).org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactoryprovidePublicKeyDataDecryptorFactory(org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey secretKey, YubikeyOpenPGPSmartCard card, org.bouncycastle.openpgp.api.KeyPassphraseProvider userPinProvider)
-
Constructor Details
-
YubikeySmartCardBackend
public YubikeySmartCardBackend(com.yubico.yubikit.desktop.YubiKitManager yubiKitManager, org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter keyConverter, org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator fingerprintCalculator, YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider)
-
-
Method Details
-
createInstance
-
createInstance
public static YubikeySmartCardBackend createInstance(YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) -
createInstance
public static YubikeySmartCardBackend createInstance(com.yubico.yubikit.desktop.YubiKitManager yubiKitManager, YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) -
createInstance
public static YubikeySmartCardBackend createInstance(com.yubico.yubikit.desktop.YubiKitManager yubiKitManager, org.bouncycastle.jce.provider.BouncyCastleProvider provider, YubikeySmartCardBackend.YubikeyDecryptorFactoryProvider decryptorFactoryProvider) -
getName
Description copied from class:OpenPGPSmartCardBackendReturn the name of the backend.- Specified by:
getNamein classOpenPGPSmartCardBackend<YubikeyOpenPGPSmartCard>- Returns:
- backend name
-
listSmartCards
Return the connected YubiKey devices whose serial number has been allow-listed withaddAllowedCardSerial(Integer). Devices that have not been allow-listed are never opened, so no APDU is exchanged with a device the caller did not nominate; a backend with an empty allow-list therefore always returns an empty list.- Specified by:
listSmartCardsin classOpenPGPSmartCardBackend<YubikeyOpenPGPSmartCard>- Returns:
- allow-listed smart cards
- Throws:
CardException- if the device layer cannot be queried, or a nominated device cannot be read
-
providePublicKeyDataDecryptorFactory
public org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory providePublicKeyDataDecryptorFactory(org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey secretKey, YubikeyOpenPGPSmartCard card, org.bouncycastle.openpgp.api.KeyPassphraseProvider userPinProvider) throws org.bouncycastle.openpgp.PGPException - Specified by:
providePublicKeyDataDecryptorFactoryin classOpenPGPSmartCardBackend<YubikeyOpenPGPSmartCard>- Throws:
org.bouncycastle.openpgp.PGPException
-
addAllowedCardSerial
Nominate a device serial number this backend is permitted to open. Nothing is enumerated until at least one serial has been added - seelistSmartCards().- Parameters:
number- device serial number- Returns:
- this
-
convertPublicKey
public org.bouncycastle.openpgp.PGPPublicKey convertPublicKey(com.yubico.yubikit.core.keys.PublicKeyValues pkVal, byte[] storedFingerprint, Date creationTime) throws org.bouncycastle.openpgp.PGPException, NoSuchAlgorithmException, InvalidKeySpecException Convert the key fromPublicKeyValuesinto a barePGPPublicKey, brute-forcing the algorithm id. Brute-forcing is done by comparing the fingerprint of the reconstructed PGP key to the fingerprint stored on the key.- Parameters:
pkVal- Yubikey PublicKeyValuesstoredFingerprint- fingerprint as it is stored on the Yubikey devicecreationTime- creation time as it is stored on the Yubikey device- Returns:
- converted PGP public key
- Throws:
org.bouncycastle.openpgp.PGPException- if the key cannot be reconstructedNoSuchAlgorithmException- if no Provider supports an implementation for the PublicKeyValues algorithmInvalidKeySpecException- if the PublicKeyValues specification is inappropriate to produce a public key
-
bcImpl
-
jceImpl
-
jceImpl
JCE-backed decryptor factory provider drawing its cryptographic primitives from the given JCA provider.- Parameters:
provider- provider object for cryptographic primitives.- Returns:
- decryptor factory provider.
-