org.eparapher.core.crypto
Class EPKeyManager

java.lang.Object
  extended by org.eparapher.core.crypto.EPKeyManager

public class EPKeyManager
extends Object


Constructor Summary
EPKeyManager()
           
 
Method Summary
static byte[] decryptWithSymetricKey(SecretKey sKey, byte[] cipheredBits)
          Decrypt with the given symetric key
static byte[] encryptWithSymetricKey(SecretKey sKey, byte[] clearbits)
          Encrypt with the given symetric key
static KeyPair genAsymetricKey(String algo, int size)
          Generate an asymetric key pair
static SecretKey genSymetricKey(String algo, int size)
          Generate a new symetric key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EPKeyManager

public EPKeyManager()
Method Detail

genSymetricKey

public static SecretKey genSymetricKey(String algo,
                                       int size)
                                throws NoSuchAlgorithmException,
                                       NoSuchProviderException
Generate a new symetric key

Parameters:
algo - Algorithm name
size - Key size
Throws:
NoSuchProviderException
NoSuchAlgorithmException

encryptWithSymetricKey

public static byte[] encryptWithSymetricKey(SecretKey sKey,
                                            byte[] clearbits)
                                     throws NoSuchAlgorithmException,
                                            NoSuchPaddingException,
                                            InvalidKeyException,
                                            IllegalBlockSizeException,
                                            BadPaddingException
Encrypt with the given symetric key

Parameters:
sKey - the secret key used for encryption
clearBits - Data to encrypt
Throws:
NoSuchPaddingException
NoSuchAlgorithmException
InvalidKeyException
BadPaddingException
IllegalBlockSizeException

decryptWithSymetricKey

public static byte[] decryptWithSymetricKey(SecretKey sKey,
                                            byte[] cipheredBits)
                                     throws NoSuchAlgorithmException,
                                            NoSuchPaddingException,
                                            InvalidKeyException,
                                            IllegalBlockSizeException,
                                            BadPaddingException
Decrypt with the given symetric key

Parameters:
sKey - the secret key used for decryption
cipheredBits - Encrypted data
Returns:
Decrypted data in a byte array
Throws:
NoSuchPaddingException
NoSuchAlgorithmException
InvalidKeyException
BadPaddingException
IllegalBlockSizeException

genAsymetricKey

public static KeyPair genAsymetricKey(String algo,
                                      int size)
                               throws NoSuchAlgorithmException,
                                      NoSuchProviderException
Generate an asymetric key pair

Parameters:
algo - The symetric Algorithm : usually RSA, DSA or ECDSA
size - The size of the KeyPair, usually in bytes
Returns:
The KeyPair
Throws:
NoSuchProviderException
NoSuchAlgorithmException


Copyright © 2009 eParapher Software Foundation. All Rights Reserved.