Top Inners Fields Constructors Methods
org.bouncycastle.jcajce.provider.keystore.pkcs12

public Class PKCS12KeyStoreSpi

extends KeyStoreSpi
implements PKCSObjectIdentifiers, X509ObjectIdentifiers, BCKeyStore
Class Inheritance
All Implemented Interfaces
org.bouncycastle.jce.interfaces.BCKeyStore, org.bouncycastle.asn1.x509.X509ObjectIdentifiers, org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers
Imports
java.io.BufferedInputStream, .ByteArrayInputStream, .EOFException, .IOException, .InputStream, .OutputStream, java.math.BigInteger, java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .Key, .KeyStore, .KeyStore.LoadStoreParameter, .KeyStore.ProtectionParameter, .KeyStoreException, .KeyStoreSpi, .NoSuchAlgorithmException, .NoSuchProviderException, .Principal, .PrivateKey, .PublicKey, .SecureRandom, .UnrecoverableKeyException, java.security.cert.Certificate, .CertificateEncodingException, .CertificateException, .CertificateFactory, .X509Certificate, java.security.spec.InvalidKeySpecException, java.util.Collections, .Date, .Enumeration, .HashMap, .HashSet, .Hashtable, .Map, .Set, .Vector, javax.crypto.Cipher, .Mac, .NoSuchPaddingException, .SecretKey, .SecretKeyFactory, javax.crypto.spec.IvParameterSpec, .PBEKeySpec, .PBEParameterSpec, org.bouncycastle.asn1.ASN1BMPString, .ASN1Encodable, .ASN1EncodableVector, .ASN1Encoding, .ASN1InputStream, .ASN1ObjectIdentifier, .ASN1OctetString, .ASN1Primitive, .ASN1Sequence, .ASN1Set, .BEROctetString, .BERSequence, .DERBMPString, .DERNull, .DEROctetString, .DERSequence, .DERSet, org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers, .GOST28147Parameters, org.bouncycastle.asn1.misc.MiscObjectIdentifiers, org.bouncycastle.asn1.nist.NISTObjectIdentifiers, org.bouncycastle.asn1.ntt.NTTObjectIdentifiers, org.bouncycastle.asn1.oiw.OIWObjectIdentifiers, org.bouncycastle.asn1.pkcs.AuthenticatedSafe, .CertBag, .ContentInfo, .EncryptedData, .MacData, .PBES2Parameters, .PBKDF2Params, .PKCS12PBEParams, .PKCSObjectIdentifiers, .Pfx, .SafeBag, org.bouncycastle.asn1.util.ASN1Dump, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .AuthorityKeyIdentifier, .DigestInfo, .ExtendedKeyUsage, .Extension, .Extensions, .KeyPurposeId, .SubjectKeyIdentifier, .SubjectPublicKeyInfo, .TBSCertificate, .X509ObjectIdentifiers, org.bouncycastle.crypto.CryptoServicesRegistrar, .Digest, org.bouncycastle.crypto.util.DigestFactory, org.bouncycastle.jcajce.BCLoadStoreParameter, .PKCS12Key, .PKCS12StoreParameter, org.bouncycastle.jcajce.provider.keystore.util.AdaptingKeyStoreSpi, .ParameterUtil, org.bouncycastle.jcajce.spec.GOST28147ParameterSpec, .PBKDF2KeySpec, org.bouncycastle.jcajce.util.BCJcaJceHelper, .DefaultJcaJceHelper, .JcaJceHelper, org.bouncycastle.jce.interfaces.BCKeyStore, .PKCS12BagAttributeCarrier, org.bouncycastle.jce.provider.BouncyCastleProvider, .JDKPKCS12StoreParameter, org.bouncycastle.util.Arrays, .Integers, .Properties, .Strings, org.bouncycastle.util.encoders.Hex

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
private class
private static class
public static class
public static class
private static class

Field Summary

Modifier and TypeField and Description
private ASN1ObjectIdentifier
private CertificateFactory
pack-priv static final int
private PKCS12KeyStoreSpi.IgnoresCaseHashtable
private Hashtable<K, V>
private final JcaJceHelper
private int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
private ASN1ObjectIdentifier
private Hashtable<K, V>
private PKCS12KeyStoreSpi.IgnoresCaseHashtable
private static final PKCS12KeyStoreSpi.DefaultSecretKeyProvider
private PKCS12KeyStoreSpi.IgnoresCaseHashtable
private AlgorithmIdentifier
private static final int
pack-priv static final int
pack-priv static final String
protected SecureRandom
private static final int
private int
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private byte[]
calculatePbeMac(ASN1ObjectIdentifier oid, byte[] salt, int itCount, char[] password, boolean wrongPkcs12Zero, byte[] data)

private Cipher
createCipher(int mode, char[] password, AlgorithmIdentifier algId)

private SafeBag
private SubjectKeyIdentifier
protected byte[]
cryptData(boolean forEncryption, AlgorithmIdentifier algId, char[] password, boolean wrongPKCS12Zero, byte[] data)

private void
doStore(OutputStream stream, char[] password, boolean useDEREncoding)

public Enumeration<E>
engineAliases()

Implements abstract java.security.KeyStoreSpi.engineAliases.

Lists all the alias names of this keystore.
public boolean
engineContainsAlias(String
the alias name
alias
)

