
io.github.mmm.crypto.asymmetric.sign.SignatureProcessorFactoryImplWithHash Maven / Gradle / Ivy
package io.github.mmm.crypto.asymmetric.sign;
import java.security.PrivateKey;
import java.security.PublicKey;
import io.github.mmm.crypto.hash.HashCreator;
import io.github.mmm.crypto.hash.HashFactory;
/**
* Implementation of {@link SignatureProcessorFactory} combining a {@link SignatureProcessor} with a
* {@link HashCreator}.
*
* @param type of {@link SignatureBinary}.
* @param type of {@link PrivateKey}.
* @param type of {@link PublicKey}.
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 1.0.0
*/
public class SignatureProcessorFactoryImplWithHash
implements SignatureProcessorFactory {
private final SignatureProcessorFactory signatureFactory;
private final HashFactory hashFactory;
/**
* The constructor.
*
* @param signatureFactory the {@link SignatureProcessorFactory} to delegate to.
* @param hashFactory the {@link HashFactory} to apply before signing or verifying.
*/
public SignatureProcessorFactoryImplWithHash(SignatureProcessorFactory signatureFactory,
HashFactory hashFactory) {
super();
this.signatureFactory = signatureFactory;
this.hashFactory = hashFactory;
}
@Override
public SignatureSigner newSigner(PR privateKey) {
return new SignatureSignerImplWithHash<>(this.hashFactory.newHashCreator(), this.signatureFactory.newSigner(privateKey));
}
@Override
public SignatureVerifier newVerifier(PU publicKey) {
return new SignatureVerifierImplWithHash<>(this.hashFactory.newHashCreator(), this.signatureFactory.newVerifier(publicKey));
}
@Override
public S createSignature(byte[] data) {
return this.signatureFactory.createSignature(data);
}
@Override
public SignatureProcessorFactory getSignatureFactoryWithoutHash() {
return this.signatureFactory;
}
@Override
public String toString() {
return this.hashFactory.toString() + "+" + this.signatureFactory.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy