Package org.cryptacular.generator
Class LegacyP12Generator
java.lang.Object
org.cryptacular.generator.AbstractP12Generator
org.cryptacular.generator.LegacyP12Generator
- All Implemented Interfaces:
P12Generator
Generates PKCS12 containers using DES3+SHA1 for private keys and 40-bit RC2+SHA1 for encrypted data.
These algorithms are considered unsecure by today's standards (2024), but are needed for interoperability
in some cases. Importing a keypair into the Mac keychain is a notable use case.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.bouncycastle.pkcs.bc.BcPKCS12PBEOutputEncryptorBuilderData encryptor builder.private final intNumber of hashing rounds.private final org.bouncycastle.pkcs.bc.BcPKCS12PBEOutputEncryptorBuilderKey encryptor builder. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance that encrypts with 1024 rounds of hashing.LegacyP12Generator(int iterations) Creates a new instance that encrypts with the given number of hashing rounds. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.bouncycastle.operator.OutputEncryptordataOutputEncryptor(char[] password) Builds a new output encryptor that performs password-based encryption on encrypted data in the P12 file.protected org.bouncycastle.asn1.ASN1ObjectIdentifierprotected DigestSpecintprotected org.bouncycastle.operator.OutputEncryptorkeyOutputEncryptor(char[] password) Builds a new output encryptor that performs password-based encryption on keys in the P12 file.Methods inherited from class org.cryptacular.generator.AbstractP12Generator
generate, generate
-
Field Details
-
iterations
private final int iterationsNumber of hashing rounds. -
keyEncryptorBuilder
private final org.bouncycastle.pkcs.bc.BcPKCS12PBEOutputEncryptorBuilder keyEncryptorBuilderKey encryptor builder. -
dataEncryptorBuilder
private final org.bouncycastle.pkcs.bc.BcPKCS12PBEOutputEncryptorBuilder dataEncryptorBuilderData encryptor builder.
-
-
Constructor Details
-
LegacyP12Generator
public LegacyP12Generator()Creates a new instance that encrypts with 1024 rounds of hashing. -
LegacyP12Generator
public LegacyP12Generator(int iterations) Creates a new instance that encrypts with the given number of hashing rounds.- Parameters:
iterations- Number of hashing rounds.
-
-
Method Details
-
getIterations
public int getIterations()- Specified by:
getIterationsin classAbstractP12Generator- Returns:
- Number of hashing rounds.
-
getDigestAlgorithmId
protected org.bouncycastle.asn1.ASN1ObjectIdentifier getDigestAlgorithmId()- Specified by:
getDigestAlgorithmIdin classAbstractP12Generator- Returns:
- Digest algorithm object identifier.
-
getDigestSpec
- Specified by:
getDigestSpecin classAbstractP12Generator- Returns:
- Digest specification.
-
keyOutputEncryptor
protected org.bouncycastle.operator.OutputEncryptor keyOutputEncryptor(char[] password) Description copied from class:AbstractP12GeneratorBuilds a new output encryptor that performs password-based encryption on keys in the P12 file.- Specified by:
keyOutputEncryptorin classAbstractP12Generator- Parameters:
password- Password tha will the basis of an encryption key.- Returns:
- Output encryptor.
-
dataOutputEncryptor
protected org.bouncycastle.operator.OutputEncryptor dataOutputEncryptor(char[] password) Description copied from class:AbstractP12GeneratorBuilds a new output encryptor that performs password-based encryption on encrypted data in the P12 file.- Specified by:
dataOutputEncryptorin classAbstractP12Generator- Parameters:
password- Password tha will the basis of an encryption key.- Returns:
- Output encryptor.
-