View Javadoc
1   /*
2    * GordianKnot: Security Suite
3    * Copyright 2012-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  package io.github.tonywasher.joceanus.gordianknot.api.keypair;
18  
19  import org.bouncycastle.asn1.ASN1ObjectIdentifier;
20  import org.bouncycastle.asn1.bc.BCObjectIdentifiers;
21  import org.bouncycastle.pqc.crypto.frodo.FrodoParameters;
22  import org.bouncycastle.pqc.jcajce.spec.FrodoParameterSpec;
23  
24  /**
25   * FRODO KeySpecs.
26   */
27  public enum GordianFRODOSpec {
28      /**
29       * AES 640.
30       */
31      AES640,
32  
33      /**
34       * SHAKE 640.
35       */
36      SHAKE640,
37  
38      /**
39       * AES 976.
40       */
41      AES976,
42  
43      /**
44       * SHAKE 976.
45       */
46      SHAKE976,
47  
48      /**
49       * AES 1344.
50       */
51      AES1344,
52  
53      /**
54       * SHAKE 1344.
55       */
56      SHAKE1344;
57  
58      /**
59       * Obtain Frodo Parameters.
60       *
61       * @return the parameters.
62       */
63      public FrodoParameters getParameters() {
64          switch (this) {
65              case AES640:
66                  return FrodoParameters.frodokem640aes;
67              case SHAKE640:
68                  return FrodoParameters.frodokem640shake;
69              case AES976:
70                  return FrodoParameters.frodokem976aes;
71              case SHAKE976:
72                  return FrodoParameters.frodokem976shake;
73              case AES1344:
74                  return FrodoParameters.frodokem1344aes;
75              case SHAKE1344:
76                  return FrodoParameters.frodokem1344shake;
77              default:
78                  throw new IllegalArgumentException();
79          }
80      }
81  
82      /**
83       * Obtain Frodo ParameterSpec.
84       *
85       * @return the parameters.
86       */
87      public FrodoParameterSpec getParameterSpec() {
88          switch (this) {
89              case AES640:
90                  return FrodoParameterSpec.frodokem640aes;
91              case SHAKE640:
92                  return FrodoParameterSpec.frodokem640shake;
93              case AES976:
94                  return FrodoParameterSpec.frodokem976aes;
95              case SHAKE976:
96                  return FrodoParameterSpec.frodokem976shake;
97              case AES1344:
98                  return FrodoParameterSpec.frodokem1344aes;
99              case SHAKE1344:
100                 return FrodoParameterSpec.frodokem1344shake;
101             default:
102                 throw new IllegalArgumentException();
103         }
104     }
105 
106     /**
107      * Obtain Frodo algorithm Identifier.
108      *
109      * @return the identifier.
110      */
111     public ASN1ObjectIdentifier getIdentifier() {
112         switch (this) {
113             case AES640:
114                 return BCObjectIdentifiers.frodokem640aes;
115             case SHAKE640:
116                 return BCObjectIdentifiers.frodokem640shake;
117             case AES976:
118                 return BCObjectIdentifiers.frodokem976aes;
119             case SHAKE976:
120                 return BCObjectIdentifiers.frodokem976shake;
121             case AES1344:
122                 return BCObjectIdentifiers.frodokem1344aes;
123             case SHAKE1344:
124                 return BCObjectIdentifiers.frodokem1344shake;
125             default:
126                 throw new IllegalArgumentException();
127         }
128     }
129 }