package meerkat.crypto;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.security.*;
import java.security.cert.CertificateException;
import java.util.Date;

/**
 * A {@link DigitalSignature} that supports key generation.
 */
public interface DigitalSignatureGenerator extends DigitalSignature {
    /**
     * Generate a new verification key / signature key pair.
     * The keypair is loaded as the default signing key.
     *
     * @param serial serial number of certificate
     * @param notBefore earliest valid time
     * @param notAfter expiration
     * @param subjectName name corresponding to cert (will be used as "common name" in x509 cert).
     */
    public void generateSigningCertificate(BigInteger serial, Date notBefore, Date notAfter,
                                           String subjectName);


    /**
     * Store a keypair in a given keystore.
     *
     * @param store
     * @param alias
     * @param password
     * @throws IOException
     * @throws KeyStoreException
     */
    public void storeSignatureKeypair(KeyStore store, String alias, char[] password)
            throws IOException, KeyStoreException;
}
