public final class ECDHEncryptionHandler extends Object implements EncryptionHandler
Some points to note:
This encryption scheme is also generally known as ECIES - Elliptic Curve Integrated Encryption Scheme.
Modifier and Type | Method and Description |
---|---|
byte[] |
decryptCiphertext(Key contentEncryptionKey,
byte[] initialisationVector,
byte[] ciphertext,
byte[] authenticationTag,
byte[] additionalAuthenticatedData)
Decrypts the ciphertext with the Content Encryption Key, using the initialisation vector and additional
authenticated data, following the steps defined by the EncryptionHandler JweAlgorithm.
|
Key |
decryptContentEncryptionKey(Key key,
byte[] encryptedContentEncryptionKey,
JweHeader header)
Decrypts the Content Encryption Key (CEK) following the appropriate steps defined by the EncryptionHandler
JweAlgorithm.
|
JweEncryption |
encryptPlaintext(Key contentEncryptionKey,
byte[] initialisationVector,
byte[] plaintext,
byte[] additionalAuthenticatedData)
Encrypts the plaintext with the Content Encryption Key, using the initialisation vector and additional
authenticated data, following the steps defined by the EncryptionHandler JweAlgorithm.
|
byte[] |
generateInitialisationVector()
Generates a random JWE Initialisation Vector of the correct size for the encryption algorithm, if the
EncryptionHandler JweAlgorithm does not required an initialisation vector then the initialisation vector will
be an empty octet sequence.
|
byte[] |
generateJWEEncryptedKey(Key key,
Key ephemeralKey,
JweHeader header)
Generates the Content Encryption Key (CEK) following the appropriate steps defined by the EncryptionHandler
JweAlgorithm.
|
Key |
getContentEncryptionKey()
Creates a Content Encryption Key (CEK) following the appropriate steps defined by the EncryptionHandler
JweAlgorithm.
|
static ECDHEncryptionHandler |
getInstance(EncryptionHandler keyWrappingHandler,
JweAlgorithm algorithm,
EncryptionMethod encryptionMethod)
Get an instance of the ECDH-ES encryption handler for the given parameters.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decryptContentEncryptionKey, generateJWEEncryptedKey
public static ECDHEncryptionHandler getInstance(EncryptionHandler keyWrappingHandler, JweAlgorithm algorithm, EncryptionMethod encryptionMethod)
keyWrappingHandler
- the underlying key wrapping or direct encryption mode.algorithm
- the overall JWE algorithm to be used. Must be an ECDH-ES type.encryptionMethod
- the content encryption method.public Key getContentEncryptionKey()
EncryptionHandler
See points 1, 2, 3 in Section 5.1 of the JWE Specification.
getContentEncryptionKey
in interface EncryptionHandler
public byte[] generateJWEEncryptedKey(Key key, Key ephemeralKey, JweHeader header)
EncryptionHandler
See points 4, 5, 6 in Section 5.1 of the JWE Specification.
generateJWEEncryptedKey
in interface EncryptionHandler
key
- The key to use to encrypt the Content Encryption Key, if the EncryptionHandler JweAlgorithm requires.ephemeralKey
- The Content Encryption Key (CEK).header
- The JWE header.public byte[] generateInitialisationVector()
EncryptionHandler
See points 9 in Section 5.1 of the JWE Specification.
generateInitialisationVector
in interface EncryptionHandler
public JweEncryption encryptPlaintext(Key contentEncryptionKey, byte[] initialisationVector, byte[] plaintext, byte[] additionalAuthenticatedData)
EncryptionHandler
See points 15, 16 in Section 5.1 of the JWE Specification.
encryptPlaintext
in interface EncryptionHandler
contentEncryptionKey
- The Content Encryption Key.initialisationVector
- The Initialisation Vector.plaintext
- The plaintext to encrypt.additionalAuthenticatedData
- An array of bytes representing the additional authenticated data.public Key decryptContentEncryptionKey(Key key, byte[] encryptedContentEncryptionKey, JweHeader header)
EncryptionHandler
See points 9, 10 in Section 5.2 of the JWE Specification.
decryptContentEncryptionKey
in interface EncryptionHandler
key
- The private key pair to the public key that encrypted the JWT.encryptedContentEncryptionKey
- The encrypted Content Encryption Key.header
- The JWE header.public byte[] decryptCiphertext(Key contentEncryptionKey, byte[] initialisationVector, byte[] ciphertext, byte[] authenticationTag, byte[] additionalAuthenticatedData)
EncryptionHandler
See points 14, 15 in Section 5.2 of the JWE Specification.
decryptCiphertext
in interface EncryptionHandler
contentEncryptionKey
- The Content Encryption Key.initialisationVector
- The Initialisation Vector.ciphertext
- The ciphertext to decrypt.authenticationTag
- The authentication tag.additionalAuthenticatedData
- An array of bytes representing the additional authenticated data.Copyright 2010-2022 ForgeRock AS.