|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.pkcs.pkcs7.RSACipherProvider
A RSA cipher provider that may be used by an application to control RSA cipher operations used by SignerInfos and RecipientInfos.
The RSACipherProvider allows an application to control the RSA cipher
encryption/decryption operations during signature creation/verification for
SignerInfo
objects and the RSA cipher encryption/decryption
(content encryption key encryption/decryption) operations for
SignerInfo
objects.
To, for instance, use the IAIK PKCS#11 provider for RSA cipher private key based encryption during SignerInfo signature creation only, but the first installed provider for RSA cipher public key based decryption during signature verification you may set the PKCS#11 provider as RSA encryption provider for your SignerInfo object:
IAIKPkcs11 pkcs11Provider = new IAIKPkcs11(); Security.addProvider(pkcs11Provider); ... RSACipherProvider rsaProv = new RSACipherProvider(pkcs11Provider.getName(), null); ... SignerInfo signerInfo = ...; ... signerInfo.setRSACipherProvider(rsaProv, null);To, for instance, use the IAIK PKCS#11 provider for ReceipientInfo decryption (RSA cipher private key decryption) only, but the first installed provider for encryption (RSA cipher public encryption) you may set the PKCS#11 provider as RSA decryption provider for your RecipientInfo object:
IAIKPkcs11 pkcs11Provider = new IAIKPkcs11(); Security.addProvider(pkcs11Provider); ... RSACipherProvider rsaProv = new RSACipherProvider(null, pkcs11Provider.getName()); ... ReceipientInfo signerInfo = ...; ... recipientInfo.setRSACipherProvider(rsaProv, null);In overriding method
cipher
you even
can take more influence on the ciphering process.
The default RSACipherProvider uses the first installed RSA capable crypto provider for RSA en/deciphering.
Field Summary | |
protected String |
cipherDecryptProvider_
Name of the crypto provider to be used for RSA decryption. |
protected String |
cipherEncryptProvider_
Name of the crypto provider to be used for RSA encryption. |
static int |
DECRYPT_MODE
Cipher decrypt mode. |
static int |
ENCRYPT_MODE
Cipher encrypt mode. |
Constructor Summary | |
RSACipherProvider()
Default constructor. |
|
RSACipherProvider(String cipherEncryptProvider,
String cipherDecryptProvider)
Creates a new RSACipherProvider for the given RSA cipher en/decryption providers. |
Method Summary | |
protected byte[] |
cipher(int mode,
Key key,
byte[] data)
Performs an RSA cipher operation on the supplied data. |
void |
setCipherProvider(int cipherMode,
String providerName)
Sets the crypto provider to be used for RSA cipher en/decryption providers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ENCRYPT_MODE
public static final int DECRYPT_MODE
protected String cipherEncryptProvider_
protected String cipherDecryptProvider_
Constructor Detail |
public RSACipherProvider()
public RSACipherProvider(String cipherEncryptProvider, String cipherDecryptProvider)
cipherEncryptProvider
- the name of the crypto provider to be used for RSA encryptioncipherDecryptProvider
- the name of the crypto provider to be used for RSA encryptionMethod Detail |
public void setCipherProvider(int cipherMode, String providerName) throws IllegalArgumentException
cipherMode
- the mode -- ENCRYPT (1) or DECRYPT (2) -- for which to use the given crypto providerproviderName
- the name of the crypto provider to be used for RSA cipher operations according
to the requested modeIllegalArgumentException
- if the supplied mode is invalid (only ENCRYPT (1) or DECRYPT (2)
are allowedprotected byte[] cipher(int mode, Key key, byte[] data) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, GeneralSecurityException
mode
- the cipher mode, either ENCRYPT (1) or DECRYPT (2)key
- the key to be useddata
- the data to be en/deciphered:
NoSuchProviderException
- if any of the crypto providers of this RSACipherProvider is not suitable
for requested operationNoSuchAlgorithmException
- if RSA ciphering is not supportedInvalidKeyException
- if the supplied key is invalidGeneralSecurityException
- if a general security problem occurs
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |