View Javadoc
1   /*
2    * GordianKnot: Security Suite
3    * Copyright 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  
18  package io.github.tonywasher.joceanus.gordianknot.api.cipher;
19  
20  import io.github.tonywasher.joceanus.gordianknot.api.base.GordianKeySpec;
21  import io.github.tonywasher.joceanus.gordianknot.api.cipher.GordianCipherParams.GordianAEADCipherParameters;
22  import io.github.tonywasher.joceanus.gordianknot.api.cipher.GordianCipherParams.GordianKeyCipherParameters;
23  import io.github.tonywasher.joceanus.gordianknot.api.cipher.GordianCipherParams.GordianPBECipherParameters;
24  import io.github.tonywasher.joceanus.gordianknot.api.cipher.spec.GordianPBESpec;
25  import io.github.tonywasher.joceanus.gordianknot.api.key.GordianKey;
26  
27  /**
28   * Cipher Parameters Builder.
29   */
30  public interface GordianCipherParamsBuilder {
31      /**
32       * Obtain keySpec Parameters.
33       *
34       * @param <T>  the keyType
35       * @param pKey the key
36       * @return the keySpec
37       */
38      <T extends GordianKeySpec> GordianKeyCipherParameters<T> key(GordianKey<T> pKey);
39  
40      /**
41       * Obtain keyAndNonce Parameters.
42       *
43       * @param <T>    the keyType
44       * @param pKey   the key
45       * @param pNonce the nonce
46       * @return the keySpec
47       */
48      <T extends GordianKeySpec> GordianKeyCipherParameters<T> keyAndNonce(GordianKey<T> pKey,
49                                                                           byte[] pNonce);
50  
51      /**
52       * Obtain keyAndRandomNonce Parameters.
53       *
54       * @param <T>  the keyType
55       * @param pKey the key
56       * @return the keySpec
57       */
58      <T extends GordianKeySpec> GordianKeyCipherParameters<T> keyWithRandomNonce(GordianKey<T> pKey);
59  
60      /**
61       * Obtain aeadAndNonce Parameters.
62       *
63       * @param <T>          the keyType
64       * @param pKey         the key
65       * @param pInitialAEAD the initialAEAD
66       * @param pNonce       the nonce
67       * @return the keySpec
68       */
69      <T extends GordianKeySpec> GordianAEADCipherParameters<T> aeadAndNonce(GordianKey<T> pKey,
70                                                                             byte[] pInitialAEAD,
71                                                                             byte[] pNonce);
72  
73      /**
74       * Obtain aeadAndRandomNonce Parameters.
75       *
76       * @param <T>          the keyType
77       * @param pKey         the key
78       * @param pInitialAEAD the initialAEAD
79       * @return the keySpec
80       */
81      <T extends GordianKeySpec> GordianAEADCipherParameters<T> aeadWithRandomNonce(GordianKey<T> pKey,
82                                                                                    byte[] pInitialAEAD);
83  
84      /**
85       * Obtain pbe Parameters.
86       *
87       * @param pPBESpec  the pbeSpec
88       * @param pPassword the password
89       * @return the keySpec
90       */
91      GordianPBECipherParameters pbe(GordianPBESpec pPBESpec,
92                                     char[] pPassword);
93  
94      /**
95       * Obtain pneAndNonce Parameters.
96       *
97       * @param pPBESpec  the pbeSpec
98       * @param pPassword the password
99       * @param pNonce    the nonce
100      * @return the keySpec
101      */
102     GordianPBECipherParameters pbeAndNonce(GordianPBESpec pPBESpec,
103                                            char[] pPassword,
104                                            byte[] pNonce);
105 }