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.picnic.PicnicParameters;
22  import org.bouncycastle.pqc.jcajce.spec.PicnicParameterSpec;
23  
24  /**
25   * PICNIC KeySpec.
26   */
27  public enum GordianPicnicSpec {
28      /**
29       * l1fs.
30       */
31      L1FS,
32  
33      /**
34       * l1ur.
35       */
36      L1UR,
37  
38      /**
39       * l1full.
40       */
41      L1FULL,
42  
43      /**
44       * 3l1.
45       */
46      L13,
47  
48      /**
49       * l3fs.
50       */
51      L3FS,
52  
53      /**
54       * l3ur.
55       */
56      L3UR,
57  
58      /**
59       * l3full.
60       */
61      L3FULL,
62  
63      /**
64       * 3l3.
65       */
66      L33,
67  
68      /**
69       * l5fs.
70       */
71      L5FS,
72  
73      /**
74       * l5ur.
75       */
76      L5UR,
77  
78      /**
79       * l5full.
80       */
81      L5FULL,
82  
83      /**
84       * 3L5.
85       */
86      L53;
87  
88      /**
89       * Obtain SABER Parameters.
90       *
91       * @return the parameters.
92       */
93      public PicnicParameters getParameters() {
94          switch (this) {
95              case L1UR:
96                  return PicnicParameters.picnicl1ur;
97              case L1FS:
98                  return PicnicParameters.picnicl1fs;
99              case L1FULL:
100                 return PicnicParameters.picnicl1full;
101             case L13:
102                 return PicnicParameters.picnic3l1;
103             case L3UR:
104                 return PicnicParameters.picnicl3ur;
105             case L3FS:
106                 return PicnicParameters.picnicl3fs;
107             case L3FULL:
108                 return PicnicParameters.picnicl3full;
109             case L33:
110                 return PicnicParameters.picnic3l3;
111             case L5UR:
112                 return PicnicParameters.picnicl5ur;
113             case L5FS:
114                 return PicnicParameters.picnicl5fs;
115             case L5FULL:
116                 return PicnicParameters.picnicl5full;
117             case L53:
118                 return PicnicParameters.picnic3l5;
119             default:
120                 throw new IllegalArgumentException();
121         }
122     }
123 
124     /**
125      * Obtain SABER ParameterSpec.
126      *
127      * @return the parameters.
128      */
129     public PicnicParameterSpec getParameterSpec() {
130         switch (this) {
131             case L1UR:
132                 return PicnicParameterSpec.picnicl1ur;
133             case L1FS:
134                 return PicnicParameterSpec.picnicl1fs;
135             case L1FULL:
136                 return PicnicParameterSpec.picnicl1full;
137             case L13:
138                 return PicnicParameterSpec.picnic3l1;
139             case L3UR:
140                 return PicnicParameterSpec.picnicl3ur;
141             case L3FS:
142                 return PicnicParameterSpec.picnicl3fs;
143             case L3FULL:
144                 return PicnicParameterSpec.picnicl3full;
145             case L33:
146                 return PicnicParameterSpec.picnic3l3;
147             case L5UR:
148                 return PicnicParameterSpec.picnicl5ur;
149             case L5FS:
150                 return PicnicParameterSpec.picnicl5fs;
151             case L5FULL:
152                 return PicnicParameterSpec.picnicl5full;
153             case L53:
154                 return PicnicParameterSpec.picnic3l5;
155             default:
156                 throw new IllegalArgumentException();
157         }
158     }
159 
160     /**
161      * Obtain Picnic algorithm Identifier.
162      *
163      * @return the identifier.
164      */
165     public ASN1ObjectIdentifier getIdentifier() {
166         switch (this) {
167             case L1UR:
168                 return BCObjectIdentifiers.picnicl1ur;
169             case L1FS:
170                 return BCObjectIdentifiers.picnicl1fs;
171             case L1FULL:
172                 return BCObjectIdentifiers.picnicl1full;
173             case L13:
174                 return BCObjectIdentifiers.picnic3l1;
175             case L3UR:
176                 return BCObjectIdentifiers.picnicl3ur;
177             case L3FS:
178                 return BCObjectIdentifiers.picnicl3fs;
179             case L3FULL:
180                 return BCObjectIdentifiers.picnicl3full;
181             case L33:
182                 return BCObjectIdentifiers.picnic3l3;
183             case L5UR:
184                 return BCObjectIdentifiers.picnicl5ur;
185             case L5FS:
186                 return BCObjectIdentifiers.picnicl5fs;
187             case L5FULL:
188                 return BCObjectIdentifiers.picnicl5full;
189             case L53:
190                 return BCObjectIdentifiers.picnic3l5;
191             default:
192                 throw new IllegalArgumentException();
193         }
194     }
195 }