View Javadoc
1   /*
2    * GordianKnot: Security Suite
3    * Copyright 2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   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, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  
18  package io.github.tonywasher.joceanus.gordianknot.api.cipher.spec;
19  
20  import io.github.tonywasher.joceanus.gordianknot.api.base.GordianLength;
21  
22  /**
23   * SymKey specification Builder.
24   */
25  public interface GordianSymKeySpecBuilder {
26      /**
27       * Define SymKeyType.
28       *
29       * @param pType the type
30       * @return the Builder
31       */
32      GordianSymKeySpecBuilder withType(GordianSymKeyType pType);
33  
34      /**
35       * Define BlockLength.
36       *
37       * @param pBlockLength the blockLength
38       * @return the Builder
39       */
40      GordianSymKeySpecBuilder withBlockLength(GordianLength pBlockLength);
41  
42      /**
43       * Define KeyLength.
44       *
45       * @param pKeyLength the keyLength
46       * @return the Builder
47       */
48      GordianSymKeySpecBuilder withKeyLength(GordianLength pKeyLength);
49  
50      /**
51       * Build symKeySpec.
52       *
53       * @return the symKeySpec
54       */
55      GordianSymKeySpec build();
56  
57      /**
58       * Create generic.
59       *
60       * @param pKeyType   the keyType
61       * @param pKeyLength the keyLength
62       * @return the keySpec
63       */
64      default GordianSymKeySpec symKey(final GordianSymKeyType pKeyType,
65                                       final GordianLength pKeyLength) {
66          return withType(pKeyType).withKeyLength(pKeyLength).build();
67      }
68  
69      /**
70       * Create generic.
71       *
72       * @param pKeyType     the keyType
73       * @param pBlockLength the blockLength
74       * @param pKeyLength   the keyLength
75       * @return the keySpec
76       */
77      default GordianSymKeySpec symKey(final GordianSymKeyType pKeyType,
78                                       final GordianLength pBlockLength,
79                                       final GordianLength pKeyLength) {
80          return withType(pKeyType).withBlockLength(pBlockLength).withKeyLength(pKeyLength).build();
81      }
82  
83      /**
84       * Create aes.
85       *
86       * @param pKeyLength the keyLength
87       * @return the keySpec
88       */
89      default GordianSymKeySpec aes(final GordianLength pKeyLength) {
90          return withType(GordianSymKeyType.AES).withKeyLength(pKeyLength).build();
91      }
92  
93      /**
94       * Create serpent.
95       *
96       * @param pKeyLength the keyLength
97       * @return the keySpec
98       */
99      default GordianSymKeySpec serpent(final GordianLength pKeyLength) {
100         return withType(GordianSymKeyType.SERPENT).withKeyLength(pKeyLength).build();
101     }
102 
103     /**
104      * Create twoFish.
105      *
106      * @param pKeyLength the keyLength
107      * @return the keySpec
108      */
109     default GordianSymKeySpec twoFish(final GordianLength pKeyLength) {
110         return withType(GordianSymKeyType.TWOFISH).withKeyLength(pKeyLength).build();
111     }
112 
113     /**
114      * Create threeFish.
115      *
116      * @param pKeyLength the keyLength
117      * @return the keySpec
118      */
119     default GordianSymKeySpec threeFish(final GordianLength pKeyLength) {
120         return withType(GordianSymKeyType.THREEFISH).withKeyLength(pKeyLength).build();
121     }
122 
123     /**
124      * Create camellia.
125      *
126      * @param pKeyLength the keyLength
127      * @return the keySpec
128      */
129     default GordianSymKeySpec camellia(final GordianLength pKeyLength) {
130         return withType(GordianSymKeyType.CAMELLIA).withKeyLength(pKeyLength).build();
131     }
132 
133     /**
134      * Create rc2.
135      *
136      * @param pKeyLength the keyLength
137      * @return the keySpec
138      */
139     default GordianSymKeySpec rc2(final GordianLength pKeyLength) {
140         return withType(GordianSymKeyType.RC2).withKeyLength(pKeyLength).build();
141     }
142 
143     /**
144      * Create rc5.
145      *
146      * @return the keySpec
147      */
148     default GordianSymKeySpec rc5() {
149         return withType(GordianSymKeyType.RC5).build();
150     }
151 
152     /**
153      * Create rc5KeySpec.
154      *
155      * @param pBlockLength the blockLength
156      * @return the keySpec
157      */
158     default GordianSymKeySpec rc5(final GordianLength pBlockLength) {
159         return withType(GordianSymKeyType.RC5).withBlockLength(pBlockLength).build();
160     }
161 
162     /**
163      * Create rc6.
164      *
165      * @param pKeyLength the keyLength
166      * @return the keySpec
167      */
168     default GordianSymKeySpec rc6(final GordianLength pKeyLength) {
169         return withType(GordianSymKeyType.RC6).withKeyLength(pKeyLength).build();
170     }
171 
172     /**
173      * Create cast5.
174      *
175      * @return the keySpec
176      */
177     default GordianSymKeySpec cast5() {
178         return withType(GordianSymKeyType.CAST5).build();
179     }
180 
181     /**
182      * Create cast6.
183      *
184      * @param pKeyLength the keyLength
185      * @return the keySpec
186      */
187     default GordianSymKeySpec cast6(final GordianLength pKeyLength) {
188         return withType(GordianSymKeyType.CAST6).withKeyLength(pKeyLength).build();
189     }
190 
191     /**
192      * Create aria.
193      *
194      * @param pKeyLength the keyLength
195      * @return the keySpec
196      */
197     default GordianSymKeySpec aria(final GordianLength pKeyLength) {
198         return withType(GordianSymKeyType.ARIA).withKeyLength(pKeyLength).build();
199     }
200 
201     /**
202      * Create sm4.
203      *
204      * @return the keySpec
205      */
206     default GordianSymKeySpec sm4() {
207         return withType(GordianSymKeyType.SM4).build();
208     }
209 
210     /**
211      * Create noeKeon.
212      *
213      * @return the keySpec
214      */
215     default GordianSymKeySpec noekeon() {
216         return withType(GordianSymKeyType.NOEKEON).build();
217     }
218 
219     /**
220      * Create seed.
221      *
222      * @return the keySpec
223      */
224     default GordianSymKeySpec seed() {
225         return withType(GordianSymKeyType.SEED).build();
226     }
227 
228     /**
229      * Create tea.
230      *
231      * @return the keySpec
232      */
233     default GordianSymKeySpec tea() {
234         return withType(GordianSymKeyType.TEA).build();
235     }
236 
237     /**
238      * Create xtea.
239      *
240      * @return the keySpec
241      */
242     default GordianSymKeySpec xtea() {
243         return withType(GordianSymKeyType.XTEA).build();
244     }
245 
246     /**
247      * Create idea.
248      *
249      * @return the keySpec
250      */
251     default GordianSymKeySpec idea() {
252         return withType(GordianSymKeyType.IDEA).build();
253     }
254 
255     /**
256      * Create skipjack.
257      *
258      * @return the keySpec
259      */
260     default GordianSymKeySpec skipjack() {
261         return withType(GordianSymKeyType.SKIPJACK).build();
262     }
263 
264     /**
265      * Create desede.
266      *
267      * @param pKeyLength the keyLength
268      * @return the keySpec
269      */
270     default GordianSymKeySpec desede(final GordianLength pKeyLength) {
271         return withType(GordianSymKeyType.DESEDE).build();
272     }
273 
274     /**
275      * Create blowfish.
276      *
277      * @param pKeyLength the keyLength
278      * @return the keySpec
279      */
280     default GordianSymKeySpec blowfish(final GordianLength pKeyLength) {
281         return withType(GordianSymKeyType.BLOWFISH).build();
282     }
283 
284     /**
285      * Create kalyna.
286      *
287      * @param pKeyLength the keyLength
288      * @return the keySpec
289      */
290     default GordianSymKeySpec kalyna(final GordianLength pKeyLength) {
291         return withType(GordianSymKeyType.KALYNA).withKeyLength(pKeyLength).build();
292     }
293 
294     /**
295      * Create kalyna.
296      *
297      * @param pBlockLength the block length
298      * @param pKeyLength   the keyLength
299      * @return the keySpec
300      */
301     default GordianSymKeySpec kalyna(final GordianLength pBlockLength,
302                                      final GordianLength pKeyLength) {
303         return withType(GordianSymKeyType.KALYNA).withBlockLength(pBlockLength).withKeyLength(pKeyLength).build();
304     }
305 
306     /**
307      * Create gost.
308      *
309      * @return the keySpec
310      */
311     default GordianSymKeySpec gost() {
312         return withType(GordianSymKeyType.GOST).build();
313     }
314 
315     /**
316      * Create kuznyechik.
317      *
318      * @return the keySpec
319      */
320     default GordianSymKeySpec kuznyechik() {
321         return withType(GordianSymKeyType.KUZNYECHIK).build();
322     }
323 
324     /**
325      * Create shacal2.
326      *
327      * @param pKeyLength the keyLength
328      * @return the keySpec
329      */
330     default GordianSymKeySpec shacal2(final GordianLength pKeyLength) {
331         return withType(GordianSymKeyType.SHACAL2).withKeyLength(pKeyLength).build();
332     }
333 
334     /**
335      * Create speck.
336      *
337      * @param pKeyLength the keyLength
338      * @return the keySpec
339      */
340     default GordianSymKeySpec speck(final GordianLength pKeyLength) {
341         return withType(GordianSymKeyType.SPECK).withKeyLength(pKeyLength).build();
342     }
343 
344     /**
345      * Create simon.
346      *
347      * @param pKeyLength the keyLength
348      * @return the keySpec
349      */
350     default GordianSymKeySpec simon(final GordianLength pKeyLength) {
351         return withType(GordianSymKeyType.SIMON).withKeyLength(pKeyLength).build();
352     }
353 
354     /**
355      * Create mars.
356      *
357      * @param pKeyLength the keyLength
358      * @return the keySpec
359      */
360     default GordianSymKeySpec mars(final GordianLength pKeyLength) {
361         return withType(GordianSymKeyType.MARS).withKeyLength(pKeyLength).build();
362     }
363 
364     /**
365      * Create anubis.
366      *
367      * @param pKeyLength the keyLength
368      * @return the keySpec
369      */
370     default GordianSymKeySpec anubis(final GordianLength pKeyLength) {
371         return withType(GordianSymKeyType.ANUBIS).withKeyLength(pKeyLength).build();
372     }
373 
374     /**
375      * Create lea.
376      *
377      * @param pKeyLength the keyLength
378      * @return the keySpec
379      */
380     default GordianSymKeySpec lea(final GordianLength pKeyLength) {
381         return withType(GordianSymKeyType.LEA).withKeyLength(pKeyLength).build();
382     }
383 }