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.cipher;
18  
19  import io.github.tonywasher.joceanus.gordianknot.api.base.GordianException;
20  import io.github.tonywasher.joceanus.gordianknot.api.base.GordianKeySpec;
21  import io.github.tonywasher.joceanus.gordianknot.api.base.GordianLength;
22  import io.github.tonywasher.joceanus.gordianknot.api.key.GordianKey;
23  import io.github.tonywasher.joceanus.gordianknot.api.key.GordianKeyGenerator;
24  
25  import java.util.List;
26  import java.util.function.Predicate;
27  
28  /**
29   * Cipher factory.
30   */
31  public interface GordianCipherFactory {
32      /**
33       * obtain GordianKeyGenerator for SymKeySpec.
34       *
35       * @param <T>      the key type
36       * @param pKeyType the KeyType
37       * @return the new KeyGenerator
38       * @throws GordianException on error
39       */
40      <T extends GordianKeySpec> GordianKeyGenerator<T> getKeyGenerator(T pKeyType) throws GordianException;
41  
42      /**
43       * create GordianSymCipher.
44       *
45       * @param pCipherSpec the cipherSpec
46       * @return the new Cipher
47       * @throws GordianException on error
48       */
49      GordianSymCipher createSymKeyCipher(GordianSymCipherSpec pCipherSpec) throws GordianException;
50  
51      /**
52       * create GordianStreamCipher.
53       *
54       * @param pCipherSpec the cipherSpec
55       * @return the new Cipher
56       * @throws GordianException on error
57       */
58      GordianStreamCipher createStreamKeyCipher(GordianStreamCipherSpec pCipherSpec) throws GordianException;
59  
60      /**
61       * Obtain predicate for supported symKeySpecs.
62       *
63       * @return the predicate
64       */
65      Predicate<GordianSymKeySpec> supportedSymKeySpecs();
66  
67      /**
68       * Obtain predicate for supported symCipherSpecs.
69       *
70       * @return the predicate
71       */
72      Predicate<GordianSymCipherSpec> supportedSymCipherSpecs();
73  
74      /**
75       * Obtain predicate for supported SymKeyTypes.
76       *
77       * @return the predicate
78       */
79      Predicate<GordianSymKeyType> supportedSymKeyTypes();
80  
81      /**
82       * Obtain predicate for supported streamKeySpecs.
83       *
84       * @return the predicate
85       */
86      Predicate<GordianStreamKeySpec> supportedStreamKeySpecs();
87  
88      /**
89       * Obtain predicate for supported streamCipherSpecs.
90       *
91       * @return the predicate
92       */
93      Predicate<GordianStreamCipherSpec> supportedStreamCipherSpecs();
94  
95      /**
96       * Obtain predicate for supported StreamKeyTypes.
97       *
98       * @return the predicate
99       */
100     Predicate<GordianStreamKeyType> supportedStreamKeyTypes();
101 
102     /**
103      * create GordianWrapper.
104      *
105      * @param pKey the Key
106      * @return the new wrapper
107      * @throws GordianException on error
108      */
109     GordianWrapper createKeyWrapper(GordianKey<GordianSymKeySpec> pKey) throws GordianException;
110 
111     /**
112      * Obtain a list of supported symCipherSpecs.
113      *
114      * @param pSpec the symKeySpec
115      * @return the list of supported symCipherSpecs.
116      */
117     List<GordianSymCipherSpec> listAllSupportedSymCipherSpecs(GordianSymKeySpec pSpec);
118 
119     /**
120      * Obtain a list of supported symKeySpecs for the keyLength.
121      *
122      * @param pKeyLen the keyLength
123      * @return the list of supported symKeySpecs.
124      */
125     List<GordianSymKeySpec> listAllSupportedSymKeySpecs(GordianLength pKeyLen);
126 
127     /**
128      * List all possible symKeySpecs for the keyLength.
129      *
130      * @param pKeyLen the keyLength
131      * @return the list
132      */
133     List<GordianSymKeySpec> listAllSymKeySpecs(GordianLength pKeyLen);
134 
135     /**
136      * Obtain a list of supported symKeyTypes.
137      *
138      * @return the list of supported symKeyTypes.
139      */
140     List<GordianSymKeyType> listAllSupportedSymKeyTypes();
141 
142     /**
143      * Obtain a list of supported streamCipherSpecs for the keyLength.
144      *
145      * @param pKeyLen the keyLength
146      * @return the list of supported streamCipherSpecs.
147      */
148     List<GordianStreamCipherSpec> listAllSupportedStreamCipherSpecs(GordianLength pKeyLen);
149 
150     /**
151      * Obtain a list of supported streamKeySpecs for the keyLength.
152      *
153      * @param pKeyLen the keyLength
154      * @return the list of supported streamKeySpecs.
155      */
156     List<GordianStreamKeySpec> listAllSupportedStreamKeySpecs(GordianLength pKeyLen);
157 
158     /**
159      * Obtain a list of supported streamKeyTypes.
160      *
161      * @return the list of supported streamKeyTypes.
162      */
163     List<GordianStreamKeyType> listAllSupportedStreamKeyTypes();
164 
165     /**
166      * List all possible cipherSpecs for a SymKeySpec.
167      *
168      * @param pSpec the keySpec
169      * @return the list
170      */
171     List<GordianSymCipherSpec> listAllSymCipherSpecs(GordianSymKeySpec pSpec);
172 }