Rename LibrePGP features

This commit is contained in:
Paul Schaub 2024-01-24 11:25:24 +01:00
parent ce51f4b8cc
commit acd7f15744
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
3 changed files with 26 additions and 18 deletions

View File

@ -7,7 +7,10 @@ package org.pgpainless.algorithm
/**
* An enumeration of features that may be set in the feature subpacket.
*
* See [RFC4880: Features](https://tools.ietf.org/html/rfc4880#section-5.2.3.24)
* See [RFC4880: Features](https://tools.ietf.org/html/rfc4880#section-5.2.3.24) See
* [crypto-refresh: Features](https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-features)
* See
* [LibrePGP: Features](https://www.ietf.org/archive/id/draft-koch-librepgp-00.html#name-features)
*/
enum class Feature(val featureId: Byte) {
@ -17,39 +20,44 @@ enum class Feature(val featureId: Byte) {
*
* See
* [RFC-4880 §5.14: Modification Detection Code Packet](https://tools.ietf.org/html/rfc4880#section-5.14)
* See
* [Crypto-Refresh: Features](https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-features)
*/
MODIFICATION_DETECTION(0x01),
/**
* Support for Authenticated Encryption with Additional Data (AEAD). If a key announces this
* feature, it signals support for consuming AEAD Encrypted Data Packets.
* Support for OCB Encrypted Data (AEAD) as defined in LibrePGP (NON-STANDARD!) If a key
* announces this feature, it signals support for consuming OCB Encrypted Data Packets.
*
* NOTE: PGPAINLESS DOES NOT YET SUPPORT THIS FEATURE!!! NOTE: This value is currently RESERVED.
*
* See
* [AEAD Encrypted Data Packet](https://openpgp-wg.gitlab.io/rfc4880bis/#name-aead-encrypted-data-packet-)
* [LibrePGP: OCB Encrypted Data Packet](https://www.ietf.org/archive/id/draft-koch-librepgp-00.html#name-features)
*/
GNUPG_AEAD_ENCRYPTED_DATA(0x02),
LIBREPGP_OCB_ENCRYPTED_DATA(0x02),
/**
* If a key announces this feature, it is a version 5 public key. The version 5 format is
* similar to the version 4 format except for the addition of a count for the key material. This
* count helps to parse secret key packets (which are an extension of the public key packet
* format) in the case of an unknown algorithm. In addition, fingerprints of version 5 keys are
* calculated differently from version 4 keys.
* If a key announces this feature, it is a version 5 public key as defined in LibrePGP
* (NON-STANDARD!). The version 5 format is similar to the version 4 format except for the
* addition of a count for the key material. This count helps to parse secret key packets (which
* are an extension of the public key packet format) in the case of an unknown algorithm. In
* addition, fingerprints of version 5 keys are calculated differently from version 4 keys.
*
* NOTE: PGPAINLESS DOES NOT YET SUPPORT THIS FEATURE!!! NOTE: This value is currently RESERVED.
*
* See
* [Public-Key Packet Formats](https://openpgp-wg.gitlab.io/rfc4880bis/#name-public-key-packet-formats)
* [LibrePGP: Version 5 Public-Key Format](https://www.ietf.org/archive/id/draft-koch-librepgp-00.html#name-features)
*/
GNUPG_VERSION_5_PUBLIC_KEY(0x04),
LIBREPGP_VERSION_5_PUBLIC_KEY(0x04),
/**
* Support for Symmetrically Encrypted Integrity Protected Data packet version 2.
* Support for Symmetrically Encrypted Integrity Protected Data packet version 2. This packet
* protects data using AEAD encryption as defined in crypto-refresh.
*
* See
* [crypto-refresh-06 §5.13.2. Version 2 Sym. Encrypted Integrity Protected Data Packet Format](https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-06.html#version-two-seipd)
* See
* [crypto-refresh: Features](https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-features)
*/
MODIFICATION_DETECTION_2(0x08),
;

View File

@ -140,7 +140,7 @@ public class SignatureSubpacketsUtilTest {
PGPSignatureGenerator generator = getSignatureGenerator(certKey, SignatureType.CASUAL_CERTIFICATION);
PGPSignatureSubpacketGenerator hashed = new PGPSignatureSubpacketGenerator();
hashed.setFeature(true, Feature.toBitmask(Feature.MODIFICATION_DETECTION, Feature.GNUPG_AEAD_ENCRYPTED_DATA));
hashed.setFeature(true, Feature.toBitmask(Feature.MODIFICATION_DETECTION, Feature.LIBREPGP_OCB_ENCRYPTED_DATA));
generator.setHashedSubpackets(hashed.generate());
PGPSignature signature = generator.generateCertification(secretKeys.getPublicKey());
@ -148,8 +148,8 @@ public class SignatureSubpacketsUtilTest {
assertNotNull(featureSet);
assertEquals(2, featureSet.size());
assertTrue(featureSet.contains(Feature.MODIFICATION_DETECTION));
assertTrue(featureSet.contains(Feature.GNUPG_AEAD_ENCRYPTED_DATA));
assertFalse(featureSet.contains(Feature.GNUPG_VERSION_5_PUBLIC_KEY));
assertTrue(featureSet.contains(Feature.LIBREPGP_OCB_ENCRYPTED_DATA));
assertFalse(featureSet.contains(Feature.LIBREPGP_VERSION_5_PUBLIC_KEY));
}
@Test

View File

@ -388,7 +388,7 @@ public class SignatureSubpacketsTest {
@Test
public void testSetFeatures() {
wrapper.setFeatures(Feature.MODIFICATION_DETECTION, Feature.GNUPG_AEAD_ENCRYPTED_DATA);
wrapper.setFeatures(Feature.MODIFICATION_DETECTION, Feature.LIBREPGP_OCB_ENCRYPTED_DATA);
PGPSignatureSubpacketVector vector = SignatureSubpacketsHelper.toVector(wrapper);
Features features = vector.getFeatures();
@ -476,7 +476,7 @@ public class SignatureSubpacketsTest {
subpackets.setKeyFlags(true, KeyFlag.toBitmask(KeyFlag.SIGN_DATA, KeyFlag.CERTIFY_OTHER));
subpackets.addSignerUserID(false, "alice@test.test");
subpackets.setRevocationReason(true, RevocationAttributes.Reason.KEY_RETIRED.code(), "Key was retired.");
subpackets.setFeature(true, Feature.toBitmask(Feature.MODIFICATION_DETECTION, Feature.GNUPG_AEAD_ENCRYPTED_DATA));
subpackets.setFeature(true, Feature.toBitmask(Feature.MODIFICATION_DETECTION, Feature.LIBREPGP_OCB_ENCRYPTED_DATA));
byte[] hash = new byte[128];
new Random().nextBytes(hash);
subpackets.setSignatureTarget(false, publicKeys.getPublicKey().getAlgorithm(), HashAlgorithm.SHA512.getAlgorithmId(), hash);