001// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org> 002// 003// SPDX-License-Identifier: Apache-2.0 004 005package org.pgpainless.decryption_verification; 006 007import javax.annotation.Nonnull; 008import javax.annotation.Nullable; 009 010import org.bouncycastle.openpgp.PGPPublicKeyRing; 011 012public interface MissingPublicKeyCallback { 013 014 /** 015 * This method gets called if we encounter a signature made by a key which was not provided for signature verification. 016 * If you cannot provide the requested key, it is safe to return null here. 017 * PGPainless will then continue verification with the next signature. 018 * 019 * Note: The key-id might belong to a subkey, so be aware that when looking up the {@link PGPPublicKeyRing}, 020 * you may not only search for the key-id on the key rings primary key! 021 * 022 * It would be super cool to provide the OpenPgp fingerprint here, but unfortunately one-pass-signatures 023 * only contain the key id (see https://datatracker.ietf.org/doc/html/rfc4880#section-5.4) 024 * 025 * @param keyId ID of the missing signing (sub)key 026 * 027 * @return keyring containing the key or null 028 */ 029 @Nullable PGPPublicKeyRing onMissingPublicKeyEncountered(@Nonnull Long keyId); 030 031}