All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.mmm.crypto.asymmetric.key.AsymmetricKeyPairFactory Maven / Gradle / Ivy

package io.github.mmm.crypto.asymmetric.key;

import java.security.PrivateKey;
import java.security.PublicKey;

import io.github.mmm.binary.Binary;
import io.github.mmm.crypto.CryptoBinary;

/**
 * Interface for factory to create instances of {@link AsymmetricKeyPair}, {@link PrivateKey}, and {@link PublicKey}. It
 * shall only be used internally (as SPI). End-users shall use {@link AsymmetricKeyCreator}.
 *
 * @param  type of {@link PrivateKey}.
 * @param  type of {@link PublicKey}.
 * @param  type of {@link AsymmetricKeyPair}.
 * @since 1.0.0
 */
public interface AsymmetricKeyPairFactory>
    extends PrivateKeyFactory, PublicKeyFactory, AsymmetricKeyPairFactorySimple {

  /**
   * @param keyPair the {@link AsymmetricKeyPair} to serialize.
   * @return the serialized {@link Binary}.
   */
  default Binary asBinary(PAIR keyPair) {

    return new CryptoBinary(asData(keyPair));
  }

  /**
   * @param keyPair the {@link AsymmetricKeyPair} to serialize.
   * @return the serialized binary data.
   */
  byte[] asData(PAIR keyPair);

  /**
   * @param data the {@link AsymmetricKeyPair} in its binary form.
   * @return the deserialized {@link AsymmetricKeyPair}.
   */
  PAIR createKeyPair(byte[] data);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy