codec.pkcs8
Class EncryptedPrivateKeyInfo
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--codec.asn1.ASN1AbstractCollection
|
+--codec.asn1.ASN1Sequence
|
+--codec.pkcs8.EncryptedPrivateKeyInfo
- All Implemented Interfaces:
- ASN1Collection, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable
- Direct Known Subclasses:
- PKCS8ShroudedKeyBag
- public class EncryptedPrivateKeyInfo
- extends ASN1Sequence
This class represents an EncryptedPrivateKeyInfo as defined in
PKCS#8.
The ASN.1 definition of this structure is
EncryptedPrivateKeyInfo ::= SEQUENCE (
encryptionAlgorithm EncryptionAlgorithmIdentifier,
encryptedData EncryptedData
}
EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
EncryptedData ::= OCTET STRING
- Version:
- "$Id: EncryptedPrivateKeyInfo.java,v 1.2 2000/12/06 17:47:33 vroth
Exp $"
- Author:
- Volker Roth
- See Also:
- Serialized Form
|
Constructor Summary |
EncryptedPrivateKeyInfo()
This method builds the tree of ASN.1 objects used for decoding this
structure. |
|
Method Summary |
PrivateKey |
getPrivateKey(char[] password)
This method decrypts the stored encrypted private key info and extracts
the private key from it. |
void |
setPrivateKey(PrivateKey key,
char[] passwd)
Encrypts the given private key information using the given password and
stores the resulting encrypted private key info. |
void |
setPrivateKey(PrivateKey key,
char[] passwd,
String algorithm)
This constructor works with a PrivateKey, a password and an algorithm.
|
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
DEFAULT_PBE
public static final String DEFAULT_PBE
- Default PBE encryption algorithm (PBEWithMD5AndDES).
DEFAULT_SALT
public static final int DEFAULT_SALT
- Default salt length as suggested in the PKCS#5
Specification is 8.
DEFAULT_ITERATIONCOUNT
public static final int DEFAULT_ITERATIONCOUNT
- The default iteration count. Used for generating a
PBEParameterSpec
encryptedData_
protected ASN1OctetString encryptedData_
- The result of encrypting the private-key information.
algorithm_
protected AlgorithmIdentifier algorithm_
- The name of the algorithm to use when encrypting PrivateKeyInfos or
null if the algorithm name is not known or not yet
initialized.
random_
protected SecureRandom random_
- The source of randomness used for generating salt values. If no PRNG is
set then the default one is used.
pbeParamSpec_
protected PBEParameterSpec pbeParamSpec_
- This variable has to be defined as a variable with global scope. It
stores the
salt and iterationCount used for
encoding a private Key. The information is stored as an instance of
AlgorithmParameters used for a later decoding
of the key.
EncryptedPrivateKeyInfo
public EncryptedPrivateKeyInfo()
- This method builds the tree of ASN.1 objects used for decoding this
structure.
setPrivateKey
public void setPrivateKey(PrivateKey key,
char[] passwd)
throws GeneralSecurityException
- Encrypts the given private key information using the given password and
stores the resulting encrypted private key info.
- Parameters:
key - The private key to encrypt.passwd - The password to use.- Throws:
GeneralSecurityException - if there is one of the various exceptions related to
ciphers being thrown.
setPrivateKey
public void setPrivateKey(PrivateKey key,
char[] passwd,
String algorithm)
throws GeneralSecurityException
- This constructor works with a PrivateKey, a password and an algorithm.
Any traces of the private key that are created during encryption and
encoding are deleted after use unless there is an exception being thrown
during encryption.
- Parameters:
key - The private key to encrypt.passwd - The password to use for generating the encryption key.algorithm - The name of the PBE algorithm to use for encryption.- Throws:
GeneralSecurityException - if there is one of the various exceptions related to
ciphers being thrown.
getPrivateKey
public PrivateKey getPrivateKey(char[] password)
throws GeneralSecurityException
- This method decrypts the stored encrypted private key info and extracts
the private key from it.
- Parameters:
password - The password required for decryption.- Returns:
- The private key.
- Throws:
UnrecoverableKeyException - if the key could not be decrypted or decoded.
Copyright © Fraunhofer Gesellschaft. All Rights Reserved.