|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object anon.crypto.PKCS12
public final class PKCS12
This class creates and handles PKCS12 certificates, that include a private key, a public key and an X509 certificate.
Nested Class Summary | |
---|---|
private static class |
PKCS12.MyCipher
|
Field Summary | |
---|---|
private static java.lang.String |
BASE64_TAG
|
private static java.lang.String |
CERT_ALGORITHM
|
static java.lang.String |
FILE_EXTENSION
|
private static java.lang.String |
KEY_ALGORITHM
|
private AsymmetricCryptoKeyPair |
m_keyPair
|
private JAPCertificate |
m_x509certificate
|
private static int |
MIN_ITERATIONS
|
private java.security.SecureRandom |
random
|
private static int |
SALT_SIZE
|
static java.lang.String |
XML_ELEMENT_NAME
|
Fields inherited from interface org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers |
---|
bagtypes, canNotDecryptAny, certBag, certTypes, crlBag, crlTypes, data, des_EDE3_CBC, dhKeyAgreement, digestAlgorithm, digestedData, encryptedData, encryptionAlgorithm, envelopedData, id_aa, id_aa_commitmentType, id_aa_contentHint, id_aa_contentIdentifier, id_aa_encrypKeyPref, id_aa_ets_archiveTimestamp, id_aa_ets_certCRLTimestamp, id_aa_ets_certificateRefs, id_aa_ets_certValues, id_aa_ets_commitmentType, id_aa_ets_contentTimestamp, id_aa_ets_escTimeStamp, id_aa_ets_otherSigCert, id_aa_ets_revocationRefs, id_aa_ets_revocationValues, id_aa_ets_signerAttr, id_aa_ets_signerLocation, id_aa_ets_sigPolicyId, id_aa_otherSigCert, id_aa_receiptRequest, id_aa_signatureTimeStampToken, id_aa_signerLocation, id_aa_signingCertificate, id_aa_signingCertificateV2, id_aa_sigPolicyId, id_alg_CMS3DESwrap, id_alg_CMSRC2wrap, id_alg_PWRI_KEK, id_ct, id_ct_compressedData, id_ct_TSTInfo, id_cti, id_cti_ets_proofOfApproval, id_cti_ets_proofOfCreation, id_cti_ets_proofOfDelivery, id_cti_ets_proofOfOrigin, id_cti_ets_proofOfReceipt, id_cti_ets_proofOfSender, id_hmacWithSHA1, id_hmacWithSHA224, id_hmacWithSHA256, id_hmacWithSHA384, id_hmacWithSHA512, id_mgf1, id_PBES2, id_PBKDF2, id_pSpecified, id_RSAES_OAEP, id_RSASSA_PSS, id_spq, id_spq_ets_unotice, id_spq_ets_uri, keyBag, md2, md2WithRSAEncryption, md4, md4WithRSAEncryption, md5, md5WithRSAEncryption, pbeWithMD2AndDES_CBC, pbeWithMD2AndRC2_CBC, pbeWithMD5AndDES_CBC, pbeWithMD5AndRC2_CBC, pbeWithSHA1AndDES_CBC, pbeWithSHA1AndRC2_CBC, pbeWithSHAAnd128BitRC2_CBC, pbeWithSHAAnd128BitRC4, pbeWithSHAAnd2_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC, pbeWithSHAAnd40BitRC4, pkcs_1, pkcs_12, pkcs_12PbeIds, pkcs_3, pkcs_5, pkcs_7, pkcs_9, pkcs_9_at_challengePassword, pkcs_9_at_contentType, pkcs_9_at_counterSignature, pkcs_9_at_emailAddress, pkcs_9_at_extendedCertificateAttributes, pkcs_9_at_extensionRequest, pkcs_9_at_friendlyName, pkcs_9_at_localKeyId, pkcs_9_at_messageDigest, pkcs_9_at_signingDescription, pkcs_9_at_signingTime, pkcs_9_at_smimeCapabilities, pkcs_9_at_unstructuredAddress, pkcs_9_at_unstructuredName, pkcs8ShroudedKeyBag, preferSignedData, RC2_CBC, rsaEncryption, safeContentsBag, sdsiCertificate, secretBag, sha1WithRSAEncryption, sha224WithRSAEncryption, sha256WithRSAEncryption, sha384WithRSAEncryption, sha512WithRSAEncryption, signedAndEnvelopedData, signedData, sMIMECapabilitiesVersions, srsaOAEPEncryptionSET, x509Certificate, x509certType, x509Crl |
Fields inherited from interface org.bouncycastle.asn1.x509.X509ObjectIdentifiers |
---|
commonName, countryName, crlAccessMethod, id, id_ad, id_ad_caIssuers, id_ad_ocsp, id_ea_rsa, id_pe, id_pkix, id_SHA1, localityName, ocspAccessMethod, organization, organizationalUnitName, ripemd160, ripemd160WithRSAEncryption, stateOrProvinceName |
Constructor Summary | |
---|---|
private |
PKCS12(AsymmetricCryptoKeyPair a_keyPair,
JAPCertificate a_X509certificate)
Creates a new PKCS12 certificate. |
|
PKCS12(X509DistinguishedName a_ownerAlias,
AsymmetricCryptoKeyPair a_keyPair,
Validity a_validity)
Creates a new PKCS12 certificate. |
|
PKCS12(X509DistinguishedName a_ownerAlias,
AsymmetricCryptoKeyPair a_keyPair,
Validity a_validity,
X509Extensions a_extensions)
Creates a new PKCS12 certificate. |
Method Summary | |
---|---|
private static byte[] |
codeData(boolean encrypt,
byte[] data,
org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams,
char[] password,
org.bouncycastle.crypto.BlockCipher cipher,
int keySize)
|
PKCS10CertificationRequest |
createCertifcationRequest()
Creates a certification request from this private certificate. |
private org.bouncycastle.asn1.x509.SubjectKeyIdentifier |
createSubjectKeyId()
|
java.lang.String |
getAlias()
|
private static PKCS12.MyCipher |
getCipher(java.lang.String algId)
|
X509Extensions |
getExtensions()
|
static PKCS12 |
getInstance(byte[] a_bytes,
char[] a_password)
Loads a PKCS12 certificate from a byte array. |
static PKCS12 |
getInstance(byte[] a_bytes,
IMiscPasswordReader a_passwordReader)
Loads a PKCS12 certificate from a byte array. |
static PKCS12 |
getInstance(byte[] a_bytes,
java.lang.String a_password)
|
static PKCS12 |
getInstance(java.io.InputStream a_stream,
char[] password)
Loads a PKCS12 certificate from an input stream. |
static PKCS12 |
getInstance(java.io.InputStream a_stream,
IMiscPasswordReader a_passwordReader)
Loads a PKCS12 certificate from an input stream. |
static PKCS12 |
getInstance(java.io.InputStream a_stream,
java.lang.String password)
|
static PKCS12 |
getInstance(java.lang.String privCertString,
java.lang.String password)
|
X509DistinguishedName |
getIssuer()
|
AsymmetricCryptoKeyPair |
getKeyPair()
Returns the key pair of this certificate. |
IMyPrivateKey |
getPrivateKey()
Returns the private key of this certificate. |
IMyPublicKey |
getPublicKey()
Returns the public key of this certificate. |
X509DistinguishedName |
getSubject()
|
JAPCertificate |
getX509Certificate()
Returns the X509 certificate corresponding to this PKCS12 certificate. |
private static org.bouncycastle.crypto.PBEParametersGenerator |
makePBEGenerator()
|
private static org.bouncycastle.crypto.CipherParameters |
makePBEMacParameters(char[] password,
org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams,
int keySize)
|
private static org.bouncycastle.crypto.CipherParameters |
makePBEParameters(char[] password,
org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams,
java.lang.String targetAlgorithm,
int keySize,
int ivSize)
|
boolean |
setX509Certificate(JAPCertificate a_X509certificate)
Replaces the current X509 certificate by a clone of the given certificate if the given certificate has the same public key as the current certificate. |
void |
sign(PKCS12 a_pkcs12Certificate)
Signs the coresponding X509 certificate with an other pkcs12 certificate. |
void |
sign(PKCS12 a_signerCertificate,
Validity a_validity,
X509Extensions a_extensions,
java.math.BigInteger a_serialNumber)
Signs the coresponding X509 certificate with an other pkcs12 certificate. |
void |
store(java.io.OutputStream stream,
char[] password)
Writes the certificate to an output stream. |
byte[] |
toByteArray()
Converts the certificate to a byte array. |
byte[] |
toByteArray(boolean a_Base64Encoded)
|
byte[] |
toByteArray(char[] a_password)
Converts the certificate to a (optionally encrypted) byte array. |
byte[] |
toByteArray(char[] a_password,
boolean a_Base64Encoded)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String FILE_EXTENSION
private static final int SALT_SIZE
private static final int MIN_ITERATIONS
private static final java.lang.String BASE64_TAG
public static final java.lang.String XML_ELEMENT_NAME
private static final java.lang.String KEY_ALGORITHM
private static final java.lang.String CERT_ALGORITHM
private java.security.SecureRandom random
private AsymmetricCryptoKeyPair m_keyPair
private JAPCertificate m_x509certificate
Constructor Detail |
---|
public PKCS12(X509DistinguishedName a_ownerAlias, AsymmetricCryptoKeyPair a_keyPair, Validity a_validity)
a_ownerAlias
- The owner of the certificate. The name is set as the common name (CN).a_keyPair
- a key pair with a private and a public keya_validFrom
- The date from which the certificate is valid.a_validTo
- The date until which the certificate is valid.public PKCS12(X509DistinguishedName a_ownerAlias, AsymmetricCryptoKeyPair a_keyPair, Validity a_validity, X509Extensions a_extensions)
a_ownerAlias
- The owner of the certificate. The name is set as the common name (CN).a_keyPair
- a key pair with a private and a public keya_validFrom
- The date from which the certificate is valid.a_validTo
- The date until which the certificate is valid.a_extensions
- optional X509 extensions; may be nullprivate PKCS12(AsymmetricCryptoKeyPair a_keyPair, JAPCertificate a_X509certificate)
a_keyPair
- a key pair with a private and a public keya_X509certificate
- an X509 certificateMethod Detail |
---|
public static PKCS12 getInstance(byte[] a_bytes, char[] a_password)
a_bytes
- a byte arraya_password
- a password (may be null)
IMyPrivateKey
,
ClassUtil.loadClasses()
,
anon.crypto.AsymmetricKeyPair
public static PKCS12 getInstance(byte[] a_bytes, java.lang.String a_password)
public static PKCS12 getInstance(java.lang.String privCertString, java.lang.String password)
public static PKCS12 getInstance(byte[] a_bytes, IMiscPasswordReader a_passwordReader)
a_bytes
- a byte arraya_password
- a password (may be null)
IMyPrivateKey
,
ClassUtil.loadClasses()
,
anon.crypto.AsymmetricKeyPair
public static PKCS12 getInstance(java.io.InputStream a_stream, char[] password)
a_stream
- InputStreampassword
- a password (may be null)
IMyPrivateKey
,
ClassUtil.loadClasses()
,
anon.crypto.AsymmetricKeyPair
public static PKCS12 getInstance(java.io.InputStream a_stream, java.lang.String password)
public static PKCS12 getInstance(java.io.InputStream a_stream, IMiscPasswordReader a_passwordReader)
a_stream
- InputStreampassword
- a password (may be null)
IMyPrivateKey
,
ClassUtil.loadClasses()
,
anon.crypto.AsymmetricKeyPair
public byte[] toByteArray()
toByteArray
in interface ICertificate
public byte[] toByteArray(boolean a_Base64Encoded)
public byte[] toByteArray(char[] a_password, boolean a_Base64Encoded)
public byte[] toByteArray(char[] a_password)
a_password
- a password
java.io.IOException
public void store(java.io.OutputStream stream, char[] password) throws java.io.IOException
stream
- an output streampassword
- a password; may be null
java.io.IOException
- if an I/O error occurspublic java.lang.String getAlias()
public X509Extensions getExtensions()
public X509DistinguishedName getSubject()
public X509DistinguishedName getIssuer()
public IMyPrivateKey getPrivateKey()
public IMyPublicKey getPublicKey()
getPublicKey
in interface ICertificate
public AsymmetricCryptoKeyPair getKeyPair()
public JAPCertificate getX509Certificate()
getX509Certificate
in interface ICertificate
public PKCS10CertificationRequest createCertifcationRequest()
public boolean setX509Certificate(JAPCertificate a_X509certificate)
a_X509certificate
- JAPCertificate
public void sign(PKCS12 a_pkcs12Certificate)
a_pkcs12Certificate
- a PKCS12 certificatepublic void sign(PKCS12 a_signerCertificate, Validity a_validity, X509Extensions a_extensions, java.math.BigInteger a_serialNumber)
a_signerCertificate
- the PKCS12 certificate of the signera_validFrom
- The date from which the certificate is valid.a_validTo
- The date until which the certificate is valid.a_extensions
- some X509 extensions (may be null)a_serialNumber
- the serial number for this certificate (may be null)private static byte[] codeData(boolean encrypt, byte[] data, org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams, char[] password, org.bouncycastle.crypto.BlockCipher cipher, int keySize) throws java.io.IOException
java.io.IOException
private static org.bouncycastle.crypto.CipherParameters makePBEMacParameters(char[] password, org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams, int keySize)
private static org.bouncycastle.crypto.CipherParameters makePBEParameters(char[] password, org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams, java.lang.String targetAlgorithm, int keySize, int ivSize)
private static org.bouncycastle.crypto.PBEParametersGenerator makePBEGenerator()
private static PKCS12.MyCipher getCipher(java.lang.String algId)
private org.bouncycastle.asn1.x509.SubjectKeyIdentifier createSubjectKeyId()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |