public class EciesCipher extends PKCS11Cipher
Modifier and Type | Field and Description |
---|---|
protected int |
blockSize_ |
protected java.io.ByteArrayOutputStream |
buffer_
The buffer to collect all input, because RSA encryption/decryption mechanisms only support
single-part operations.
|
protected static java.lang.String |
CIPHER_NAME
The JCE name of this cipher.
|
protected static iaik.pkcs.pkcs11.Mechanism |
DEFAULT_MECHANISM
The defualt mechanism for this cipher.
|
protected static java.lang.String |
DEFAULT_MODE
The defualt mode of operation for this cipher.
|
protected static java.lang.String |
DEFAULT_PADDING
The defualt padding scheme for this cipher.
|
protected static int |
PKCS11_OPERATION_ENCRYPT_DECRYPT
Indicates that this cipher should use the normal PKCS#11 encryption and decryption.
|
protected static int |
PKCS11_OPERATION_SIGN_VERIFY
Indicates that this cipher should use the PKCS#11 sign opertion for private key encryption.
|
protected int |
pkcs11Operation_
The currently active PKCS11 operation sign/verify or encrypt/decrypt.
|
protected static java.lang.String |
PKCS5_PADDING |
currentKeyIsSoftwareKey_, DUMMY_DATA, initialized_, key_, keyObject_, mechanism_, mode_, modeChanged_, operationMode_, padding_, paddingChanged_, parameters_, parameterSpecs_, pkcs11OperationInitialized_, session_, softwareDelegate_, tokenManager_, unwrapTemplate_, updateUsed_, usedMechanismInfos_, usedMechanisms_
Constructor and Description |
---|
EciesCipher()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkKeyObject(iaik.pkcs.pkcs11.objects.Key keyObject)
Check the given key object, if it is acceptable for this cipher.
|
protected int |
engineGetKeySize(java.security.Key key)
If initialized with a PKCS#11 key, this method returns -1 by default.
|
protected java.lang.String |
getAlgorithmName()
Get the JCE name of this cipher algorithm.
|
protected iaik.pkcs.pkcs11.Mechanism |
getDefaultMechanism()
Get the default mechanism of this cipher.
|
protected java.lang.String |
getDefaultMode()
Get the default mode of operation of this cipher.
|
protected java.lang.String |
getDefaultPadding()
Get the default padding scheme of this cipher.
|
protected iaik.pkcs.pkcs11.Mechanism |
getMechanism()
Get the current mechanism of this cipher object.
|
protected iaik.pkcs.pkcs11.Mechanism |
getMechanismForModeAndPadding()
This method returns a mechanism object that corresponds to the currently set mode and padding.
|
protected iaik.pkcs.pkcs11.MechanismInfo[][] |
getUsedMechanismFeatures()
Returns an two-dimensional array of MechanismInfos that this engine class uses.
|
protected iaik.pkcs.pkcs11.Mechanism[] |
getUsedMechanisms()
Returns an array of Mechanisms that this engine class uses.
|
protected void |
initializePkcs11Operation()
The internal session initialization method, if all necessary member variables are set.
|
protected boolean |
isModeSupported(java.lang.String mode)
Check, if the given mode of operation is supported by this cipher.
|
protected boolean |
isPaddingSupported(java.lang.String padding)
Check, if the given padding scheme is supported by this cipher.
|
protected byte[] |
pkcs11DoFinal(byte[] input,
int inputOffset,
int inputLength)
Update the currently running cipher operation with the given data and finish the current
operation.
|
protected int |
pkcs11GetBlockSize()
Get the block size of this cipher algorithm.
|
protected void |
pkcs11Init(int operationMode,
java.security.Key key,
java.security.spec.AlgorithmParameterSpec parameterSpecs,
java.security.SecureRandom randomSource)
Initialize this cipher for an operation.
|
protected byte[] |
pkcs11Update(byte[] data,
int offset,
int length)
Update the currently running cipher operation with the given data.
|
engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUnwrap, engineUpdate, engineUpdate, engineUpdateAAD, engineWrap, finalize, finalizePkcs11Operation, getFullAlgorithmName, initialize, initializeSession, initializeSoftwareDelegate, isSupportedBy, pkcs11DoFinal, pkcs11GetIV, pkcs11GetKeySize, pkcs11GetOutputSize, pkcs11GetParameters, pkcs11Init, pkcs11Init, pkcs11Unwrap, pkcs11Update, pkcs11Wrap, updateAAD, updateAAD, updateAAD
protected static final java.lang.String CIPHER_NAME
protected static final java.lang.String DEFAULT_MODE
protected static final java.lang.String DEFAULT_PADDING
protected static final java.lang.String PKCS5_PADDING
protected static final iaik.pkcs.pkcs11.Mechanism DEFAULT_MECHANISM
protected static final int PKCS11_OPERATION_SIGN_VERIFY
protected static final int PKCS11_OPERATION_ENCRYPT_DECRYPT
protected int pkcs11Operation_
protected java.io.ByteArrayOutputStream buffer_
protected int blockSize_
protected iaik.pkcs.pkcs11.Mechanism[] getUsedMechanisms()
getRequiredMechanismFeatures()
method.getUsedMechanisms
in class PKCS11Cipher
getUsedMechanismFeatures()
. May be empty, but must not be null.protected iaik.pkcs.pkcs11.MechanismInfo[][] getUsedMechanismFeatures()
getUsedMechanisms()
. The array at this index is the list of used feature
combinations used by this engine. The current token must at least support one mechanism and one
of the feature combinations (expressed as a MechanismInfo) of the same machanism.getUsedMechanismFeatures
in class PKCS11Cipher
getUsedMechanisms()
. The token must at
least supprot one of these features.protected int engineGetKeySize(java.security.Key key) throws java.security.InvalidKeyException
pkcs11
instead of engine
. This implementation tries to determine the
key length by getting the modulus.engineGetKeySize
in class PKCS11Cipher
key
- The key to check.java.security.InvalidKeyException
- If the key is invalid for this cipher.protected void checkKeyObject(iaik.pkcs.pkcs11.objects.Key keyObject) throws java.security.InvalidKeyException
checkKeyObject
in class PKCS11Cipher
keyObject
- The key object to check.java.security.InvalidKeyException
- If this cipher cannot work with this type of key object.protected void pkcs11Init(int operationMode, java.security.Key key, java.security.spec.AlgorithmParameterSpec parameterSpecs, java.security.SecureRandom randomSource) throws java.security.InvalidAlgorithmParameterException, java.security.InvalidKeyException
pkcs11Init
in class PKCS11Cipher
operationMode
- The operation to initialize; Cipher.ENCRYPT_MODE, Cipher.DECRYPT_MODE,
Cipher.UNWRAP_MODE or Cipher.WRAP_MODE.key
- The key to use for the operation.parameterSpecs
- The parameter specs to use. Some cipher do not support parameter specs, they require
null.randomSource
- Optional random source to use.java.security.InvalidAlgorithmParameterException
- If the parameter specs are invalid.java.security.InvalidKeyException
- If the key is invalid for this operation.protected void initializePkcs11Operation() throws java.security.InvalidAlgorithmParameterException, java.security.InvalidKeyException
initializePkcs11Operation
in class PKCS11Cipher
java.security.InvalidAlgorithmParameterException
- If the parameter specs are invalid.java.security.InvalidKeyException
- If the key is invalid for this operation.protected boolean isModeSupported(java.lang.String mode)
PKCS11Cipher
isModeSupported
in class PKCS11Cipher
mode
- The mode to check.protected boolean isPaddingSupported(java.lang.String padding)
PKCS11Cipher
isPaddingSupported
in class PKCS11Cipher
padding
- The padding scheme to check.protected byte[] pkcs11Update(byte[] data, int offset, int length)
pkcs11Update
in class PKCS11Cipher
data
- The byte array that holds the data.offset
- The offset in the byte array that indicates the first data byte to read.length
- The number of bytes to read starting from offset.protected byte[] pkcs11DoFinal(byte[] input, int inputOffset, int inputLength) throws javax.crypto.BadPaddingException, javax.crypto.IllegalBlockSizeException
pkcs11DoFinal
in class PKCS11Cipher
input
- The byte array that holds the input data.inputOffset
- The offset in the input byte array that indicates the first input data byte to read.inputLength
- The number of bytes to read starting from offset.javax.crypto.BadPaddingException
- If the padding of the decrypted data is bad or if the padding of the input data
failed.javax.crypto.IllegalBlockSizeException
- If the input data size does not match the required block size.protected java.lang.String getAlgorithmName()
getAlgorithmName
in class PKCS11Cipher
protected int pkcs11GetBlockSize()
pkcs11GetBlockSize
in class PKCS11Cipher
protected iaik.pkcs.pkcs11.Mechanism getDefaultMechanism()
getDefaultMechanism
in class PKCS11Cipher
protected java.lang.String getDefaultMode()
protected java.lang.String getDefaultPadding()
protected iaik.pkcs.pkcs11.Mechanism getMechanism()
getMechanism
in class PKCS11Cipher
protected iaik.pkcs.pkcs11.Mechanism getMechanismForModeAndPadding() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
- If the current combination of mode and padding is unsupported.IAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4