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.mayo.MayoParameters;
22  import org.bouncycastle.pqc.jcajce.spec.MayoParameterSpec;
23  
24  /**
25   * Mayo KeySpec.
26   */
27  public enum GordianMayoSpec {
28      /**
29       * Mayo 1.
30       */
31      MAYO1,
32  
33      /**
34       * Mayo 2.
35       */
36      MAYO2,
37  
38      /**
39       * Mayo 3.
40       */
41      MAYO3,
42  
43      /**
44       * Mayo 5.
45       */
46      MAYO5;
47  
48      /**
49       * Obtain Mayo Parameters.
50       *
51       * @return the parameters.
52       */
53      public MayoParameters getParameters() {
54          switch (this) {
55              case MAYO1:
56                  return MayoParameters.mayo1;
57              case MAYO2:
58                  return MayoParameters.mayo2;
59              case MAYO3:
60                  return MayoParameters.mayo3;
61              case MAYO5:
62                  return MayoParameters.mayo5;
63              default:
64                  throw new IllegalArgumentException();
65          }
66      }
67  
68      /**
69       * Obtain Mayo ParameterSpec.
70       *
71       * @return the parameters.
72       */
73      public MayoParameterSpec getParameterSpec() {
74          switch (this) {
75              case MAYO1:
76                  return MayoParameterSpec.mayo1;
77              case MAYO2:
78                  return MayoParameterSpec.mayo2;
79              case MAYO3:
80                  return MayoParameterSpec.mayo3;
81              case MAYO5:
82                  return MayoParameterSpec.mayo5;
83              default:
84                  throw new IllegalArgumentException();
85          }
86      }
87  
88      /**
89       * Obtain MAYO algorithm Identifier.
90       *
91       * @return the identifier.
92       */
93      public ASN1ObjectIdentifier getIdentifier() {
94          switch (this) {
95              case MAYO1:
96                  return BCObjectIdentifiers.mayo1;
97              case MAYO2:
98                  return BCObjectIdentifiers.mayo2;
99              case MAYO3:
100                 return BCObjectIdentifiers.mayo3;
101             case MAYO5:
102                 return BCObjectIdentifiers.mayo5;
103             default:
104                 throw new IllegalArgumentException();
105         }
106     }
107 }