Package com.nimbusds.jose
Class EncryptionMethod
java.lang.Object
com.nimbusds.jose.Algorithm
com.nimbusds.jose.EncryptionMethod
- All Implemented Interfaces:
Serializable
Encryption method name, represents the
enc
header parameter in JSON
Web Encryption (JWE) objects. This class is immutable.
Includes constants for the following encryption method names:
A128CBC-HS256
A192CBC-HS384
A256CBC-HS512
A128GCM
A192GCM
A256GCM
XC20P
A128CBC+HS256 (deprecated)
A256CBC+HS512 (deprecated)
Additional encryption method names can be defined using the constructors.
- Version:
- 2021-08-22
- Author:
- Vladimir Dzhuvinov
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Encryption method family. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EncryptionMethod
AES_128_CBC_HMAC_SHA_256 authenticated encryption using a 256 bit key (required).static final EncryptionMethod
AES_128_CBC_HMAC_SHA_256 authenticated encryption using a 256 bit key, deprecated in JOSE draft suite version 09.static final EncryptionMethod
AES in Galois/Counter Mode (GCM) (NIST.800-38D) using a 128 bit key (recommended).static final EncryptionMethod
AES_192_CBC_HMAC_SHA_384 authenticated encryption using a 384 bit key (optional).static final EncryptionMethod
AES in Galois/Counter Mode (GCM) (NIST.800-38D) using a 192 bit key (optional).static final EncryptionMethod
AES_256_CBC_HMAC_SHA_512 authenticated encryption using a 512 bit key (required).static final EncryptionMethod
AES_256_CBC_HMAC_SHA_512 authenticated encryption using a 512 bit key, deprecated in JOSE draft suite version 09.static final EncryptionMethod
AES in Galois/Counter Mode (GCM) (NIST.800-38D) using a 256 bit key (recommended).static final EncryptionMethod
XChaCha: eXtended-nonce ChaCha and AEAD_XChaCha20_Poly1305 (optional) -
Constructor Summary
ConstructorsConstructorDescriptionEncryptionMethod
(String name) Creates a new encryption method.EncryptionMethod
(String name, Requirement req) Creates a new encryption method.EncryptionMethod
(String name, Requirement req, int cekBitLength) Creates a new encryption method. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the length of the associated Content Encryption Key (CEK).static EncryptionMethod
Parses an encryption method from the specified string.Methods inherited from class com.nimbusds.jose.Algorithm
equals, getName, getRequirement, hashCode, toJSONString, toString
-
Field Details
-
A128CBC_HS256
AES_128_CBC_HMAC_SHA_256 authenticated encryption using a 256 bit key (required). -
A192CBC_HS384
AES_192_CBC_HMAC_SHA_384 authenticated encryption using a 384 bit key (optional). -
A256CBC_HS512
AES_256_CBC_HMAC_SHA_512 authenticated encryption using a 512 bit key (required). -
A128CBC_HS256_DEPRECATED
AES_128_CBC_HMAC_SHA_256 authenticated encryption using a 256 bit key, deprecated in JOSE draft suite version 09. -
A256CBC_HS512_DEPRECATED
AES_256_CBC_HMAC_SHA_512 authenticated encryption using a 512 bit key, deprecated in JOSE draft suite version 09. -
A128GCM
AES in Galois/Counter Mode (GCM) (NIST.800-38D) using a 128 bit key (recommended). -
A192GCM
AES in Galois/Counter Mode (GCM) (NIST.800-38D) using a 192 bit key (optional). -
A256GCM
AES in Galois/Counter Mode (GCM) (NIST.800-38D) using a 256 bit key (recommended). -
XC20P
XChaCha: eXtended-nonce ChaCha and AEAD_XChaCha20_Poly1305 (optional)
-
-
Constructor Details
-
EncryptionMethod
Creates a new encryption method.- Parameters:
name
- The encryption method name. Must not benull
.req
- The implementation requirement,null
if not known.cekBitLength
- The Content Encryption Key (CEK) bit length, zero if not specified.
-
EncryptionMethod
Creates a new encryption method. The Content Encryption Key (CEK) bit length is not specified.- Parameters:
name
- The encryption method name. Must not benull
.req
- The implementation requirement,null
if not known.
-
EncryptionMethod
Creates a new encryption method. The implementation requirement and the Content Encryption Key (CEK) bit length are not specified.- Parameters:
name
- The encryption method name. Must not benull
.
-
-
Method Details
-
cekBitLength
Gets the length of the associated Content Encryption Key (CEK).- Returns:
- The Content Encryption Key (CEK) bit length, zero if not specified.
-
parse
Parses an encryption method from the specified string.- Parameters:
s
- The string to parse. Must not benull
.- Returns:
- The encryption method (matching standard algorithm constant, else a newly created algorithm).
-