APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.pkcs11

pack-priv final Class P11Cipher

extends CipherSpi
Class Inheritance
Imports
java.nio.ByteBuffer, java.util.Arrays, .Locale, java.security.*, java.security.spec.*, javax.crypto.*, javax.crypto.spec.*, jdk.internal.access.JavaNioAccess, .SharedSecrets, sun.nio.ch.DirectBuffer, sun.security.jca.JCAUtil, sun.security.pkcs11.wrapper.*

Cipher implementation class. This class currently supports DES, DESede, AES, ARCFOUR, and Blowfish. This class is designed to support ECB, CBC, CTR, CTS with NoPadding and ECB, CBC with PKCS5Padding. It will use its own padding impl if the native mechanism does not support padding. Note that PKCS#11 currently only supports ECB, CBC, and CTR. There are no provisions for other modes such as CFB, OFB, and PCBC.
Author
Andreas Sterbenz
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private static enum
private static interface
private static class

Field Summary

Modifier and TypeField and Description
private final String
private final P11Cipher.Mode
private final int
private int
private boolean
private int
private boolean
private byte[]
private final String
private final long
private static final JavaNioAccess
private P11Key
private byte[]
private int
private P11Cipher.Padding
private P11Cipher.Pad
private boolean
private Session
private final Token

Constructor Summary

AccessConstructor and Description
pack-priv
P11Cipher(Token token, String algorithm, long mechanism)

Method Summary

Modifier and TypeMethod and Description
private final void
bufferInputBytes(byte[] in, int inOfs, int len)

private final void
bufferInputBytes(ByteBuffer inBuffer, int len)

private void
private void
convertCTSVariant(ByteBuffer ciphertextBuf, byte[] ciphertextArr, int ciphertextEnd)

The ciphertext ordering for the three variants can be depicted as follows, where 'p' is the penultimate block (which may be partial or full), and 'f' the full final block: 'p' is a partial block 'p' is a full block ------------------------ --------------------- CS1 (NIST) | ....

private int
doFinalLength(int inLen)

protected byte[]
engineDoFinal(byte[] in, int inOfs, int inLen)

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation.

protected int
engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out, int outOfs)

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation.

protected int
engineDoFinal(ByteBuffer inBuffer, ByteBuffer outBuffer)

Overrides javax.crypto.CipherSpi.engineDoFinal.

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation.

protected int
engineGetBlockSize()

Implements abstract javax.crypto.CipherSpi.engineGetBlockSize.

Returns the block size (in bytes).

protected byte[]
engineGetIV()

Implements abstract javax.crypto.CipherSpi.engineGetIV.

Returns the initialization vector (IV) in a new buffer.

protected int
engineGetKeySize(Key key)

Overrides javax.crypto.CipherSpi.engineGetKeySize.

Returns the key size of the given key object in bits.

protected int
engineGetOutputSize(int inputLen)

Implements abstract javax.crypto.CipherSpi.engineGetOutputSize.

Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes).

protected AlgorithmParameters
engineGetParameters()

Implements abstract javax.crypto.CipherSpi.engineGetParameters.

Returns the parameters used with this cipher.

protected void
engineInit(int opmode, Key key, SecureRandom random)

Implements abstract javax.crypto.CipherSpi.engineInit.

Initializes this CipherSpi object with a key and a source of randomness.

protected void
engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)

Implements abstract javax.crypto.CipherSpi.engineInit.

Initializes this CipherSpi object with a key, a set of algorithm parameters, and a source of randomness.

protected void
engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random)

Implements abstract javax.crypto.CipherSpi.engineInit.

Initializes this CipherSpi object with a key, a set of algorithm parameters, and a source of randomness.

protected void
engineSetMode(String mode)

Implements abstract javax.crypto.CipherSpi.engineSetMode.

Sets the mode of this cipher.

protected void
engineSetPadding(String padding)

Implements abstract javax.crypto.CipherSpi.engineSetPadding.

Sets the padding mechanism of this cipher.

protected Key
engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)

Overrides javax.crypto.CipherSpi.engineUnwrap.

Unwrap a previously wrapped key.

protected byte[]
engineUpdate(byte[] in, int inOfs, int inLen)

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Continues a multiple-part encryption or decryption operation (depending on how this CipherSpi object was initialized), processing another data part.

protected int
engineUpdate(byte[] in, int inOfs, int inLen, byte[] out, int outOfs)

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Continues a multiple-part encryption or decryption operation (depending on how this CipherSpi object was initialized), processing another data part.

protected int
engineUpdate(ByteBuffer inBuffer, ByteBuffer outBuffer)

Overrides javax.crypto.CipherSpi.engineUpdate.

Continues a multiple-part encryption or decryption operation (depending on how this CipherSpi object was initialized), processing another data part.

protected byte[]
private void
private int
getBytesToCompleteBlock(int availableBytes)

private int
getCTSMustBeBuffered(int availableBytes)

private void
private int
implDoFinal(byte[] out, int outOfs, int outLen)

private int
private void
implInit(int opmode, Key key, byte[] iv, SecureRandom random)

private int
implUpdate(byte[] in, int inOfs, int inLen, byte[] out, int outOfs, int outLen)

private int
implUpdate(ByteBuffer inBuffer, ByteBuffer outBuffer)

private void
private P11Cipher.Mode
private void
reset(boolean doCancel)

private static void
swapLastTwoBlocks(ByteBuffer ciphertextBuf, int ciphertextEnd, int prevBlockLen, int lastBlockLen)

private int
updateLength(int inLen)

Inherited from javax.crypto.CipherSpi:
engineUpdateAADengineUpdateAAD

Field Detail

algorithmback to summary
private final String algorithm
blockModeback to summary
private final P11Cipher.Mode blockMode
blockSizeback to summary
private final int blockSize
bytesBufferedback to summary
private int bytesBuffered
encryptback to summary
private boolean encrypt
fixedKeySizeback to summary
private int fixedKeySize
initializedback to summary
private boolean initialized
ivback to summary
private byte[] iv
keyAlgorithmback to summary
private final String keyAlgorithm
mechanismback to summary
private final long mechanism
NIO_ACCESSback to summary
private static final JavaNioAccess NIO_ACCESS
p11Keyback to summary
private P11Key p11Key
padBufferback to summary
private byte[] padBuffer
padBufferLenback to summary
private int padBufferLen
paddingObjback to summary
private P11Cipher.Padding paddingObj
paddingTypeback to summary
private P11Cipher.Pad paddingType
reqBlockUpdatesback to summary
private boolean reqBlockUpdates
sessionback to summary
private Session session
tokenback to summary
private final Token token

Constructor Detail

P11Cipherback to summary
pack-priv P11Cipher(Token token, String algorithm, long mechanism) throws PKCS11Exception, NoSuchAlgorithmException

Method Detail

bufferInputBytesback to summary
private final void bufferInputBytes(byte[] in, int inOfs, int len)
bufferInputBytesback to summary
private final void bufferInputBytes(ByteBuffer inBuffer, int len)
cancelOperationback to summary
private void cancelOperation()
convertCTSVariantback to summary
private void convertCTSVariant(ByteBuffer ciphertextBuf, byte[] ciphertextArr, int ciphertextEnd)

The ciphertext ordering for the three variants can be depicted as follows, where 'p' is the penultimate block (which may be partial or full), and 'f' the full final block: 'p' is a partial block 'p' is a full block ------------------------ --------------------- CS1 (NIST) | .... pp ffff | .... pppp ffff CS2 (Schneier) | .... ffff pp | .... pppp ffff CS3 (Kerberos) | .... ffff pp | .... ffff pppp After encryption, we get the ciphertext from the token formatted as specified in the SunPKCS11 'cipherTextStealingVariant' configuration property. Conversely, before decryption, the ciphertext has to be passed to the token according to the previous formatting. This method converts the ciphertext between the format used by the token and the one used by SunJCE's "AES/CTS/NoPadding" implementation (CS3 as described by RFC 2040, section 8).

doFinalLengthback to summary
private int doFinalLength(int inLen)
engineDoFinalback to summary
protected byte[] engineDoFinal(byte[] in, int inOfs, int inLen) throws IllegalBlockSizeException, BadPaddingException

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Doc from javax.crypto.CipherSpi.engineDoFinal.

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this CipherSpi object was initialized.

The first inputLen bytes in the input buffer, starting at inputOffset inclusive, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. If an AEAD mode (such as GCM or CCM) is being used, the authentication tag is appended in the case of encryption, or verified in the case of decryption. The result is stored in a new buffer.

