1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00

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. * 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) { enum class Feature(val featureId: Byte) {
@ -17,39 +20,44 @@ enum class Feature(val featureId: Byte) {
* *
* See * See
* [RFC-4880 §5.14: Modification Detection Code Packet](https://tools.ietf.org/html/rfc4880#section-5.14) * [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), MODIFICATION_DETECTION(0x01),
/** /**
* Support for Authenticated Encryption with Additional Data (AEAD). If a key announces this * Support for OCB Encrypted Data (AEAD) as defined in LibrePGP (NON-STANDARD!) If a key
* feature, it signals support for consuming AEAD Encrypted Data Packets. * 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. * NOTE: PGPAINLESS DOES NOT YET SUPPORT THIS FEATURE!!! NOTE: This value is currently RESERVED.
* *
* See * 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 * If a key announces this feature, it is a version 5 public key as defined in LibrePGP
* similar to the version 4 format except for the addition of a count for the key material. This * (NON-STANDARD!). The version 5 format is similar to the version 4 format except for the
* count helps to parse secret key packets (which are an extension of the public key packet * addition of a count for the key material. This count helps to parse secret key packets (which
* format) in the case of an unknown algorithm. In addition, fingerprints of version 5 keys are * are an extension of the public key packet format) in the case of an unknown algorithm. In
* calculated differently from version 4 keys. * 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. * NOTE: PGPAINLESS DOES NOT YET SUPPORT THIS FEATURE!!! NOTE: This value is currently RESERVED.
* *
* See * 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 * 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) * [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), MODIFICATION_DETECTION_2(0x08),
; ;

View file

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

View file

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