1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-17 00:54:50 +02:00
pgpainless/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevocationCertificateTest.java
Paul Schaub 68575f9f1e
Reorganize classes in packages
Move ArmorUtils to org.pgpainless.ascii_armor
Move Armored*StreamFactory to org.pgpainless.ascii_armor
Move CRCingArmoredInputStreamWrapper to org.pgpainless.ascii_armor
Move SessionKey to org.pgpainless.s2k
Move RevocationAttributes to org.pgpainless.key
Move UserId to org.pgpainless.key
Move Passphrase to org.pgpainless.s2k
Move NotationRegistry to org.pgpainless.policy
2022-09-07 13:35:58 +02:00

47 lines
1.8 KiB
Java

// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.key.modification;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSignature;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.protection.SecretKeyRingProtector;
import org.pgpainless.key.util.KeyRingUtils;
import org.pgpainless.key.RevocationAttributes;
public class RevocationCertificateTest {
@Test
public void createRevocationCertificateTest() throws PGPException, IOException {
PGPSecretKeyRing secretKeys = TestKeys.getEmilSecretKeyRing();
PGPSignature revocation = PGPainless.modifyKeyRing(secretKeys)
.createRevocationCertificate(SecretKeyRingProtector.unprotectedKeys(),
RevocationAttributes.createKeyRevocation()
.withReason(RevocationAttributes.Reason.KEY_RETIRED)
.withoutDescription());
assertNotNull(revocation);
assertTrue(PGPainless.inspectKeyRing(secretKeys).isKeyValidlyBound(secretKeys.getPublicKey().getKeyID()));
// merge key and revocation certificate
PGPSecretKeyRing revokedKey = KeyRingUtils.keysPlusSecretKey(
secretKeys,
KeyRingUtils.secretKeyPlusSignature(secretKeys.getSecretKey(), revocation));
assertFalse(PGPainless.inspectKeyRing(revokedKey).isKeyValidlyBound(secretKeys.getPublicKey().getKeyID()));
}
}