|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--codec.asn1.ASN1AbstractCollection
|
+--codec.asn1.ASN1Sequence
|
+--codec.pkcs12.PFX
This class represents a PFX as defined in PKCS#12.
The ASN.1 definition of this structure is
PFX ::= SEQUENCE {
version INTEGER{v3(3)}(v3,...),
authSafe ContentInfo,
macData MacData OPTIONAL
}
MacData ::= SEQUENCE {
mac DigestInfo,
macSalt OCTET STRING,
iterations INTEGER DEFAULT 1
--NOTE: The default is for historical reasons and its use is deprecated.
A higher value like 1024 is recommended.
PFX The PFX is the outer integrity wrapper of a PDU.
To create a PKCS#12 file that can be read by Netscape or Internet Explorer, do the following:
PrivateKey priv = ...;
PublicKey pub = ...;
X509Certificate cert = ...;
char[] password = ...; // this password protects both privacy and integrity
PFX myPFX = new PFX( priv, cert, null, password, "My Certificate", null);
DEREncoder enc = new DEREncoder(new FileOutputStream("myCert.p12"));
myPFX.encode(enc);
enc.close();
| Field Summary | |
protected ContentInfo |
authSafe_
The actual content of this structure. |
protected int |
INTEGRITY_MODE_
holds the current integrity mode |
static int |
INTEGRITY_MODE_NONE
for PFX with no integrity mode |
static int |
INTEGRITY_MODE_PASSWORD
for PFX protected in password integrity mode |
static int |
INTEGRITY_MODE_PUBLIC_KEY
for PFX protected in public key integrity mode |
protected MacData |
macData_
The mac data that protects the integrity of the PFX in password-based-integrity- mode. |
protected static ASN1Integer |
version_
The PFX Version Number. |
| Fields inherited from class java.util.AbstractList |
modCount |
| Constructor Summary | |
PFX()
This constructor builds the tree of ASN.1 objects used for decoding this structure. |
|
PFX(AuthenticatedSafe authSafe)
This constructor creates a PFX without integrity protection. |
|
PFX(AuthenticatedSafe authSafe,
char[] pwd)
This constructor takes an authenticated safe and creates a PFX PDU that is protected through password-integrity-mode. |
|
PFX(AuthenticatedSafe authSafe,
PrivateKey pk,
X509Certificate cert,
String sigAlgName,
AlgorithmParameters params)
This constructor takes an authenticated safe and creates a PFX PDU that is protected by public-key-integrity-mode. |
|
PFX(PrivateKey pr_key,
X509Certificate cert,
X509Certificate[] chain,
char[] pin,
String user_fn,
byte[] lk_id)
This constructor is for the convenient use of a PFX PDU for PKCS#12 files that can be imported by Netscape or Internet Explorer. |
|
| Method Summary | |
boolean |
checkIntegrity(char[] pwd)
verifies the the Hmac of this PFX if INTEGRITY_MODE_PASSWORD was used. |
X509Certificate |
checkIntegrity(X509Certificate cert)
verifies the signature of the AuthenticatedSafe if INTEGRITY_MODE_PUBLIC_KEY was used. |
void |
decode(Decoder dec)
Decodes this structure. |
AuthenticatedSafe |
getAuthSafe()
This method returns the AuthenticatedSafe structure inside this PFX PDU |
int |
getIntegrityMode()
Returns the integrity protection mode. |
ASN1Integer |
getVersion()
This method returns the version number of this structure. |
String |
toString()
Returns a human-readable String representation of this object. |
| Methods inherited from class codec.asn1.ASN1Sequence |
getTag |
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, 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 class java.util.AbstractList |
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
containsAll, remove, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface java.util.List |
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
| Field Detail |
protected static ASN1Integer version_
protected ContentInfo authSafe_
protected MacData macData_
public static final int INTEGRITY_MODE_NONE
public static final int INTEGRITY_MODE_PASSWORD
public static final int INTEGRITY_MODE_PUBLIC_KEY
protected int INTEGRITY_MODE_
| Constructor Detail |
public PFX()
DERDecoder
of the asn1 package.
public PFX(AuthenticatedSafe authSafe)
throws ASN1Exception
ASN1Exception - if the authSafe could not be encoded
public PFX(AuthenticatedSafe authSafe,
char[] pwd)
throws ASN1Exception,
NoSuchAlgorithmException,
InvalidKeySpecException,
InvalidKeyException,
InvalidAlgorithmParameterException
authSafe - The AuthenticatedSafe to be wrapped in a PFX PDU.pwd - The password used to ensure the integrity of the PFX PDU.ASN1Exception - if the authSafe could not be encodedNoSuchAlgorithmException - if the HMAC algorithms is not availableInvalidKeySpecException - if there was a problem with the HMACInvalidKeyException - if there was a problem with the HMACInvalidAlgorithmParameterException - if there was a problem with the HMAC
public PFX(AuthenticatedSafe authSafe,
PrivateKey pk,
X509Certificate cert,
String sigAlgName,
AlgorithmParameters params)
throws SignatureException,
GeneralSecurityException,
ASN1Exception
authSafe - the authenticated safe that shall be secured in a pdu.pk - the private key that is used to sign the pdu.cert - the corresponding certificate to the private key.sigAlgName - the signature algorithm nameparams - the parameters needed for the signature algorithm. if no
parameters are needed params should be null.SignatureException - if there was a problem with the signing of the PFX pduGeneralSecurityException - if some general problem with the signing occuredASN1Exception - if the authSafe could not be encoded
public PFX(PrivateKey pr_key,
X509Certificate cert,
X509Certificate[] chain,
char[] pin,
String user_fn,
byte[] lk_id)
throws GeneralSecurityException,
CertificateEncodingException,
ASN1Exception
pr_key - the private key.cert - The certificate corresponding to the private keychain - The certificate chain up to the root CA (excluding the
certificate passed in cert). If no chain is used, just
pass nullpin - The password to encrypt and integrity-protect this PFXuser_fn - the user friendlyName attribute (can be null)lk_id - the localKeyId attribute (can be null)GeneralSecurityException - if there was a general problem with the signatureCertificateEncodingException - if there was a problem with the certificateASN1Exception - if some ASN1 type could not be encoded properly| Method Detail |
public boolean checkIntegrity(char[] pwd)
throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException,
InvalidKeyException,
InvalidKeySpecException
pwd - the password protecting the pduNoSuchAlgorithmException - if the HMAC algorithm is not availableInvalidAlgorithmParameterException - if there was a problem with the HMACInvalidKeyException - if there was a problem with the HMACInvalidKeySpecException - if there was a problem with the HMACIllegalStateException - if there this PFX is not protected by
INTEGRITY_MODE_PASSWORD
public X509Certificate checkIntegrity(X509Certificate cert)
throws GeneralSecurityException
cert - the certificate with the public-key to verify the
signature on the AuthenticatedSafe.GeneralSecurityException - if there was a problem with the signature
public void decode(Decoder dec)
throws ASN1Exception,
IOException
BERDecoder.decode in class ASN1AbstractCollectioncodec.asn1.ASN1AbstractCollectiondec - The decoder to read from.
public AuthenticatedSafe getAuthSafe()
throws ASN1Exception,
IllegalStateException
IllegalStateException - if there were no dataASN1Exception - if the authSafe could not proberly be decodedpublic int getIntegrityMode()
public ASN1Integer getVersion()
public String toString()
toString in class ASN1AbstractCollectioncodec.asn1.ASN1AbstractCollection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||