Class KeyFactorySpi

java.lang.Object
java.security.KeyFactorySpi
org.bouncycastle.jcajce.provider.asymmetric.util.BaseKeyFactorySpi
org.bouncycastle.jcajce.provider.asymmetric.compositekem.KeyFactorySpi
All Implemented Interfaces:
AsymmetricKeyInfoConverter

public class KeyFactorySpi extends BaseKeyFactorySpi implements AsymmetricKeyInfoConverter
KeyFactory for Composite ML-KEM keys as defined in Composite ML-KEM for use in X.509 Public Key Infrastructure. The supported parameter sets are registered in CompositeIndex.
  • Constructor Details

    • KeyFactorySpi

      public KeyFactorySpi()
    • KeyFactorySpi

      public KeyFactorySpi(JcaJceHelper helper)
  • Method Details

    • engineTranslateKey

      protected Key engineTranslateKey(Key key) throws InvalidKeyException
      Specified by:
      engineTranslateKey in class KeyFactorySpi
      Throws:
      InvalidKeyException
    • generatePrivate

      public PrivateKey generatePrivate(PrivateKeyInfo keyInfo) throws IOException
      Creates a CompositePrivateKey from its PrivateKeyInfo encoded form. Per draft-ietf-lamps-pq-composite-kem the private key body is the 64-byte ML-KEM seed concatenated with the traditional private key encoding; the two components are split and decoded with their respective component key factories.
      Specified by:
      generatePrivate in interface AsymmetricKeyInfoConverter
      Parameters:
      keyInfo - PrivateKeyInfo whose key body is the concatenation of the two component keys.
      Returns:
      A CompositePrivateKey holding both component private keys.
      Throws:
      IOException - on a malformed encoding.
    • generatePublic

      public PublicKey generatePublic(SubjectPublicKeyInfo keyInfo) throws IOException
      Creates a CompositePublicKey from its SubjectPublicKeyInfo encoded form. Per draft-ietf-lamps-pq-composite-kem the public key is the concatenation of the two raw component public keys; it is split at the fixed ML-KEM public key size and each component is decoded with its key factory.
      Specified by:
      generatePublic in interface AsymmetricKeyInfoConverter
      Parameters:
      keyInfo - SubjectPublicKeyInfo whose key body is the concatenation of the two component public keys.
      Returns:
      A CompositePublicKey holding both component public keys.
      Throws:
      IOException - on a malformed encoding.