public class RSAEncrypter extends java.lang.Object implements JWEEncrypter
Modifier and Type | Field and Description |
---|---|
static java.util.Set<JWEAlgorithm> |
SUPPORTED_ALGORITHMS |
static java.util.Set<EncryptionMethod> |
SUPPORTED_ENCRYPTION_METHODS |
Constructor and Description |
---|
RSAEncrypter(java.security.interfaces.RSAPublicKey pubKey)
Creates a new RSA encrypter.
|
Modifier and Type | Method and Description |
---|---|
JWECryptoParts |
encrypt(ReadOnlyJWEHeader readOnlyJWEHeader,
byte[] bytes)
Encrypts the specified clear text of a
JWE object . |
protected static javax.crypto.SecretKey |
generateAESCMK(int keyLength)
Generates an AES Content Master Key (CMK) of the specified length.
|
protected byte[] |
generateAESGCMIV()
Generates a random 96 bit (12 byte) Initialisation Vector(IV) for
use in AES-GCM encryption.
|
protected int |
keyLengthForMethod(EncryptionMethod method)
Gets the Content Master Key (CMK) length for the specified
encryption method.
|
java.util.Set<JWEAlgorithm> |
supportedAlgorithms()
Returns the names of the supported JWE algorithms.
|
java.util.Set<EncryptionMethod> |
supportedEncryptionMethods()
Returns the names of the supported encryption methods.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
supportedAlgorithms, supportedEncryptionMethods
public static final java.util.Set<JWEAlgorithm> SUPPORTED_ALGORITHMS
public static final java.util.Set<EncryptionMethod> SUPPORTED_ENCRYPTION_METHODS
public RSAEncrypter(java.security.interfaces.RSAPublicKey pubKey)
pubKey
- The public RSA key. Must not be null
.public JWECryptoParts encrypt(ReadOnlyJWEHeader readOnlyJWEHeader, byte[] bytes) throws JOSEException
JWEEncrypter
JWE object
.encrypt
in interface JWEEncrypter
readOnlyJWEHeader
- The JSON Web Encryption (JWE) header. Must specify a
supported JWE algorithm and must not be
null
.bytes
- The clear text to encrypt. Must not be null
.JOSEException
- If the JWE algorithm is not supported or if
encryption failed for some other reason.protected static javax.crypto.SecretKey generateAESCMK(int keyLength) throws java.security.NoSuchAlgorithmException
keyLength
- The key length, in bits.java.security.NoSuchAlgorithmException
- If AES key generation is not
supported.protected byte[] generateAESGCMIV()
See http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-08#section-4.9
public java.util.Set<JWEAlgorithm> supportedAlgorithms()
JWEAlgorithmProvider
alg
JWE header parameter.supportedAlgorithms
in interface JWEAlgorithmProvider
public java.util.Set<EncryptionMethod> supportedEncryptionMethods()
JWEAlgorithmProvider
enc
JWE header parameter.supportedEncryptionMethods
in interface JWEAlgorithmProvider
protected int keyLengthForMethod(EncryptionMethod method)
method
- The encryption method. Must be supported by this RSA
provider. Must not be null
.Copyright © 2013 NimbusDS. All Rights Reserved.