createPBE
public static EncryptedContentInfo createPBE(PBEAlgorithm keyGenAlg,
Password password,
byte[] salt,
int iterationCount,
KeyGenerator.CharToByteConverter charToByteConverter,
byte[] toBeEncrypted)
throws CryptoManager.NotInitializedException,
NoSuchAlgorithmException,
InvalidKeyException,
InvalidAlgorithmParameterException,
TokenException,
CharConversionException
Creates a new EncryptedContentInfo, where the data is encrypted
with a password-based key.
keyGenAlg
- 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.
decrypt
public byte[] decrypt(Password pass,
KeyGenerator.CharToByteConverter charToByteConverter)
throws IllegalStateException,
CryptoManager.NotInitializedException,
NoSuchAlgorithmException,
InvalidBERException,
IOException,
InvalidKeyException,
InvalidAlgorithmParameterException,
TokenException,
IllegalBlockSizeException,
BadPaddingException
Decrypts the content of an EncryptedContentInfo encrypted with a
PBE key.
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.
- The decrypted contents of the EncryptedContentInfo. The contents
are first unpadded using the PKCS padding mechanism.
encode
public void encode(OutputStream ostream)
throws IOException
Write this value's DER encoding to an output stream using
its own base tag.
- encode in interface ASN1Value
encode
public void encode(Tag tag,
OutputStream ostream)
throws IOException
Write this value's DER encoding to an output stream using
an implicit tag.
- encode in interface ASN1Value
getEncryptedContent
public OCTET_STRING getEncryptedContent()
getTag
public Tag getTag()
Returns the base tag for this type, not counting any tags
that may be imposed on it by its context.
- getTag in interface ASN1Value
hasEncryptedContent
public boolean hasEncryptedContent()