01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: * NOTE:
27: * Because of various external restrictions (i.e. US export
28: * regulations, etc.), the actual source code can not be provided
29: * at this time. This file represents the skeleton of the source
30: * file, so that javadocs of the API can be created.
31: */
32:
33: package javax.crypto.spec;
34:
35: import com.sun.midp.crypto.Util;
36:
37: import java.security.spec.AlgorithmParameterSpec;
38:
39: /**
40: * This class specifies an <i>initialization vector</i> (IV).
41: * Examples which use IVs are ciphers in feedback mode, e.g., DES in
42: * CBC mode and RSA ciphers with OAEP encoding operation.
43: *
44: *
45: * @version 1.14, 09/13/01
46: * @since 1.4
47: */
48: public class IvParameterSpec implements AlgorithmParameterSpec {
49:
50: /** Initial vector. */
51: private byte[] IV; // initial vector
52:
53: /**
54: * Uses the first <code>len</code> bytes in <code>iv</code>,
55: * beginning at <code>offset</code> inclusive, as the IV.
56: *
57: * <p> The bytes that constitute the IV are those between
58: * <code>iv[offset]</code> and <code>iv[offset+len-1]</code> inclusive.
59: *
60: * @param iv the buffer with the IV
61: * @param offset the offset in <code>iv</code> where the IV
62: * starts
63: * @param len the number of IV bytes
64: */
65: public IvParameterSpec(byte[] iv, int offset, int len) {
66: IV = new byte[len];
67: System.arraycopy(iv, offset, IV, 0, len);
68: }
69:
70: /**
71: * Returns the initialization vector (IV).
72: *
73: * @return the initialization vector (IV)
74: */
75: public byte[] getIV() {
76: return Util.cloneArray(IV);
77: }
78: }
|