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:
parent
ba47194cb7
commit
c3c8ce8193
1 changed files with 13 additions and 0 deletions
|
|
@ -12,9 +12,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.bouncycastle.bcpg.KeyIdentifier;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
|
import org.bouncycastle.openpgp.PGPSignature;
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
@ -44,6 +46,17 @@ public class GenerateKeyTest {
|
||||||
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing()
|
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing()
|
||||||
.secretKeyRing(bytes);
|
.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)
|
assertTrue(PGPainless.inspectKeyRing(secretKeys)
|
||||||
.isUserIdValid("Alice <alice@pgpainless.org>"));
|
.isUserIdValid("Alice <alice@pgpainless.org>"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue