FileDocCategorySizeDatePackage
IvParameterSpec.javaAPI DocAndroid 1.5 API3351Wed May 06 22:41:02 BST 2009javax.crypto.spec

IvParameterSpec

public class IvParameterSpec extends Object implements AlgorithmParameterSpec
The algorithm parameter specification for an initialization vector.

Fields Summary
private final byte[]
iv
Constructors Summary
public IvParameterSpec(byte[] iv)
Creates a new IvParameterSpec instance with the bytes from the specified buffer iv used as initialization vector.

param
iv the buffer used as initialization vector.
throws
NullPointerException if the specified buffer is null.

        if (iv == null) {
            throw new NullPointerException(Messages.getString("crypto.38")); //$NON-NLS-1$
        }
        this.iv = new byte[iv.length];
        System.arraycopy(iv, 0, this.iv, 0, iv.length);
    
public IvParameterSpec(byte[] iv, int offset, int len)
Creates a new IvParameterSpec instance with len bytes from the specified buffer iv starting at offset.

param
iv the buffer used as initialization vector.
param
offset the offset to start in the buffer.
param
len the length of the data.
throws
IllegalArgumentException if the specified buffer is null or offset and len do not specify a valid chunk in the specified buffer.
throws
ArrayIndexOutOfBoundsException if offset or len are negative.

        if ((iv == null) || (iv.length - offset < len)) {
            throw new IllegalArgumentException(
                    Messages.getString("crypto.39")); //$NON-NLS-1$
        }
        if (offset < 0 || len < 0) {
            throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.3A")); //$NON-NLS-1$
        }
        this.iv = new byte[len];
        System.arraycopy(iv, offset, this.iv, 0, len);
    
Methods Summary
public byte[]getIV()
Returns a copy of the initialization vector data.

return
a copy of the initialization vector data.

        byte[] res = new byte[iv.length];
        System.arraycopy(iv, 0, res, 0, iv.length);
        return res;