de.flexiprovider.core.elgamal.semanticallysecure
Class SSVElGamal
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.AsymmetricBlockCipher
|
+--de.flexiprovider.core.elgamal.semanticallysecure.SSVElGamal
- public class SSVElGamal
- extends AsymmetricBlockCipher
This class implements a semantically secure variant of the original ElGamal
encryption. The implementation is based on algorithm 14.2, page 476 of the
book: Modern Cryptography - Theory & Practice by Wenbo Mao.
- Author:
- Thomas Wahrenbruch, Roberto Samarone dos Santos Araújo
|
Field Summary |
static java.lang.String |
ALG_NAME
The algorithm name. |
| Methods inherited from class de.flexiprovider.api.AsymmetricBlockCipher |
checkLength, doFinal, doFinal, getBlockSize, getIV, getOutputSize, getParameters, initDecrypt, initDecrypt, initEncrypt, initEncrypt, initEncrypt, initEncrypt, setMode, setPadding, update, update |
| Methods inherited from class de.flexiprovider.api.Cipher |
doFinal, doFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, 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 |
ALG_NAME
public static final java.lang.String ALG_NAME
- The algorithm name.
SSVElGamal
public SSVElGamal()
getName
public java.lang.String getName()
- Return the name of this cipher.
- Overrides:
getName in class Cipher
- Returns:
ALG_NAME
getKeySize
public int getKeySize(Key key)
throws InvalidKeyException
- Return the key size of the given key object in bits. Checks whether the
key object is an instance of ElGamalPublicKey or
ElGamalPrivateKey.
- Overrides:
getKeySize in class Cipher
- Parameters:
key - the key object- Returns:
- the key size of the given key object.
- Throws:
InvalidKeyException - if key is invalid.
initCipherEncrypt
protected void initCipherEncrypt(Key key,
AlgorithmParameterSpec params,
SecureRandom secureRandom)
throws InvalidKeyException
- Initialize the block cipher with a key for data encryption. Parameters
are currently not supported.
- Overrides:
initCipherEncrypt in class AsymmetricBlockCipher
- Parameters:
key - the key which has to be used to encrypt data.params - the algorithm parameters.secureRandom - a source of randomness.- Throws:
InvalidKeyException - if the given key is inappropriate for initializing this
cipher.
initCipherDecrypt
protected void initCipherDecrypt(Key key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- Initialize the block cipher with a key for data encryption. Parameters
are currently not supported.
- Overrides:
initCipherDecrypt in class AsymmetricBlockCipher
- Parameters:
key - the key which has to be used to decrypt data.params - the algorithm parameters.- Throws:
InvalidKeyException - if the given key is inappropriate for initializing this
cipher.
messageEncrypt
protected byte[] messageEncrypt(byte[] input)
- Encrypt a message.
- Overrides:
messageEncrypt in class AsymmetricBlockCipher
- Parameters:
input - the message- Returns:
- the encrypted message
messageDecrypt
protected byte[] messageDecrypt(byte[] input)
throws BadPaddingException
- Decrypt a ciphertext.
- Overrides:
messageDecrypt in class AsymmetricBlockCipher
- Parameters:
input - the ciphertext- Returns:
- the decrypted ciphertext
- Throws:
BadPaddingException - if the ciphertext is invalid.