01: package org.bouncycastle.jce.spec;
02:
03: import java.security.spec.AlgorithmParameterSpec;
04:
05: import org.bouncycastle.crypto.engines.GOST28147Engine;
06:
07: /**
08: * A parameter spec for the GOST-28147 cipher.
09: */
10: public class GOST28147ParameterSpec implements AlgorithmParameterSpec {
11: private byte[] iv = null;
12: private byte[] sBox = null;
13:
14: public GOST28147ParameterSpec(byte[] sBox) {
15: this .sBox = new byte[sBox.length];
16:
17: System.arraycopy(sBox, 0, this .sBox, 0, sBox.length);
18: }
19:
20: public GOST28147ParameterSpec(byte[] sBox, byte[] iv) {
21: this (sBox);
22: this .iv = new byte[iv.length];
23:
24: System.arraycopy(iv, 0, this .iv, 0, iv.length);
25: }
26:
27: public GOST28147ParameterSpec(String sBoxName) {
28: this .sBox = GOST28147Engine.getSBox(sBoxName);
29: }
30:
31: public GOST28147ParameterSpec(String sBoxName, byte[] iv) {
32: this (sBoxName);
33: this .iv = new byte[iv.length];
34:
35: System.arraycopy(iv, 0, this .iv, 0, iv.length);
36: }
37:
38: public byte[] getSbox() {
39: return sBox;
40: }
41:
42: /**
43: * Returns the IV or null if this parameter set does not contain an IV.
44: *
45: * @return the IV or null if this parameter set does not contain an IV.
46: */
47: public byte[] getIV() {
48: if (iv == null) {
49: return null;
50: }
51:
52: byte[] tmp = new byte[iv.length];
53:
54: System.arraycopy(iv, 0, tmp, 0, tmp.length);
55:
56: return tmp;
57: }
58: }
|