com.nimbusds.jose.crypto
Class RSADecrypter

java.lang.Object
  extended by com.nimbusds.jose.crypto.RSADecrypter
All Implemented Interfaces:
JWEAlgorithmProvider, JWEDecrypter

public class RSADecrypter
extends Object
implements JWEDecrypter

RSA decrypter of JWE objects. This class is thread-safe.

Supports the following JWE algorithms:

Supports the following encryption methods:

Accepts all reserved JWE header parameters. Modify the header filter properties to restrict the acceptable JWE algorithms, encryption methods and header parameters, or to allow custom JWE header parameters.

Version:
$version$ (2013-03-27)
Author:
David Ortiz, Vladimir Dzhuvinov

Field Summary
static Set<JWEAlgorithm> SUPPORTED_ALGORITHMS
          The supported JWE algorithms.
static Set<EncryptionMethod> SUPPORTED_ENCRYPTION_METHODS
          The supported encryption methods.
 
Constructor Summary
RSADecrypter(RSAPrivateKey privateKey)
          Creates a new RSA decrypter.
 
Method Summary
protected static int cekBitLength(EncryptionMethod method)
          Gets the Content Encryption Key (CEK) length for the specified encryption method.
protected static int cikBitLength(EncryptionMethod method)
          Gets the Content Integrity Key (CIK) length for the specified encryption method.
protected static int cmkBitLength(EncryptionMethod method)
          Gets the Content Master Key (CMK) length for the specified encryption method.
 byte[] decrypt(ReadOnlyJWEHeader readOnlyJWEHeader, Base64URL encryptedKey, Base64URL iv, Base64URL cipherText, Base64URL integrityValue)
          Decrypts the specified cipher text of a JWE Object.
 JWEHeaderFilter getJWEHeaderFilter()
          Gets the JWE header filter associated with the decrypter.
 RSAPrivateKey getPrivateKey()
          Gets the private RSA key.
 Set<JWEAlgorithm> supportedAlgorithms()
          Returns the names of the supported JWE algorithms.
 Set<EncryptionMethod> supportedEncryptionMethods()
          Returns the names of the supported encryption methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.nimbusds.jose.JWEAlgorithmProvider
supportedAlgorithms, supportedEncryptionMethods
 

Field Detail

SUPPORTED_ALGORITHMS

public static final Set<JWEAlgorithm> SUPPORTED_ALGORITHMS
The supported JWE algorithms.


SUPPORTED_ENCRYPTION_METHODS

public static final Set<EncryptionMethod> SUPPORTED_ENCRYPTION_METHODS
The supported encryption methods.

Constructor Detail

RSADecrypter

public RSADecrypter(RSAPrivateKey privateKey)
Creates a new RSA decrypter.

Parameters:
privateKey - The private RSA key. Must not be null.
Method Detail

getPrivateKey

public RSAPrivateKey getPrivateKey()
Gets the private RSA key.

Returns:
The private RSA key.

getJWEHeaderFilter

public JWEHeaderFilter getJWEHeaderFilter()
Description copied from interface: JWEDecrypter
Gets the JWE header filter associated with the decrypter. Specifies the names of those supported JWE algorithms and header parameters that the decrypter is configured to accept.

Attempting to decrypt a JWE object with an algorithm or header parameter that is not accepted must result in a JOSEException.

Specified by:
getJWEHeaderFilter in interface JWEDecrypter
Returns:
The JWE header filter.

decrypt

public byte[] decrypt(ReadOnlyJWEHeader readOnlyJWEHeader,
                      Base64URL encryptedKey,
                      Base64URL iv,
                      Base64URL cipherText,
                      Base64URL integrityValue)
               throws JOSEException
Description copied from interface: JWEDecrypter
Decrypts the specified cipher text of a JWE Object.

Specified by:
decrypt in interface JWEDecrypter
Parameters:
readOnlyJWEHeader - The JSON Web Encryption (JWE) header. Must specify an accepted JWE algorithm, must contain only accepted header parameters, and must not be null.
encryptedKey - The encrypted key, null if not required by the JWE algorithm.
iv - The initialisation vector, null if not required by the JWE algorithm.
cipherText - The cipher text to decrypt. Must not be null.
integrityValue - The integrity value, null if not required by the JWE algorithm.
Returns:
The clear text.
Throws:
JOSEException - If the JWE algorithm is not accepted, if a header parameter is not accepted, or if decryption failed for some other reason.

cmkBitLength

protected static int cmkBitLength(EncryptionMethod method)
                           throws JOSEException
Gets the Content Master Key (CMK) length for the specified encryption method.

Parameters:
method - The encryption method. Must be supported by this RSA provider. Must not be null.
Returns:
The CMK length, in bits.
Throws:
JOSEException - If the encryption method is not supported.

cekBitLength

protected static int cekBitLength(EncryptionMethod method)
                           throws JOSEException
Gets the Content Encryption Key (CEK) length for the specified encryption method.

Parameters:
method - The encryption method. Must be supported by this RSA provider and must employ CEKs. Must not be null.
Returns:
The CEK length, in bits.
Throws:
JOSEException - If the encryption method is not supported or doesn't employ CEKs.

cikBitLength

protected static int cikBitLength(EncryptionMethod method)
                           throws JOSEException
Gets the Content Integrity Key (CIK) length for the specified encryption method.

Parameters:
method - The encryption method. Must be supported by this RSA provider and must employ CIKs. Must not be null.
Returns:
The CIK length, in bits.
Throws:
JOSEException - If the encryption method is not supported or doesn't employ CIKs.

supportedAlgorithms

public Set<JWEAlgorithm> supportedAlgorithms()
Description copied from interface: JWEAlgorithmProvider
Returns the names of the supported JWE algorithms. These correspond to the alg JWE header parameter.

Specified by:
supportedAlgorithms in interface JWEAlgorithmProvider
Returns:
The supported JWE algorithms, empty set if none.

supportedEncryptionMethods

public Set<EncryptionMethod> supportedEncryptionMethods()
Description copied from interface: JWEAlgorithmProvider
Returns the names of the supported encryption methods. These correspond to the enc JWE header parameter.

Specified by:
supportedEncryptionMethods in interface JWEAlgorithmProvider
Returns:
The supported encryption methods, empty set if none.


Copyright © 2013 NimbusDS. All Rights Reserved.