|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.security.AlgorithmParametersSpi
de.fhg.igd.crypto.RC2Parameters
public class RC2Parameters
This class represents a RC2 Parameters
as defined in
RFC 2311 and
RFC 2268.
This structure is identified by the OID of the RC2-CBC
algorithm, which is
{iso(1) member-body(2) us(840) rsadsi(113549) encryptionAlgorithm(3) 2}
RFC 2311 defines three effective key lengths and the according version numbers. These lengths are 40, 64, and 128, the parameter version values are 160, 120, and 58 respectively.
This class supports the full range of effective key lengths as specified by Ron Rivest in RFC 2268. In this RFC, Mr. Rivest specifies a permutation mapping from effective key lengths to version numbers. The map defines a one-to-one correspondence. Why he defined this is beyond my understanding. It complicates parameter encoding and decoding considerably, and it does not seem to serve any purpose byond that. Anyway, it is fully supported.
Encoding and decoding according to RFC 2311 and RFC 2268 is supported (ASN.1/DER). If the effective key length is 32 then the parameters are encoded as an OCTET STRING. Other effective key lengths lead to the encoding of the full SEQUENCE containing the version as well as the IV.
Field Summary | |
---|---|
protected static byte[] |
c10
The encoding with ekb == 32. |
protected static byte[] |
c15
The encoding with version < 128 && ekb != 32. |
protected static byte[] |
c16
The encoding with version > 127. |
protected int |
ekb_
The number of effective key bits. |
protected static byte[] |
ekb2v_
Maps effective key lengths between 0 and 255 to the appropriate version number as specified in RFC2311. |
protected byte[] |
iv_
The initialisation vector (IV), consisting of 8 bytes. |
protected static byte[] |
v2ekb_
Maps version numbers between 0 and 255 to the appropriate effective key lengths as specified in RFC2311. |
protected int |
version_
The parameter version. |
Constructor Summary | |
---|---|
RC2Parameters()
|
Method Summary | |
---|---|
byte[] |
engineGetEncoded()
|
byte[] |
engineGetEncoded(String format)
This method returns the ASN.1/DER encoded parameter structure as defined in the S/MIME standard. |
AlgorithmParameterSpec |
engineGetParameterSpec(Class paramSpec)
|
void |
engineInit(AlgorithmParameterSpec paramSpec)
This method accepts an RC2ParameterSpec . |
void |
engineInit(byte[] encoded)
This method expects DER encoded RC2Parameters as defined in the S/MIME standard. |
void |
engineInit(byte[] params,
String format)
This method ignores the format string and attempts to decode according to ASN.1/DER and the parameter structure defined in the S/MIME standard. |
String |
engineToString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final byte[] ekb2v_
protected static final byte[] v2ekb_
protected static final byte[] c16
protected static final byte[] c15
protected static final byte[] c10
protected byte[] iv_
protected int ekb_
protected int version_
Constructor Detail |
---|
public RC2Parameters()
Method Detail |
---|
public void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException
RC2ParameterSpec
. Other specs cause an exception being
thrown. Three different effective key lengths are defined
in S/MIME, 40, 64, and 128. If the parameter spec defines
a different effective key length then an exception is
thrown.
The RC2ParameterSpec may return a null
as the IV. In that case, the IV is set to zeroes.
Hence, this parameter class will always define an
IV, as will any parameter specs derived from it.
The IV will always have exactly 8 bytes as defined
in RFC2311. Should the spec return a longer or
shorter IV then this IV will be either padded
with zeroes or it is truncated. This is to work
around a bug in the ABA provider until it is
fixed.
engineInit
in class AlgorithmParametersSpi
paramSpec
- The RC2ParameterSpec with the IV
and effective key length in bits.
InvalidParameterSpecException
- if the spec
is of the wrong class or the key size is non-standard.public void engineInit(byte[] encoded) throws IOException
engineInit
in class AlgorithmParametersSpi
encoded
- The encoded algorithm parameters.
IOException
- in case of a bad encoding.public void engineInit(byte[] params, String format) throws IOException
engineInit
in class AlgorithmParametersSpi
IOException
public AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec) throws InvalidParameterSpecException
engineGetParameterSpec
in class AlgorithmParametersSpi
InvalidParameterSpecException
public byte[] engineGetEncoded() throws IOException
engineGetEncoded
in class AlgorithmParametersSpi
IOException
public byte[] engineGetEncoded(String format) throws IOException
engineGetEncoded
in class AlgorithmParametersSpi
format
- The name of the encoding format; this
parameter is ignored.
IOException
public String engineToString()
engineToString
in class AlgorithmParametersSpi
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |