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.mac;
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.GordianKeyGenerator;
23  
24  import java.util.List;
25  import java.util.function.Predicate;
26  
27  /**
28   * Mac factory.
29   */
30  public interface GordianMacFactory {
31      /**
32       * obtain GordianKeyGenerator for MacSpec.
33       *
34       * @param <T>      the keyType
35       * @param pKeyType the KeyType
36       * @return the new KeyGenerator
37       * @throws GordianException on error
38       */
39      <T extends GordianKeySpec> GordianKeyGenerator<T> getKeyGenerator(T pKeyType) throws GordianException;
40  
41      /**
42       * create GordianMac.
43       *
44       * @param pMacSpec the MacSpec
45       * @return the new MAC
46       * @throws GordianException on error
47       */
48      GordianMac createMac(GordianMacSpec pMacSpec) throws GordianException;
49  
50      /**
51       * Obtain predicate for supported macSpecs.
52       *
53       * @return the predicate
54       */
55      Predicate<GordianMacSpec> supportedMacSpecs();
56  
57      /**
58       * Obtain predicate for supported macTypes.
59       *
60       * @return the predicate
61       */
62      Predicate<GordianMacType> supportedMacTypes();
63  
64      /**
65       * Obtain a list of supported macSpecs for a keyLength.
66       *
67       * @param pKeyLen the keyLength
68       * @return the list of supported macSpecs.
69       */
70      List<GordianMacSpec> listAllSupportedSpecs(GordianLength pKeyLen);
71  }