Package org.mozilla.jss.pkcs7
Class EncryptedContentInfo
java.lang.Object
org.mozilla.jss.pkcs7.EncryptedContentInfo
- All Implemented Interfaces:
ASN1Value
The PKCS #7 type EncryptedContentInfo, which encapsulates
encrypted data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A template file for decoding a EnvelopedData blob -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AlgorithmIdentifier
private OBJECT_IDENTIFIER
private OCTET_STRING
private SEQUENCE
private static final Tag
private static final EncryptedContentInfo.Template
-
Constructor Summary
ConstructorsConstructorDescriptionEncryptedContentInfo
(OBJECT_IDENTIFIER contentType, AlgorithmIdentifier contentEncryptionAlgorithm, OCTET_STRING encryptedContent) Create a EnvelopedData ASN1 object.EncryptedContentInfo
(OBJECT_IDENTIFIER contentType, AlgorithmIdentifier contentEncryptionAlgorithm, OCTET_STRING encryptedContent, boolean createHackedCRSCompatibleECI) -
Method Summary
Modifier and TypeMethodDescriptionstatic EncryptedContentInfo
createCRSCompatibleEncryptedContentInfo
(OBJECT_IDENTIFIER contentType, AlgorithmIdentifier contentEncryptionAlgorithm, OCTET_STRING encryptedContent) static EncryptedContentInfo
createPBE
(PBEAlgorithm pbeAlg, Password password, byte[] salt, int iterationCount, KeyGenerator.CharToByteConverter charToByteConverter, byte[] toBeEncrypted) Creates a new EncryptedContentInfo, where the data is encrypted with a password-based key.byte[]
decrypt
(Password pass, KeyGenerator.CharToByteConverter charToByteConverter) Decrypts the content of an EncryptedContentInfo encrypted with a PBE key.void
encode
(OutputStream ostream) Write this value's DER encoding to an output stream using its own base tag.void
encode
(Tag tag, OutputStream ostream) Write this value's DER encoding to an output stream using an implicit tag.getTag()
Returns the base tag for this type, not counting any tags that may be imposed on it by its context.boolean
-
Field Details
-
contentType
-
contentEncryptionAlgorithm
-
encryptedContent
-
sequence
-
TAG
-
templateInstance
-
-
Constructor Details
-
EncryptedContentInfo
public EncryptedContentInfo(OBJECT_IDENTIFIER contentType, AlgorithmIdentifier contentEncryptionAlgorithm, OCTET_STRING encryptedContent) Create a EnvelopedData ASN1 object. -
EncryptedContentInfo
public EncryptedContentInfo(OBJECT_IDENTIFIER contentType, AlgorithmIdentifier contentEncryptionAlgorithm, OCTET_STRING encryptedContent, boolean createHackedCRSCompatibleECI)
-
-
Method Details
-
getContentType
-
getContentEncryptionAlgorithm
-
getEncryptedContent
-
hasEncryptedContent
public boolean hasEncryptedContent() -
createCRSCompatibleEncryptedContentInfo
public static EncryptedContentInfo createCRSCompatibleEncryptedContentInfo(OBJECT_IDENTIFIER contentType, AlgorithmIdentifier contentEncryptionAlgorithm, OCTET_STRING encryptedContent) -
createPBE
public static EncryptedContentInfo createPBE(PBEAlgorithm pbeAlg, Password password, byte[] salt, int iterationCount, KeyGenerator.CharToByteConverter charToByteConverter, byte[] toBeEncrypted) throws NotInitializedException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, TokenException, CharConversionException Creates a new EncryptedContentInfo, where the data is encrypted with a password-based key.- Parameters:
pbeAlg
- The algorithm for generating a symmetric key from a password, salt, and iteration count.password
- The password to use in generating the key.salt
- The salt to use in generating the key.iterationCount
- The number of hashing iterations to perform while generating the key.charToByteConverter
- The mechanism for converting the characters in the password into bytes. If null, the default mechanism will be used, which is UTF8.toBeEncrypted
- The bytes to be encrypted and stored in the EncryptedContentInfo. Before they are encrypted, they will be padded using PKCS padding.- Throws:
NotInitializedException
NoSuchAlgorithmException
InvalidKeyException
InvalidAlgorithmParameterException
TokenException
CharConversionException
-
decrypt
public byte[] decrypt(Password pass, KeyGenerator.CharToByteConverter charToByteConverter) throws IllegalStateException, NotInitializedException, NoSuchAlgorithmException, InvalidBERException, IOException, InvalidKeyException, InvalidAlgorithmParameterException, TokenException, IllegalBlockSizeException, BadPaddingException Decrypts the content of an EncryptedContentInfo encrypted with a PBE key.- Parameters:
pass
- The password to use in generating the PBE decryption key.charToByteConverter
- The converter for converting the password characters into bytes. May be null to use the default.- Returns:
- The decrypted contents of the EncryptedContentInfo. The contents are first unpadded using the PKCS padding mechanism.
- Throws:
IllegalStateException
NotInitializedException
NoSuchAlgorithmException
InvalidBERException
IOException
InvalidKeyException
InvalidAlgorithmParameterException
TokenException
IllegalBlockSizeException
BadPaddingException
-
getTag
Description copied from interface:ASN1Value
Returns the base tag for this type, not counting any tags that may be imposed on it by its context. -
encode
Description copied from interface:ASN1Value
Write this value's DER encoding to an output stream using its own base tag.- Specified by:
encode
in interfaceASN1Value
- Parameters:
ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
encode
Description copied from interface:ASN1Value
Write this value's DER encoding to an output stream using an implicit tag.- Specified by:
encode
in interfaceASN1Value
- Parameters:
tag
- Implicit tag.ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
getTemplate
-