|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cms.crypto.ContentCipher
public class ContentCipher
Encrypts a plaintext message (the "content") using a specified content encryption algorithm and associated parameters, and a provided secret Content Encryption Key (CEK).
This class supports the creation of "detached" encrypted content through
its createDetached(), encryptDetached() and
decryptDetached() methods. Detached encrypted content messages
are defined in the ISO 22895 Cryptographic syntax schema standard
for cryptographic message types EncryptedData, EnvelopedData,
and NamedKeyEncryptedData, which all reference ASN.1 type
EncryptedContentInfo, whose optional encryptedContent
component may be present or absent in a message.
ASN.1 type EncryptedContentInfo is defined in IETF RFC 3852:2004 as:
EncryptedContentInfo ::= SEQUENCE {
contentType ContentType,
contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
}
ContentType ::= CONTENTS.&id({Contents}) -- OBJECT IDENTIFIER
ContentEncryptionAlgorithmIdentifier ::= SEQUENCE {
algorithm ALGORITHM.&id({ContentEncryptionAlgorithms}),
parameters ALGORITHM.&Type({ContentEncryptionAlgorithms}{@algorithm}) OPTIONAL
}
ContentEncryptionAlgorithms ALGORITHM ::= {
... -- Expect additional content encryption algorithm objects --
}
EncryptedContent ::= OCTET STRING
| Constructor Summary | |
|---|---|
ContentCipher(Codec codec)
Constructor for ContentCipher with ASN.1 encoding rules parameter. |
|
| Method Summary | |
|---|---|
EncryptedContentInfo |
createDetached(ContentType contentType,
ContentEncryptionAlgorithmIdentifier contentEncryptionAlgorithm)
Creates a value of ASN.1 type EncryptedContentInfo with the
optional encryptedContent component absent, to form a "detached"
value for a cryptographic message. |
byte[] |
decrypt(byte[] ciphertext,
EncryptedContentInfo message,
javax.crypto.SecretKey key)
The decryptDetached |
byte[] |
decrypt(EncryptedContentInfo message,
javax.crypto.SecretKey key)
ASN.1 decodes a value of ASN.1 type EncryptedContentInfo and decrypts
the ciphertext in the encryptedContent component of this ASN.1 type. |
EncryptedContentInfo |
encrypt(byte[] plaintext,
ContentType contentType,
ContentEncryptionAlgorithmIdentifier contentEncryptionAlgorithm,
javax.crypto.SecretKey key)
Encrypts the plaintext using the specified content encryption algorithm and the provided secret Content Encryption Key CEK), and includes the ciphertext results of encrypting the plaintext in the encryptedContent component of ASN.1 type EncryptedContentInfo. |
byte[] |
encryptDetached(byte[] content,
ContentEncryptionAlgorithmIdentifier contentEncryptionAlgorithm,
javax.crypto.SecretKey key)
Encrypts detached content using the specified content encryption algorithm and the provided secret Content Encryption Key CEK), and returns the ciphertext results of encrypting the content to the caller. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ContentCipher(Codec codec)
ContentCipher with ASN.1 encoding rules parameter.
codec - ASN.1 encoding rules| Method Detail |
|---|
public EncryptedContentInfo encrypt(byte[] plaintext,
ContentType contentType,
ContentEncryptionAlgorithmIdentifier contentEncryptionAlgorithm,
javax.crypto.SecretKey key)
throws CryptoException
EncryptedContentInfo.
plaintext - the content to be encryptedcontentType - content type of the palintext to be encryptedcontentEncryptionAlgorithm - content encryption algorithm identifierkey - Content Encryption Key (CEK)
EncryptedContentInfo
containing the ciphertext results of encrypting the provided plaintext
using the specified content encryption algorithm and provided Content Encryption Key (CEK)
CryptoException
public byte[] decrypt(EncryptedContentInfo message,
javax.crypto.SecretKey key)
throws CryptoException
EncryptedContentInfo and decrypts
the ciphertext in the encryptedContent component of this ASN.1 type.
message - a value of ASN.1 type EncryptedContentInfo containing the ciphertext to be decrypted in order to recover the plaintextkey - the secret Content Encryption Key (CEK) used to encrypt the plaintext and to decrypt the ciphertext
CryptoException
public EncryptedContentInfo createDetached(ContentType contentType,
ContentEncryptionAlgorithmIdentifier contentEncryptionAlgorithm)
EncryptedContentInfo with the
optional encryptedContent component absent, to form a "detached"
value for a cryptographic message.
Note that to create a value of ASN.1 type EncryptedContentInfo
with the encrypted content "detached", this method should be used along
with the encryptDetached() method.
contentType - content type of the palintext to be encryptedcontentEncryptionAlgorithm - content encryption algorithm identifier
EncryptedContentInfo with the
optional encryptedContent component not present in the message.
public byte[] encryptDetached(byte[] content,
ContentEncryptionAlgorithmIdentifier contentEncryptionAlgorithm,
javax.crypto.SecretKey key)
throws CryptoException
Note that to create a value of ASN.1 type EncryptedContentInfo
with the encrypted content "detached", this method should be used along
with the createDetached() method.
content - the content to be encryptedcontentEncryptionAlgorithm - content encryption algorithm identifierkey - Content Encryption Key (CEK)
content
using the specified content encryption algorithm and provided Content Encryption Key (CEK)
CryptoException
public byte[] decrypt(byte[] ciphertext,
EncryptedContentInfo message,
javax.crypto.SecretKey key)
throws CryptoException
decryptDetached method ASN.1 decodes a value of
ASN.1 type EncryptedContentInfo having
"detached" encrypted content and to determine the content encryption
algorithm in the contentEncryptionAlgorithm component
of this ASN.1 type to use to decrypt the provided ciphertext
- Parameters:
ciphertext - value to be dectryptedmessage - a value of ASN.1 type EncryptedContentInfo
containing the content encryption algorithm identifier needed to decrypt the
"detached" ciphertext in order to recover the plaintextkey - the symmetric Content Encryption Key (CEK) used to encrypt the
plaintext and decrypt the ciphertext
- Returns:
- the plaintext (the decrypted ciphertext)
- Throws:
CryptoException
|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||