net.handle.security.provider
Class GenericProvider

java.lang.Object
  extended by net.handle.security.HdlSecurityProvider
      extended by net.handle.security.provider.GenericProvider

public final class GenericProvider
extends HdlSecurityProvider

An implementation of the net.handle.HDLSecurityProvider interface that accesses the generic java security/crypto interfaces.


Field Summary
 
Fields inherited from class net.handle.security.HdlSecurityProvider
ENCRYPT_ALG_AES, ENCRYPT_ALG_DES, ENCRYPT_ALG_DESEDE
 
Constructor Summary
GenericProvider()
           
 
Method Summary
 byte[] decrypt_DES_ECB_PKCS5(byte[] ciphertext, int offset, int len, byte[] secretKey)
          Deprecated. use the getEncryptCipher and getDecryptCipher methods now that the java crypto API, and therefore the Cipher class, is standard and included in java 1.4 and higher. Using a returned Cipher object will be vastly more efficient than calling this method, which constructs a new Cipher every time.
 byte[] encrypt_DES_ECB_PKCS5(byte[] cleartext, int offset, int len, byte[] secretKey)
          Deprecated. use the getEncryptCipher and getDecryptCipher methods now that the java crypto API, and therefore the Cipher class, is standard and included in java 1.4 and higher. Using a returned Cipher object will be vastly more efficient than calling this method, which constructs a new Cipher every time.
 java.security.KeyPair generateDHKeyPair(java.math.BigInteger p, java.math.BigInteger g)
           
 java.security.KeyPair generateDHKeyPair(int keySize)
           
 byte[] generateSecretKey(int keyAlg)
          Generate and encode a secret key for use with the given algorithm
 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)
           
 byte[] getKeyFromDH(javax.crypto.interfaces.DHPublicKey pub, javax.crypto.interfaces.DHPrivateKey priv, int algorithm)
          Using the given diffie-hellman key pair, generate the secret key with the algorithm ID (ENCRYPT_ALG_DES, ENCRYPT_ALG_AES or ENCRYPT_ALG_DESEDE) in the first four bytes of the array
static void main(java.lang.String[] argv)
           
 
Methods inherited from class net.handle.security.HdlSecurityProvider
decrypt_RSA_ECB_PKCS1, encrypt_RSA_ECB_PKCS1, generateRSAKeyPair, getInstance, sign_RSA_MD5_PKCS1, sign_RSA_SHA1_PKCS1, verify_RSA_MD5_PKCS1, verify_RSA_SHA1_PKCS1
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericProvider

public GenericProvider()
Method Detail

getCipher

public 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.

Specified by:
getCipher in class HdlSecurityProvider
Throws:
java.lang.Exception

generateSecretKey

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

Specified by:
generateSecretKey in class HdlSecurityProvider
Throws:
java.lang.Exception

encrypt_DES_ECB_PKCS5

@Deprecated
public byte[] encrypt_DES_ECB_PKCS5(byte[] cleartext,
                                               int offset,
                                               int len,
                                               byte[] secretKey)
                             throws java.lang.Exception
Deprecated. use the getEncryptCipher and getDecryptCipher methods now that the java crypto API, and therefore the Cipher class, is standard and included in java 1.4 and higher. Using a returned Cipher object will be vastly more efficient than calling this method, which constructs a new Cipher every time.

Description copied from class: HdlSecurityProvider
encrypt a chunk of data using the DES/ECB/PKCS5 algorith/padding/encoding

Specified by:
encrypt_DES_ECB_PKCS5 in class HdlSecurityProvider
Throws:
java.lang.Exception

decrypt_DES_ECB_PKCS5

@Deprecated
public byte[] decrypt_DES_ECB_PKCS5(byte[] ciphertext,
                                               int offset,
                                               int len,
                                               byte[] secretKey)
                             throws java.lang.Exception
Deprecated. use the getEncryptCipher and getDecryptCipher methods now that the java crypto API, and therefore the Cipher class, is standard and included in java 1.4 and higher. Using a returned Cipher object will be vastly more efficient than calling this method, which constructs a new Cipher every time.

Description copied from class: HdlSecurityProvider
decrypt a chunk of data using the DES/ECB/PKCS5 algorith/padding/encoding

Specified by:
decrypt_DES_ECB_PKCS5 in class HdlSecurityProvider
Throws:
java.lang.Exception

getDESKeyFromDH

public byte[] getDESKeyFromDH(javax.crypto.interfaces.DHPublicKey pub,
                              javax.crypto.interfaces.DHPrivateKey priv)
                       throws java.lang.Exception
Overrides:
getDESKeyFromDH in class HdlSecurityProvider
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 the secret key with the algorithm ID (ENCRYPT_ALG_DES, ENCRYPT_ALG_AES or ENCRYPT_ALG_DESEDE) in the first four bytes of the array

Overrides:
getKeyFromDH in class HdlSecurityProvider
Throws:
java.lang.Exception

generateDHKeyPair

public java.security.KeyPair generateDHKeyPair(int keySize)
                                        throws java.lang.Exception
Overrides:
generateDHKeyPair in class HdlSecurityProvider
Throws:
java.lang.Exception

generateDHKeyPair

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

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception