mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
Remove deprecated OpenPgpMetadata class
This commit is contained in:
parent
8c25b59c8b
commit
1a701333e3
19 changed files with 123 additions and 518 deletions
|
@ -1,380 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package org.pgpainless.decryption_verification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPLiteralData;
|
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|
||||||
import org.bouncycastle.openpgp.PGPSignature;
|
|
||||||
import org.pgpainless.algorithm.CompressionAlgorithm;
|
|
||||||
import org.pgpainless.algorithm.StreamEncoding;
|
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
|
||||||
import org.pgpainless.exception.SignatureValidationException;
|
|
||||||
import org.pgpainless.key.OpenPgpFingerprint;
|
|
||||||
import org.pgpainless.key.SubkeyIdentifier;
|
|
||||||
import org.pgpainless.util.SessionKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legacy class containing metadata about an OpenPGP message.
|
|
||||||
* It is advised to use {@link MessageMetadata} instead.
|
|
||||||
*
|
|
||||||
* TODO: Remove in 1.6.X
|
|
||||||
*/
|
|
||||||
public class OpenPgpMetadata {
|
|
||||||
|
|
||||||
private final Set<Long> recipientKeyIds;
|
|
||||||
private final SubkeyIdentifier decryptionKey;
|
|
||||||
private final List<SignatureVerification> verifiedInbandSignatures;
|
|
||||||
private final List<SignatureVerification.Failure> invalidInbandSignatures;
|
|
||||||
private final List<SignatureVerification> verifiedDetachedSignatures;
|
|
||||||
private final List<SignatureVerification.Failure> invalidDetachedSignatures;
|
|
||||||
private final SessionKey sessionKey;
|
|
||||||
private final CompressionAlgorithm compressionAlgorithm;
|
|
||||||
private final String fileName;
|
|
||||||
private final Date modificationDate;
|
|
||||||
private final StreamEncoding fileEncoding;
|
|
||||||
private final boolean cleartextSigned;
|
|
||||||
|
|
||||||
public OpenPgpMetadata(Set<Long> recipientKeyIds,
|
|
||||||
SubkeyIdentifier decryptionKey,
|
|
||||||
SessionKey sessionKey,
|
|
||||||
CompressionAlgorithm algorithm,
|
|
||||||
List<SignatureVerification> verifiedInbandSignatures,
|
|
||||||
List<SignatureVerification.Failure> invalidInbandSignatures,
|
|
||||||
List<SignatureVerification> verifiedDetachedSignatures,
|
|
||||||
List<SignatureVerification.Failure> invalidDetachedSignatures,
|
|
||||||
String fileName,
|
|
||||||
Date modificationDate,
|
|
||||||
StreamEncoding fileEncoding,
|
|
||||||
boolean cleartextSigned) {
|
|
||||||
|
|
||||||
this.recipientKeyIds = Collections.unmodifiableSet(recipientKeyIds);
|
|
||||||
this.decryptionKey = decryptionKey;
|
|
||||||
this.sessionKey = sessionKey;
|
|
||||||
this.compressionAlgorithm = algorithm;
|
|
||||||
this.verifiedInbandSignatures = Collections.unmodifiableList(verifiedInbandSignatures);
|
|
||||||
this.invalidInbandSignatures = Collections.unmodifiableList(invalidInbandSignatures);
|
|
||||||
this.verifiedDetachedSignatures = Collections.unmodifiableList(verifiedDetachedSignatures);
|
|
||||||
this.invalidDetachedSignatures = Collections.unmodifiableList(invalidDetachedSignatures);
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.modificationDate = modificationDate;
|
|
||||||
this.fileEncoding = fileEncoding;
|
|
||||||
this.cleartextSigned = cleartextSigned;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a set of key-ids the messages was encrypted for.
|
|
||||||
*
|
|
||||||
* @return recipient ids
|
|
||||||
*/
|
|
||||||
public @Nonnull Set<Long> getRecipientKeyIds() {
|
|
||||||
return recipientKeyIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true, if the message was encrypted.
|
|
||||||
*
|
|
||||||
* @return true if encrypted, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean isEncrypted() {
|
|
||||||
return sessionKey != null && sessionKey.getAlgorithm() != SymmetricKeyAlgorithm.NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the {@link SubkeyIdentifier} of the key that was used to decrypt the message.
|
|
||||||
* This can be null if the message was decrypted using a {@link org.pgpainless.util.Passphrase}, or if it was not
|
|
||||||
* encrypted at all (e.g. signed only).
|
|
||||||
*
|
|
||||||
* @return subkey identifier of decryption key
|
|
||||||
*/
|
|
||||||
public @Nullable SubkeyIdentifier getDecryptionKey() {
|
|
||||||
return decryptionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the algorithm that was used to symmetrically encrypt the message.
|
|
||||||
*
|
|
||||||
* @return encryption algorithm
|
|
||||||
*/
|
|
||||||
public @Nullable SymmetricKeyAlgorithm getSymmetricKeyAlgorithm() {
|
|
||||||
return sessionKey == null ? null : sessionKey.getAlgorithm();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable SessionKey getSessionKey() {
|
|
||||||
return sessionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the {@link CompressionAlgorithm} that was used to compress the message.
|
|
||||||
*
|
|
||||||
* @return compression algorithm
|
|
||||||
*/
|
|
||||||
public @Nullable CompressionAlgorithm getCompressionAlgorithm() {
|
|
||||||
return compressionAlgorithm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a set of all signatures on the message.
|
|
||||||
* Note: This method returns just the signatures. There is no guarantee that the signatures are verified or even correct.
|
|
||||||
*
|
|
||||||
* Use {@link #getVerifiedSignatures()} instead to get all verified signatures.
|
|
||||||
* @return unverified and verified signatures
|
|
||||||
*/
|
|
||||||
public @Nonnull Set<PGPSignature> getSignatures() {
|
|
||||||
Set<PGPSignature> signatures = new HashSet<>();
|
|
||||||
for (SignatureVerification v : getVerifiedDetachedSignatures()) {
|
|
||||||
signatures.add(v.getSignature());
|
|
||||||
}
|
|
||||||
for (SignatureVerification v : getVerifiedInbandSignatures()) {
|
|
||||||
signatures.add(v.getSignature());
|
|
||||||
}
|
|
||||||
for (SignatureVerification.Failure f : getInvalidDetachedSignatures()) {
|
|
||||||
signatures.add(f.getSignatureVerification().getSignature());
|
|
||||||
}
|
|
||||||
for (SignatureVerification.Failure f : getInvalidInbandSignatures()) {
|
|
||||||
signatures.add(f.getSignatureVerification().getSignature());
|
|
||||||
}
|
|
||||||
return signatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if the message contained at least one signature.
|
|
||||||
*
|
|
||||||
* Note: This method does not reflect, whether the signature on the message is correct.
|
|
||||||
* Use {@link #isVerified()} instead to determine, if the message carries a verifiable signature.
|
|
||||||
*
|
|
||||||
* @return true if message contains at least one unverified or verified signature, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean isSigned() {
|
|
||||||
return !getSignatures().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a map of all verified signatures on the message.
|
|
||||||
* The map contains verified signatures as value, with the {@link SubkeyIdentifier} of the key that was used to verify
|
|
||||||
* the signature as the maps keys.
|
|
||||||
*
|
|
||||||
* @return verified detached and one-pass signatures
|
|
||||||
*/
|
|
||||||
public Map<SubkeyIdentifier, PGPSignature> getVerifiedSignatures() {
|
|
||||||
Map<SubkeyIdentifier, PGPSignature> verifiedSignatures = new ConcurrentHashMap<>();
|
|
||||||
for (SignatureVerification detachedSignature : getVerifiedDetachedSignatures()) {
|
|
||||||
verifiedSignatures.put(detachedSignature.getSigningKey(), detachedSignature.getSignature());
|
|
||||||
}
|
|
||||||
for (SignatureVerification inbandSignatures : verifiedInbandSignatures) {
|
|
||||||
verifiedSignatures.put(inbandSignatures.getSigningKey(), inbandSignatures.getSignature());
|
|
||||||
}
|
|
||||||
|
|
||||||
return verifiedSignatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SignatureVerification> getVerifiedInbandSignatures() {
|
|
||||||
return verifiedInbandSignatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SignatureVerification> getVerifiedDetachedSignatures() {
|
|
||||||
return verifiedDetachedSignatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SignatureVerification.Failure> getInvalidInbandSignatures() {
|
|
||||||
return invalidInbandSignatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SignatureVerification.Failure> getInvalidDetachedSignatures() {
|
|
||||||
return invalidDetachedSignatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true, if the message is signed and at least one signature on the message was verified successfully.
|
|
||||||
*
|
|
||||||
* @return true if message is verified, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean isVerified() {
|
|
||||||
return !getVerifiedSignatures().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true, if the message contains at least one verified signature made by a key in the
|
|
||||||
* given certificate.
|
|
||||||
*
|
|
||||||
* @param certificate certificate
|
|
||||||
* @return true if message was signed by the certificate (and the signature is valid), false otherwise
|
|
||||||
*/
|
|
||||||
public boolean containsVerifiedSignatureFrom(PGPPublicKeyRing certificate) {
|
|
||||||
for (PGPPublicKey key : certificate) {
|
|
||||||
OpenPgpFingerprint fingerprint = OpenPgpFingerprint.of(key);
|
|
||||||
if (containsVerifiedSignatureFrom(fingerprint)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true, if the message contains at least one valid signature made by the key with the given
|
|
||||||
* fingerprint, false otherwise.
|
|
||||||
*
|
|
||||||
* The fingerprint might be of the signing subkey, or the primary key of the signing certificate.
|
|
||||||
*
|
|
||||||
* @param fingerprint fingerprint of primary key or signing subkey
|
|
||||||
* @return true if validly signed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean containsVerifiedSignatureFrom(OpenPgpFingerprint fingerprint) {
|
|
||||||
for (SubkeyIdentifier verifiedSigningKey : getVerifiedSignatures().keySet()) {
|
|
||||||
if (verifiedSigningKey.getPrimaryKeyFingerprint().equals(fingerprint) ||
|
|
||||||
verifiedSigningKey.getSubkeyFingerprint().equals(fingerprint)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the name of the encrypted / signed file.
|
|
||||||
*
|
|
||||||
* @return file name
|
|
||||||
*/
|
|
||||||
public String getFileName() {
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true, if the encrypted data is intended for your eyes only.
|
|
||||||
*
|
|
||||||
* @return true if for-your-eyes-only
|
|
||||||
*/
|
|
||||||
public boolean isForYourEyesOnly() {
|
|
||||||
return PGPLiteralData.CONSOLE.equals(getFileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the modification date of the encrypted / signed file.
|
|
||||||
*
|
|
||||||
* @return modification date
|
|
||||||
*/
|
|
||||||
public Date getModificationDate() {
|
|
||||||
return modificationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the encoding format of the encrypted / signed file.
|
|
||||||
*
|
|
||||||
* @return encoding
|
|
||||||
*/
|
|
||||||
public StreamEncoding getFileEncoding() {
|
|
||||||
return fileEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if the message was signed using the cleartext signature framework.
|
|
||||||
*
|
|
||||||
* @return true if cleartext signed.
|
|
||||||
*/
|
|
||||||
public boolean isCleartextSigned() {
|
|
||||||
return cleartextSigned;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder getBuilder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
|
|
||||||
private final Set<Long> recipientFingerprints = new HashSet<>();
|
|
||||||
private SessionKey sessionKey;
|
|
||||||
private SubkeyIdentifier decryptionKey;
|
|
||||||
private CompressionAlgorithm compressionAlgorithm = CompressionAlgorithm.UNCOMPRESSED;
|
|
||||||
private String fileName;
|
|
||||||
private StreamEncoding fileEncoding;
|
|
||||||
private Date modificationDate;
|
|
||||||
private boolean cleartextSigned = false;
|
|
||||||
|
|
||||||
private final List<SignatureVerification> verifiedInbandSignatures = new ArrayList<>();
|
|
||||||
private final List<SignatureVerification> verifiedDetachedSignatures = new ArrayList<>();
|
|
||||||
private final List<SignatureVerification.Failure> invalidInbandSignatures = new ArrayList<>();
|
|
||||||
private final List<SignatureVerification.Failure> invalidDetachedSignatures = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
public Builder addRecipientKeyId(Long keyId) {
|
|
||||||
this.recipientFingerprints.add(keyId);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setDecryptionKey(SubkeyIdentifier decryptionKey) {
|
|
||||||
this.decryptionKey = decryptionKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setSessionKey(SessionKey sessionKey) {
|
|
||||||
this.sessionKey = sessionKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setCompressionAlgorithm(CompressionAlgorithm algorithm) {
|
|
||||||
this.compressionAlgorithm = algorithm;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setFileName(@Nullable String fileName) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setModificationDate(Date modificationDate) {
|
|
||||||
this.modificationDate = modificationDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setFileEncoding(StreamEncoding encoding) {
|
|
||||||
this.fileEncoding = encoding;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addVerifiedInbandSignature(SignatureVerification signatureVerification) {
|
|
||||||
this.verifiedInbandSignatures.add(signatureVerification);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addVerifiedDetachedSignature(SignatureVerification signatureVerification) {
|
|
||||||
this.verifiedDetachedSignatures.add(signatureVerification);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addInvalidInbandSignature(SignatureVerification signatureVerification, SignatureValidationException e) {
|
|
||||||
this.invalidInbandSignatures.add(new SignatureVerification.Failure(signatureVerification, e));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addInvalidDetachedSignature(SignatureVerification signatureVerification, SignatureValidationException e) {
|
|
||||||
this.invalidDetachedSignatures.add(new SignatureVerification.Failure(signatureVerification, e));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setCleartextSigned() {
|
|
||||||
this.cleartextSigned = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenPgpMetadata build() {
|
|
||||||
return new OpenPgpMetadata(
|
|
||||||
recipientFingerprints, decryptionKey,
|
|
||||||
sessionKey, compressionAlgorithm,
|
|
||||||
verifiedInbandSignatures, invalidInbandSignatures,
|
|
||||||
verifiedDetachedSignatures, invalidDetachedSignatures,
|
|
||||||
fileName, modificationDate, fileEncoding, cleartextSigned);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,16 +18,4 @@ abstract class DecryptionStream: InputStream() {
|
||||||
* @return message metadata
|
* @return message metadata
|
||||||
*/
|
*/
|
||||||
abstract val metadata: MessageMetadata
|
abstract val metadata: MessageMetadata
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a [OpenPgpMetadata] object containing information about the decrypted / verified message.
|
|
||||||
* The [DecryptionStream] MUST be closed via [close] before the metadata object can be accessed.
|
|
||||||
*
|
|
||||||
* @return message metadata
|
|
||||||
* @deprecated use [metadata] instead.
|
|
||||||
*/
|
|
||||||
@Deprecated("Use of OpenPgpMetadata is discouraged.",
|
|
||||||
ReplaceWith("metadata"))
|
|
||||||
val result: OpenPgpMetadata
|
|
||||||
get() = metadata.toLegacyMetadata()
|
|
||||||
}
|
}
|
|
@ -130,6 +130,6 @@ public class OnePassSignatureVerificationWithPartialLengthLiteralDataRegressionT
|
||||||
|
|
||||||
Streams.pipeAll(decryptionStream, out);
|
Streams.pipeAll(decryptionStream, out);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
decryptionStream.getResult();
|
decryptionStream.getMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void noInputEncodingBinaryDataBinarySig() throws PGPException, IOException {
|
public void noInputEncodingBinaryDataBinarySig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.BINARY, false);
|
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.BINARY, false);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -136,9 +136,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void noInputEncodingBinaryDataTextSig() throws PGPException, IOException {
|
public void noInputEncodingBinaryDataTextSig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.BINARY, false);
|
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.BINARY, false);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -150,9 +150,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void noInputEncodingTextDataBinarySig() throws PGPException, IOException {
|
public void noInputEncodingTextDataBinarySig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, false);
|
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, false);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -164,9 +164,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void noInputEncodingTextDataTextSig() throws PGPException, IOException {
|
public void noInputEncodingTextDataTextSig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.TEXT, false);
|
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.TEXT, false);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -178,9 +178,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void noInputEncodingUtf8DataBinarySig() throws PGPException, IOException {
|
public void noInputEncodingUtf8DataBinarySig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.UTF8, false);
|
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.UTF8, false);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -192,9 +192,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void noInputEncodingUtf8DataTextSig() throws PGPException, IOException {
|
public void noInputEncodingUtf8DataTextSig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.UTF8, false);
|
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.UTF8, false);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -207,9 +207,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void inputEncodingBinaryDataBinarySig() throws PGPException, IOException {
|
public void inputEncodingBinaryDataBinarySig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.BINARY, true);
|
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.BINARY, true);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -221,9 +221,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void inputEncodingBinaryDataTextSig() throws PGPException, IOException {
|
public void inputEncodingBinaryDataTextSig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.BINARY, true);
|
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.BINARY, true);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -235,9 +235,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void inputEncodingTextDataBinarySig() throws PGPException, IOException {
|
public void inputEncodingTextDataBinarySig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, true);
|
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, true);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -249,9 +249,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void inputEncodingTextDataTextSig() throws PGPException, IOException {
|
public void inputEncodingTextDataTextSig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.TEXT, true);
|
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.TEXT, true);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -263,9 +263,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void inputEncodingUtf8DataBinarySig() throws PGPException, IOException {
|
public void inputEncodingUtf8DataBinarySig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.UTF8, true);
|
String msg = encryptAndSign(message, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.UTF8, true);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -277,9 +277,9 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
@Test
|
@Test
|
||||||
public void inputEncodingUtf8DataTextSig() throws PGPException, IOException {
|
public void inputEncodingUtf8DataTextSig() throws PGPException, IOException {
|
||||||
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.UTF8, true);
|
String msg = encryptAndSign(message, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT, StreamEncoding.UTF8, true);
|
||||||
OpenPgpMetadata metadata = decryptAndVerify(msg);
|
MessageMetadata metadata = decryptAndVerify(msg);
|
||||||
|
|
||||||
if (!metadata.isVerified()) {
|
if (!metadata.isVerifiedSigned()) {
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
System.out.println("Not verified. Session-Key: " + metadata.getSessionKey());
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
|
@ -360,7 +360,7 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpenPgpMetadata decryptAndVerify(String msg) throws PGPException, IOException {
|
private MessageMetadata decryptAndVerify(String msg) throws PGPException, IOException {
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8));
|
ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8));
|
||||||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(in)
|
.onInputStream(in)
|
||||||
|
@ -371,7 +371,7 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
Streams.drain(decryptionStream);
|
Streams.drain(decryptionStream);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
return decryptionStream.getResult();
|
return decryptionStream.getMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -439,8 +439,8 @@ public class CanonicalizedDataEncryptionTest {
|
||||||
|
|
||||||
Streams.pipeAll(decryptionStream, decrypted);
|
Streams.pipeAll(decryptionStream, decrypted);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
assertTrue(metadata.isVerified(), "Not verified! Sig Type: " + sigType + " StreamEncoding: " + streamEncoding);
|
assertTrue(metadata.isVerifiedSigned(), "Not verified! Sig Type: " + sigType + " StreamEncoding: " + streamEncoding);
|
||||||
|
|
||||||
assertArrayEquals(msg, decrypted.toByteArray());
|
assertArrayEquals(msg, decrypted.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,11 +96,11 @@ public class CleartextSignatureVerificationTest {
|
||||||
Streams.pipeAll(decryptionStream, out);
|
Streams.pipeAll(decryptionStream, out);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata result = decryptionStream.getResult();
|
MessageMetadata result = decryptionStream.getMetadata();
|
||||||
assertTrue(result.isVerified());
|
assertTrue(result.isVerifiedSigned());
|
||||||
assertTrue(result.isCleartextSigned());
|
assertTrue(result.isUsingCleartextSignatureFramework());
|
||||||
|
|
||||||
PGPSignature signature = result.getVerifiedSignatures().values().iterator().next();
|
PGPSignature signature = result.getVerifiedSignatures().iterator().next().getSignature();
|
||||||
|
|
||||||
assertEquals(signature.getKeyID(), signingKeys.getPublicKey().getKeyID());
|
assertEquals(signature.getKeyID(), signingKeys.getPublicKey().getKeyID());
|
||||||
assertArrayEquals(MESSAGE_BODY, out.toByteArray());
|
assertArrayEquals(MESSAGE_BODY, out.toByteArray());
|
||||||
|
@ -125,10 +125,10 @@ public class CleartextSignatureVerificationTest {
|
||||||
Streams.pipeAll(decryptionStream, out);
|
Streams.pipeAll(decryptionStream, out);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata result = decryptionStream.getResult();
|
MessageMetadata result = decryptionStream.getMetadata();
|
||||||
assertTrue(result.isVerified());
|
assertTrue(result.isVerifiedSigned());
|
||||||
|
|
||||||
PGPSignature signature = result.getVerifiedSignatures().values().iterator().next();
|
PGPSignature signature = result.getVerifiedSignatures().iterator().next().getSignature();
|
||||||
|
|
||||||
assertEquals(signature.getKeyID(), signingKeys.getPublicKey().getKeyID());
|
assertEquals(signature.getKeyID(), signingKeys.getPublicKey().getKeyID());
|
||||||
FileInputStream fileIn = new FileInputStream(file);
|
FileInputStream fileIn = new FileInputStream(file);
|
||||||
|
@ -178,7 +178,7 @@ public class CleartextSignatureVerificationTest {
|
||||||
Streams.pipeAll(decryptionStream, out);
|
Streams.pipeAll(decryptionStream, out);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
assertEquals(1, metadata.getVerifiedSignatures().size());
|
assertEquals(1, metadata.getVerifiedSignatures().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,8 +210,8 @@ public class CleartextSignatureVerificationTest {
|
||||||
Streams.pipeAll(verificationStream, msgOut);
|
Streams.pipeAll(verificationStream, msgOut);
|
||||||
verificationStream.close();
|
verificationStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = verificationStream.getResult();
|
MessageMetadata metadata = verificationStream.getMetadata();
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class DecryptAndVerifyMessageTest {
|
||||||
Streams.pipeAll(decryptor, toPlain);
|
Streams.pipeAll(decryptor, toPlain);
|
||||||
decryptor.close();
|
decryptor.close();
|
||||||
toPlain.close();
|
toPlain.close();
|
||||||
OpenPgpMetadata metadata = decryptor.getResult();
|
MessageMetadata metadata = decryptor.getMetadata();
|
||||||
|
|
||||||
byte[] expected = TestKeys.TEST_MESSAGE_01_PLAIN.getBytes(UTF8);
|
byte[] expected = TestKeys.TEST_MESSAGE_01_PLAIN.getBytes(UTF8);
|
||||||
byte[] actual = toPlain.toByteArray();
|
byte[] actual = toPlain.toByteArray();
|
||||||
|
@ -72,14 +72,13 @@ public class DecryptAndVerifyMessageTest {
|
||||||
assertArrayEquals(expected, actual);
|
assertArrayEquals(expected, actual);
|
||||||
|
|
||||||
assertTrue(metadata.isEncrypted());
|
assertTrue(metadata.isEncrypted());
|
||||||
assertTrue(metadata.isSigned());
|
assertFalse(metadata.isUsingCleartextSignatureFramework());
|
||||||
assertFalse(metadata.isCleartextSigned());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
assertTrue(metadata.isVerified());
|
|
||||||
assertEquals(CompressionAlgorithm.ZLIB, metadata.getCompressionAlgorithm());
|
assertEquals(CompressionAlgorithm.ZLIB, metadata.getCompressionAlgorithm());
|
||||||
assertEquals(SymmetricKeyAlgorithm.AES_256, metadata.getSymmetricKeyAlgorithm());
|
assertEquals(SymmetricKeyAlgorithm.AES_256, metadata.getEncryptionAlgorithm());
|
||||||
assertEquals(1, metadata.getSignatures().size());
|
|
||||||
assertEquals(1, metadata.getVerifiedSignatures().size());
|
assertEquals(1, metadata.getVerifiedSignatures().size());
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(TestKeys.JULIET_FINGERPRINT));
|
assertEquals(1, metadata.getVerifiedSignatures().size());
|
||||||
|
assertTrue(metadata.isVerifiedSignedBy(TestKeys.JULIET_FINGERPRINT));
|
||||||
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +103,7 @@ public class DecryptAndVerifyMessageTest {
|
||||||
|
|
||||||
decryptor.close();
|
decryptor.close();
|
||||||
toPlain.close();
|
toPlain.close();
|
||||||
OpenPgpMetadata metadata = decryptor.getResult();
|
MessageMetadata metadata = decryptor.getMetadata();
|
||||||
|
|
||||||
byte[] expected = TestKeys.TEST_MESSAGE_01_PLAIN.getBytes(UTF8);
|
byte[] expected = TestKeys.TEST_MESSAGE_01_PLAIN.getBytes(UTF8);
|
||||||
byte[] actual = toPlain.toByteArray();
|
byte[] actual = toPlain.toByteArray();
|
||||||
|
@ -112,14 +111,13 @@ public class DecryptAndVerifyMessageTest {
|
||||||
assertArrayEquals(expected, actual);
|
assertArrayEquals(expected, actual);
|
||||||
|
|
||||||
assertTrue(metadata.isEncrypted());
|
assertTrue(metadata.isEncrypted());
|
||||||
assertTrue(metadata.isSigned());
|
assertFalse(metadata.isUsingCleartextSignatureFramework());
|
||||||
assertFalse(metadata.isCleartextSigned());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
assertTrue(metadata.isVerified());
|
|
||||||
assertEquals(CompressionAlgorithm.ZLIB, metadata.getCompressionAlgorithm());
|
assertEquals(CompressionAlgorithm.ZLIB, metadata.getCompressionAlgorithm());
|
||||||
assertEquals(SymmetricKeyAlgorithm.AES_256, metadata.getSymmetricKeyAlgorithm());
|
assertEquals(SymmetricKeyAlgorithm.AES_256, metadata.getEncryptionAlgorithm());
|
||||||
assertEquals(1, metadata.getSignatures().size());
|
|
||||||
assertEquals(1, metadata.getVerifiedSignatures().size());
|
assertEquals(1, metadata.getVerifiedSignatures().size());
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(TestKeys.JULIET_FINGERPRINT));
|
assertEquals(1, metadata.getVerifiedSignatures().size());
|
||||||
|
assertTrue(metadata.isVerifiedSignedBy(TestKeys.JULIET_FINGERPRINT));
|
||||||
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,8 +139,9 @@ public class DecryptHiddenRecipientMessageTest {
|
||||||
Streams.pipeAll(decryptionStream, out);
|
Streams.pipeAll(decryptionStream, out);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
assertEquals(0, metadata.getRecipientKeyIds().size());
|
assertEquals(1, metadata.getRecipientKeyIds().size());
|
||||||
|
assertEquals(0L, metadata.getRecipientKeyIds().get(0));
|
||||||
|
|
||||||
KeyRingInfo info = new KeyRingInfo(secretKeys);
|
KeyRingInfo info = new KeyRingInfo(secretKeys);
|
||||||
List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
|
List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
|
||||||
|
|
|
@ -104,9 +104,9 @@ public class IgnoreUnknownSignatureVersionsTest {
|
||||||
"ou1uiXJaDzZ6wQfB\n" +
|
"ou1uiXJaDzZ6wQfB\n" +
|
||||||
"=uHRc\n" +
|
"=uHRc\n" +
|
||||||
"-----END PGP SIGNATURE-----\n";
|
"-----END PGP SIGNATURE-----\n";
|
||||||
OpenPgpMetadata metadata = verifySignature(cert, BASE_CASE);
|
MessageMetadata metadata = verifySignature(cert, BASE_CASE);
|
||||||
|
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -137,9 +137,9 @@ public class IgnoreUnknownSignatureVersionsTest {
|
||||||
"ou1uiXJaDzZ6wQfB\n" +
|
"ou1uiXJaDzZ6wQfB\n" +
|
||||||
"=/JL1\n" +
|
"=/JL1\n" +
|
||||||
"-----END PGP SIGNATURE-----\n";
|
"-----END PGP SIGNATURE-----\n";
|
||||||
OpenPgpMetadata metadata = verifySignature(cert, SIG4SIG23);
|
MessageMetadata metadata = verifySignature(cert, SIG4SIG23);
|
||||||
|
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -170,12 +170,12 @@ public class IgnoreUnknownSignatureVersionsTest {
|
||||||
"ou1uiXJaDzZ6wQfB\n" +
|
"ou1uiXJaDzZ6wQfB\n" +
|
||||||
"=Yc8d\n" +
|
"=Yc8d\n" +
|
||||||
"-----END PGP SIGNATURE-----\n";
|
"-----END PGP SIGNATURE-----\n";
|
||||||
OpenPgpMetadata metadata = verifySignature(cert, SIG23SIG4);
|
MessageMetadata metadata = verifySignature(cert, SIG23SIG4);
|
||||||
|
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpenPgpMetadata verifySignature(PGPPublicKeyRing cert, String BASE_CASE) throws PGPException, IOException {
|
private MessageMetadata verifySignature(PGPPublicKeyRing cert, String BASE_CASE) throws PGPException, IOException {
|
||||||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify().onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)))
|
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify().onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)))
|
||||||
.withOptions(new ConsumerOptions()
|
.withOptions(new ConsumerOptions()
|
||||||
.addVerificationCert(cert)
|
.addVerificationCert(cert)
|
||||||
|
@ -184,6 +184,6 @@ public class IgnoreUnknownSignatureVersionsTest {
|
||||||
Streams.drain(decryptionStream);
|
Streams.drain(decryptionStream);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
return decryptionStream.getResult();
|
return decryptionStream.getMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
|
||||||
|
|
||||||
Streams.drain(decryptionStream);
|
Streams.drain(decryptionStream);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
|
|
||||||
assertEquals(new SubkeyIdentifier(secretKeys, secretKeys.getPublicKey().getKeyID()), metadata.getDecryptionKey());
|
assertEquals(new SubkeyIdentifier(secretKeys, secretKeys.getPublicKey().getKeyID()), metadata.getDecryptionKey());
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
|
||||||
|
|
||||||
Streams.drain(decryptionStream);
|
Streams.drain(decryptionStream);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
|
|
||||||
assertEquals(new SubkeyIdentifier(secretKeys, secretKeys.getPublicKey().getKeyID()), metadata.getDecryptionKey());
|
assertEquals(new SubkeyIdentifier(secretKeys, secretKeys.getPublicKey().getKeyID()), metadata.getDecryptionKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,10 @@ public class SignedMessageVerificationWithoutCertIsStillSignedTest {
|
||||||
Streams.pipeAll(verificationStream, out);
|
Streams.pipeAll(verificationStream, out);
|
||||||
verificationStream.close();
|
verificationStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = verificationStream.getResult();
|
MessageMetadata metadata = verificationStream.getMetadata();
|
||||||
|
|
||||||
assertFalse(metadata.isCleartextSigned());
|
assertFalse(metadata.isUsingCleartextSignatureFramework());
|
||||||
assertTrue(metadata.isSigned(), "Message is signed, even though we miss the verification cert.");
|
assertTrue(metadata.hasRejectedSignatures(), "Message is signed, even though we miss the verification cert.");
|
||||||
assertFalse(metadata.isVerified(), "Message is not verified because we lack the verification cert.");
|
assertFalse(metadata.isVerifiedSigned(), "Message is not verified because we lack the verification cert.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ public class VerifyDetachedSignatureTest {
|
||||||
|
|
||||||
Streams.drain(verifier);
|
Streams.drain(verifier);
|
||||||
verifier.close();
|
verifier.close();
|
||||||
OpenPgpMetadata metadata = verifier.getResult();
|
MessageMetadata metadata = verifier.getMetadata();
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -140,7 +140,7 @@ public class VerifyDetachedSignatureTest {
|
||||||
|
|
||||||
Streams.drain(verifier);
|
Streams.drain(verifier);
|
||||||
verifier.close();
|
verifier.close();
|
||||||
OpenPgpMetadata metadata = verifier.getResult();
|
MessageMetadata metadata = verifier.getMetadata();
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
|
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.getVerifiedSignatures().containsKey(new SubkeyIdentifier(certificate)));
|
assertTrue(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -81,8 +81,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
.onInputStream(new ByteArrayInputStream(data))
|
.onInputStream(new ByteArrayInputStream(data))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
|
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(certificate));
|
assertTrue(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -93,8 +93,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertTrue(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -106,8 +106,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(data))
|
.onInputStream(new ByteArrayInputStream(data))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertTrue(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -118,8 +118,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertFalse(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertFalse(metadata.isVerifiedInlineSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -131,8 +131,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(data))
|
.onInputStream(new ByteArrayInputStream(data))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertFalse(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertFalse(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -143,8 +143,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertTrue(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -156,8 +156,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(data))
|
.onInputStream(new ByteArrayInputStream(data))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertTrue(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -168,8 +168,8 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
.onInputStream(new ByteArrayInputStream(inlineSigned))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertFalse(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertFalse(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -181,13 +181,13 @@ public class VerifyNotBeforeNotAfterTest {
|
||||||
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
|
||||||
.onInputStream(new ByteArrayInputStream(data))
|
.onInputStream(new ByteArrayInputStream(data))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertFalse(metadata.getVerifiedSignatures().containsKey(signingKey));
|
assertFalse(metadata.isVerifiedSignedBy(certificate));
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpenPgpMetadata processSignedData(DecryptionStream verifier) throws IOException {
|
private MessageMetadata processSignedData(DecryptionStream verifier) throws IOException {
|
||||||
Streams.drain(verifier);
|
Streams.drain(verifier);
|
||||||
verifier.close();
|
verifier.close();
|
||||||
return verifier.getResult();
|
return verifier.getMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ class VerifyVersion3SignaturePacketTest {
|
||||||
.onInputStream(new ByteArrayInputStream(DATA))
|
.onInputStream(new ByteArrayInputStream(DATA))
|
||||||
.withOptions(options);
|
.withOptions(options);
|
||||||
|
|
||||||
OpenPgpMetadata metadata = processSignedData(verifier);
|
MessageMetadata metadata = processSignedData(verifier);
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(TestKeys.getEmilPublicKeyRing()));
|
assertTrue(metadata.isVerifiedSignedBy(TestKeys.getEmilPublicKeyRing()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PGPSignature generateV3Signature() throws IOException, PGPException {
|
private static PGPSignature generateV3Signature() throws IOException, PGPException {
|
||||||
|
@ -61,9 +61,9 @@ class VerifyVersion3SignaturePacketTest {
|
||||||
return signatureGenerator.generate();
|
return signatureGenerator.generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OpenPgpMetadata processSignedData(DecryptionStream verifier) throws IOException {
|
private MessageMetadata processSignedData(DecryptionStream verifier) throws IOException {
|
||||||
Streams.drain(verifier);
|
Streams.drain(verifier);
|
||||||
verifier.close();
|
verifier.close();
|
||||||
return verifier.getResult();
|
return verifier.getMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class VerifyWithMissingPublicKeyCallbackTest {
|
||||||
verificationStream.close();
|
verificationStream.close();
|
||||||
|
|
||||||
assertArrayEquals(msg.getBytes(StandardCharsets.UTF_8), plainOut.toByteArray());
|
assertArrayEquals(msg.getBytes(StandardCharsets.UTF_8), plainOut.toByteArray());
|
||||||
OpenPgpMetadata metadata = verificationStream.getResult();
|
MessageMetadata metadata = verificationStream.getMetadata();
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(signingPubKeys));
|
assertTrue(metadata.isVerifiedSignedBy(signingPubKeys));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,12 +102,12 @@ public class WrongSignerUserIdTest {
|
||||||
Streams.pipeAll(decryptionStream, out);
|
Streams.pipeAll(decryptionStream, out);
|
||||||
|
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
|
|
||||||
if (expectSuccessfulVerification) {
|
if (expectSuccessfulVerification) {
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
} else {
|
} else {
|
||||||
assertFalse(metadata.isVerified());
|
assertFalse(metadata.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
import org.pgpainless.decryption_verification.MessageMetadata;
|
||||||
import org.pgpainless.exception.KeyException;
|
import org.pgpainless.exception.KeyException;
|
||||||
import org.pgpainless.key.SubkeyIdentifier;
|
import org.pgpainless.key.SubkeyIdentifier;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
|
@ -185,11 +185,10 @@ public class EncryptDecryptTest {
|
||||||
decryptor.close();
|
decryptor.close();
|
||||||
|
|
||||||
assertArrayEquals(secretMessage, decryptedSecretMessage.toByteArray());
|
assertArrayEquals(secretMessage, decryptedSecretMessage.toByteArray());
|
||||||
OpenPgpMetadata result = decryptor.getResult();
|
MessageMetadata result = decryptor.getMetadata();
|
||||||
assertTrue(result.containsVerifiedSignatureFrom(senderPub));
|
assertTrue(result.isVerifiedSignedBy(senderPub));
|
||||||
assertTrue(result.isSigned());
|
|
||||||
assertTrue(result.isEncrypted());
|
assertTrue(result.isEncrypted());
|
||||||
assertTrue(result.isVerified());
|
assertTrue(result.isVerifiedSigned());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
|
@ -233,7 +232,7 @@ public class EncryptDecryptTest {
|
||||||
Streams.pipeAll(verifier, dummyOut);
|
Streams.pipeAll(verifier, dummyOut);
|
||||||
verifier.close();
|
verifier.close();
|
||||||
|
|
||||||
OpenPgpMetadata decryptionResult = verifier.getResult();
|
MessageMetadata decryptionResult = verifier.getMetadata();
|
||||||
assertFalse(decryptionResult.getVerifiedSignatures().isEmpty());
|
assertFalse(decryptionResult.getVerifiedSignatures().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +262,7 @@ public class EncryptDecryptTest {
|
||||||
Streams.pipeAll(verifier, signOut);
|
Streams.pipeAll(verifier, signOut);
|
||||||
verifier.close();
|
verifier.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = verifier.getResult();
|
MessageMetadata metadata = verifier.getMetadata();
|
||||||
assertFalse(metadata.getVerifiedSignatures().isEmpty());
|
assertFalse(metadata.getVerifiedSignatures().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.pgpainless.algorithm.HashAlgorithm;
|
||||||
import org.pgpainless.algorithm.KeyFlag;
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
import org.pgpainless.decryption_verification.MessageMetadata;
|
||||||
import org.pgpainless.exception.KeyException;
|
import org.pgpainless.exception.KeyException;
|
||||||
import org.pgpainless.key.SubkeyIdentifier;
|
import org.pgpainless.key.SubkeyIdentifier;
|
||||||
import org.pgpainless.key.TestKeys;
|
import org.pgpainless.key.TestKeys;
|
||||||
|
@ -106,12 +106,11 @@ public class SigningTest {
|
||||||
Streams.pipeAll(decryptionStream, plaintextOut);
|
Streams.pipeAll(decryptionStream, plaintextOut);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
assertTrue(metadata.isEncrypted());
|
assertTrue(metadata.isEncrypted());
|
||||||
assertTrue(metadata.isSigned());
|
assertTrue(metadata.isVerifiedSigned());
|
||||||
assertTrue(metadata.isVerified());
|
assertTrue(metadata.isVerifiedSignedBy(KeyRingUtils.publicKeyRingFrom(cryptieKeys)));
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(KeyRingUtils.publicKeyRingFrom(cryptieKeys)));
|
assertFalse(metadata.isVerifiedSignedBy(julietKeys));
|
||||||
assertFalse(metadata.containsVerifiedSignatureFrom(julietKeys));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.algorithm.KeyFlag;
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
import org.pgpainless.decryption_verification.MessageMetadata;
|
||||||
import org.pgpainless.decryption_verification.SignatureVerification;
|
import org.pgpainless.decryption_verification.SignatureVerification;
|
||||||
import org.pgpainless.encryption_signing.EncryptionOptions;
|
import org.pgpainless.encryption_signing.EncryptionOptions;
|
||||||
import org.pgpainless.encryption_signing.EncryptionResult;
|
import org.pgpainless.encryption_signing.EncryptionResult;
|
||||||
|
@ -88,10 +88,10 @@ public class GenerateKeyWithoutUserIdTest {
|
||||||
Streams.pipeAll(decryptionStream, plaintextOut);
|
Streams.pipeAll(decryptionStream, plaintextOut);
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
|
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
|
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(certificate),
|
assertTrue(metadata.isVerifiedSignedBy(certificate),
|
||||||
failuresToString(metadata.getInvalidInbandSignatures()));
|
failuresToString(metadata.getRejectedInlineSignatures()));
|
||||||
assertTrue(metadata.isEncrypted());
|
assertTrue(metadata.isEncrypted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
import org.pgpainless.decryption_verification.MessageMetadata;
|
||||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||||
import org.pgpainless.key.util.KeyRingUtils;
|
import org.pgpainless.key.util.KeyRingUtils;
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ public class IgnoreMarkerPacketsTest {
|
||||||
Streams.pipeAll(decryptionStream, outputStream);
|
Streams.pipeAll(decryptionStream, outputStream);
|
||||||
|
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(new OpenPgpV4Fingerprint("D1A66E1A23B182C9980F788CFBFCC82A015E7330")));
|
assertTrue(metadata.isVerifiedSignedBy(new OpenPgpV4Fingerprint("D1A66E1A23B182C9980F788CFBFCC82A015E7330")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -204,8 +204,8 @@ public class IgnoreMarkerPacketsTest {
|
||||||
|
|
||||||
decryptionStream.close();
|
decryptionStream.close();
|
||||||
assertArrayEquals(data.getBytes(StandardCharsets.UTF_8), outputStream.toByteArray());
|
assertArrayEquals(data.getBytes(StandardCharsets.UTF_8), outputStream.toByteArray());
|
||||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
MessageMetadata metadata = decryptionStream.getMetadata();
|
||||||
assertTrue(metadata.containsVerifiedSignatureFrom(new OpenPgpV4Fingerprint("D1A66E1A23B182C9980F788CFBFCC82A015E7330")));
|
assertTrue(metadata.isVerifiedSignedBy(new OpenPgpV4Fingerprint("D1A66E1A23B182C9980F788CFBFCC82A015E7330")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue