You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.




org.mozilla.jss.pkix.primitive
Class EncryptedPrivateKeyInfo

java.lang.Object
  extended by org.mozilla.jss.pkix.primitive.EncryptedPrivateKeyInfo
All Implemented Interfaces:
ASN1Value

public class EncryptedPrivateKeyInfo
extends java.lang.Object
implements ASN1Value

PKCS #8 EncryptedPrivateKeyInfo.

 EncryptedPrivateKeyInfo ::= SEQUENCE {
      encryptionAlgorithm     AlgorithmIdentifier,
      encryptedData           OCTET STRING }
 


Nested Class Summary
static class EncryptedPrivateKeyInfo.Template
          A template class for decoding EncryptedPrivateKeyInfos from BER.
 
Constructor Summary
EncryptedPrivateKeyInfo(AlgorithmIdentifier encryptionAlgorithm, OCTET_STRING encryptedData)
          Creates an EncryptedPrivateKeyInfo from its components.
 
Method Summary
static EncryptedPrivateKeyInfo createPBE(PBEAlgorithm keyGenAlg, Password password, byte[] salt, int iterationCount, KeyGenerator.CharToByteConverter charToByteConverter, PrivateKeyInfo pki)
          Creates a new EncryptedPrivateKeyInfo, where the data is encrypted with a password-based key.
 PrivateKeyInfo decrypt(Password pass, KeyGenerator.CharToByteConverter charToByteConverter)
          Decrypts an EncryptedPrivateKeyInfo that was encrypted with a PBE algorithm.
 void encode(java.io.OutputStream ostream)
          Write this value's DER encoding to an output stream using its own base tag.
 void encode(Tag implicitTag, java.io.OutputStream ostream)
          Write this value's DER encoding to an output stream using an implicit tag.
 OCTET_STRING getEncryptedData()
           
 AlgorithmIdentifier getEncryptionAlgorithm()
           
 Tag getTag()
          Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
static EncryptedPrivateKeyInfo.Template getTemplate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptedPrivateKeyInfo

public EncryptedPrivateKeyInfo(AlgorithmIdentifier encryptionAlgorithm,
                               OCTET_STRING encryptedData)
Creates an EncryptedPrivateKeyInfo from its components.

Method Detail

getEncryptionAlgorithm

public AlgorithmIdentifier getEncryptionAlgorithm()

getEncryptedData

public OCTET_STRING getEncryptedData()

createPBE

public static EncryptedPrivateKeyInfo createPBE(PBEAlgorithm keyGenAlg,
                                                Password password,
                                                byte[] salt,
                                                int iterationCount,
                                                KeyGenerator.CharToByteConverter charToByteConverter,
                                                PrivateKeyInfo pki)
                                         throws CryptoManager.NotInitializedException,
                                                java.security.NoSuchAlgorithmException,
                                                java.security.InvalidKeyException,
                                                java.security.InvalidAlgorithmParameterException,
                                                TokenException,
                                                java.io.CharConversionException
Creates a new EncryptedPrivateKeyInfo, where the data is encrypted with a password-based key.

Parameters:
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.
Throws:
CryptoManager.NotInitializedException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
TokenException
java.io.CharConversionException

decrypt

public PrivateKeyInfo decrypt(Password pass,
                              KeyGenerator.CharToByteConverter charToByteConverter)
                       throws CryptoManager.NotInitializedException,
                              java.security.NoSuchAlgorithmException,
                              InvalidBERException,
                              java.security.InvalidKeyException,
                              java.security.InvalidAlgorithmParameterException,
                              TokenException,
                              IllegalBlockSizeException,
                              BadPaddingException,
                              java.io.CharConversionException
Decrypts an EncryptedPrivateKeyInfo that was encrypted with a PBE algorithm. The algorithm and its parameters are extracted from the EncryptedPrivateKeyInfo.

Parameters:
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.
Throws:
CryptoManager.NotInitializedException
java.security.NoSuchAlgorithmException
InvalidBERException
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
TokenException
IllegalBlockSizeException
BadPaddingException
java.io.CharConversionException

getTag

public Tag 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.

Specified by:
getTag in interface ASN1Value

encode

public void encode(java.io.OutputStream ostream)
            throws java.io.IOException
Description copied from interface: ASN1Value
Write this value's DER encoding to an output stream using its own base tag.

Specified by:
encode in interface ASN1Value
Throws:
java.io.IOException

encode

public void encode(Tag implicitTag,
                   java.io.OutputStream ostream)
            throws java.io.IOException
Description copied from interface: ASN1Value
Write this value's DER encoding to an output stream using an implicit tag.

Specified by:
encode in interface ASN1Value
Throws:
java.io.IOException

getTemplate

public static EncryptedPrivateKeyInfo.Template getTemplate()