public final class PKCS12 extends java.lang.Object implements mybouncycastle.org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers, mybouncycastle.org.bouncycastle.asn1.x509.X509ObjectIdentifiers, ICertificate
Modifier and Type | Class and Description |
---|---|
private static class |
PKCS12.MyCipher |
Modifier and Type | Field and Description |
---|---|
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 |
bagtypes, canNotDecryptAny, certBag, certTypes, crlBag, crlTypes, data, des_EDE3_CBC, dhKeyAgreement, digestAlgorithm, digestedData, encryptedData, encryptionAlgorithm, envelopedData, id_aa, id_aa_asymmDecryptKeyID, id_aa_cmsAlgorithmProtect, id_aa_commitmentType, id_aa_communityIdentifiers, id_aa_contentHint, id_aa_contentIdentifier, id_aa_contentReference, id_aa_decryptKeyID, 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_implCompressAlgs, id_aa_implCryptoAlgs, id_aa_msgSigDigest, id_aa_otherSigCert, id_aa_receiptRequest, id_aa_signatureTimeStampToken, id_aa_signerLocation, id_aa_signingCertificate, id_aa_signingCertificateV2, id_aa_sigPolicyId, id_alg, id_alg_AEADChaCha20Poly1305, id_alg_CMS3DESwrap, id_alg_CMSRC2wrap, id_alg_ESDH, id_alg_hkdf_with_sha256, id_alg_hkdf_with_sha384, id_alg_hkdf_with_sha512, id_alg_hss_lms_hashsig, id_alg_PWRI_KEK, id_alg_SSDH, id_ct, id_ct_authData, id_ct_authEnvelopedData, id_ct_compressedData, id_ct_timestampedData, 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_rsa_KEM, id_RSAES_OAEP, id_RSASSA_PSS, id_smime, 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, 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, rc4, rsaEncryption, safeContentsBag, sdsiCertificate, secretBag, sha1WithRSAEncryption, sha224WithRSAEncryption, sha256WithRSAEncryption, sha384WithRSAEncryption, sha512_224WithRSAEncryption, sha512_256WithRSAEncryption, sha512WithRSAEncryption, signedAndEnvelopedData, signedData, sMIMECapabilitiesVersions, srsaOAEPEncryptionSET, x509Certificate, x509certType, x509Crl
commonName, countryName, crlAccessMethod, id_ad, id_ad_caIssuers, id_ad_ocsp, id_at_name, id_at_organizationIdentifier, id_at_telephoneNumber, id_ce, id_ea_rsa, id_ecdsa_with_shake128, id_ecdsa_with_shake256, id_pe, id_pkix, id_rsassa_pss_shake128, id_rsassa_pss_shake256, id_SHA1, localityName, ocspAccessMethod, organization, organizationalUnitName, ripemd160, ripemd160WithRSAEncryption, stateOrProvinceName
Modifier | Constructor and Description |
---|---|
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,
MyX509Extensions a_extensions)
Creates a new PKCS12 certificate.
|
Modifier and Type | Method and Description |
---|---|
private static byte[] |
codeData(boolean encrypt,
byte[] data,
mybouncycastle.org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams,
char[] password,
mybouncycastle.org.bouncycastle.crypto.BlockCipher cipher,
int keySize) |
PKCS10CertificationRequest |
createCertifcationRequest()
Creates a certification request from this private certificate.
|
private mybouncycastle.org.bouncycastle.asn1.x509.SubjectKeyIdentifier |
createSubjectKeyId() |
java.lang.String |
getAlias() |
private static PKCS12.MyCipher |
getCipher(java.lang.String algId) |
MyX509Extensions |
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 mybouncycastle.org.bouncycastle.crypto.PBEParametersGenerator |
makePBEGenerator() |
private static mybouncycastle.org.bouncycastle.crypto.CipherParameters |
makePBEMacParameters(char[] password,
mybouncycastle.org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams,
int keySize) |
private static mybouncycastle.org.bouncycastle.crypto.CipherParameters |
makePBEParameters(char[] password,
mybouncycastle.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,
MyX509Extensions 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) |
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
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, MyX509Extensions 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 certificatepublic 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 passwordjava.io.IOException
public void store(java.io.OutputStream stream, char[] password) throws java.io.IOException
stream
- an output streampassword
- a password; may be nulljava.io.IOException
- if an I/O error occurspublic java.lang.String getAlias()
public MyX509Extensions 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
- JAPCertificatepublic void sign(PKCS12 a_pkcs12Certificate)
a_pkcs12Certificate
- a PKCS12 certificatepublic void sign(PKCS12 a_signerCertificate, Validity a_validity, MyX509Extensions 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, mybouncycastle.org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams, char[] password, mybouncycastle.org.bouncycastle.crypto.BlockCipher cipher, int keySize) throws java.io.IOException
java.io.IOException
private static mybouncycastle.org.bouncycastle.crypto.CipherParameters makePBEMacParameters(char[] password, mybouncycastle.org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams, int keySize)
private static mybouncycastle.org.bouncycastle.crypto.CipherParameters makePBEParameters(char[] password, mybouncycastle.org.bouncycastle.asn1.pkcs.PKCS12PBEParams pbeParams, java.lang.String targetAlgorithm, int keySize, int ivSize)
private static mybouncycastle.org.bouncycastle.crypto.PBEParametersGenerator makePBEGenerator()
private static PKCS12.MyCipher getCipher(java.lang.String algId)
private mybouncycastle.org.bouncycastle.asn1.x509.SubjectKeyIdentifier createSubjectKeyId()
Copyright © 2023. All rights reserved.