public class RC2Parameters extends IvParameters
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
RC2Parameters 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 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
RC2Parameters object, the getParameterSpec
method can be used;
for obtaining the parameters as DER encoded ASN.1 object, use
getEncoded
.
Constructor and Description |
---|
RC2Parameters()
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 RC2 parameters as transparent RC2 parameter specification of
the given class type.
|
protected void |
engineInit(java.security.spec.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,
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 RC2Parameters()
RC2Parameters
object. Applications shall use one of the
AlgorithmParameters.getInstance
factory methods for obtaining
RC2Parameters.protected byte[] engineGetEncoded() throws java.io.IOException
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.
engineGetEncoded
in class IvParameters
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()
, regardless of what
is specified in the format
string.
engineGetEncoded
in class IvParameters
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 IvParameters
paramSpec
- the desired parameter specification class (RC2ParameterSpec)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
engineInit
in class IvParameters
paramSpec
- the parameter specification, which has to be a RC2ParameterSpecjava.security.spec.InvalidParameterSpecException
- if the given parameter specification is not a RC2ParameterSpec
or the included parameters are invalidprotected void engineInit(byte[] params) throws java.io.IOException
From the given byte array an ASN.1 object is created and parsed for the inherent RC2 parameter values.
engineInit
in class IvParameters
params
- the DER encoded byte arrayjava.io.IOException
- if an error occurs when decoding the given byte array or the
derived parameter values are invalidprotected void engineInit(byte[] params, java.lang.String format) throws java.io.IOException
engineInit(params)
for initializing this
RC2Parameters object from the given DER encoded byte array, regardless of
what is specified in the format
string.
engineInit
in class IvParameters
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 IvParameters