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.falcon.FalconParameters;
22  import org.bouncycastle.pqc.jcajce.spec.FalconParameterSpec;
23  
24  /**
25   * FALCON KeySpec.
26   */
27  public enum GordianFalconSpec {
28      /**
29       * Falcon 512.
30       */
31      FALCON512,
32  
33      /**
34       * Falcon 1024.
35       */
36      FALCON1024;
37  
38      /**
39       * Obtain FALCON Parameters.
40       *
41       * @return the parameters.
42       */
43      public FalconParameters getParameters() {
44          switch (this) {
45              case FALCON512:
46                  return FalconParameters.falcon_512;
47              case FALCON1024:
48                  return FalconParameters.falcon_1024;
49              default:
50                  throw new IllegalArgumentException();
51          }
52      }
53  
54      /**
55       * Obtain Falcon ParameterSpec.
56       *
57       * @return the parameters.
58       */
59      public FalconParameterSpec getParameterSpec() {
60          switch (this) {
61              case FALCON512:
62                  return FalconParameterSpec.falcon_512;
63              case FALCON1024:
64                  return FalconParameterSpec.falcon_1024;
65              default:
66                  throw new IllegalArgumentException();
67          }
68      }
69  
70      /**
71       * Obtain Falcon algorithm Identifier.
72       *
73       * @return the identifier.
74       */
75      public ASN1ObjectIdentifier getIdentifier() {
76          switch (this) {
77              case FALCON512:
78                  return BCObjectIdentifiers.falcon_512;
79              case FALCON1024:
80                  return BCObjectIdentifiers.falcon_1024;
81              default:
82                  throw new IllegalArgumentException();
83          }
84      }
85  }