public class IvParameters
extends java.security.AlgorithmParametersSpi
The initialization vector (IV) represented by this class may be used by any algorithm that needs an IV, e.g. when running a DES, TripleDES, IDEA,... cipher in CBC, PCBC, CFB or OFB mode.
IvParameters can be generated provider independently by calling one of the
AlgorithmParameters.getInstance
methods for the algorithm in
mind. Subsequently the new AlgorithmParameters object must be initialized with
a proper IV parameter specification or a DER encoded byte array. If the first
way is chosen, the IV value for initializing the new AlgorithmParameters object
immediately is taken from the given IV parameter specification; if the parameters are given
as DER encoded byte array, an ASN.1 OCTET_STRING is created from this byte
array for subsequently parsing the IV value, e.g.:
IvParameterSpec ivParamSpec = ...; AlgorithmParameters params = AlgorithmParameters.getInstance("DES", "IAIK"); params.init(ivParamSpec);
For obtaining IV parameters in transparent representation from an opaque
IvParameters object, the getParameterSpec
method can be used;
for obtaining the parameters as DER encoded ASN.1 object, use
getEncoded
.
Constructor and Description |
---|
IvParameters()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected byte[] |
engineGetEncoded()
Returns the parameters as DER byte array.
|
protected byte[] |
engineGetEncoded(java.lang.String format)
Returns the parameters as a DER byte array.
|
protected java.security.spec.AlgorithmParameterSpec |
engineGetParameterSpec(java.lang.Class paramSpec)
Returns the IV parameters as transparent IV parameter specification of the
given class type.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec paramSpec)
Initializes this IvParameters with the IV value from a
given IvParameterspec.
|
protected void |
engineInit(byte[] params)
Initializes this IvParameters object from the given DER encoded byte array.
|
protected void |
engineInit(byte[] params,
java.lang.String format)
Inits the parameters from an DER encoded byte array.
|
protected java.lang.String |
engineToString()
Returns a String representation of the parameters.
|
public IvParameters()
IvParameters
object.
Applications shall use one of the AlgorithmParameters.getInstance
factory methods for obtaining IvParameters.protected byte[] engineGetEncoded() throws java.io.IOException
Encodes the IV value as ASN.1 OCTET STRING.
engineGetEncoded
in class java.security.AlgorithmParametersSpi
java.io.IOException
- if an encoding error occursprotected byte[] engineGetEncoded(java.lang.String format) throws java.io.IOException
Format is ignored. Only DER encoding is supported at this time. This method
only calls engineGetEncoded()
for encoding the IV value as ASN.1 OCTET STRING, regardless of what
is specified in the format
string.
engineGetEncoded
in class java.security.AlgorithmParametersSpi
format
- the encoding format; ignoredjava.io.IOException
- if an encoding error occursprotected java.security.spec.AlgorithmParameterSpec engineGetParameterSpec(java.lang.Class paramSpec) throws java.security.spec.InvalidParameterSpecException
engineGetParameterSpec
in class java.security.AlgorithmParametersSpi
paramSpec
- the desired parameter specification class (IvParameterSpec)java.security.spec.InvalidParameterSpecException
- if the parameters cannot be converted to
the desired parameter specificationprotected void engineInit(java.security.spec.AlgorithmParameterSpec paramSpec) throws java.security.spec.InvalidParameterSpecException
Attention! No check is performed if the length of the IV value (derived from the IvParameterSpec) is suitable for the algorithm this IvParameters is used for.
engineInit
in class java.security.AlgorithmParametersSpi
paramSpec
- the parameter specification, which has to be a IvParameterSpecjava.security.spec.InvalidParameterSpecException
- if the given parameter specification
is not a IvParameterSpecprotected void engineInit(byte[] params) throws java.io.IOException
From the given byte array an ASN.1 object is created and parsed for the required IV value.
Attention! No check is performed if the length of the IV value (derived from the encoding) is suitable for the algorithm this IvParameters is used for.
engineInit
in class java.security.AlgorithmParametersSpi
params
- the DER encoded byte arrayjava.io.IOException
- if an error occurs when decoding the given byte arrayprotected void engineInit(byte[] params, java.lang.String format) throws java.io.IOException
engineInit(params)
for initializing this IvParameters
object from the given DER encoded byte array, regardless of what is specified
in the format
string.
Attention! No check is performed if the length of the IV value (derived from the encoding) is suitable for the algorithm this IvParameters is used for.
engineInit
in class java.security.AlgorithmParametersSpi
params
- the DER encoded byte arrayformat
- the encoding format; ignoredjava.io.IOException
- if an error occurs when decoding the given byte arrayprotected java.lang.String engineToString()
engineToString
in class java.security.AlgorithmParametersSpi