public abstract class BlockCipher extends PKCS11Cipher
Modifier and Type | Field and Description |
---|---|
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 iaik.pkcs.pkcs11.provider.ciphers.Padding |
externalPadding_
The implementation of the current external padding.
|
protected static java.util.Vector |
externalPaddings_
The supported software padding schemes of this cipher.
|
protected java.security.spec.AlgorithmParameterSpec |
ivParameterSpec_
The current initialization vector parameter.
|
protected boolean |
ivParameterSpecChanged_
Indicates that the ivParameterSpec_ has been changed.
|
protected java.util.Hashtable |
modePaddingMechanisms_
The mapping from mode + "/" + padding to the cryptoki mechanism.
|
protected static java.util.Vector |
supportedModes_
The supported modes of operation of this cipher.
|
protected static java.util.Vector |
supportedPaddings_
The supported padding schemes of this cipher.
|
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 |
---|
BlockCipher()
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 abstract 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 abstract java.util.Hashtable |
getModePaddingMechanisms()
Get the hashtable that maps from mode + "/" + padding to the cryptoki mechanism.
|
protected iaik.pkcs.pkcs11.MechanismInfo[][] |
getUsedMechanismFeatures()
Returns a two-dimensional array of MechanismInfos that this engine class uses.
|
protected static boolean |
isExternalPaddingSupported(java.lang.String padding)
Check, if an external software implementation is available for the given padding scheme.
|
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 abstract int |
pkcs11GetBlockSize()
Get the block size of this cipher algorithm.
|
protected byte[] |
pkcs11GetIV()
Get the currently set initialization vector.
|
protected abstract int |
pkcs11GetKeySize(java.security.Key key)
Determines the key size in bits.
|
protected java.security.AlgorithmParameters |
pkcs11GetParameters()
Returns the parameters used with this cipher.
|
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 void |
pkcs11Init(int operationMode,
java.security.Key key,
java.security.AlgorithmParameters parameters,
java.security.SecureRandom random)
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, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUnwrap, engineUpdate, engineUpdate, engineUpdateAAD, engineWrap, finalize, finalizePkcs11Operation, getAlgorithmName, getFullAlgorithmName, getUsedMechanisms, initialize, initializePkcs11Operation, initializeSession, initializeSoftwareDelegate, isSupportedBy, pkcs11DoFinal, pkcs11GetOutputSize, pkcs11Init, pkcs11Unwrap, pkcs11Update, pkcs11Wrap, updateAAD, updateAAD, updateAAD
protected static final java.lang.String DEFAULT_MODE
protected static final java.lang.String DEFAULT_PADDING
protected static java.util.Vector supportedModes_
protected static java.util.Vector supportedPaddings_
protected static java.util.Vector externalPaddings_
protected java.util.Hashtable modePaddingMechanisms_
protected java.security.spec.AlgorithmParameterSpec ivParameterSpec_
protected boolean ivParameterSpecChanged_
protected iaik.pkcs.pkcs11.provider.ciphers.Padding externalPadding_
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 mechanism.getUsedMechanismFeatures
in class PKCS11Cipher
getUsedMechanisms()
. The token must at
least support one of these features.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.AlgorithmParameters parameters, java.security.SecureRandom random) throws java.security.InvalidAlgorithmParameterException, java.security.InvalidKeyException
pkcs11
instead
of engine
.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.parameters
- The parameters to use. Some cipher do not support parameters, they require null.
Despite null, this implementation only supports IV parameters.random
- Optional random source to use.java.security.InvalidAlgorithmParameterException
- If the parameters are invalid.java.security.InvalidKeyException
- If the key is invalid for this operation.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 java.security.AlgorithmParameters pkcs11GetParameters()
pkcs11GetParameters
in class PKCS11Cipher
protected abstract int pkcs11GetKeySize(java.security.Key key) throws java.security.InvalidKeyException
pkcs11GetKeySize
in class PKCS11Cipher
key
- The key to get the length for.java.security.InvalidKeyException
- If the given key is not supported by this class.protected abstract int pkcs11GetBlockSize()
pkcs11GetBlockSize
in class PKCS11Cipher
protected byte[] pkcs11GetIV()
pkcs11GetIV
in class PKCS11Cipher
protected java.lang.String getDefaultMode()
protected java.lang.String getDefaultPadding()
protected abstract iaik.pkcs.pkcs11.Mechanism getDefaultMechanism()
getDefaultMechanism
in class PKCS11Cipher
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.protected abstract java.util.Hashtable getModePaddingMechanisms()
protected boolean isModeSupported(java.lang.String mode)
isModeSupported
in class PKCS11Cipher
mode
- The mode to check.protected boolean isPaddingSupported(java.lang.String padding)
isPaddingSupported
in class PKCS11Cipher
padding
- The padding scheme to check.protected static boolean isExternalPaddingSupported(java.lang.String padding)
padding
- The padding scheme to check.protected byte[] pkcs11Update(byte[] data, int offset, int length)
PKCS11Cipher
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
PKCS11Cipher
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.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