iaik.security.cipher
Class RC2Parameters

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

public class RC2Parameters
extends IvParameters

This class represents RC2 paramters in opaque form and may be used for generating opaque RC2 parameters and converting them between various formats.

The parameters specified for the RC2 algorithm in RFC2268 consist of an initialization vector (of eight octets) and an optional RC2 parameter version number in the range of 1-1024 for calculating the effective key bits to be used for the RC2 algorithm:

 RC2-CBCParameter :: CHOICE {
   iv IV,
   params SEQUENCE {
     version RC2Version,
     iv IV
   }
 }
 IV ::= OCTET STRING -- 8 octets
 RC2Version ::= INTEGER -- 1-1024
 

RC2Paramters 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 RC2 parameter specification or a DER encoded byte array. If the first way is chosen, the parameter values (iv and if present RC2Version) for initializing the new AlgorithmParameters object immediately are taken from the given RC2 parameter specification; if the parameters are given as DER encoded byte array, the values are parsed from the derived ASN.1 object, e.g.:

 RC2Parameterspec rc2ParamSpec = ...;
 AlgorithmParameters params = AlgorithmParameters.getInstance("RC2", "IAIK");
 params.init(rc2ParamsSpec);
 

For obtaining RC2 parameters in transparent representation from an opaque RC2Paramters object, the getParameterSpec method can be used; for obtaining the parameters as DER encoded ASN.1 object, use getEncoded.

Version:
File Revision 12

Constructor Summary
RC2Parameters()
          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 RC2 parameters as transparent RC2 parameter specification of the given class type.
protected  void engineInit(AlgorithmParameterSpec paramSpec)
          Initializes this RC2Parameters with the RC2 parameter values from a given RC2Parameterspec.
protected  void engineInit(byte[] params)
          Initializes this RC2Parameters 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

RC2Parameters

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

engineGetEncoded

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

Depending on the presence of RC2Version either an ASN.1 SEQUENCE is created from version and iv or an OCTET_STRING is created from the sole iv. Subsequently the ASN.1 object is DER encoded and returned as byte array.

Overrides:
engineGetEncoded in class IvParameters
Returns:
the RC2 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(), regardless of what is specified in the format string.

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

engineGetParameterSpec

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

engineInit

protected void engineInit(AlgorithmParameterSpec paramSpec)
                   throws InvalidParameterSpecException
Initializes this RC2Parameters with the RC2 parameter values from a given RC2Parameterspec.

Overrides:
engineInit in class IvParameters
Parameters:
paramSpec - the parameter specification, which has to be a RC2ParameterSpec
Throws:
InvalidParameterSpecException - if the given parameter specification is not a RC2ParameterSpec or the included parameters are invalid

engineInit

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

From the given byte array an ASN.1 object is created and parsed for the inherent RC2 parameter values.

Overrides:
engineInit in class IvParameters
Parameters:
params - the DER encoded byte array
Throws:
IOException - if an error occurs when decoding the given byte array or the derived parameter values are invalid

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 RC2Paramters object from the given DER encoded byte array, regardless of what is specified in the format string.

Overrides:
engineInit in class IvParameters
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 IvParameters
Returns:
a String representation of this RC2Parameters 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