net.handle.security
Class HdlSecurityProvider

java.lang.Object
  extended by net.handle.security.HdlSecurityProvider
Direct Known Subclasses:
GenericProvider

public abstract class HdlSecurityProvider
extends java.lang.Object


Field Summary
static int ENCRYPT_ALG_AES
           
static int ENCRYPT_ALG_DES
           
static int ENCRYPT_ALG_DESEDE
           
 
Constructor Summary
HdlSecurityProvider()
           
 
Method Summary
abstract  byte[] decrypt_DES_ECB_PKCS5(byte[] ciphertext, int offset, int len, byte[] secretKey)
          Deprecated. use getCipher() instead and re-use the returned Cipher object
 byte[] decrypt_RSA_ECB_PKCS1(byte[] ciphertext, int offset, int len, java.security.interfaces.RSAPrivateKey privateKey)
           
abstract  byte[] encrypt_DES_ECB_PKCS5(byte[] cleartext, int offset, int len, byte[] secretKey)
          Deprecated. use getCipher() instead and re-use the returned Cipher object
 byte[] encrypt_RSA_ECB_PKCS1(byte[] cleartext, int offset, int len, java.security.interfaces.RSAPublicKey publicKey)
           
 java.security.KeyPair generateDHKeyPair(java.math.BigInteger p, java.math.BigInteger g)
           
 java.security.KeyPair generateDHKeyPair(int keySize)
           
 java.security.KeyPair generateRSAKeyPair(int keySize)
           
abstract  byte[] generateSecretKey(int keyAlg)
          Generate and encode a secret key for use with the given algorithm
abstract  javax.crypto.Cipher getCipher(int algorithm, byte[] secretKey, int direction)
          Construct and return a Cipher object, initialized to either decrypt or encrypt using the given algorithm and secret key.
 byte[] getDESKeyFromDH(javax.crypto.interfaces.DHPublicKey pub, javax.crypto.interfaces.DHPrivateKey priv)
           
static HdlSecurityProvider getInstance()
           
 byte[] getKeyFromDH(javax.crypto.interfaces.DHPublicKey pub, javax.crypto.interfaces.DHPrivateKey priv, int algorithm)
          Using the given diffie-hellman key pair, generate a secret key with the given algorithm.
 byte[] sign_RSA_MD5_PKCS1(byte[] ciphertext, int offset, int len, java.security.interfaces.RSAPrivateKey privateKey)
           
 byte[] sign_RSA_SHA1_PKCS1(byte[] ciphertext, int offset, int len, java.security.interfaces.RSAPrivateKey privateKey)
           
 boolean verify_RSA_MD5_PKCS1(byte[] plaintext, int offset, int len, byte[] signature, java.security.interfaces.RSAPublicKey publicKey)
           
 boolean verify_RSA_SHA1_PKCS1(byte[] plaintext, int offset, int len, byte[] signature, java.security.interfaces.RSAPublicKey publicKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCRYPT_ALG_DES

public static final int ENCRYPT_ALG_DES
See Also:
Constant Field Values

ENCRYPT_ALG_DESEDE

public static final int ENCRYPT_ALG_DESEDE
See Also:
Constant Field Values

ENCRYPT_ALG_AES

public static final int ENCRYPT_ALG_AES
See Also:
Constant Field Values
Constructor Detail

HdlSecurityProvider

public HdlSecurityProvider()
Method Detail

getInstance

public static final HdlSecurityProvider getInstance()

getCipher

public abstract javax.crypto.Cipher getCipher(int algorithm,
                                              byte[] secretKey,
                                              int direction)
                                       throws java.lang.Exception
Construct and return a Cipher object, initialized to either decrypt or encrypt using the given algorithm and secret key. The direction parameter must be either Cipher.ENCRYPT_MODE or Cipher.DECRYPT_MODE. The algorithm parameter should be one of the HdlSecurityProvider.ENCRYPT_ALG_* constants.

Throws:
java.lang.Exception

generateSecretKey

public abstract byte[] generateSecretKey(int keyAlg)
                                  throws java.lang.Exception
Generate and encode a secret key for use with the given algorithm

Throws:
java.lang.Exception

encrypt_DES_ECB_PKCS5

@Deprecated
public abstract byte[] encrypt_DES_ECB_PKCS5(byte[] cleartext,
                                                        int offset,
                                                        int len,
                                                        byte[] secretKey)
                                      throws java.lang.Exception
Deprecated. use getCipher() instead and re-use the returned Cipher object

encrypt a chunk of data using the DES/ECB/PKCS5 algorith/padding/encoding

Throws:
java.lang.Exception

decrypt_DES_ECB_PKCS5

@Deprecated
public abstract byte[] decrypt_DES_ECB_PKCS5(byte[] ciphertext,
                                                        int offset,
                                                        int len,
                                                        byte[] secretKey)
                                      throws java.lang.Exception
Deprecated. use getCipher() instead and re-use the returned Cipher object

decrypt a chunk of data using the DES/ECB/PKCS5 algorith/padding/encoding

Throws:
java.lang.Exception

generateRSAKeyPair

public java.security.KeyPair generateRSAKeyPair(int keySize)
                                         throws java.lang.Exception
Throws:
java.lang.Exception

encrypt_RSA_ECB_PKCS1

public byte[] encrypt_RSA_ECB_PKCS1(byte[] cleartext,
                                    int offset,
                                    int len,
                                    java.security.interfaces.RSAPublicKey publicKey)
                             throws java.lang.Exception
Throws:
java.lang.Exception

decrypt_RSA_ECB_PKCS1

public byte[] decrypt_RSA_ECB_PKCS1(byte[] ciphertext,
                                    int offset,
                                    int len,
                                    java.security.interfaces.RSAPrivateKey privateKey)
                             throws java.lang.Exception
Throws:
java.lang.Exception

sign_RSA_MD5_PKCS1

public byte[] sign_RSA_MD5_PKCS1(byte[] ciphertext,
                                 int offset,
                                 int len,
                                 java.security.interfaces.RSAPrivateKey privateKey)
                          throws java.lang.Exception
Throws:
java.lang.Exception

verify_RSA_MD5_PKCS1

public boolean verify_RSA_MD5_PKCS1(byte[] plaintext,
                                    int offset,
                                    int len,
                                    byte[] signature,
                                    java.security.interfaces.RSAPublicKey publicKey)
                             throws java.lang.Exception
Throws:
java.lang.Exception

sign_RSA_SHA1_PKCS1

public byte[] sign_RSA_SHA1_PKCS1(byte[] ciphertext,
                                  int offset,
                                  int len,
                                  java.security.interfaces.RSAPrivateKey privateKey)
                           throws java.lang.Exception
Throws:
java.lang.Exception

verify_RSA_SHA1_PKCS1

public boolean verify_RSA_SHA1_PKCS1(byte[] plaintext,
                                     int offset,
                                     int len,
                                     byte[] signature,
                                     java.security.interfaces.RSAPublicKey publicKey)
                              throws java.lang.Exception
Throws:
java.lang.Exception

generateDHKeyPair

public java.security.KeyPair generateDHKeyPair(int keySize)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

generateDHKeyPair

public java.security.KeyPair generateDHKeyPair(java.math.BigInteger p,
                                               java.math.BigInteger g)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

getDESKeyFromDH

public byte[] getDESKeyFromDH(javax.crypto.interfaces.DHPublicKey pub,
                              javax.crypto.interfaces.DHPrivateKey priv)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getKeyFromDH

public byte[] getKeyFromDH(javax.crypto.interfaces.DHPublicKey pub,
                           javax.crypto.interfaces.DHPrivateKey priv,
                           int algorithm)
                    throws java.lang.Exception
Using the given diffie-hellman key pair, generate a secret key with the given algorithm. The first four bytes of the secret key will identify the algorithm for the secret key (DES, AES, DESede)

Throws:
java.lang.Exception