openlsd.network.server.legacy.LSDCrypto Class Reference

Collaboration diagram for openlsd.network.server.legacy.LSDCrypto:

Collaboration graph
[legend]

List of all members.


Detailed Description

Module for cryptography : use Blowfish with key of size defined in KEY_SIZE in LSDPathConstants.

Author:
Frederic Bregier LGPL

Public Member Functions

 LSDCrypto ()
void setSecretKey (Key secretKey)
void setSecretKey (byte[] keyData)
Cipher toCrypt ()
Cipher toDecrypt ()

Static Public Member Functions

static void main (String[] args) throws Exception

Protected Member Functions

Key getSecretKey ()

Private Member Functions

byte[] getSecretKeyInBytes ()
void generateKey () throws NoSuchAlgorithmException
byte[] crypt (byte[] plaintext) throws IllegalBlockSizeException,BadPaddingException
byte[] crypt (String plaintext) throws Exception
byte[] decryptInBytes (byte[] ciphertext) throws IllegalBlockSizeException,BadPaddingException
String decryptInString (byte[] ciphertext) throws Exception

Private Attributes

Key secretKey = null

Constructor & Destructor Documentation

openlsd.network.server.legacy.LSDCrypto.LSDCrypto (  ) 

Create a new LSDCrypto


Member Function Documentation

Key openlsd.network.server.legacy.LSDCrypto.getSecretKey (  )  [protected]

Returns the secretKey

Returns:
the current secretKey

byte [] openlsd.network.server.legacy.LSDCrypto.getSecretKeyInBytes (  )  [private]

Returns all information about the key in an array of byte. Therefore this key can be stored and then rebuild later on using the setSecretKey(byte[] keyData) method.

Returns:
the secretKey in byte[]

void openlsd.network.server.legacy.LSDCrypto.setSecretKey ( Key  secretKey  ) 

Set the secretKey associated with this LSDCrypto

Parameters:
secretKey 

void openlsd.network.server.legacy.LSDCrypto.setSecretKey ( byte[]  keyData  ) 

Allows to rebuild the secret Key with the data stored in the array of byte.

Parameters:
keyData 

void openlsd.network.server.legacy.LSDCrypto.generateKey (  )  throws NoSuchAlgorithmException [private]

Generate a new key according to the Blowfish algorithm.

Exceptions:
NoSuchAlgorithmException 

byte [] openlsd.network.server.legacy.LSDCrypto.crypt ( byte[]  plaintext  )  throws IllegalBlockSizeException,BadPaddingException [private]

Crypt the array of bytes plaintext and returns the result in an array of byte or null if the cipher (key or algorithm) is incorrect..

Parameters:
plaintext 
Returns:
the crypted array of byte or null if the cipher (key or algorithm) is incorrect.
Exceptions:
IllegalBlockSizeException if the encryption failed
BadPaddingException if the encryption failed

byte [] openlsd.network.server.legacy.LSDCrypto.crypt ( String  plaintext  )  throws Exception [private]

Crypt the String plaintext and returns the result in an array of byte or null if the cipher (key or algorithm) is incorrect..

Parameters:
plaintext 
Returns:
the crypted array of byte or null if the cipher (key or algorithm) is incorrect.
Exceptions:
Exception if the encryption failed

Cipher openlsd.network.server.legacy.LSDCrypto.toCrypt (  ) 

Returns a cipher for encryption associated with the key

Returns:
the cipher for encryption or null if it fails in case Encryption method or key is incorrect

Cipher openlsd.network.server.legacy.LSDCrypto.toDecrypt (  ) 

Returns a cipher for decryption associated with the key

Returns:
the cipher for decryption or null if it fails in case Encryption method or key is incorrect

byte [] openlsd.network.server.legacy.LSDCrypto.decryptInBytes ( byte[]  ciphertext  )  throws IllegalBlockSizeException,BadPaddingException [private]

Decrypt the array of byte ciphertext and returns the result in an array of byte or null if the cipher (key or algorithm) is incorrect.

Parameters:
ciphertext the array of encrypted byte
Returns:
the array of decrypted byte or null if the cipher (key or algorithm) is incorrect.
Exceptions:
IllegalBlockSizeException if the decryption failed
BadPaddingException if the decryption failed

String openlsd.network.server.legacy.LSDCrypto.decryptInString ( byte[]  ciphertext  )  throws Exception [private]

Decrypt the array of byte ciphertext and returns the result in a string or null if the cipher (key or algorithm) is incorrect..

Parameters:
ciphertext the array of encrypted byte
Returns:
the string of decrypted byte or null if the cipher (key or algorithm) is incorrect.
Exceptions:
Exception if the decryption failed

static void openlsd.network.server.legacy.LSDCrypto.main ( String[]  args  )  throws Exception [static]

For testing purpose

Parameters:
args is the text to crypt
Exceptions:
Exception 


Member Data Documentation

Crypto Key


The documentation for this class was generated from the following file: