
io.github.mmm.crypto.asymmetric.sign.SignatureProcessorFactory Maven / Gradle / Ivy
package io.github.mmm.crypto.asymmetric.sign;
import java.security.PrivateKey;
import java.security.PublicKey;
import io.github.mmm.crypto.AbstractCryptoFactory;
/**
* Interface for a {@link AbstractCryptoFactory factory} to create instances of {@link SignatureProcessor} for
* {@link io.github.mmm.crypto.asymmetric.key.AsymmetricKeyPair asymmetric cryptography}.
* {@link SignatureBinary Signatures} only work with asymmetric security. For a given {@link PrivateKey private key} a
* {@link SignatureSigner} can be {@link #newSigner(PrivateKey) created} that allows to
* {@link SignatureSigner#sign(byte[], boolean) sign} any message. With the corresponding {@link PublicKey
* public key} anyone can {@link #newVerifier(PublicKey) create} a {@link SignatureVerifier} to
* {@link SignatureVerifier#verify(byte[], SignatureBinary) verify} the {@link SignatureBinary}.
* An instance of {@link SignatureProcessorFactory} typically combines asymmetric
* {@link io.github.mmm.crypto.crypt.Cryptor cryptography} with
* {@link io.github.mmm.crypto.hash.HashCreator hashing}.
*
* @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 interface SignatureProcessorFactory
extends SignatureFactory {
/**
* @param privateKey the {@link PrivateKey} to use for signing.
* @return the {@link SignatureSigner} for signing.
*/
@SuppressWarnings("unchecked")
default SignatureSigner newSignerUnsafe(PrivateKey privateKey) {
return newSigner((PR) privateKey);
}
/**
* @param privateKey the {@link PrivateKey} to use for signing.
* @return the {@link SignatureSigner} for signing.
*/
SignatureSigner newSigner(PR privateKey);
/**
* @param publicKey the {@link PublicKey} to use for verifying.
* @return the {@link SignatureVerifier} for verifying.
*/
@SuppressWarnings("unchecked")
default SignatureVerifier newVerifierUnsafe(PublicKey publicKey) {
return newVerifier((PU) publicKey);
}
/**
* @param publicKey the {@link PublicKey} to use for verifying.
* @return the {@link SignatureVerifier} for verifying.
*/
SignatureVerifier newVerifier(PU publicKey);
/**
* @return an instance of this {@link SignatureFactory} that does not hash before signing so you can control
* the hashing manually and only sign the resulting hash (e.g. to reuse the hash value for further
* calculations).
*/
SignatureProcessorFactory getSignatureFactoryWithoutHash();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy