org.mozilla.jss.pkix.primitive
Class EncryptedPrivateKeyInfo
java.lang.Object
org.mozilla.jss.pkix.primitive.EncryptedPrivateKeyInfo
- ASN1Value
public class EncryptedPrivateKeyInfo
extends java.lang.Object
PKCS #8
EncryptedPrivateKeyInfo.
EncryptedPrivateKeyInfo ::= SEQUENCE {
encryptionAlgorithm AlgorithmIdentifier,
encryptedData OCTET STRING }
EncryptedPrivateKeyInfo
public EncryptedPrivateKeyInfo(AlgorithmIdentifier encryptionAlgorithm,
OCTET_STRING encryptedData)
Creates an EncryptedPrivateKeyInfo from its components.
createPBE
public static EncryptedPrivateKeyInfo createPBE(PBEAlgorithm keyGenAlg,
Password password,
byte[] salt,
int iterationCount,
KeyGenerator.CharToByteConverter charToByteConverter,
PrivateKeyInfo pki)
throws CryptoManager.NotInitializedException,
NoSuchAlgorithmException,
InvalidKeyException,
InvalidAlgorithmParameterException,
TokenException,
CharConversionException
Creates a new EncryptedPrivateKeyInfo, 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.pki
- The PrivateKeyInfo to be encrypted and stored in the
EncryptedContentInfo. Before they are encrypted, they will be
padded using PKCS padding.
decrypt
public PrivateKeyInfo decrypt(Password pass,
KeyGenerator.CharToByteConverter charToByteConverter)
throws CryptoManager.NotInitializedException,
NoSuchAlgorithmException,
InvalidBERException,
InvalidKeyException,
InvalidAlgorithmParameterException,
TokenException,
IllegalBlockSizeException,
BadPaddingException,
CharConversionException
Decrypts an EncryptedPrivateKeyInfo that was encrypted with a PBE
algorithm. The algorithm and its parameters are extracted from
the EncryptedPrivateKeyInfo.
pass
- The password to use to generate the PBE key.charToByteConverter
- The converter to change the password
characters to bytes. If null, the default conversion is used.
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 implicitTag,
OutputStream ostream)
throws IOException
Write this value's DER encoding to an output stream using
an implicit tag.
- encode in interface ASN1Value
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