de.flexiprovider.core.pbe
Class PBEWithSHA1AndDES_CBC
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.core.pbe.interfaces.PBES1
|
+--de.flexiprovider.core.pbe.PBES1
|
+--de.flexiprovider.core.pbe.PBEWithSHA1AndDES_CBC
- public class PBEWithSHA1AndDES_CBC
- extends PBES1
This class implements passphrase based encryption (PBE) as defined in PKCS#5
version 2.0. The key for the cipher (here DES) is derived from the
passphrase by applying a hashfunction (here
SHA-1) several times on it. Because we
don't provide single DES, DESede
with the same key for encryption, decryption, encryption is used instead.
- Author:
- Thomas Wahrenbruch
|
Field Summary |
static java.lang.String |
OID
The OID of PBEWithSHA1AndDES_CBC. |
| Fields inherited from class de.flexiprovider.core.pbe.PBES1 |
cipher, kdf |
|
Constructor Summary |
PBEWithSHA1AndDES_CBC()
The default constructor tries to initialize the message digest, the
secret key factory and the cipher. |
| Methods inherited from class de.flexiprovider.core.pbe.interfaces.PBES1 |
engineInit |
| Methods inherited from class de.flexiprovider.api.Cipher |
doFinal, doFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, update |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OID
public static final java.lang.String OID
- The OID of PBEWithSHA1AndDES_CBC.
PBEWithSHA1AndDES_CBC
public PBEWithSHA1AndDES_CBC()
- The default constructor tries to initialize the message digest, the
secret key factory and the cipher.
getName
public java.lang.String getName()
- Overrides:
getName in class Cipher
- Returns:
- the name of this cipher
getKeySize
public int getKeySize(Key key)
throws InvalidKeyException
- Returns the key size of the given key object. Since the cipher underlying
this PBE scheme is DES, we always return 56 as the effective key size if
the key is valid.
- Overrides:
getKeySize in class Cipher
- Parameters:
key - the key object- Returns:
- the key size of the given key object.
- Throws:
InvalidKeyException - if key is not an instance of PBEKey
initEncrypt
public void initEncrypt(Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
- Initializes this cipher with a key, a set of algorithm parameters, and a
source of randomness.
The cipher is initialized for encryption.
If this cipher requires any algorithm parameters and params is null, the
underlying cipher implementation is supposed to generate the required
parameters itself (using provider-specific default or random values) if
it is being initialized for encryption, and raise an
InvalidAlgorithmParameterException if it is being initialized for
decryption. The generated parameters can be retrieved using
engineGetParameters or engineGetIV (if the parameter is an IV).
If this cipher (including its underlying feedback or padding scheme)
requires any random bytes (e.g., for parameter generation), it will get
them from random.
Note that when a Cipher object is initialized, it loses all
previously-acquired state. In other words, initializing a Cipher is
equivalent to creating a new instance of that Cipher and initializing it.
- Overrides:
initEncrypt in class Cipher
- Parameters:
key - the encryption keyparams - the algorithm parametersrandom - the source of randomness- Throws:
InvalidKeyException - if the given key is inappropriate for initializing this
cipherInvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for
this cipher, or if this cipher is being initialized fro
decryption and requires algorithm parameters and params
is null
initDecrypt
public void initDecrypt(Key key,
AlgorithmParameterSpec params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
- Initializes this cipher with a key, a set of algorithm parameters, and a
source of randomness.
The cipher is initialized for decryption.
If this cipher requires any algorithm parameters and params is null, the
underlying cipher implementation is supposed to generate the required
parameters itself (using provider-specific default or random values) if
it is being initialized for encryption, and raise an
InvalidAlgorithmParameterException if it is being initialized for
decryption. The generated parameters can be retrieved using
engineGetParameters or engineGetIV (if the parameter is an IV).
If this cipher (including its underlying feedback or padding scheme)
requires any random bytes (e.g., for parameter generation), it will get
them from random.
Note that when a Cipher object is initialized, it loses all
previously-acquired state. In other words, initializing a Cipher is
equivalent to creating a new instance of that Cipher and initializing it.
- Overrides:
initDecrypt in class Cipher
- Parameters:
key - the encryption keyparams - the algorithm parameters- Throws:
InvalidKeyException - if the given key is inappropriate for initializing this
cipherInvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for
this cipher, or if this cipher is being initialized fro
decryption and requires algorithm parameters and params
is null