Package com.easydesk.crypto
Interface CryptoAlgorithm
- All Known Implementing Classes:
AESCrypt,BlowfishCrypt,CleanCrypt,DigestCrypt,HmacCrypt,JavaCrypt
public interface CryptoAlgorithm
This interface describes the various Crypto Algorithms that are handed out by
the Crypto Service.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]byte[]decrypt(char[] value, byte[] salt, int iteration) byte[]encrypt(byte[] value, byte[] salt, int iteration) Performs the actual encryption.byte[]encrypt(char[] value, byte[] salt, int iteration) Performs the actual encryption.byte[]DOCUMENT ME!encrytedFullPassword(char[] test) intgetKey(byte[] key) byte[]getRandom(int length) byte[]getSalt()Returns a salt value.booleanfor hashing mechanismbooleanfor enc-dec mechanismvoidAlgorithms that perform multiple ciphers get told with setCipher, which cipher to use.voidsetKeyLength(int length) 64 * length value of keyvoidsetSaltSize(int size) voidAllows the user to set a salt value whenever the algorithm is used.
-
Method Details
-
setCipher
Algorithms that perform multiple ciphers get told with setCipher, which cipher to use. This should be called before any other method call. If called after any call to encrypt or setSeed, the CryptoAlgorithm may choose to ignore this or to reset and use the new cipher. If any other call is used before this, the algorithm should use a default cipher and not throw an error.- Parameters:
cipher- The cipher to use.
-
setSeed
Allows the user to set a salt value whenever the algorithm is used. Setting a new salt should invalidate all internal state of this object.Algorithms that do not use a salt are allowed to ignore this parameter.
Algorithms must be able to deal with the null value as salt. They should treat it as "use a random salt".
- Parameters:
seed- The seed value
-
setKeyLength
void setKeyLength(int length) 64 * length value of key- Parameters:
length-
-
setSaltSize
void setSaltSize(int size) - Parameters:
size-
-
encrypt
Performs the actual encryption.- Parameters:
value- The value to be encryptedsalt-iteration-- Returns:
- The encrypted value
- Throws:
GeneralSecurityException- various errors from the underlying ciphers.
-
encrypt
Performs the actual encryption.- Parameters:
value- The value to be encryptedsalt-iteration-- Returns:
- The encrypted value
- Throws:
GeneralSecurityException- various errors from the underlying ciphers.
-
encrypt
DOCUMENT ME!- Parameters:
value- DOCUMENT ME!key- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
GeneralSecurityException- DOCUMENT ME!
-
decrypt
- Parameters:
value-salt-iteration-- Returns:
- Throws:
GeneralSecurityException
-
decrypt
- Parameters:
value- the value to be decryptedkey- DOCUMENT ME!- Throws:
GeneralSecurityException
-
getKey
- Parameters:
key- DOCUMENT ME!
-
getSalt
Returns a salt value.- Returns:
- A salt value
- Throws:
NoSuchAlgorithmException- If the requested algorithm is not available
-
getIteration
int getIteration()- Returns:
- int value for encryption iteration value
-
getRandom
- Parameters:
length-- Returns:
- Throws:
NoSuchAlgorithmException
-
isValid
boolean isValid(char[] test, String stored, char[] salt, int iterate) throws GeneralSecurityException for enc-dec mechanism- Parameters:
test-stored-salt-iterate-- Returns:
- Throws:
GeneralSecurityException
-
isValid
for hashing mechanism- Parameters:
test-stored-- Returns:
- Throws:
GeneralSecurityException
-
encrytedFullPassword
- Parameters:
test-- Returns:
- Throws:
GeneralSecurityException
-