Upon finishing, this method resets this CipherSpi object to the state it was in when previously initialized via a call to engineInit. That is, the object is reset and available to encrypt or decrypt (depending on the operation mode that was specified in the call to engineInit) more data.

Note

if any exception is thrown, this CipherSpi object may need to be reset before it can be used again.

Exceptions
IllegalBlockSizeException:
if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size; or if this encryption algorithm is unable to process the input data provided
BadPaddingException:
if this CipherSpi object is in decryption mode, and (un)padding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
engineDoFinalback to summary
protected int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out, int outOfs) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException

Implements abstract javax.crypto.CipherSpi.engineDoFinal.

Doc from javax.crypto.CipherSpi.engineDoFinal.

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this CipherSpi object was initialized.

The first inputLen bytes in the input buffer, starting at inputOffset inclusive, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. If an AEAD mode such as GCM or CCM is being used, the authentication tag is appended in the case of encryption, or verified in the case of decryption. The result is stored in the output buffer, starting at outputOffset inclusive.

If the output buffer is too small to hold the result, a ShortBufferException is thrown.

Upon finishing, this method resets this CipherSpi object to the state it was in when previously initialized via a call to engineInit. That is, the object is reset and available to encrypt or decrypt (depending on the operation mode that was specified in the call to engineInit) more data.

Note

if any exception is thrown, this CipherSpi object may need to be reset before it can be used again.

Exceptions
ShortBufferException:
if the given output buffer is too small to hold the result
IllegalBlockSizeException:
if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size; or if this encryption algorithm is unable to process the input data provided
BadPaddingException:
if this CipherSpi object is in decryption mode, and (un)padding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
engineDoFinalback to summary
protected int engineDoFinal(ByteBuffer inBuffer, ByteBuffer outBuffer) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException

Overrides javax.crypto.CipherSpi.engineDoFinal.

Doc from javax.crypto.CipherSpi.engineDoFinal.

Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this CipherSpi object was initialized.

All input.remaining() bytes starting at input.position() are processed. If an AEAD mode such as GCM or CCM is being used, the authentication tag is appended in the case of encryption, or verified in the case of decryption. The result is stored in the output buffer. Upon return, the input buffer's position will be equal to its limit; its limit will not have changed. The output buffer's position will have advanced by n, where n is the value returned by this method; the output buffer's limit will not have changed.

If output.remaining() bytes are insufficient to hold the result, a ShortBufferException is thrown.

Upon finishing, this method resets this CipherSpi object to the state it was in when previously initialized via a call to engineInit. That is, the object is reset and available to encrypt or decrypt (depending on the operation mode that was specified in the call to engineInit more data.

Note

if any exception is thrown, this CipherSpi object may need to be reset before it can be used again.

Subclasses should consider overriding this method if they can process ByteBuffers more efficiently than byte arrays.

Annotations
@Override
Exceptions
ShortBufferException:
if there is insufficient space in the output buffer
IllegalBlockSizeException:
if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size; or if this encryption algorithm is unable to process the input data provided
BadPaddingException:
if this CipherSpi object is in decryption mode, and (un)padding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
engineGetBlockSizeback to summary
protected int engineGetBlockSize()

Implements abstract javax.crypto.CipherSpi.engineGetBlockSize.

Doc from javax.crypto.CipherSpi.engineGetBlockSize.

Returns the block size (in bytes).

engineGetIVback to summary
protected byte[] engineGetIV()

Implements abstract javax.crypto.CipherSpi.engineGetIV.

Doc from javax.crypto.CipherSpi.engineGetIV.

Returns the initialization vector (IV) in a new buffer.

This is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.

engineGetKeySizeback to summary
protected int engineGetKeySize(Key key) throws InvalidKeyException

Overrides javax.crypto.CipherSpi.engineGetKeySize.

Doc from javax.crypto.CipherSpi.engineGetKeySize.

Returns the key size of the given key object in bits.

This concrete method has been added to this previously-defined abstract class. It throws an UnsupportedOperationException if it is not overridden by the provider.

Annotations
@Override
Exceptions
InvalidKeyException:
if key is invalid
engineGetOutputSizeback to summary
protected int engineGetOutputSize(int inputLen)

Implements abstract javax.crypto.CipherSpi.engineGetOutputSize.

Doc from javax.crypto.CipherSpi.engineGetOutputSize.

Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes).

