public class Pkcs11Decrypter extends Decrypter
Decrypter class implementing a workaround for the problem that when using the
SunPKCS11 crypto provider OAEPPadding does not work.
See this post on Stack overflow.
| Constructor and Description |
|---|
Pkcs11Decrypter(DecryptionParameters params)
Constructor.
|
Pkcs11Decrypter(KeyInfoCredentialResolver newResolver,
KeyInfoCredentialResolver newKEKResolver,
EncryptedKeyResolver newEncKeyResolver)
Constructor.
|
Pkcs11Decrypter(KeyInfoCredentialResolver newResolver,
KeyInfoCredentialResolver newKEKResolver,
EncryptedKeyResolver newEncKeyResolver,
Collection<String> whitelistAlgos,
Collection<String> blacklistAlgos)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Key |
decryptKey(EncryptedKey encryptedKey,
String algorithm)
Extends
Decrypter.decryptKey(EncryptedKey, String) so that we may get hold of the corresponding RSA
certificate. |
Key |
decryptKey(EncryptedKey encryptedKey,
String algorithm,
Key kek)
Extends
Decrypter.decryptKey(EncryptedKey, String, Key) with an implementation for missing OAEP padding in
the SunPKCS11 provider. |
protected Key |
decryptKey(EncryptedKey encryptedKey,
String algorithm,
Key kek,
int keysize)
Decrypts the key (work-around for OAEP padding).
|
void |
setTestMode(boolean testMode)
Should we run this class in test mode? By using test mode, the customized code where we handle padding for OAEP is
executed even if the SunPKCS11 provider is not in use.
|
decrypt, decrypt, decrypt, decryptbuildParserPool, checkAndMarshall, decryptData, decryptData, decryptDataToDOM, decryptDataToDOM, decryptDataToList, decryptDataToList, getJCAProviderName, getKEKResolverCriteria, getKeyResolverCriteria, isRootInNewDocument, preProcessEncryptedKey, setJCAProviderName, setKEKResolverCriteria, setKeyResolverCriteria, setRootInNewDocument, validateAlgorithms, validateAlgorithms, validateAlgorithmURIpublic Pkcs11Decrypter(DecryptionParameters params)
params - decryption parameters to usepublic Pkcs11Decrypter(KeyInfoCredentialResolver newResolver, KeyInfoCredentialResolver newKEKResolver, EncryptedKeyResolver newEncKeyResolver)
newResolver - resolver for data encryption keys.newKEKResolver - resolver for key encryption keys.newEncKeyResolver - resolver for EncryptedKey elementspublic Pkcs11Decrypter(KeyInfoCredentialResolver newResolver, KeyInfoCredentialResolver newKEKResolver, EncryptedKeyResolver newEncKeyResolver, Collection<String> whitelistAlgos, Collection<String> blacklistAlgos)
newResolver - resolver for data encryption keys.newKEKResolver - resolver for key encryption keys.newEncKeyResolver - resolver for EncryptedKey elementswhitelistAlgos - collection of whitelisted algorithm URIsblacklistAlgos - collection of blacklisted algorithm URIs@Nonnull public Key decryptKey(@Nonnull EncryptedKey encryptedKey, @Nonnull String algorithm, @Nonnull Key kek) throws DecryptionException
Decrypter.decryptKey(EncryptedKey, String, Key) with an implementation for missing OAEP padding in
the SunPKCS11 provider.decryptKey in class DecrypterDecryptionException@Nonnull public Key decryptKey(@Nonnull EncryptedKey encryptedKey, @Nonnull String algorithm) throws DecryptionException
Decrypter.decryptKey(EncryptedKey, String) so that we may get hold of the corresponding RSA
certificate. We need that since we need to figure out the key length of the RSA private key (and we can't ask a
SunPKCS11 private key for its key length).decryptKey in class DecrypterDecryptionException@Nonnull protected Key decryptKey(@Nonnull EncryptedKey encryptedKey, @Nonnull String algorithm, @Nonnull Key kek, int keysize) throws DecryptionException
encryptedKey - encrypted key element containing the encrypted key to be decryptedalgorithm - the algorithm associated with the decrypted keykek - the key encryption key with which to attempt decryption of the encrypted keykeysize - the key lengthDecryptionException - for decryption errorspublic void setTestMode(boolean testMode)
testMode - test mode flagCopyright © 2020 Sweden Connect. All rights reserved.