Class SimulatorOpenPGPSmartCard
Test and development use only. Unlike a real card this offers no isolation whatsoever: the
uploaded secret keys are held in the heap of the calling process
and getSoftwareKey(OpenPGPCertificate.OpenPGPComponentKey, KeyPassphraseProvider) hands the private key straight back. It exists so that the smart-card API
can be exercised without hardware; never use it as a substitute for a token in production.
-
Field Summary
Fields inherited from class OpenPGPSmartCard
keys -
Constructor Summary
ConstructorsConstructorDescriptionSimulatorOpenPGPSmartCard(SimulatorSmartCardBackend backend, Integer serialNumber) -
Method Summary
Modifier and TypeMethodDescriptionstatic SimulatorOpenPGPSmartCardcreateSimulatedCardFrom(SimulatorSmartCardBackend backend, Integer serialNumber, org.bouncycastle.openpgp.api.OpenPGPKey softwareKey) static SimulatorOpenPGPSmartCardcreateSimulatedCardFrom(SimulatorSmartCardBackend backend, org.bouncycastle.openpgp.api.OpenPGPKey softwareKey) Return aStringrepresenting the card type.Return the serial number of this smart card.org.bouncycastle.openpgp.PGPPrivateKeygetSoftwareKey(org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey key, org.bouncycastle.openpgp.api.KeyPassphraseProvider passphraseProvider) Return the version number of this smart card.booleanisKeySupported(byte keyRef, org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey key) Return true, if the smart card supports the givenOpenPGPCertificate.OpenPGPComponentKey.org.bouncycastle.openpgp.PGPPublicKeyreconstructPGPPublicKey(byte keyRef) Return thePGPPublicKeycomponent of the key in the slot identified by keyRef.reset()Reset the smart card, clearing all key slots and resetting the admin PIN, user PIN to their defaults.uploadKey(byte keyRef, org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey key, char[] adminPin) Upload the givenOpenPGPKey.OpenPGPPrivateKeyto the given keyRef slot on the card.Methods inherited from class OpenPGPSmartCard
getAuthenticationKey, getBackend, getDecryptionKey, getKeyByFingerprint, getKeyByKeyRef, getKeys, getSignatureKey, hasAuthenticationKey, hasDecryptionKey, hasKey, hasKeyWithFingerprint, hasSignatureKey, putKey, toString, uploadAuthenticationKey, uploadDecryptionKey, uploadSigningKey
-
Constructor Details
-
SimulatorOpenPGPSmartCard
-
-
Method Details
-
createSimulatedCardFrom
public static SimulatorOpenPGPSmartCard createSimulatedCardFrom(SimulatorSmartCardBackend backend, org.bouncycastle.openpgp.api.OpenPGPKey softwareKey) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
createSimulatedCardFrom
public static SimulatorOpenPGPSmartCard createSimulatedCardFrom(SimulatorSmartCardBackend backend, Integer serialNumber, org.bouncycastle.openpgp.api.OpenPGPKey softwareKey) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
getSerialNumber
Description copied from class:OpenPGPSmartCardReturn the serial number of this smart card.- Specified by:
getSerialNumberin classOpenPGPSmartCard- Returns:
- serial number
-
getVersion
Description copied from class:OpenPGPSmartCardReturn the version number of this smart card.- Specified by:
getVersionin classOpenPGPSmartCard- Returns:
- version number
-
isKeySupported
public boolean isKeySupported(byte keyRef, org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey key) Description copied from class:OpenPGPSmartCardReturn true, if the smart card supports the givenOpenPGPCertificate.OpenPGPComponentKey.- Specified by:
isKeySupportedin classOpenPGPSmartCard- Parameters:
keyRef- key referencekey- OpenPGP key- Returns:
- true if the card supports the key
-
reset
Description copied from class:OpenPGPSmartCardReset the smart card, clearing all key slots and resetting the admin PIN, user PIN to their defaults.- Specified by:
resetin classOpenPGPSmartCard- Returns:
- this
-
uploadKey
public SimulatorOpenPGPSmartCard uploadKey(byte keyRef, org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey key, char[] adminPin) Upload the givenOpenPGPKey.OpenPGPPrivateKeyto the given keyRef slot on the card.The simulator enforces no admin PIN, so
adminPinis ignored.- Specified by:
uploadKeyin classOpenPGPSmartCard- Parameters:
keyRef- keyRefkey- OpenPGP private keyadminPin- admin pin of the card- Returns:
- card
-
reconstructPGPPublicKey
public org.bouncycastle.openpgp.PGPPublicKey reconstructPGPPublicKey(byte keyRef) Return thePGPPublicKeycomponent of the key in the slot identified by keyRef.Note: The key might be reconstructed on the fly. In this case,
Public key algorithmand version number might be brute-forced by comparing the resultingkeysfingerprint to the contents of the cardsOpenPGPHardwareKey.getFingerprint()field.Returns null if the given slot is empty, matching the hardware implementations.
- Specified by:
reconstructPGPPublicKeyin classOpenPGPSmartCard- Parameters:
keyRef- key reference- Returns:
- PGPPublicKey representation
-
getSoftwareKey
public org.bouncycastle.openpgp.PGPPrivateKey getSoftwareKey(org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey key, org.bouncycastle.openpgp.api.KeyPassphraseProvider passphraseProvider) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
getCardType
Description copied from class:OpenPGPSmartCardReturn aStringrepresenting the card type. This is an informative description of the device.- Specified by:
getCardTypein classOpenPGPSmartCard- Returns:
- card type
-