Class DnieCipherImpl
java.lang.Object
javax.crypto.CipherSpi
es.gob.jmulticard.jse.provider.rsacipher.DnieCipherImpl
RSA cipher implementation. Supports RSA en/decryption and signing/verifying
using PKCS#1 v1.5 padding and without padding (raw RSA). Note that raw RSA
is supported mostly for completeness and should only be used in rare cases.
Objects should be instantiated by calling Cipher.getInstance() using the
following algorithm names:
. "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 padding. The mode (blocktype)
is selected based on the en/decryption mode and public/private key used
. "RSA/ECB/NoPadding" for rsa RSA.
We only do one RSA operation per doFinal() call. If the application passes
more data via calls to update() or doFinal(), we throw an
IllegalBlockSizeException when doFinal() is called (see JCE API spec).
Bulk encryption using RSA does not make sense and is not standardized.
Note: RSA keys should be at least 512 bits long
- Since:
- 1.5
- Author:
- Andreas Sterbenz
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]engineDoFinal(byte[] inData, int inOfs, int inLen) protected intengineDoFinal(byte[] inData, int inOfs, int inLen, byte[] out, int outOfs) protected intprotected byte[]protected intengineGetKeySize(Key key) protected intengineGetOutputSize(int inputLen) protected AlgorithmParametersprotected voidengineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom rnd) protected voidengineInit(int opmode, Key key, SecureRandom rnd) protected voidengineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom rnd) protected voidengineSetMode(String cipherMode) protected voidengineSetPadding(String paddingName) protected KeyengineUnwrap(byte[] wrappedKey, String algorithm, int type) protected byte[]engineUpdate(byte[] inData, int inOfs, int inLen) protected intengineUpdate(byte[] inData, int inOfs, int inLen, byte[] out, int outOfs) protected byte[]engineWrap(Key key) Methods inherited from class CipherSpi
engineDoFinal, engineUpdate, engineUpdateAAD, engineUpdateAAD
-
Constructor Details
-
DnieCipherImpl
public DnieCipherImpl()Construye un cifrador RSA para el DNIe.
-
-
Method Details
-
engineSetMode
- Specified by:
engineSetModein classCipherSpi- Throws:
NoSuchAlgorithmException
-
engineSetPadding
- Specified by:
engineSetPaddingin classCipherSpi- Throws:
NoSuchPaddingException
-
engineGetBlockSize
protected int engineGetBlockSize()- Specified by:
engineGetBlockSizein classCipherSpi
-
engineGetOutputSize
protected int engineGetOutputSize(int inputLen) - Specified by:
engineGetOutputSizein classCipherSpi
-
engineGetIV
protected byte[] engineGetIV()- Specified by:
engineGetIVin classCipherSpi
-
engineGetParameters
- Specified by:
engineGetParametersin classCipherSpi
-
engineInit
- Specified by:
engineInitin classCipherSpi- Throws:
InvalidKeyException
-
engineInit
protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom rnd) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
engineInitin classCipherSpi- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
engineInit
protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom rnd) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
engineInitin classCipherSpi- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
engineUpdate
protected byte[] engineUpdate(byte[] inData, int inOfs, int inLen) - Specified by:
engineUpdatein classCipherSpi
-
engineUpdate
protected int engineUpdate(byte[] inData, int inOfs, int inLen, byte[] out, int outOfs) - Specified by:
engineUpdatein classCipherSpi
-
engineDoFinal
protected byte[] engineDoFinal(byte[] inData, int inOfs, int inLen) throws BadPaddingException, IllegalBlockSizeException - Specified by:
engineDoFinalin classCipherSpi- Throws:
BadPaddingExceptionIllegalBlockSizeException
-
engineDoFinal
protected int engineDoFinal(byte[] inData, int inOfs, int inLen, byte[] out, int outOfs) throws ShortBufferException, BadPaddingException, IllegalBlockSizeException - Specified by:
engineDoFinalin classCipherSpi- Throws:
ShortBufferExceptionBadPaddingExceptionIllegalBlockSizeException
-
engineWrap
- Overrides:
engineWrapin classCipherSpi- Throws:
InvalidKeyExceptionIllegalBlockSizeException
-
engineUnwrap
protected Key engineUnwrap(byte[] wrappedKey, String algorithm, int type) throws InvalidKeyException, NoSuchAlgorithmException - Overrides:
engineUnwrapin classCipherSpi- Throws:
InvalidKeyExceptionNoSuchAlgorithmException
-
engineGetKeySize
- Overrides:
engineGetKeySizein classCipherSpi- Throws:
InvalidKeyException
-