1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-05 03:41:07 +01:00

Add test for subkey binding signature issuer info

This commit is contained in:
Paul Schaub 2025-10-13 14:46:31 +02:00
parent ba47194cb7
commit c3c8ce8193
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -12,9 +12,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.bcpg.KeyIdentifier;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.api.OpenPGPKey;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -44,6 +46,17 @@ public class GenerateKeyTest {
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing()
.secretKeyRing(bytes);
for (PGPSecretKey subkey : secretKeys) {
if (subkey.isMasterKey()) {
continue;
}
PGPSignature binding = subkey.getPublicKey().getKeySignatures().next();
for (KeyIdentifier issuer : binding.getKeyIdentifiers()) {
assertTrue(issuer.matchesExplicit(secretKeys.getPublicKey().getKeyIdentifier()),
"Subkey signature MUST be issued by primary key.");
}
}
assertTrue(PGPainless.inspectKeyRing(secretKeys)
.isUserIdValid("Alice <alice@pgpainless.org>"));
}