1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package io.github.tonywasher.joceanus.gordianknot.impl.ext.params;
19
20 import org.bouncycastle.crypto.params.SkeinParameters;
21
22 import java.util.Date;
23 import java.util.Enumeration;
24 import java.util.Hashtable;
25 import java.util.Locale;
26
27
28
29
30 public class GordianSkeinParameters
31 extends SkeinParameters {
32
33
34
35 private long theMaxXofLen;
36
37
38
39
40 private short theFanOut;
41
42
43
44
45 private short theMaxDepth;
46
47
48
49
50 private int theLeafLen;
51
52
53
54
55
56
57 public long getMaxOutputLength() {
58 return theMaxXofLen;
59 }
60
61
62
63
64
65
66 public int getTreeLeafLen() {
67 return theLeafLen;
68 }
69
70
71
72
73
74
75 public short getTreeFanOut() {
76 return theFanOut;
77 }
78
79
80
81
82
83
84 public short getTreeMaxDepth() {
85 return theMaxDepth;
86 }
87
88
89
90
91 public static class GordianSkeinParametersBuilder
92 extends SkeinParameters.Builder {
93
94
95
96 private long theMaxXofLen;
97
98
99
100
101 private short theFanOut;
102
103
104
105
106 private short theMaxDepth;
107
108
109
110
111 private int theLeafLen;
112
113 @Override
114 public GordianSkeinParametersBuilder set(final int type,
115 final byte[] value) {
116 return (GordianSkeinParametersBuilder) super.set(type, value);
117 }
118
119 @Override
120 public GordianSkeinParametersBuilder setKey(final byte[] key) {
121 return (GordianSkeinParametersBuilder) super.setKey(key);
122 }
123
124 @Override
125 public GordianSkeinParametersBuilder setPersonalisation(final byte[] personalisation) {
126 return (GordianSkeinParametersBuilder) super.setPersonalisation(personalisation);
127 }
128
129 @Override
130 public GordianSkeinParametersBuilder setPersonalisation(final Date date,
131 final String emailAddress,
132 final String distinguisher) {
133 return (GordianSkeinParametersBuilder) super.setPersonalisation(date, emailAddress, distinguisher);
134 }
135
136 @Override
137 public GordianSkeinParametersBuilder setPersonalisation(final Date date,
138 final Locale dateLocale,
139 final String emailAddress,
140 final String distinguisher) {
141 return (GordianSkeinParametersBuilder) super.setPersonalisation(date, dateLocale, emailAddress, distinguisher);
142 }
143
144 @Override
145 public GordianSkeinParametersBuilder setPublicKey(final byte[] publicKey) {
146 return (GordianSkeinParametersBuilder) super.setPublicKey(publicKey);
147 }
148
149 @Override
150 public GordianSkeinParametersBuilder setKeyIdentifier(final byte[] keyId) {
151 return (GordianSkeinParametersBuilder) super.setKeyIdentifier(keyId);
152 }
153
154 @Override
155 public GordianSkeinParametersBuilder setNonce(final byte[] nonce) {
156 return (GordianSkeinParametersBuilder) super.setNonce(nonce);
157 }
158
159
160
161
162
163
164
165 public GordianSkeinParametersBuilder setMaxOutputLen(final long pMaxOutLen) {
166 theMaxXofLen = pMaxOutLen;
167 return this;
168 }
169
170
171
172
173
174
175
176
177
178 public GordianSkeinParametersBuilder setTreeConfig(final int pFanOut,
179 final int pMaxDepth,
180 final int pLeafLen) {
181 theFanOut = (short) pFanOut;
182 theMaxDepth = (short) pMaxDepth;
183 theLeafLen = pLeafLen;
184 return this;
185 }
186
187 @Override
188 @SuppressWarnings("unchecked")
189 public GordianSkeinParameters build() {
190
191 final SkeinParameters myBaseParms = super.build();
192 final GordianSkeinParameters myParams = new GordianSkeinParameters();
193
194
195 final Hashtable<Integer, Object> myBaseStore = myBaseParms.getParameters();
196 final Hashtable<Integer, Object> myStore = myParams.getParameters();
197 final Enumeration<Integer> keys = myBaseStore.keys();
198 while (keys.hasMoreElements()) {
199 final Integer key = keys.nextElement();
200 myStore.put(key, myBaseStore.get(key));
201 }
202
203
204 myParams.theMaxXofLen = theMaxXofLen;
205
206
207 myParams.theFanOut = theFanOut;
208 myParams.theMaxDepth = theMaxDepth;
209 myParams.theLeafLen = theLeafLen;
210 return myParams;
211 }
212 }
213 }