1 /*
2 * Copyright 2024–2026 Michael Osipov
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.michaelo.tomcat.pac;
17
18 import java.security.Key;
19 import java.security.SignatureException;
20
21 /**
22 * An interface for pluggable PAC signature verifier implementations for {@link PacSignatureData}.
23 *
24 * <p>The specification of Kerberos checksum (calculation) is available at
25 *
26 * <ul>
27 * <li><a href="https://datatracker.ietf.org/doc/html/rfc4120#section-4">RFC 4120, section 4</a>
28 * <li><a href="https://www.rfc-editor.org/rfc/rfc4757.html#section-4">RFC 4757, section 4</a>
29 * <li><a href="https://datatracker.ietf.org/doc/html/rfc3961">RFC 3961</a>
30 * <li><a href="https://www.rfc-editor.org/rfc/rfc3962.html">RFC 9362</a>
31 * </ul>
32 */
33 public interface PacSignatureVerifier {
34
35 /* Key usage as per:
36 * - https://github.com/krb5/krb5-assignments/blob/master/key-usage
37 * - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-pac/a194aa34-81bd-46a0-a931-2e05b87d1098
38 */
39 int KU_KERB_NON_KERB_CKSUM_SALT = 17;
40
41 /**
42 * Verifies the signature on the supplied data with an array of suitable Kerberos keys.
43 *
44 * @param signatureData the PAC signature data to be verified
45 * @param data the data to be verififed
46 * @param keys an array of keys to calculate the signature
47 * @throws NullPointerException if any argument is null
48 * @throws IllegalArgumentException if any array is empty
49 * @throws IllegalArgumentException if no key algorithm matches the {@link PacSignatureData.SignatureType#getEType()
50 * signature encryption type}
51 * @throws SignatureException if signature cannot be verified
52 */
53 void verify(PacSignatureData signatureData, byte[] data, Key[] keys) throws SignatureException;
54 }