This call takes into account any unprocessed (buffered) data from a previous update call, padding, and AEAD tagging.

The actual output length of the next update or doFinal call may be smaller than the length returned by this method.

engineGetParametersback to summary
protected AlgorithmParameters engineGetParameters()

Implements abstract javax.crypto.CipherSpi.engineGetParameters.

Doc from javax.crypto.CipherSpi.engineGetParameters.

Returns the parameters used with this cipher.

The returned parameters may be the same that were used to initialize this cipher, or may contain additional default or random parameter values used by the underlying cipher implementation. If the required parameters were not supplied and can be generated by the cipher, the generated parameters are returned. Otherwise, null is returned.

engineInitback to summary
protected void engineInit(int opmode, Key key, SecureRandom random) throws InvalidKeyException

Implements abstract javax.crypto.CipherSpi.engineInit.

Doc from javax.crypto.CipherSpi.engineInit.

Initializes this CipherSpi object with a key and a source of randomness.

The CipherSpi object is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opmode.

If this cipher requires any algorithm parameters that cannot be derived from the given key, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption or key wrapping, and raise an InvalidKeyException if it is being initialized for decryption or key unwrapping. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).

If this cipher requires algorithm parameters that cannot be derived from the input parameters, and there are no reasonable provider-specific default values, initialization will necessarily fail.

If this cipher (including its feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.

Note that when a CipherSpi object is initialized, it loses all previously-acquired state. In other words, initializing a CipherSpi object is equivalent to creating a new instance of that CipherSpi object and initializing it.

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher, or requires algorithm parameters that cannot be determined from the given key
engineInitback to summary
protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract javax.crypto.CipherSpi.engineInit.

Doc from javax.crypto.CipherSpi.engineInit.

Initializes this CipherSpi object with a key, a set of algorithm parameters, and a source of randomness.

The CipherSpi object is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opmode.

If this cipher requires any algorithm parameters and params is null, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption or key wrapping, and raise an InvalidAlgorithmParameterException if it is being initialized for decryption or key unwrapping. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).

If this cipher requires algorithm parameters that cannot be derived from the input parameters, and there are no reasonable provider-specific default values, initialization will necessarily fail.

If this cipher (including its feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.

Note that when a CipherSpi object is initialized, it loses all previously-acquired state. In other words, initializing a CipherSpi object is equivalent to creating a new instance of that CipherSpi object and initializing it.

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher
InvalidAlgorithmParameterException:
if the given algorithm parameters are inappropriate for this cipher, or if this cipher requires algorithm parameters and params is null
engineInitback to summary
protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract javax.crypto.CipherSpi.engineInit.

Doc from javax.crypto.CipherSpi.engineInit.

Initializes this CipherSpi object with a key, a set of algorithm parameters, and a source of randomness.

The CipherSpi object is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opmode.

If this cipher requires any algorithm parameters and params is null, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption or key wrapping, and raise an InvalidAlgorithmParameterException if it is being initialized for decryption or key unwrapping. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).

If this cipher requires algorithm parameters that cannot be derived from the input parameters, and there are no reasonable provider-specific default values, initialization will necessarily fail.

If this cipher (including its feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.

Note that when a CipherSpi object is initialized, it loses all previously-acquired state. In other words, initializing a CipherSpi object is equivalent to creating a new instance of that CipherSpi object and initializing it.

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher
InvalidAlgorithmParameterException:
if the given algorithm parameters are inappropriate for this cipher, or if this cipher requires algorithm parameters and params is null
engineSetModeback to summary
protected void engineSetMode(String mode) throws NoSuchAlgorithmException

Implements abstract javax.crypto.CipherSpi.engineSetMode.

Doc from javax.crypto.CipherSpi.engineSetMode.

Sets the mode of this cipher.

Exceptions
NoSuchAlgorithmException:
if the requested cipher mode does not exist
engineSetPaddingback to summary
protected void engineSetPadding(String padding) throws NoSuchPaddingException

Implements abstract javax.crypto.CipherSpi.engineSetPadding.

Doc from javax.crypto.CipherSpi.engineSetPadding.

Sets the padding mechanism of this cipher.

Exceptions
NoSuchPaddingException:
if the requested padding mechanism does not exist
engineUnwrapback to summary
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException

Overrides javax.crypto.CipherSpi.engineUnwrap.

Doc from javax.crypto.CipherSpi.engineUnwrap.

Unwrap a previously wrapped key.

This concrete method has been added to this previously-defined abstract class. (For backwards compatibility, it cannot be abstract.) It may be overridden by a provider to unwrap a previously wrapped key. Such an override is expected to throw an InvalidKeyException if the given wrapped key cannot be unwrapped. If this method is not overridden, it always throws an UnsupportedOperationException.

Exceptions
InvalidKeyException:
if wrappedKey does not represent a wrapped key of type wrappedKeyType for the wrappedKeyAlgorithm
NoSuchAlgorithmException:
if no installed providers can create keys of type wrappedKeyType for the wrappedKeyAlgorithm
engineUpdateback to summary
protected byte[] engineUpdate(byte[] in, int inOfs, int inLen)

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Doc from javax.crypto.CipherSpi.engineUpdate.

Continues a multiple-part encryption or decryption operation (depending on how this CipherSpi object was initialized), processing another data part.

The first inputLen bytes in the input buffer, starting at inputOffset inclusive, are processed, and the result is stored in a new buffer.

engineUpdateback to summary
protected int engineUpdate(byte[] in, int inOfs, int inLen, byte[] out, int outOfs) throws ShortBufferException

Implements abstract javax.crypto.CipherSpi.engineUpdate.

Doc from javax.crypto.CipherSpi.engineUpdate.

Continues a multiple-part encryption or decryption operation (depending on how this CipherSpi object was initialized), processing another data part.

The first inputLen bytes in the input buffer, starting at inputOffset inclusive, are processed, and the result is stored in the output buffer, starting at outputOffset inclusive.

If the output buffer is too small to hold the result, a ShortBufferException is thrown.

Exceptions
ShortBufferException:
if the given output buffer is too small to hold the result
engineUpdateback to summary
protected int engineUpdate(ByteBuffer inBuffer, ByteBuffer outBuffer) throws ShortBufferException

Overrides javax.crypto.CipherSpi.engineUpdate.

Doc from javax.crypto.CipherSpi.engineUpdate.

Continues a multiple-part encryption or decryption operation (depending on how this CipherSpi object was initialized), processing another data part.

All input.remaining() bytes starting at input.position() are processed. The result is stored in the output buffer. Upon return, the input buffer's position will be equal to its limit; its limit will not have changed. The output buffer's position will have advanced by n, where n is the value returned by this method; the output buffer's limit will not have changed.

If output.remaining() bytes are insufficient to hold the result, a ShortBufferException is thrown.

Subclasses should consider overriding this method if they can process ByteBuffers more efficiently than byte arrays.

Annotations
@Override
Exceptions
ShortBufferException:
if there is insufficient space in the output buffer
engineWrapback to summary
protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException

Overrides javax.crypto.CipherSpi.engineWrap.

Doc from javax.crypto.CipherSpi.engineWrap.

Wrap a key.

This concrete method has been added to this previously-defined abstract class. (For backwards compatibility, it cannot be abstract.) It may be overridden by a provider to wrap a key. Such an override is expected to throw an IllegalBlockSizeException or InvalidKeyException (under the specified circumstances), if the given key cannot be wrapped. If this method is not overridden, it always throws an UnsupportedOperationException.

Exceptions
IllegalBlockSizeException:
if this cipher is a block cipher, no padding has been requested, and the length of the encoding of the key to be wrapped is not a multiple of the block size
InvalidKeyException:
if it is impossible or unsafe to wrap the key with this cipher (e.g., a hardware protected key is being passed to a software-only cipher)
ensureInitializedback to summary
private void ensureInitialized() throws PKCS11Exception
getBytesToCompleteBlockback to summary
private int getBytesToCompleteBlock(int availableBytes)
getCTSMustBeBufferedback to summary
private int getCTSMustBeBuffered(int availableBytes)
handleExceptionback to summary
private void handleException(PKCS11Exception e) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
implDoFinalback to summary
private int implDoFinal(byte[] out, int outOfs, int outLen) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
implDoFinalback to summary
private int implDoFinal(ByteBuffer outBuffer) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
implInitback to summary
private void implInit(int opmode, Key key, byte[] iv, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
implUpdateback to summary
private int implUpdate(byte[] in, int inOfs, int inLen, byte[] out, int outOfs, int outLen) throws ShortBufferException
implUpdateback to summary
private int implUpdate(ByteBuffer inBuffer, ByteBuffer outBuffer) throws ShortBufferException
initializeback to summary
private void initialize() throws PKCS11Exception
parseModeback to summary
private P11Cipher.Mode parseMode(String mode) throws NoSuchAlgorithmException
resetback to summary
private void reset(boolean doCancel)
swapLastTwoBlocksback to summary
private static void swapLastTwoBlocks(ByteBuffer ciphertextBuf, int ciphertextEnd, int prevBlockLen, int lastBlockLen)
updateLengthback to summary
private int updateLength(int inLen)
sun.security.pkcs11 back to summary

private final Enum P11Cipher.Mode

extends Enum<P11Cipher.Mode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final P11Cipher.Mode
public static final P11Cipher.Mode
public static final P11Cipher.Mode
public static final P11Cipher.Mode

Constructor Summary

AccessConstructor and Description
private
Mode()

Method Summary

Modifier and TypeMethod and Description
public static P11Cipher.Mode
public static P11Cipher.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CBCback to summary
public static final P11Cipher.Mode CBC
CTRback to summary
public static final P11Cipher.Mode CTR
CTSback to summary
public static final P11Cipher.Mode CTS
ECBback to summary
public static final P11Cipher.Mode ECB

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static P11Cipher.Mode valueOf(String name)
valuesback to summary
public static P11Cipher.Mode[] values()
sun.security.pkcs11 back to summary

private final Enum P11Cipher.Pad

extends Enum<P11Cipher.Pad>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final P11Cipher.Pad
public static final P11Cipher.Pad

Constructor Summary

AccessConstructor and Description
private
Pad()

Method Summary

Modifier and TypeMethod and Description
public static P11Cipher.Pad
public static P11Cipher.Pad[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NONEback to summary
public static final P11Cipher.Pad NONE
PKCS5back to summary
public static final P11Cipher.Pad PKCS5

Constructor Detail

Padback to summary
private Pad()

Method Detail

valueOfback to summary
public static P11Cipher.Pad valueOf(String name)
valuesback to summary
public static P11Cipher.Pad[] values()
sun.security.pkcs11 back to summary

private Interface P11Cipher.Padding

Known Direct Implementers
sun.security.pkcs11.P11Cipher.PKCS5Padding

Method Summary

Modifier and TypeMethod and Description
public int
setPaddingBytes(byte[] paddingBuffer, int startOff, int padLen)

public int
unpad(byte[] paddedData, int len)

Method Detail

setPaddingBytesback to summary
public int setPaddingBytes(byte[] paddingBuffer, int startOff, int padLen)
unpadback to summary
public int unpad(byte[] paddedData, int len) throws BadPaddingException, IllegalBlockSizeException
sun.security.pkcs11 back to summary

private Class P11Cipher.PKCS5Padding

extends Object
implements Padding
Class Inheritance
All Implemented Interfaces
sun.security.pkcs11.P11Cipher.Padding

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
PKCS5Padding(int blockSize)

Method Summary

Modifier and TypeMethod and Description
public int
setPaddingBytes(byte[] paddingBuffer, int startOff, int padLen)

Implements sun.security.pkcs11.P11Cipher.Padding.setPaddingBytes.

public int
unpad(byte[] paddedData, int len)

Implements sun.security.pkcs11.P11Cipher.Padding.unpad.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockSizeback to summary
private final int blockSize

Constructor Detail

PKCS5Paddingback to summary
pack-priv PKCS5Padding(int blockSize) throws NoSuchPaddingException

Method Detail

setPaddingBytesback to summary
public int setPaddingBytes(byte[] paddingBuffer, int startOff, int padLen)

Implements sun.security.pkcs11.P11Cipher.Padding.setPaddingBytes.

unpadback to summary
public int unpad(byte[] paddedData, int len) throws BadPaddingException, IllegalBlockSizeException

Implements sun.security.pkcs11.P11Cipher.Padding.unpad.