Implements abstract java.security.KeyStoreSpi.engineContainsAlias.

Checks if the given alias exists in this keystore.
public void
engineDeleteEntry(String
the alias name
alias
)

Implements abstract java.security.KeyStoreSpi.engineDeleteEntry.

this is not quite complete - we should follow up on the chain, a bit tricky if a certificate appears in more than one chain...
public Certificate
engineGetCertificate(String
the alias name
alias
)

Implements abstract java.security.KeyStoreSpi.engineGetCertificate.

simply return the cert for the private key
public String
engineGetCertificateAlias(Certificate
the certificate to match with.
cert
)

Implements abstract java.security.KeyStoreSpi.engineGetCertificateAlias.

Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.
public Certificate[]
engineGetCertificateChain(String
the alias name
alias
)

Implements abstract java.security.KeyStoreSpi.engineGetCertificateChain.

Returns the certificate chain associated with the given alias.
public Date
engineGetCreationDate(String
the alias name
alias
)

Implements abstract java.security.KeyStoreSpi.engineGetCreationDate.

Returns the creation date of the entry identified by the given alias.
public Key
engineGetKey(String
the alias name
alias
,
char[]
the password for recovering the key
password
)

Implements abstract java.security.KeyStoreSpi.engineGetKey.

Returns the key associated with the given alias, using the given password to recover it.
public boolean
engineIsCertificateEntry(String
the alias for the keystore entry to be checked
alias
)

Implements abstract java.security.KeyStoreSpi.engineIsCertificateEntry.

Returns true if the entry identified by the given alias was created by a call to setCertificateEntry, or created by a call to setEntry with a TrustedCertificateEntry.
public boolean
engineIsKeyEntry(String
the alias for the keystore entry to be checked
alias
)

Implements abstract java.security.KeyStoreSpi.engineIsKeyEntry.

Returns true if the entry identified by the given alias was created by a call to setKeyEntry, or created by a call to setEntry with a PrivateKeyEntry or a SecretKeyEntry.
public void
engineLoad(KeyStore.LoadStoreParameter
the KeyStore.LoadStoreParameter that specifies how to load the keystore, which may be null
loadStoreParameter
)

Overrides java.security.KeyStoreSpi.engineLoad.

Loads the keystore using the given KeyStore.LoadStoreParameter.
public void
engineLoad(InputStream
the input stream from which the keystore is loaded, or null
stream
,
char[]
the password used to check the integrity of the keystore, the password used to unlock the keystore, or null
password
)

Implements abstract java.security.KeyStoreSpi.engineLoad.

Loads the keystore from the given input stream.
public boolean
engineProbe(InputStream
the keystore data to be probed
stream
)

Overrides java.security.KeyStoreSpi.engineProbe.

Probes the specified input stream to determine whether it contains a keystore that is supported by this implementation, or not.
public void
engineSetCertificateEntry(String
the alias name
alias
,
Certificate
the certificate
cert
)

Implements abstract java.security.KeyStoreSpi.engineSetCertificateEntry.

Assigns the given certificate to the given alias.
public void
engineSetKeyEntry(String
the alias name
alias
,
byte[]
the key (in protected format) to be associated with the alias
key
,
Certificate[]
the certificate chain for the corresponding public key (only useful if the protected key is of type java.security.PrivateKey).
chain
)

Implements abstract java.security.KeyStoreSpi.engineSetKeyEntry.

Assigns the given key (that has already been protected) to the given alias.
public void
engineSetKeyEntry(String
the alias name
alias
,
Key
the key to be associated with the alias
key
,
char[]
the password to protect the key
password
,
Certificate[]
the certificate chain for the corresponding public key (only required if the given key is of type java.security.PrivateKey).
chain
)

Implements abstract java.security.KeyStoreSpi.engineSetKeyEntry.

Assigns the given key to the given alias, protecting it with the given password.
public int
engineSize()

Implements abstract java.security.KeyStoreSpi.engineSize.

Retrieves the number of entries in this keystore.
public void
engineStore(KeyStore.LoadStoreParameter
the KeyStore.LoadStoreParameter that specifies how to store the keystore, which may be null
param
)

Overrides java.security.KeyStoreSpi.engineStore.

Stores this keystore using the given KeyStore.LoadStoreParameter.
public void
engineStore(OutputStream
the output stream to which this keystore is written.
stream
,
char[]
the password to generate the keystore integrity check. May be null if the keystore does not support or require an integrity check.
password
)

Implements abstract java.security.KeyStoreSpi.engineStore.

Stores this keystore to the given output stream, and protects its integrity with the given password.
private static byte[]
private Set<E>
private void
private boolean
processShroudedKeyBag(SafeBag b, char[] password, boolean wrongPKCS12Zero)

public void
setRandom(SecureRandom rand)

Implements org.bouncycastle.jce.interfaces.BCKeyStore.setRandom.

set the random source for the key store
protected PrivateKey
unwrapKey(AlgorithmIdentifier algId, byte[] data, char[] password, boolean wrongPKCS12Zero)

private int
protected byte[]
wrapKey(String algorithm, Key key, PKCS12PBEParams pbeParams, char[] password)

Inherited from java.security.KeyStoreSpi:
engineEntryInstanceOfengineGetAttributesengineGetEntryengineSetEntry