Class ECDHEncrypter

    • Constructor Detail

      • ECDHEncrypter

        public ECDHEncrypter​(ECPublicKey publicKey)
                      throws JOSEException
        Creates a new Elliptic Curve Diffie-Hellman encrypter.
        Parameters:
        publicKey - The public EC key. Must not be null.
        Throws:
        JOSEException - If the elliptic curve is not supported.
      • ECDHEncrypter

        public ECDHEncrypter​(ECKey ecJWK)
                      throws JOSEException
        Creates a new Elliptic Curve Diffie-Hellman encrypter.
        Parameters:
        ecJWK - The EC JSON Web Key (JWK). Must not be null.
        Throws:
        JOSEException - If the elliptic curve is not supported.
      • ECDHEncrypter

        public ECDHEncrypter​(ECPublicKey publicKey,
                             SecretKey contentEncryptionKey)
                      throws JOSEException
        Creates a new Elliptic Curve Diffie-Hellman encrypter with an optionally specified content encryption key (CEK).
        Parameters:
        publicKey - The public EC key. Must not be null.
        contentEncryptionKey - The content encryption key (CEK) to use. If specified its algorithm must be "AES" and its length must match the expected for the JWE encryption method ("enc"). If null a CEK will be generated for each JWE.
        Throws:
        JOSEException - If the elliptic curve is not supported.
    • Method Detail

      • encrypt

        public JWECryptoParts encrypt​(JWEHeader header,
                                      byte[] clearText)
                               throws JOSEException
        Description copied from interface: JWEEncrypter
        Encrypts the specified clear text of a JWE object.
        Specified by:
        encrypt in interface JWEEncrypter
        Parameters:
        header - The JSON Web Encryption (JWE) header. Must specify a supported JWE algorithm and method. Must not be null.
        clearText - The clear text to encrypt. Must not be null.
        Returns:
        The resulting JWE crypto parts.
        Throws:
        JOSEException - If the JWE algorithm or method is not supported or if encryption failed for some other internal reason.
      • supportedJWEAlgorithms

        public Set<JWEAlgorithm> supportedJWEAlgorithms()
        Description copied from interface: JWEProvider
        Returns the names of the supported algorithms by the JWE provider instance. These correspond to the alg JWE header parameter.
        Specified by:
        supportedJWEAlgorithms in interface JWEProvider
        Returns:
        The supported JWE algorithms, empty set if none.
      • supportedEncryptionMethods

        public Set<EncryptionMethod> supportedEncryptionMethods()
        Description copied from interface: JWEProvider
        Returns the names of the supported encryption methods by the JWE provier. These correspond to the enc JWE header parameter.
        Specified by:
        supportedEncryptionMethods in interface JWEProvider
        Returns:
        The supported encryption methods, empty set if none.
      • getJCAContext

        public JWEJCAContext getJCAContext()
        Description copied from interface: JCAAware
        Returns the Java Cryptography Architecture (JCA) context. May be used to set a specific JCA security provider or secure random generator.
        Specified by:
        getJCAContext in interface JCAAware<JWEJCAContext>
        Returns:
        The JCA context. Not null.