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 import io.github.tonywasher.joceanus.gordianknot.api.mac.spec.GordianMacSpec;
24 import io.github.tonywasher.joceanus.gordianknot.api.mac.spec.GordianMacSpecBuilder;
25 import io.github.tonywasher.joceanus.gordianknot.api.mac.spec.GordianMacType;
26
27 import java.util.List;
28 import java.util.function.Predicate;
29
30 /**
31 * Mac factory.
32 */
33 public interface GordianMacFactory {
34 /**
35 * obtain GordianKeyGenerator for MacSpec.
36 *
37 * @param <T> the keyType
38 * @param pKeyType the KeyType
39 * @return the new KeyGenerator
40 * @throws GordianException on error
41 */
42 <T extends GordianKeySpec> GordianKeyGenerator<T> getKeyGenerator(T pKeyType) throws GordianException;
43
44 /**
45 * create GordianMac.
46 *
47 * @param pMacSpec the MacSpec
48 * @return the new MAC
49 * @throws GordianException on error
50 */
51 GordianMac createMac(GordianMacSpec pMacSpec) throws GordianException;
52
53 /**
54 * create new GordianMacSpecBuilder.
55 *
56 * @return the new MacSpecBuilder
57 */
58 GordianMacSpecBuilder newMacSpecBuilder();
59
60 /**
61 * create new GordianMacParamsBuilder.
62 *
63 * @return the new MacParamsBuilder
64 */
65 GordianMacParamsBuilder newMacParamsBuilder();
66
67 /**
68 * Obtain predicate for supported macSpecs.
69 *
70 * @return the predicate
71 */
72 Predicate<GordianMacSpec> supportedMacSpecs();
73
74 /**
75 * Obtain predicate for supported macTypes.
76 *
77 * @return the predicate
78 */
79 Predicate<GordianMacType> supportedMacTypes();
80
81 /**
82 * Obtain a list of supported macSpecs for a keyLength.
83 *
84 * @param pKeyLen the keyLength
85 * @return the list of supported macSpecs.
86 */
87 List<GordianMacSpec> listAllSupportedSpecs(GordianLength pKeyLen);
88 }