Top Description Fields Constructors Methods
org.bouncycastle.pqc.jcajce.provider.util

public abstract Class AsymmetricHybridCipher

extends CipherSpiExt
Class Inheritance
Known Direct Subclasses
org.bouncycastle.pqc.jcajce.provider.mceliece.McElieceFujisakiCipherSpi, org.bouncycastle.pqc.jcajce.provider.mceliece.McElieceKobaraImaiCipherSpi, org.bouncycastle.pqc.jcajce.provider.mceliece.McEliecePointchevalCipherSpi
Imports
java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .InvalidParameterException, .Key, .SecureRandom, java.security.spec.AlgorithmParameterSpec, javax.crypto.BadPaddingException, .ShortBufferException, org.bouncycastle.crypto.CryptoServicesRegistrar

The AsymmetricHybridCipher class extends CipherSpiExt.

Note

Some Ciphers are using Padding. OneAndZeroesPadding is used as default padding. However padding can still be specified, but mode is not supported; if you try to instantiate the cipher with something else than "NONE" as mode, NoSuchAlgorithmException is thrown.

Field Summary

Modifier and TypeField and Description
protected AlgorithmParameterSpec
paramSpec

ParameterSpec used with this cipher

Inherited from org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt:
DECRYPT_MODEENCRYPT_MODEopMode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract int

Returns:

the output size
decryptOutputSize
(int
the length of the input
inLen
)

Compute the output size of an update() or doFinal() operation of a hybrid asymmetric cipher in decryption mode when given input of the specified length.

public abstract byte[]

Returns:

a new buffer with the result
doFinal
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.doFinal.

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

public final int

Returns:

the output length
doFinal
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
,
byte[]
the buffer for the result
output
,
int
the offset where the result is stored
outOff
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.doFinal.

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

protected abstract int

Returns:

the output size
encryptOutputSize
(int
the length of the input
inLen
)

Compute the output size of an update() or doFinal() operation of a hybrid asymmetric cipher in encryption mode when given input of the specified length.

public final int

Returns:

0 since the implementing algorithms are not block ciphers
getBlockSize
()

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getBlockSize.

public final byte[]

Returns:

null since no initialization vector is used.
getIV
()

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getIV.

Return the initialization vector.

public final int

Returns:

the length of the output of the next update() or doFinal() call
getOutputSize
(int
the length of the input
inLen
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getOutputSize.

Return 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 inLen (in bytes).

public final AlgorithmParameterSpec

Returns:

the parameters used with this cipher, or null if this cipher does not use any parameters.
getParameters
()

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getParameters.

Return the parameters used with this cipher.

protected abstract void
initCipherDecrypt(Key
the key which has to be used to decrypt data
key
,
AlgorithmParameterSpec
the algorithm parameters
params
)

Initialize the AsymmetricHybridCipher with a certain key for data encryption.

protected abstract void
initCipherEncrypt(Key
the key which has to be used to encrypt data
key
,
AlgorithmParameterSpec
the algorithm parameters
params
,
SecureRandom
the source of randomness
sr
)

Initialize the AsymmetricHybridCipher with a certain key for data encryption.

public final void
initDecrypt(Key
the decryption key
key
)

Initialize the cipher for decryption by forwarding it to initDecrypt(Key, FlexiSecureRandom).

public final void
initDecrypt(Key
the decryption key
key
,
AlgorithmParameterSpec
the algorithm parameters
params
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.initDecrypt.

Initialize the cipher with a certain key for data decryption.

public final void
initEncrypt(Key
the encryption key
key
)

Initialize the cipher for encryption by forwarding it to initEncrypt(Key, AlgorithmParameterSpec, SecureRandom).

public final void
initEncrypt(Key
the encryption key
key
,
SecureRandom
the source of randomness
random
)

Initialize this cipher for encryption by forwarding it to initEncrypt(Key, AlgorithmParameterSpec, SecureRandom).

public final void
initEncrypt(Key
the encryption key
key
,
AlgorithmParameterSpec
the algorithm parameters
params
)

Initialize the cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom, AlgorithmParameterSpec).

public final void
initEncrypt(Key
the encryption key
key
,
AlgorithmParameterSpec
the algorithm parameters
params
,
SecureRandom
the source of randomness
random
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.initEncrypt.

Initialize the cipher with a certain key for data encryption.

protected final void
setMode(String
the cipher mode (unused)
modeName
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.setMode.

Since asymmetric hybrid ciphers do not support modes, this method does nothing.

protected final void
setPadding(String
the name of the padding scheme (not used)
paddingName
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.setPadding.

Since asymmetric hybrid ciphers do not support padding, this method does nothing.

public abstract byte[]

Returns:

a new buffer with the result (maybe an empty byte array)
update
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.update.

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

public final int

Returns:

the length of the output
update
(byte[]
the input buffer
input
,
int
the offset where the input starts
inOff
,
int
the input length
inLen
,
byte[]
the output buffer
output
,
int
the offset where the result is stored
outOff
)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.update.

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

Inherited from org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt:
doFinaldoFinalengineDoFinalengineDoFinalengineGetBlockSizeengineGetIVengineGetKeySizeengineGetOutputSizeengineGetParametersengineInitengineInitengineInitengineSetModeengineSetPaddingengineUpdateengineUpdategetKeySizegetNameupdate

Field Detail

paramSpecback to summary
protected AlgorithmParameterSpec paramSpec

ParameterSpec used with this cipher

Constructor Detail

AsymmetricHybridCipherback to summary
public AsymmetricHybridCipher()

Method Detail

decryptOutputSizeback to summary
protected abstract int decryptOutputSize(int inLen)

Compute the output size of an update() or doFinal() operation of a hybrid asymmetric cipher in decryption mode when given input of the specified length.

Parameters
inLen:int

the length of the input

Returns:int

the output size

doFinalback to summary
public abstract byte[] doFinal(byte[] input, int inOff, int inLen) throws BadPaddingException

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.doFinal.

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

Returns:byte[]

a new buffer with the result

Exceptions
BadPaddingException:
if the ciphertext is invalid.
doFinalback to summary
public final int doFinal(byte[] input, int inOff, int inLen, byte[] output, int outOff) throws ShortBufferException, BadPaddingException

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.doFinal.

Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

output:byte[]

the buffer for the result

outOff:int

the offset where the result is stored

Returns:int

the output length

Exceptions
ShortBufferException:
if the output buffer is too small to hold the result.
BadPaddingException:
if the ciphertext is invalid.
encryptOutputSizeback to summary
protected abstract int encryptOutputSize(int inLen)

Compute the output size of an update() or doFinal() operation of a hybrid asymmetric cipher in encryption mode when given input of the specified length.

Parameters
inLen:int

the length of the input

Returns:int

the output size

getBlockSizeback to summary
public final int getBlockSize()

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getBlockSize.

Returns:int

0 since the implementing algorithms are not block ciphers

getIVback to summary
public final byte[] getIV()

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getIV.

Doc from org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getIV.

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

Returns:byte[]

null since no initialization vector is used.

getOutputSizeback to summary
public final int getOutputSize(int inLen)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getOutputSize.

Return 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 inLen (in bytes). This call takes into account any unprocessed (buffered) data from a previous update call, and padding. The actual output length of the next update() or doFinal() call may be smaller than the length returned by this method.

Parameters
inLen:int

the length of the input

Returns:int

the length of the output of the next update() or doFinal() call

getParametersback to summary
public final AlgorithmParameterSpec getParameters()

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.getParameters.

Return the parameters used with this cipher.

The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).

Returns:AlgorithmParameterSpec

the parameters used with this cipher, or null if this cipher does not use any parameters.

initCipherDecryptback to summary
protected abstract void initCipherDecrypt(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException

Initialize the AsymmetricHybridCipher with a certain key for data encryption.

Parameters
key:Key

the key which has to be used to decrypt data

params:AlgorithmParameterSpec

the algorithm parameters

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher
InvalidAlgorithmParameterException:
if the given parameters are inappropriate for initializing this cipher.
initCipherEncryptback to summary
protected abstract void initCipherEncrypt(Key key, AlgorithmParameterSpec params, SecureRandom sr) throws InvalidKeyException, InvalidAlgorithmParameterException

Initialize the AsymmetricHybridCipher with a certain key for data encryption.

Parameters
key:Key

the key which has to be used to encrypt data

params:AlgorithmParameterSpec

the algorithm parameters

sr:SecureRandom

the source of randomness

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher.
InvalidAlgorithmParameterException:
if the given parameters are inappropriate for initializing this cipher.
initDecryptback to summary
public final void initDecrypt(Key key) throws InvalidKeyException

Initialize the cipher for decryption by forwarding it to initDecrypt(Key, FlexiSecureRandom).

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, and raise an InvalidKeyException if it is being initialized for decryption. The generated parameters can be retrieved using getParameters().

Parameters
key:Key

the decryption key

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher.
initDecryptback to summary
public final void initDecrypt(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.initDecrypt.

Initialize the cipher with a certain key for data decryption.

If this cipher requires any random bytes (e.g., for parameter generation), it will get them from random.

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

Parameters
key:Key

the decryption key

params:AlgorithmParameterSpec

the algorithm parameters

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 is initialized with null parameters and cannot generate parameters itself.
initEncryptback to summary
public final void initEncrypt(Key key) throws InvalidKeyException

Initialize the cipher for encryption by forwarding it to initEncrypt(Key, AlgorithmParameterSpec, SecureRandom).

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, and raise an InvalidKeyException if it is being initialized for decryption. The generated parameters can be retrieved using getParameters().

Parameters
key:Key

the encryption key

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher.
InvalidParameterException:
if this cipher needs algorithm parameters for initialization and cannot generate parameters itself.
initEncryptback to summary
public final void initEncrypt(Key key, SecureRandom random) throws InvalidKeyException

Initialize this cipher for encryption by forwarding it to initEncrypt(Key, AlgorithmParameterSpec, SecureRandom).

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, and raise an InvalidKeyException if it is being initialized for decryption. The generated parameters can be retrieved using getParameters().

Parameters
key:Key

the encryption key

random:SecureRandom

the source of randomness

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher.
InvalidParameterException:
if this cipher needs algorithm parameters for initialization and cannot generate parameters itself.
initEncryptback to summary
public final void initEncrypt(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException

Initialize the cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom, AlgorithmParameterSpec).

Parameters
key:Key

the encryption key

params:AlgorithmParameterSpec

the algorithm parameters

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 is initialized with null parameters and cannot generate parameters itself.
initEncryptback to summary
public final void initEncrypt(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.initEncrypt.

Initialize the cipher with a certain key for data encryption.

If this cipher requires any random bytes (e.g., for parameter generation), it will get them from random.

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

Parameters
key:Key

the encryption key

params:AlgorithmParameterSpec

the algorithm parameters

random:SecureRandom

the source of randomness

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 is initialized with null parameters and cannot generate parameters itself.
setModeback to summary
protected final void setMode(String modeName)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.setMode.

Since asymmetric hybrid ciphers do not support modes, this method does nothing.

Parameters
modeName:String

the cipher mode (unused)

setPaddingback to summary
protected final void setPadding(String paddingName)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.setPadding.

Since asymmetric hybrid ciphers do not support padding, this method does nothing.

Parameters
paddingName:String

the name of the padding scheme (not used)

updateback to summary
public abstract byte[] update(byte[] input, int inOff, int inLen)

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.update.

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

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

Returns:byte[]

a new buffer with the result (maybe an empty byte array)

updateback to summary
public final int update(byte[] input, int inOff, int inLen, byte[] output, int outOff) throws ShortBufferException

Implements abstract org.bouncycastle.pqc.jcajce.provider.util.CipherSpiExt.update.

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

Parameters
input:byte[]

the input buffer

inOff:int

the offset where the input starts

inLen:int

the input length

output:byte[]

the output buffer

outOff:int

the offset where the result is stored

Returns:int

the length of the output

Exceptions
ShortBufferException:
if the output buffer is too small to hold the result.