mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-14 00:12:06 +01:00
Rename DetachedSignature -> DetachedSignatureCheck
This commit is contained in:
parent
910bae58c0
commit
0e1d6cb5a1
3 changed files with 12 additions and 12 deletions
|
@ -63,7 +63,7 @@ import org.pgpainless.key.SubkeyIdentifier;
|
||||||
import org.pgpainless.key.info.KeyRingInfo;
|
import org.pgpainless.key.info.KeyRingInfo;
|
||||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||||
import org.pgpainless.signature.DetachedSignature;
|
import org.pgpainless.signature.DetachedSignatureCheck;
|
||||||
import org.pgpainless.signature.OnePassSignatureCheck;
|
import org.pgpainless.signature.OnePassSignatureCheck;
|
||||||
import org.pgpainless.signature.SignatureUtils;
|
import org.pgpainless.signature.SignatureUtils;
|
||||||
import org.pgpainless.util.CRCingArmoredInputStreamWrapper;
|
import org.pgpainless.util.CRCingArmoredInputStreamWrapper;
|
||||||
|
@ -81,7 +81,7 @@ public final class DecryptionStreamFactory {
|
||||||
private final ConsumerOptions options;
|
private final ConsumerOptions options;
|
||||||
private final OpenPgpMetadata.Builder resultBuilder = OpenPgpMetadata.getBuilder();
|
private final OpenPgpMetadata.Builder resultBuilder = OpenPgpMetadata.getBuilder();
|
||||||
private final List<OnePassSignatureCheck> onePassSignatureChecks = new ArrayList<>();
|
private final List<OnePassSignatureCheck> onePassSignatureChecks = new ArrayList<>();
|
||||||
private final List<DetachedSignature> detachedSignatureChecks = new ArrayList<>();
|
private final List<DetachedSignatureCheck> detachedSignatureChecks = new ArrayList<>();
|
||||||
|
|
||||||
private static final PGPContentVerifierBuilderProvider verifierBuilderProvider =
|
private static final PGPContentVerifierBuilderProvider verifierBuilderProvider =
|
||||||
ImplementationFactory.getInstance().getPGPContentVerifierBuilderProvider();
|
ImplementationFactory.getInstance().getPGPContentVerifierBuilderProvider();
|
||||||
|
@ -113,7 +113,7 @@ public final class DecryptionStreamFactory {
|
||||||
SubkeyIdentifier signingKeyIdentifier = new SubkeyIdentifier(signingKeyRing, signingKey.getKeyID());
|
SubkeyIdentifier signingKeyIdentifier = new SubkeyIdentifier(signingKeyRing, signingKey.getKeyID());
|
||||||
try {
|
try {
|
||||||
signature.init(verifierBuilderProvider, signingKey);
|
signature.init(verifierBuilderProvider, signingKey);
|
||||||
DetachedSignature detachedSignature = new DetachedSignature(signature, signingKeyRing, signingKeyIdentifier);
|
DetachedSignatureCheck detachedSignature = new DetachedSignatureCheck(signature, signingKeyRing, signingKeyIdentifier);
|
||||||
detachedSignatureChecks.add(detachedSignature);
|
detachedSignatureChecks.add(detachedSignature);
|
||||||
} catch (PGPException e) {
|
} catch (PGPException e) {
|
||||||
LOGGER.warn("Cannot verify detached signature made by {}. Reason: {}", signingKeyIdentifier, e.getMessage(), e);
|
LOGGER.warn("Cannot verify detached signature made by {}. Reason: {}", signingKeyIdentifier, e.getMessage(), e);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.exception.SignatureValidationException;
|
import org.pgpainless.exception.SignatureValidationException;
|
||||||
import org.pgpainless.policy.Policy;
|
import org.pgpainless.policy.Policy;
|
||||||
import org.pgpainless.signature.CertificateValidator;
|
import org.pgpainless.signature.CertificateValidator;
|
||||||
import org.pgpainless.signature.DetachedSignature;
|
import org.pgpainless.signature.DetachedSignatureCheck;
|
||||||
import org.pgpainless.signature.OnePassSignatureCheck;
|
import org.pgpainless.signature.OnePassSignatureCheck;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -45,14 +45,14 @@ public abstract class SignatureInputStream extends FilterInputStream {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(VerifySignatures.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(VerifySignatures.class);
|
||||||
|
|
||||||
private final List<OnePassSignatureCheck> opSignatures;
|
private final List<OnePassSignatureCheck> opSignatures;
|
||||||
private final List<DetachedSignature> detachedSignatures;
|
private final List<DetachedSignatureCheck> detachedSignatures;
|
||||||
private final ConsumerOptions options;
|
private final ConsumerOptions options;
|
||||||
private final OpenPgpMetadata.Builder resultBuilder;
|
private final OpenPgpMetadata.Builder resultBuilder;
|
||||||
|
|
||||||
public VerifySignatures(
|
public VerifySignatures(
|
||||||
InputStream literalDataStream,
|
InputStream literalDataStream,
|
||||||
List<OnePassSignatureCheck> opSignatures,
|
List<OnePassSignatureCheck> opSignatures,
|
||||||
List<DetachedSignature> detachedSignatures,
|
List<DetachedSignatureCheck> detachedSignatures,
|
||||||
ConsumerOptions options,
|
ConsumerOptions options,
|
||||||
OpenPgpMetadata.Builder resultBuilder) {
|
OpenPgpMetadata.Builder resultBuilder) {
|
||||||
super(literalDataStream);
|
super(literalDataStream);
|
||||||
|
@ -114,7 +114,7 @@ public abstract class SignatureInputStream extends FilterInputStream {
|
||||||
|
|
||||||
private void verifyDetachedSignatures() {
|
private void verifyDetachedSignatures() {
|
||||||
Policy policy = PGPainless.getPolicy();
|
Policy policy = PGPainless.getPolicy();
|
||||||
for (DetachedSignature s : detachedSignatures) {
|
for (DetachedSignatureCheck s : detachedSignatures) {
|
||||||
try {
|
try {
|
||||||
signatureWasCreatedInBounds(options.getVerifyNotBefore(), options.getVerifyNotAfter()).verify(s.getSignature());
|
signatureWasCreatedInBounds(options.getVerifyNotBefore(), options.getVerifyNotAfter()).verify(s.getSignature());
|
||||||
CertificateValidator.validateCertificateAndVerifyInitializedSignature(s.getSignature(), (PGPPublicKeyRing) s.getSigningKeyRing(), policy);
|
CertificateValidator.validateCertificateAndVerifyInitializedSignature(s.getSignature(), (PGPPublicKeyRing) s.getSigningKeyRing(), policy);
|
||||||
|
@ -140,13 +140,13 @@ public abstract class SignatureInputStream extends FilterInputStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDetachedSignatures(byte b) {
|
private void updateDetachedSignatures(byte b) {
|
||||||
for (DetachedSignature detachedSignature : detachedSignatures) {
|
for (DetachedSignatureCheck detachedSignature : detachedSignatures) {
|
||||||
detachedSignature.getSignature().update(b);
|
detachedSignature.getSignature().update(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDetachedSignatures(byte[] b, int off, int read) {
|
private void updateDetachedSignatures(byte[] b, int off, int read) {
|
||||||
for (DetachedSignature detachedSignature : detachedSignatures) {
|
for (DetachedSignatureCheck detachedSignature : detachedSignatures) {
|
||||||
detachedSignature.getSignature().update(b, off, read);
|
detachedSignature.getSignature().update(b, off, read);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,19 +24,19 @@ import org.pgpainless.key.SubkeyIdentifier;
|
||||||
* Tuple-class which bundles together a signature, the signing key that created the signature,
|
* Tuple-class which bundles together a signature, the signing key that created the signature,
|
||||||
* an identifier of the signing key and a record of whether or not the signature was verified.
|
* an identifier of the signing key and a record of whether or not the signature was verified.
|
||||||
*/
|
*/
|
||||||
public class DetachedSignature {
|
public class DetachedSignatureCheck {
|
||||||
private final PGPSignature signature;
|
private final PGPSignature signature;
|
||||||
private final PGPKeyRing signingKeyRing;
|
private final PGPKeyRing signingKeyRing;
|
||||||
private final SubkeyIdentifier signingKeyIdentifier;
|
private final SubkeyIdentifier signingKeyIdentifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link DetachedSignature} object.
|
* Create a new {@link DetachedSignatureCheck} object.
|
||||||
*
|
*
|
||||||
* @param signature signature
|
* @param signature signature
|
||||||
* @param signingKeyRing signing key that created the signature
|
* @param signingKeyRing signing key that created the signature
|
||||||
* @param signingKeyIdentifier identifier of the used signing key
|
* @param signingKeyIdentifier identifier of the used signing key
|
||||||
*/
|
*/
|
||||||
public DetachedSignature(PGPSignature signature, PGPKeyRing signingKeyRing, SubkeyIdentifier signingKeyIdentifier) {
|
public DetachedSignatureCheck(PGPSignature signature, PGPKeyRing signingKeyRing, SubkeyIdentifier signingKeyIdentifier) {
|
||||||
this.signature = signature;
|
this.signature = signature;
|
||||||
this.signingKeyRing = signingKeyRing;
|
this.signingKeyRing = signingKeyRing;
|
||||||
this.signingKeyIdentifier = signingKeyIdentifier;
|
this.signingKeyIdentifier = signingKeyIdentifier;
|
Loading…
Reference in a new issue