public class PKCS5 extends java.lang.Object implements ASN1Object, java.io.Serializable
Please note that PKCS5 is the encryption algorithm used to encrypt and decrypt private keys, encapsulated by the PrivateKeyPKCS8
class. This class may not be backward compatible for Serialization: PKCS5 serialized objects created with PSE 2.2.2 and later until PSE 2.2.3 Build G may not be read.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ITER_COUNT
Deprecated.
Default password-based key derivation iteration count is 1024.
|
static int |
DEFAULT_SALT_LEN
Deprecated.
Default password-based key derivation salt length is 8 bytes.
|
static int |
MD2_DES
Deprecated.
Encryption mode identifier for MD2 with DES.
|
static int |
MD5_DES
Deprecated.
Encryption mode identifier for MD5 with DES.
|
static int |
NONE
Deprecated.
Indicates that no encryption mode is set.
|
static int |
SHA_128RC2
Deprecated.
Encryption mode identifier for SHA-1 with 128-bit RC2.
|
static int |
SHA_128RC4
Deprecated.
Encryption mode identifier for SHA-1 with 128-bit RC4.
|
static int |
SHA_2DES
Deprecated.
Encryption mode identifier for SHA-1 with two-key DES.
|
static int |
SHA_3DES
Deprecated.
Encryption mode identifier for SHA-1 with triple-DES.
|
static int |
SHA_40RC2
Deprecated.
Encryption mode identifier for SHA-1 with 40-bit RC2.
|
static int |
SHA_40RC4
Deprecated.
Encryption mode identifier for SHA-1 with 40-bit RC4.
|
Constructor and Description |
---|
PKCS5()
Deprecated.
Creates a new
PKCS5 instance. |
PKCS5(byte[] p, byte[] s, int c)
Deprecated.
Creates a new
PKCS5 instance with the given password, salt and count, and MD5_DES encryption mode. |
PKCS5(byte[] p, byte[] s, int c, int m)
Deprecated.
Creates a new
PKCS5 instance with the given password, salt, count and mode. |
PKCS5(int m)
Deprecated.
Creates a new
PKCS5 instance with the given mode ID, and default iteration count and source of randomness. |
PKCS5(int m, int c, RandomBitsSource rbs)
Deprecated.
Creates a new
PKCS5 instance. |
PKCS5(int m, RandomBitsSource rbs)
Deprecated.
Creates a new
PKCS5 instance with the given mode and source of randomness, and the default iteration count. |
PKCS5(RandomBitsSource rbs)
Deprecated.
Creates a new
PKCS5 instance with the given source of randomness, and the default mode and iteration count. |
PKCS5(java.lang.String p, byte[] s, int m)
Deprecated.
Creates a new
PKCS5 instance with the given password, salt and mode, and the default iteration count. |
PKCS5(java.lang.String p, byte[] s, int c, int m)
Deprecated.
Creates a new
PKCS5 instance with the given password, salt, count and mode. |
PKCS5(java.lang.String p, int m, int c, RandomBitsSource rbs)
Deprecated.
Creates a new
PKCS5 instance with the given password, salt, count, mode and source of randomness. |
PKCS5(java.lang.String p, int m, RandomBitsSource rbs)
Deprecated.
Creates a new
PKCS5 instance with the given password, mode and source of randomness, and the default iteration count. |
PKCS5(java.lang.String p, RandomBitsSource rbs)
Deprecated.
Creates a new
PKCS5 instance with the given password and source of randomness, and the default mode and iteration count. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
algName()
Deprecated.
|
byte[] |
decrypt(byte[] data)
Deprecated.
Decrypt an array of bytes, and return the decrypted array of bytes.
|
byte[] |
encrypt(byte[] data)
Deprecated.
Encrypt an array of bytes, and return the encrypted array of bytes.
|
int |
encryptedLength(int dataLen)
Deprecated.
|
int |
getCount()
Deprecated.
|
int |
getMode()
Deprecated.
|
ASN1ObjectID |
getModeID()
Deprecated.
|
java.lang.String |
getPassword()
Deprecated.
|
byte[] |
getSalt()
Deprecated.
|
void |
input(java.io.InputStream is)
Deprecated.
Reconstructs this object by reading its DER encoding from the specified input stream.
|
void |
inputAlgID(ASN1Sequence s)
Deprecated.
|
void |
inputAlgID(java.io.InputStream is)
Deprecated.
|
int |
length()
Deprecated.
Returns the length of this object's DER encoding.
|
static java.lang.String |
modeString(int mode)
Deprecated.
|
void |
output(java.io.OutputStream os)
Deprecated.
Outputs the DER encoding of this object to the specified output stream.
|
void |
outputAlgID(java.io.OutputStream os)
Deprecated.
|
ASN1Sequence |
outputAlgIDASN1()
Deprecated.
|
static byte[] |
pkcs12PseudoRandomBytes(byte ID, int n, AlgorithmIdentifier hashType, java.lang.String passwd, byte[] salt, int count)
Deprecated.
|
void |
setCount(int c)
Deprecated.
|
void |
setMode(ASN1ObjectID oid)
Deprecated.
|
void |
setMode(int m)
Deprecated.
|
void |
setPassword(byte[] p)
Deprecated.
|
void |
setPassword(java.lang.String p)
Deprecated.
|
void |
setSalt(byte[] s)
Deprecated.
|
java.lang.String |
toString()
Deprecated.
Returns a string representation of thie object.
|
public static final int NONE
public static final int MD2_DES
public static final int MD5_DES
public static final int SHA_128RC4
public static final int SHA_40RC4
public static final int SHA_3DES
public static final int SHA_2DES
public static final int SHA_128RC2
public static final int SHA_40RC2
public static final int DEFAULT_SALT_LEN
public static final int DEFAULT_ITER_COUNT
public PKCS5()
PKCS5
instance. The default parameters are:
public PKCS5(int m)
PKCS5
instance with the given mode ID, and default iteration count and source of randomness.m
- The encryption mode ID.PKCS5()
public PKCS5(int m, int c, RandomBitsSource rbs)
PKCS5
instance.m
- The encryption mode ID.c
- The iteration count.rbs
- The source of randomness.public PKCS5(int m, RandomBitsSource rbs)
PKCS5
instance with the given mode and source of randomness, and the default iteration count.m
- The encryption mode ID.rbs
- The source of randomness.PKCS5()
public PKCS5(RandomBitsSource rbs)
PKCS5
instance with the given source of randomness, and the default mode and iteration count.rbs
- The source of randomness.PKCS5()
public PKCS5(java.lang.String p, byte[] s, int c, int m)
PKCS5
instance with the given password, salt, count and mode.p
- The password.s
- The salt.c
- The iteration count.m
- The encryption mode.public PKCS5(java.lang.String p, byte[] s, int m)
PKCS5
instance with the given password, salt and mode, and the default iteration count.p
- The password.s
- The salt.m
- The encryption mode.PKCS5()
public PKCS5(java.lang.String p, int m, int c, RandomBitsSource rbs)
PKCS5
instance with the given password, salt, count, mode and source of randomness.p
- The password.m
- The encryption mode.c
- The iteration count.rbs
- The source of randomness.public PKCS5(java.lang.String p, int m, RandomBitsSource rbs)
PKCS5
instance with the given password, mode and source of randomness, and the default iteration count.p
- The password.m
- The encryption mode.rbs
- The source of randomness.PKCS5()
public PKCS5(java.lang.String p, RandomBitsSource rbs)
PKCS5
instance with the given password and source of randomness, and the default mode and iteration count.p
- The password.rbs
- The source of randomness.PKCS5()
public PKCS5(byte[] p, byte[] s, int c, int m)
PKCS5
instance with the given password, salt, count and mode.p
- The password.s
- The salt.c
- The iteration count.m
- The encryption mode.public PKCS5(byte[] p, byte[] s, int c)
PKCS5
instance with the given password, salt and count, and MD5_DES
encryption mode.p
- The password.s
- The salt.c
- The iteration count.public byte[] encrypt(byte[] data) throws CipherException
CipherException
public static byte[] pkcs12PseudoRandomBytes(byte ID, int n, AlgorithmIdentifier hashType, java.lang.String passwd, byte[] salt, int count) throws CipherException
CipherException
public byte[] decrypt(byte[] data) throws CipherException
CipherException
public int encryptedLength(int dataLen)
public void setMode(int m)
public int getMode()
public void setPassword(java.lang.String p)
public void setPassword(byte[] p)
public java.lang.String getPassword()
public void setSalt(byte[] s)
public byte[] getSalt()
public void setCount(int c)
public int getCount()
public void setMode(ASN1ObjectID oid) throws java.io.IOException
java.io.IOException
public ASN1ObjectID getModeID()
public void outputAlgID(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public ASN1Sequence outputAlgIDASN1()
public void output(java.io.OutputStream os) throws java.io.IOException
output
in interface Streamable
os
- the output stream to which the object will be writtenjava.io.IOException
public void inputAlgID(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void inputAlgID(ASN1Sequence s) throws java.io.IOException
java.io.IOException
public void input(java.io.InputStream is) throws java.io.IOException
input
in interface Streamable
is
- the input stream from which this object will be readjava.io.IOException
public int length()
length
in interface Streamable
public java.lang.String algName()
public static java.lang.String modeString(int mode)
public java.lang.String toString()
toString
in class java.lang.Object