public final class PKCS5PBE extends PBE
Modifier and Type | Field and Description |
---|---|
static int |
MD2_DES
The MD2 with DES CBC PKCS#5 mode.
|
static int |
MD2_RC2
The MD2 with RC2 CBC PKCS#5 mode.
|
static int |
MD5_DES
The MD5 with DES CBC PKCS#5 mode.
|
static int |
MD5_RC2
The MD5 with RC2 CBC PKCS#5 mode.
|
static int |
SHA1_DES
The SHA1 with DES CBC PKCS#5 mode.
|
static int |
SHA1_RC2
The SHA1 with RC2 CBC PKCS#5 mode.
|
algID, cipherAlgID, mdAlgID
Constructor and Description |
---|
PKCS5PBE()
Standard contstructor.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decrypt(java.lang.String password, byte[] data)
Decrypt an array of bytes, and return the decrypted array of bytes.
|
PrivateKey |
decryptPrivateKey(java.lang.String password, byte[] encPrivKey)
Decrypt a private key, and return the decrypted key.
|
SymmetricKey |
decryptSymmetricKey(java.lang.String password, byte[] encSymKey)
Decrypt a symmetric key, and return the decrypted key.
|
byte[] |
encrypt(java.lang.String password, byte[] data)
Encrypt an array of bytes, and return the encrypted array of bytes.
|
byte[] |
encryptPrivateKey(java.lang.String password, PrivateKey privKey)
Encrypt a private key, and return the encrypted key.
|
byte[] |
encryptSymmetricKey(java.lang.String password, SymmetricKey symKey)
Encrypt a symmetric key, and return the encrypted key.
|
void |
initialize(AlgorithmIdentifier algID)
Initializes this
PBE instance with the specified algorithm identifier. |
void |
initialize(int mode)
Initializes this
PBE instance with the specified PBE parameters. |
void |
initialize(int mode, byte[] salt, int iterationCount)
Initializes this
PBE instance with the specified PBE parameters. |
getAlgID, getInstance
public static final int MD2_DES
public static final int MD2_RC2
public static final int MD5_DES
public static final int MD5_RC2
public static final int SHA1_DES
public static final int SHA1_RC2
public void initialize(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
PBE
instance with the specified algorithm identifier.initialize
in class PBE
algID
- The algorithm identifier used to initialize this PBE. It should be a instance of PBEAlgorithmIdentifier
.AlgorithmIdentifierException
public void initialize(int mode, byte[] salt, int iterationCount) throws AlgorithmIdentifierException
PBE
instance with the specified PBE parameters.initialize
in class PBE
mode
- The mode to use with this PBE. The mode is a PKCS5PBE
mode value.salt
- The salt to use during the key generation.iterationCount
- The iteration count to use during the key generation.AlgorithmIdentifierException
public void initialize(int mode) throws AlgorithmIdentifierException
PBE
instance with the specified PBE parameters.initialize
in class PBE
mode
- The mode to use with this PBE. The mode is a PKCS5PBE
mode value.AlgorithmIdentifierException
public byte[] encrypt(java.lang.String password, byte[] data) throws CipherException
encrypt
in class PBE
password
- The password to use to generate the key. The password transformed to a byte array using the US-ASCII encoding.data
- The data to encrypt.CipherException
public byte[] decrypt(java.lang.String password, byte[] data) throws CipherException
decrypt
in class PBE
password
- The password to use to generate the key. The password transformed to a byte array using the US-ASCII encoding. If the decryption fails, the local encoding is used.data
- The data to decrypt.CipherException
public byte[] encryptPrivateKey(java.lang.String password, PrivateKey privKey) throws CipherException
encryptPrivateKey
in class PBE
password
- The password to use to generate the key. The password transformed to a byte array using the US-ASCII encoding.privKey
- The private key to encrypt.CipherException
public PrivateKey decryptPrivateKey(java.lang.String password, byte[] encPrivKey) throws CipherException, java.io.IOException
decryptPrivateKey
in class PBE
password
- The password to use to generate the key. The password transformed to a byte array using the US-ASCII encoding. If the decryption fails, the local encoding is used.encPrivKey
- The byte array containing the encrypted private key.CipherException
java.io.IOException
public byte[] encryptSymmetricKey(java.lang.String password, SymmetricKey symKey) throws CipherException
encryptSymmetricKey
in class PBE
password
- The password to use to generate the key. The password transformed to a byte array using the US-ASCII encoding.symKey
- The symmetric key to encrypt.CipherException
public SymmetricKey decryptSymmetricKey(java.lang.String password, byte[] encSymKey) throws CipherException
decryptSymmetricKey
in class PBE
password
- The password to use to generate the key. The password transformed to a byte array using the US-ASCII encoding. If the decryption fails, the local encoding is used.encSymKey
- The byte array containing the encrypted symmetric key.CipherException