public class IvParameterSpec extends javax.crypto.spec.IvParameterSpec implements java.security.spec.AlgorithmParameterSpec, ASN1Type
It specifies the initialization vector (IV), and is designed for use with any symmetric block cipher implementation. The IV must be the same size as the symmetric cipher block size.
This class is a re-implementation of javax.crypto.spec.IvParameterSpec, that also provides support for ASN1 encoding and decoding of an IV. This class should be used instead of javax.crypto.spec.IvParameterSpec, when ASN1 support is required.
IVParameter ::= OCTET STRING
| Constructor and Description |
|---|
IvParameterSpec()
The default constructor.
|
IvParameterSpec(ASN1Object obj)
Creates a new
IvParameterSpec object from an
ASN1Object. |
IvParameterSpec(byte[] iv)
Creates a new
IvParameterSpec object with the specified
component. |
IvParameterSpec(byte[] iv,
int offset,
int length)
Creates a new
IvParameterSpec object with the specified
component. |
| Modifier and Type | Method and Description |
|---|---|
void |
decode(ASN1Object obj)
Decodes an
IvParameterSpec object from an
ASN1Object. |
byte[] |
getIV()
Returns a copy of the initialization vector (IV).
|
void |
setIV(byte[] iv,
int offset,
int length)
Sets the initialization vector (IV) by copying specified amount of data
from the byte array beginning at the specified offset.
|
ASN1Object |
toASN1Object()
Encodes this
IvParameterSpec object as an
ASN1Object. |
java.lang.String |
toString()
Creates a text representation of the ASN.1 structure of this
IvParameterSpec object. |
public IvParameterSpec()
It creates a new IvParameterSpec object with a default
initialization vector (IV), an empty or all-zero 8-byte IV.
public IvParameterSpec(byte[] iv)
IvParameterSpec object with the specified
component.
The supplied byte array is copied, and used as the initialization vector (IV).
iv - a byte array containing the initialization vectorjava.lang.IllegalArgumentException - thrown if the byte array is nullpublic IvParameterSpec(byte[] iv,
int offset,
int length)
IvParameterSpec object with the specified
component.
The initialization vector (IV) is copied from the supplied byte array starting at the indicated offset.
iv - a byte array containing the initialization vectoroffset - the offset in the byte array where the initialization vector beginslength - the length of initialization vectorjava.lang.IllegalArgumentException - thrown if the byte array is nulljava.lang.ArrayIndexOutOfBoundsException - thrown if an initialization vector of the specified size could not be
extracted from the byte arrayjava.lang.NegativeArraySizeException - thrown if length is negativepublic IvParameterSpec(ASN1Object obj) throws CodingException
IvParameterSpec object from an
ASN1Object.
The ASN1Object must be a IVParameter structure.
obj - the ASN.1 representation of a IVParameter structureCodingException - thrown if an errors occurs while decoding the ANS1Objectpublic byte[] getIV()
getIV in class javax.crypto.spec.IvParameterSpecpublic void setIV(byte[] iv,
int offset,
int length)
iv - a byte array containing the initialization vectoroffset - the offset in the byte array where the initialization vector beginslength - the length of initialization vectorjava.lang.IllegalArgumentException - thrown if the byte array is nulljava.lang.ArrayIndexOutOfBoundsException - thrown if an initialization vector of the specified size could not be
extracted from the byte arrayjava.lang.NegativeArraySizeException - thrown if length is negativepublic void decode(ASN1Object obj) throws CodingException
IvParameterSpec object from an
ASN1Object.
The ASN1Object must be a IVParameter structure.
decode in interface ASN1Typeobj - an ASN.1 representation of an IVParameter structureCodingException - thrown if an errors occurs while decoding the ANS1Objectpublic ASN1Object toASN1Object()
IvParameterSpec object as an
ASN1Object.
toASN1Object in interface ASN1Typepublic java.lang.String toString()
IvParameterSpec object.
toString in class java.lang.Object