|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.pkcs.pkcs12.PKCS12
This class implements PKCS#12 objects exportet from Netscape Navigator or MS Internet Explorer.
The PKCS#12 Personal Information Exchange Syntax Standard describes a transfer syntax for personal identity information, including private keys, certificates, miscellaneous secrets, and extensions.
This version was successfully testet with Netscape 4.05, 4.5 and can not be used to import files created with version 4.03 or lower. On the MSIE side this version was tested against IE 4.0 with SP3 and SP4 on Windows NT. After installing SP4 on Windows NT one can choose enhanced security when exporting a private key and the corresponding certificate.
Enhanced security in that context means, that when deriving the content
encryption keys from the passphrase and the salt the value of the iteration
count is set to 2000, thus increasing the cost of brute force attacks against
the private key. This feature can be switched on when creating a new PKCS#12
object through setting parameter moreSecure
to true
in the corresponding constructor. It is also possible to import these secured
versions in Navigator 4.5!
SafeBag
,
AuthenticatedSafe
Field Summary | |
protected AuthenticatedSafe[] |
authenticated_safes
|
protected int |
mode
|
static int |
PASSWORD_INTEGRITY_MODE
The password integrity mode. |
static int |
PUBLIC_KEY_INTEGRITY_MODE
The public-key integrity mode. |
Constructor Summary | |
PKCS12(ASN1Object obj)
Creates a PKCS#12 object from an ASN1Object. |
|
PKCS12(InputStream is)
Creates a new PKCS#12 object from an InputStream. |
|
PKCS12(KeyBag keyBag,
CertificateBag[] certificateBags)
Creates a new PKCS#12 object from a KeyBag and an array of CertificateBags. |
|
PKCS12(KeyBag keyBag,
CertificateBag[] certificateBags,
boolean moreSecure)
Creates a new PKCS#12 object from a KeyBag and an array of CertificateBags. |
Method Summary | |
protected void |
decode()
Decodes this given PKCS#12 object for parsing the internal structure. |
void |
decrypt(char[] password)
Uses the provided password to decrypt this PKCS12 object for recovering the inherent authenticatedSafes. |
void |
encrypt(char[] password)
Uses the provided password to encrypt the content of this PKCS#12 object. |
void |
encrypt(char[] password,
AlgorithmID authSafesAlg,
AlgorithmID shroudedKeyBagAlg)
Uses the provided password to encrypt the content of this PKCS#12 object. |
AuthenticatedSafe[] |
getAuthenticatedSafes()
Returns all AuthenticatesSafes included in this PKCS#12 object for manually parsing. |
CertificateBag[] |
getCertificateBags()
Returns an array of all CertificateBags within this PKCS#12 object. |
KeyBag |
getKeyBag()
Tries to find a KeyBag within all AuthenticatedSafes and returns it. |
KeyBag[] |
getKeyBags()
Tries to find KeyBags within all AuthenticatedSafes and returns them. |
ASN1Object |
toASN1Object()
Returns this PKCS#12 object as ASN1Object. |
String |
toString()
Returns a string giving some information about this PKCS12
object. |
boolean |
verify(char[] password)
Verifies the MAC of this PKCS12 object. |
void |
writeTo(OutputStream os)
Writes this PKCS#12 object to the specified output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int PUBLIC_KEY_INTEGRITY_MODE
public static final int PASSWORD_INTEGRITY_MODE
protected AuthenticatedSafe[] authenticated_safes
protected int mode
Constructor Detail |
public PKCS12(KeyBag keyBag, CertificateBag[] certificateBags) throws PKCSException
keyBag
- the SafeBag containing the private keycertificateBags
- the SafeBags containing the users certificate and
maybe a chain to a CAPKCSException
- if the PKCS#12 object can not be created because of an encoding
problem concerning the private key or the certificatespublic PKCS12(KeyBag keyBag, CertificateBag[] certificateBags, boolean moreSecure) throws PKCSException
keyBag
- the SafeBag containing the private keycertificateBags
- the SafeBags containing the users certificate and
maybe a chain to a CAmoreSecure
- if true, an iteration count of 2000 is used for generating the keys.
Take a look at the general class documentation for a description of this parameter.PKCSException
- if the PKCS#12 object can not be created because of an encoding
problem concerning the private key or the certificatespublic PKCS12(InputStream is) throws IOException, PKCSParsingException
Use this constructor for creating an object from an InputStream containing a DER encoded PKCS#12 object which was exported from MSIE or Netscape.
is
- the input stream where the object shall be read fromIOException
- if the object could not be readPKCSParsingException
- if the object could not be parsedpublic PKCS12(ASN1Object obj) throws PKCSParsingException
Do not use this constructor for supplying authenticatedSafes and
setting the integrity mode. This constructor may be used for parsing an
already exisiting PKCS12
object, supplied as ASN1Object
that may have been created by calling
toASN1Object
.
obj
- the PKCS12 object as ASN1ObjectPKCSParsingException
- if the ASN1Object could not be parsedMethod Detail |
protected void decode() throws PKCSParsingException
PKCSParsingException
- if this object can not be parsedpublic void decrypt(char[] password) throws PKCSException
This method may be used for performing the decryption after
creating a PKCS12
object from a file that has been
exported from some platform,
e.g.:
PKCS12 pkcs12 = new PKCS12(new FileInputStream("pkcs12.pfx")); pkcs12.decrypt(password);
This method automatically decrypts all inherent
AuthenticatedSafe
objects that have been encrypted
with password-encrypted privacy mode.
The password may even be null
; e.g. if the key has
been exported from Internet Explorer without a password.
password
- the password to decrypt the PKCS#12 object.
null
is a valid password.PKCSException
- if the PKCS#12 object could not be decryptedpublic AuthenticatedSafe[] getAuthenticatedSafes()
public KeyBag getKeyBag()
public KeyBag[] getKeyBags()
public CertificateBag[] getCertificateBags()
public boolean verify(char[] password) throws PKCSException
The MAC is computed by using the HMAC/SHA algorithm based on a sceret key which is
derived from pseudorandom inegrity key material of 160 bit length, created
with the SHA-1 hash algorithm as proposed by PKCS#12. The
salt value necessary for generating the integrity key is derived from
the macData
, and is the same as has been used when creating this
object.
password
- the password that was used to protect this PKCS#12 objecttrue
if the MAC turns out to be correct,
false
otherwisePKCSException
- if an error occurs during the verification process
(e.g. the inherent DigestInfo
cannot
be parsed; or the MAC computation fails)public void encrypt(char[] password) throws PKCSException
null
; the result is the same as if
a key is exported from Internet Explorer without providing a password.password
- the password for performing privacy encryption and integrity
MAC computation. null
is a valid password.PKCSException
- if the PKCS#12 object could not be encryptedpublic void encrypt(char[] password, AlgorithmID authSafesAlg, AlgorithmID shroudedKeyBagAlg) throws PKCSException
null
; the result is the same as if
a key is exported from Internet Explorer without providing a password.password
- the password for performing privacy encryption and integrity
MAC computation. null
is a valid password.authSafesAlg
- the PBE algorithm to be used to encrypt authenticated safesshroudedKeyBagAlg
- the PBE algorithm to be used to encrypt the shrouded key bagsPKCSException
- if the PKCS#12 object could not be encryptedpublic ASN1Object toASN1Object() throws PKCSException
public void writeTo(OutputStream os) throws IOException
This method may be used for writing this PFX object to a file to be imported into some platform, e.g.:
pkcs12.writeTo(new FileOutputStream("pkcs12.pfx"));
public String toString()
PKCS12
object.toString
in class Object
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |