mirror of
https://codeberg.org/PGPainless/wkd-java.git
synced 2025-12-05 04:41:08 +01:00
Bump dependencies
Bump pgpainless-core to 2.0.0 Bump cert-d-java to 0.2.3 Bump cert-d-pgpainless to 0.2.3
This commit is contained in:
parent
b6643b4543
commit
483efe0412
5 changed files with 45 additions and 42 deletions
|
|
@ -6,6 +6,11 @@ SPDX-License-Identifier: Apache-2.0
|
|||
|
||||
# Changelog
|
||||
|
||||
## 0.1.3-SNAPSHOT
|
||||
- Bump `pgpainless-core` to `2.0.0`
|
||||
- Bump `cert-d-pgpainless` to `0.2.3`
|
||||
- Bump `cert-d-java` to `0.2.3`
|
||||
|
||||
## 0.1.2
|
||||
- Bump `pgpainless-core` to `1.5.6`
|
||||
- Bump `cert-d-pgpainless` to `0.2.2`
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ allprojects {
|
|||
slf4jVersion = '1.7.36'
|
||||
logbackVersion = '1.5.13'
|
||||
mockitoVersion = '4.5.1'
|
||||
pgpainlessVersion = '1.7.7'
|
||||
pgpainlessCertDVersion = '0.2.2'
|
||||
pgpainlessVersion = '2.0.0'
|
||||
pgpainlessCertDVersion = '0.2.3'
|
||||
picocliVersion = '4.6.3'
|
||||
certDJavaVersion = '0.2.2'
|
||||
certDJavaVersion = '0.2.3'
|
||||
zbase32Version = '1.0.0'
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@
|
|||
package pgp.wkd.cli;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.certificate_store.CertificateFactory;
|
||||
import org.pgpainless.key.collection.PGPKeyRingCollection;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import pgp.certificate_store.certificate.Certificate;
|
||||
import pgp.wkd.CertificateAndUserIds;
|
||||
import pgp.wkd.discovery.CertificateParser;
|
||||
|
|
@ -18,20 +17,20 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PGPainlessCertificateParser implements CertificateParser {
|
||||
@Override
|
||||
public List<CertificateAndUserIds> read(InputStream inputStream) throws IOException {
|
||||
List<CertificateAndUserIds> certificatesAndUserIds = new ArrayList<>();
|
||||
try {
|
||||
PGPKeyRingCollection keyMaterial = PGPainless.readKeyRing().keyRingCollection(inputStream, true);
|
||||
if (keyMaterial.getPGPSecretKeyRingCollection().size() != 0) {
|
||||
List<OpenPGPCertificate> keyMaterial = PGPainless.getInstance().readKey().parseKeysOrCertificates(inputStream);
|
||||
if (keyMaterial.stream().anyMatch(it -> it instanceof OpenPGPKey)) {
|
||||
throw new PGPException("Secret key material encountered!");
|
||||
}
|
||||
for (PGPPublicKeyRing certificate : keyMaterial.getPgpPublicKeyRingCollection()) {
|
||||
KeyRingInfo info = PGPainless.inspectKeyRing(certificate);
|
||||
Certificate parsedCert = CertificateFactory.certificateFromPublicKeyRing(certificate, 0L);
|
||||
List<String> userIds = info.getValidAndExpiredUserIds();
|
||||
for (OpenPGPCertificate certificate : keyMaterial) {
|
||||
Certificate parsedCert = CertificateFactory.certificateFromOpenPGPCertificate(certificate, 0L);
|
||||
List<String> userIds = certificate.getValidUserIds().stream().map(OpenPGPCertificate.OpenPGPUserId::getUserId).collect(Collectors.toList());
|
||||
certificatesAndUserIds.add(new CertificateAndUserIds(parsedCert, userIds));
|
||||
}
|
||||
return certificatesAndUserIds;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
|
||||
package pgp.wkd.test_suite;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
||||
import org.pgpainless.PGPainless;
|
||||
import pgp.wkd.discovery.DiscoveryMethod;
|
||||
|
||||
|
|
@ -15,8 +14,6 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class AbstractTestSuiteGenerator {
|
||||
protected final String domain;
|
||||
|
|
@ -37,15 +34,15 @@ public class AbstractTestSuiteGenerator {
|
|||
return structure;
|
||||
}
|
||||
|
||||
protected PGPSecretKeyRing secretKey(String userId) throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing(userId);
|
||||
return secretKeys;
|
||||
protected OpenPGPKey secretKey(String userId) {
|
||||
OpenPGPKey secretKey = PGPainless.getInstance().generateKey().modernKeyRing(userId);
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
protected PGPPublicKeyRing certificate(String userId) throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||
PGPSecretKeyRing secretKeys = secretKey(userId);
|
||||
PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys);
|
||||
return publicKeys;
|
||||
protected OpenPGPCertificate certificate(String userId) {
|
||||
OpenPGPKey secretKeys = secretKey(userId);
|
||||
OpenPGPCertificate certificate = secretKeys.toCertificate();
|
||||
return certificate;
|
||||
}
|
||||
|
||||
protected void writeDataFor(String mailAddress, WkdDirectoryStructure directory, TestSuiteGenerator.DataSink sink)
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ package pgp.wkd.test_suite;
|
|||
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import pgp.wkd.discovery.DiscoveryMethod;
|
||||
|
|
@ -54,12 +55,12 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
String userId = "WKD-Test Base Case <base-case@" + domain + ">";
|
||||
String description = "Certificate has a single, valid user-id '" + userId + "'";
|
||||
|
||||
PGPPublicKeyRing publicKeys = certificate(userId);
|
||||
OpenPGPCertificate publicKeys = certificate(userId);
|
||||
|
||||
writeDataFor(lookupMail, directoryStructure, new DataSink() {
|
||||
@Override
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
publicKeys.encode(outputStream);
|
||||
outputStream.write(publicKeys.getEncoded());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -74,16 +75,16 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
String primaryDescription = "Certificate has multiple, valid user-ids. Is looked up via primary user-id '" + primaryUserId + "' using mail address '" + primaryLookupMail + "'.";
|
||||
String secondaryDescription = "Certificate has multiple, valid user-ids. Is looked up via secondary user-id '" + secondaryUserId + "' using mail address '" + secondaryLookupMail + "'.";
|
||||
|
||||
PGPSecretKeyRing secretKeys = secretKey(primaryUserId);
|
||||
OpenPGPKey secretKeys = secretKey(primaryUserId);
|
||||
SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys();
|
||||
secretKeys = PGPainless.modifyKeyRing(secretKeys)
|
||||
secretKeys = PGPainless.getInstance().modify(secretKeys)
|
||||
.addUserId(secondaryUserId, protector)
|
||||
.done();
|
||||
PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys);
|
||||
OpenPGPCertificate publicKeys = secretKeys.toCertificate();
|
||||
DataSink sink = new DataSink() {
|
||||
@Override
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
publicKeys.encode(outputStream);
|
||||
outputStream.write(publicKeys.getEncoded());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -105,14 +106,14 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
String userId1 = "First Certificate <" + lookupMail + ">";
|
||||
String userId2 = "Second Certificate <" + lookupMail + ">";
|
||||
|
||||
PGPPublicKeyRing cert1 = certificate(userId1);
|
||||
PGPPublicKeyRing cert2 = certificate(userId2);
|
||||
OpenPGPCertificate cert1 = certificate(userId1);
|
||||
OpenPGPCertificate cert2 = certificate(userId2);
|
||||
|
||||
writeDataFor(lookupMail, directoryStructure, new DataSink() {
|
||||
@Override
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
cert1.encode(outputStream);
|
||||
cert2.encode(outputStream);
|
||||
outputStream.write(cert1.getEncoded());
|
||||
outputStream.write(cert2.getEncoded());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -123,12 +124,12 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
String lookupMail = "wrong-userid@" + domain;
|
||||
String userId = "WKD-Test Different User-ID <different-userid@" + domain + ">";
|
||||
String description = "Certificate has a single, valid user-id '" + userId + "', but is deposited for mail address '" + lookupMail + "'.";
|
||||
PGPPublicKeyRing publicKeys = certificate(userId);
|
||||
OpenPGPCertificate publicKeys = certificate(userId);
|
||||
|
||||
writeDataFor(lookupMail, directoryStructure, new DataSink() {
|
||||
@Override
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
publicKeys.encode(outputStream);
|
||||
outputStream.write(publicKeys.getEncoded());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -139,9 +140,9 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
String lookupMail = "unbound-userid@" + domain;
|
||||
String userId = "WKD-Test Unbound User-ID <" + lookupMail + ">";
|
||||
String description = "Certificate has a single User-ID '" + userId + "' without binding signature.";
|
||||
PGPPublicKeyRing publicKeys = certificate(userId);
|
||||
OpenPGPCertificate publicKeys = certificate(userId);
|
||||
|
||||
Iterator<PGPPublicKey> keyIterator = publicKeys.iterator();
|
||||
Iterator<PGPPublicKey> keyIterator = publicKeys.getPGPPublicKeyRing().iterator();
|
||||
PGPPublicKey primaryKey = keyIterator.next();
|
||||
Iterator<PGPSignature> bindingSigs = primaryKey.getSignaturesForID(userId);
|
||||
while (bindingSigs.hasNext()) {
|
||||
|
|
@ -169,7 +170,8 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
String lookupMail = "absent-userid@" + domain;
|
||||
String description = "Certificate has no user-id, but is deposited for mail address '" + lookupMail + "'.";
|
||||
// Generate certificate with temp user-id
|
||||
PGPPublicKeyRing publicKeys = certificate("DeleteMe");
|
||||
OpenPGPCertificate certificate = certificate("DeleteMe");
|
||||
PGPPublicKeyRing publicKeys = certificate.getPGPPublicKeyRing();
|
||||
|
||||
// delete user-id
|
||||
List<PGPPublicKey> keys = new ArrayList<>();
|
||||
|
|
@ -196,12 +198,12 @@ public class TestSuiteGenerator extends AbstractTestSuiteGenerator {
|
|||
private TestCase test_secretKeyMaterial(WkdDirectoryStructure directoryStructure) throws Exception {
|
||||
String lookupMail = "test-secret-key@" + domain;
|
||||
String description = "Certificate file contains secret key material.";
|
||||
PGPSecretKeyRing secretKeys = secretKey("WKD-Test Secret Key <" + lookupMail + ">");
|
||||
OpenPGPKey secretKeys = secretKey("WKD-Test Secret Key <" + lookupMail + ">");
|
||||
|
||||
writeDataFor(lookupMail, directoryStructure, new DataSink() {
|
||||
@Override
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
secretKeys.encode(outputStream);
|
||||
outputStream.write(secretKeys.getEncoded());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue