public class RC2ParameterSpec extends javax.crypto.spec.RC2ParameterSpec implements ASN1Type, java.security.spec.AlgorithmParameterSpec
It specifies the initialization vector (IV) and version, and is designed for use with RC2 symmetric block cipher implementations.
RC2Parameter ::= SEQUENCE {
version INTEGER, -- [1..1024]
iv OCTET STRING -- 8 octets
}
The version number, on the range [1..1024], specifies in a round-about manner the number of effective key bits to be used for the RC2 encryption/decryption. The correspondence between effective key bits and version number is as follows:
| Constructor and Description |
|---|
RC2ParameterSpec()
The default constructor.
|
RC2ParameterSpec(ASN1Object obj)
Creates a new
RC2ParameterSpec object from an
ASN1Object. |
RC2ParameterSpec(int effectiveKeyBits,
byte[] iv)
Creates a new
RC2ParameterSpec object with the specified
components. |
RC2ParameterSpec(int effectiveKeyBits,
byte[] iv,
int offset)
Creates a new
RC2ParameterSpec object with the specified
components. |
| Modifier and Type | Method and Description |
|---|---|
void |
decode(ASN1Object obj)
Decodes a
RC2ParameterSpec object from an
ASN1Object. |
static int |
effectiveKeyBitsToVersion(int effectiveKeyBits)
This is a utility method that provides a conversion from the number of
effective key bits to a version number.
|
int |
getEffectiveKeyBits()
Returns the number of effective key bits.
|
byte[] |
getIV()
Returns a copy of the initialization vector (IV).
|
void |
setEffectiveKeyBits(int effectiveKeyBits)
Sets the number of effective key bits.
|
void |
setIV(byte[] iv,
int offset)
Sets the initialization vector (IV) by copying 8 bytes of data from the
byte array beginning at the specified offset.
|
ASN1Object |
toASN1Object()
Encodes this
RC2ParameterSpec object as an
ASN1Object. |
java.lang.String |
toString()
Creates a text representation of the ASN.1 structure of this
RC2ParameterSpec object. |
static int |
versionToEffectiveKeyBits(int version)
This is a utility method that provides a conversion from a version number
to the number of effective key bits.
|
public RC2ParameterSpec()
It creates a new RC2ParameterSpec object with default
components; effective key bits of 32, and an empty or all-zero 8-byte
initialization vector (IV).
public RC2ParameterSpec(int effectiveKeyBits,
byte[] iv)
RC2ParameterSpec object with the specified
components.
The first 8 bytes of the supplied byte array are copied, and used as the initialization vector (IV).
effectiveKeyBits - the number of effective key bitsiv - a byte array containing the initialization vectorjava.lang.IllegalArgumentException - thrown if the byte array is null, or if the number of effective key
bits is not in the allowed range of [1..1024]java.lang.ArrayIndexOutOfBoundsException - thrown if an 8-byte initialization vector could not be extracted
from the byte arraypublic RC2ParameterSpec(int effectiveKeyBits,
byte[] iv,
int offset)
RC2ParameterSpec object with the specified
components.
The 8-byte initialization vector (IV) is copied from the supplied byte array starting at the indicated offset.
effectiveKeyBits - the number of effective key bitsiv - a byte array containing the initialization vectoroffset - the offset in the byte array where the initialization vector beginsjava.lang.IllegalArgumentException - thrown if the byte array is null, or if the number of effective key
bits is not in the allowed range of [1..1024]java.lang.ArrayIndexOutOfBoundsException - thrown if an 8-byte initialization vector could not be extracted
from the byte arraypublic RC2ParameterSpec(ASN1Object obj) throws CodingException
RC2ParameterSpec object from an
ASN1Object.
The ASN1Object must be a RC2Parameter structure.
obj - the ASN.1 representation of a RC2Parameter structureCodingException - thrown if an errors occurs while decoding the ANS1Objectpublic static int effectiveKeyBitsToVersion(int effectiveKeyBits)
The version number is only used during the ASN.1 encoding/deocding of an
RC2Parameter is not used by the RC2 symmetric block cipher. This conversion
is automatically done during a call to toASN1Object() to set the
version number in the ASN.1 structure.
The version number, on the range [1..1024], specifies in a round-about manner the number of effective key bits to be used for the RC2 encryption/decryption. The correspondence between effective key bits and version number is as follows:
effectiveKeyBits - the number of effective key bitsjava.lang.IllegalArgumentException - thrown if number of effective key bits is not in the allowed range
of [1..1024]public static int versionToEffectiveKeyBits(int version)
The version number is only used during the ASN.1 encoding/deocding of an
RC2Parameter is not used by the RC2 symmetric block cipher. This conversion
is automatically done during a call to decode(ASN1Object) to
retrieve the number of effective key bits from the ASN.1 structure.
The version number, on the range [1..1024], specifies in a round-about manner the number of effective key bits to be used for the RC2 encryption/decryption. The correspondence between effective key bits and version number is as follows:
version - the version numberjava.lang.IllegalArgumentException - thrown if version number is not in the allowed range of [1..1024]public int getEffectiveKeyBits()
getEffectiveKeyBits in class javax.crypto.spec.RC2ParameterSpecpublic byte[] getIV()
getIV in class javax.crypto.spec.RC2ParameterSpecpublic void setEffectiveKeyBits(int effectiveKeyBits)
effectiveKeyBits - the number of effective key bitsjava.lang.IllegalArgumentException - thrown if the number of effective key bits is not in the allowed
range of [1..1024]public void setIV(byte[] iv,
int offset)
iv - a byte array containing the initialization vectoroffset - the offset in the byte array where the initialization vector beginsjava.lang.ArrayIndexOutOfBoundsException - thrown if an 8-byte initialization vector could not be extracted
from the byte arraypublic void decode(ASN1Object obj) throws CodingException
RC2ParameterSpec object from an
ASN1Object.
The ASN1Object must be a RC2Parameter structure.
This method internally performs the version to effective key bit transform, so that the effective key bit length is set properly.
decode in interface ASN1Typeobj - an ASN.1 representation of a RC2Parameter structureCodingException - thrown if an errors occurs while decoding the ANS1Objectpublic ASN1Object toASN1Object()
RC2ParameterSpec object as an
ASN1Object.
This method internally performs the effective key bit to version transform, so that the version (and not the effective key bit length) is included in the ASN1 structure.
toASN1Object in interface ASN1Typepublic java.lang.String toString()
RC2ParameterSpec object.
toString in class java.lang.Object