java.lang.Object
javax.crypto.spec.RC2ParameterSpec
- All Implemented Interfaces:
AlgorithmParameterSpec
public class RC2ParameterSpec extends Object implements AlgorithmParameterSpec
This class specifies the parameters used with the
RC2
algorithm.
The parameters consist of an effective key size and optionally an 8-byte initialization vector (IV) (only in feedback mode).
This class can be used to initialize a Cipher
object that
implements the RC2 algorithm.
- Since:
- 1.4
-
Constructor Summary
Constructors Constructor Description RC2ParameterSpec(int effectiveKeyBits)
Constructs a parameter set for RC2 from the given effective key size (in bits).RC2ParameterSpec(int effectiveKeyBits, byte[] iv)
Constructs a parameter set for RC2 from the given effective key size (in bits) and an 8-byte IV.RC2ParameterSpec(int effectiveKeyBits, byte[] iv, int offset)
Constructs a parameter set for RC2 from the given effective key size (in bits) and IV. -
Method Summary
Modifier and Type Method Description boolean
equals(Object obj)
Tests for equality between the specified object and this object.int
getEffectiveKeyBits()
Returns the effective key size in bits.byte[]
getIV()
Returns the IV or null if this parameter set does not contain an IV.int
hashCode()
Calculates a hash code value for the object.
-
Constructor Details
-
RC2ParameterSpec
public RC2ParameterSpec(int effectiveKeyBits)Constructs a parameter set for RC2 from the given effective key size (in bits).- Parameters:
effectiveKeyBits
- the effective key size in bits.
-
RC2ParameterSpec
public RC2ParameterSpec(int effectiveKeyBits, byte[] iv)Constructs a parameter set for RC2 from the given effective key size (in bits) and an 8-byte IV.The bytes that constitute the IV are those between
iv[0]
andiv[7]
inclusive.- Parameters:
effectiveKeyBits
- the effective key size in bits.iv
- the buffer with the 8-byte IV. The first 8 bytes of the buffer are copied to protect against subsequent modification.- Throws:
IllegalArgumentException
- ifiv
is null.
-
RC2ParameterSpec
public RC2ParameterSpec(int effectiveKeyBits, byte[] iv, int offset)Constructs a parameter set for RC2 from the given effective key size (in bits) and IV.The IV is taken from
iv
, starting atoffset
inclusive. The bytes that constitute the IV are those betweeniv[offset]
andiv[offset+7]
inclusive.- Parameters:
effectiveKeyBits
- the effective key size in bits.iv
- the buffer with the IV. The first 8 bytes of the buffer beginning atoffset
inclusive are copied to protect against subsequent modification.offset
- the offset iniv
where the 8-byte IV starts.- Throws:
IllegalArgumentException
- ifiv
is null.
-
-
Method Details
-
getEffectiveKeyBits
public int getEffectiveKeyBits()Returns the effective key size in bits.- Returns:
- the effective key size in bits.
-
getIV
public byte[] getIV()Returns the IV or null if this parameter set does not contain an IV.- Returns:
- the IV or null if this parameter set does not contain an IV. Returns a new array each time this method is called.
-
equals
Tests for equality between the specified object and this object. Two RC2ParameterSpec objects are considered equal if their effective key sizes and IVs are equal. (Two IV references are considered equal if both arenull
.)- Overrides:
equals
in classObject
- Parameters:
obj
- the object to test for equality with this object.- Returns:
- true if the objects are considered equal, false if
obj
is null or otherwise. - See Also:
Object.hashCode()
,HashMap
-
hashCode
public int hashCode()Calculates a hash code value for the object. Objects that are equal will also have the same hashcode.- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this object.
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-