iaik.security.cipher
Class IvParameters

java.lang.Object
  |
  +--java.security.AlgorithmParametersSpi
        |
        +--iaik.security.cipher.IvParameters
Direct Known Subclasses:
RC2Parameters, RC5Parameters

public class IvParameters
extends AlgorithmParametersSpi

This class represents an initialization vector in opaque form and may be used for generating an opaque IV and converting it between various formats.

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.

IvParamters can be generated provider independently by calling one of the AlgorithmParameters.getInstance methods for the algorithm in mind. Subsequently the new AlgorithmParamters 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 IvParamters object, the getParameterSpec method can be used; for obtaining the parameters as DER encoded ASN.1 object, use getEncoded.

Version:
File Revision 10

Constructor Summary
IvParameters()
          The default constructor.
 
Method Summary
protected  byte[] engineGetEncoded()
          Returns the parameters as DER byte array.
protected  byte[] engineGetEncoded(String format)
          Returns the parameters as a DER byte array.
protected  AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
          Returns the IV parameters as transparent IV parameter specification of the given class type.
protected  void engineInit(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, String format)
          Inits the parameters from an DER encoded byte array.
protected  String engineToString()
          Returns a String representation of the parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IvParameters

public IvParameters()
The default constructor. Only internally used for creating a IvParameters object. Applications shall use one of the AlgorithmParameters.getInstance factory methods for obtaining IvParameters.
Method Detail

engineGetEncoded

protected byte[] engineGetEncoded()
                           throws IOException
Returns the parameters as DER byte array.

Encodes the IV value as ASN.1 OCTET STRING.

Overrides:
engineGetEncoded in class AlgorithmParametersSpi
Returns:
the IV parameters as DER byte array
Throws:
IOException - if an encoding error occurs

engineGetEncoded

protected byte[] engineGetEncoded(String format)
                           throws IOException
Returns the parameters as a DER byte array.

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.

Overrides:
engineGetEncoded in class AlgorithmParametersSpi
Parameters:
format - the encoding format; ignored
Returns:
the IV parameters as DER byte array
Throws:
IOException - if an encoding error occurs

engineGetParameterSpec

protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
                                                 throws InvalidParameterSpecException
Returns the IV parameters as transparent IV parameter specification of the given class type.
Overrides:
engineGetParameterSpec in class AlgorithmParametersSpi
Parameters:
paramSpec - the desired parameter specification class (IvParameterSpec)
Returns:
the IV parameters as IvParameterSpec
Throws:
InvalidParameterSpecException - if the paramters cannot be converted to the desired parameter specification

engineInit

protected void engineInit(AlgorithmParameterSpec paramSpec)
                   throws InvalidParameterSpecException
Initializes this IvParameters with the IV value from a given IvParameterspec.

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.

Overrides:
engineInit in class AlgorithmParametersSpi
Parameters:
paramSpec - the parameter specification, which has to be a IvParameterSpec
Throws:
InvalidParameterSpecException - if the given parameter specification is not a IvParameterSpec

engineInit

protected void engineInit(byte[] params)
                   throws IOException
Initializes this IvParameters object from the given DER encoded byte array.

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.

Overrides:
engineInit in class AlgorithmParametersSpi
Parameters:
params - the DER encoded byte array
Throws:
IOException - if an error occurs when decoding the given byte array

engineInit

protected void engineInit(byte[] params,
                          String format)
                   throws IOException
Inits the parameters from an DER encoded byte array. Format is ignored. Only calls {engineInit(params) for initializing this IvParamters 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.

Overrides:
engineInit in class AlgorithmParametersSpi
Parameters:
params - the DER encoded byte array
format - the encoding format; ignored
Throws:
IOException - if an error occurs when decoding the given byte array

engineToString

protected String engineToString()
Returns a String representation of the parameters.
Overrides:
engineToString in class AlgorithmParametersSpi
Returns:
a String representation of this IvParameters object

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK