01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexander Y. Kleymenov
19: * @version $Revision$
20: */package javax.crypto.spec;
21:
22: import java.security.spec.AlgorithmParameterSpec;
23:
24: import org.apache.harmony.crypto.internal.nls.Messages;
25:
26: /**
27: * @com.intel.drl.spec_ref
28: */
29: public class IvParameterSpec implements AlgorithmParameterSpec {
30:
31: private final byte[] iv;
32:
33: /**
34: * @com.intel.drl.spec_ref
35: */
36: public IvParameterSpec(byte[] iv) {
37: if (iv == null) {
38: throw new NullPointerException(Messages
39: .getString("crypto.38")); //$NON-NLS-1$
40: }
41: this .iv = new byte[iv.length];
42: System.arraycopy(iv, 0, this .iv, 0, iv.length);
43: }
44:
45: /**
46: * @com.intel.drl.spec_ref
47: */
48: public IvParameterSpec(byte[] iv, int offset, int len) {
49: if ((iv == null) || (iv.length - offset < len)) {
50: throw new IllegalArgumentException(Messages
51: .getString("crypto.39")); //$NON-NLS-1$
52: }
53: if (offset < 0 || len < 0) {
54: throw new ArrayIndexOutOfBoundsException(Messages
55: .getString("crypto.3A")); //$NON-NLS-1$
56: }
57: this .iv = new byte[len];
58: System.arraycopy(iv, offset, this .iv, 0, len);
59: }
60:
61: /**
62: * @com.intel.drl.spec_ref
63: */
64: public byte[] getIV() {
65: byte[] res = new byte[iv.length];
66: System.arraycopy(iv, 0, res, 0, iv.length);
67: return res;
68: }
69: }
|