Package org.conscrypt

Class HpkeContext

  • Direct Known Subclasses:
    HpkeContextRecipient, HpkeContextSender

    public abstract class HpkeContext
    extends java.lang.Object
    Hybrid Public Key Encryption (HPKE) sender APIs.

    Base class for HPKE sender and recipient contexts.

    This is the client API for HPKE usage, all operations are delegated to an implementation class implementing HpkeSpi which is located using the JCA Provider mechanism.

    The implementation maintains the context for an HPKE exchange, including the key schedule to use for seal and open operations. Secret key material based on the context may also be generated and exported as per RFC 9180.

    See Also:
    RFC 9180 (HPKE)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected HpkeSpi spi  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected HpkeContext​(HpkeSpi spi)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] export​(int length, byte[] context)
      Exports secret key material from this HpkeContext as described in RFC 9180.
      private static java.security.Provider findFirstProvider​(java.lang.String algorithm)  
      protected static HpkeSpi findSpi​(java.lang.String algorithm)  
      protected static HpkeSpi findSpi​(java.lang.String algorithm, java.lang.String providerName)  
      protected static HpkeSpi findSpi​(java.lang.String algorithm, java.security.Provider provider)  
      HpkeSpi getSpi()
      Returns the HpkeSpi being used by this HpkeContext.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • HpkeContext

        protected HpkeContext​(HpkeSpi spi)
    • Method Detail

      • export

        public byte[] export​(int length,
                             byte[] context)
        Exports secret key material from this HpkeContext as described in RFC 9180.
        Parameters:
        length - expected output length
        context - optional context string, may be null or empty
        Returns:
        exported value
        Throws:
        java.lang.IllegalArgumentException - if the length is not valid for the KDF in use
        java.lang.IllegalStateException - if this HpkeContext has not been initialised
      • getSpi

        public HpkeSpi getSpi()
        Returns the HpkeSpi being used by this HpkeContext.
        Returns:
        the SPI
      • findSpi

        protected static HpkeSpi findSpi​(java.lang.String algorithm)
                                  throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • findFirstProvider

        private static java.security.Provider findFirstProvider​(java.lang.String algorithm)
                                                         throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • findSpi

        protected static HpkeSpi findSpi​(java.lang.String algorithm,
                                         java.lang.String providerName)
                                  throws java.security.NoSuchAlgorithmException,
                                         java.lang.IllegalArgumentException,
                                         java.security.NoSuchProviderException
        Throws:
        java.security.NoSuchAlgorithmException
        java.lang.IllegalArgumentException
        java.security.NoSuchProviderException
      • findSpi

        protected static HpkeSpi findSpi​(java.lang.String algorithm,
                                         java.security.Provider provider)
                                  throws java.security.NoSuchAlgorithmException,
                                         java.lang.IllegalArgumentException
        Throws:
        java.security.NoSuchAlgorithmException
        java.lang.IllegalArgumentException