inescID.crypto
Class EncryptionTool

java.lang.Object
  extended byinescID.crypto.EncryptionTool

public class EncryptionTool
extends java.lang.Object

Title:

Description:

Copyright: Copyright (c) 2002

Company Inesc-ID


Field Summary
static int DEFAULT_RSA_KEY_SIZE
           
static java.lang.String RANDOM_ALGORITHM
           
static java.lang.String RSA_ALGORITHM
           
(package private)  java.security.KeyFactory RSAKeyFactory
           
(package private)  java.security.KeyPairGenerator RSAKeyPairGenerator
           
(package private)  java.security.SecureRandom secureRandom
           
static java.lang.String TRIPLE_DES
           
 
Constructor Summary
EncryptionTool()
           
 
Method Summary
 java.lang.Object ByteArrayToObject(byte[] object_bytes)
           
(package private)  java.lang.String ByteToString(byte[] b)
           
 byte[] DecryptMixCipherMode(MixCipherEnvelope envelope, java.security.interfaces.RSAKey key)
           
 java.math.BigInteger DecryptRSA_NoPad(java.math.BigInteger data, java.security.interfaces.RSAKey key)
           
 byte[] DecryptRSA_NoPad(byte[] data, java.security.interfaces.RSAKey key)
           
 byte[] DecryptTripleDES(byte[] object_encrypted, javax.crypto.SecretKey key)
           
 MixCipherEnvelope EncryptMixCipherMode(byte[] data, java.security.interfaces.RSAKey key)
           
 MixCipherEnvelope EncryptMixCipherMode(java.lang.Object obj, java.security.interfaces.RSAKey key)
           
 java.math.BigInteger EncryptRSA_NoPad(java.math.BigInteger data, java.security.interfaces.RSAKey key)
           
 byte[] EncryptRSA_NoPad(byte[] data, java.security.interfaces.RSAKey key)
           
 byte[] EncryptTripleDES(byte[] data, javax.crypto.SecretKey key)
           
 byte[] EncryptTripleDES(java.lang.Object obj, javax.crypto.SecretKey key)
           
 java.security.KeyPair genRSAKeyPair()
           
 java.security.KeyPair genRSAKeyPair(int size)
           
 java.security.interfaces.RSAPrivateKey getRSAPrivateKey(byte[] chave)
           
 java.security.interfaces.RSAPublicKey getRSAPublicKey(byte[] chave)
           
 javax.crypto.SecretKey getTripleDESkey()
           
 javax.crypto.SecretKey getTripleDESkey(byte[] key)
           
 javax.crypto.SecretKey getTripleDESkey(java.lang.String key)
           
 java.lang.String getTripleDESkeyString()
           
 byte[] ObjectToByteArray(java.lang.Object obj)
           
 java.math.BigInteger RSAEncryption(java.math.BigInteger data, java.security.interfaces.RSAKey key)
           
(package private)  byte[] StringToByte(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RSA_KEY_SIZE

public static final int DEFAULT_RSA_KEY_SIZE
See Also:
Constant Field Values

RANDOM_ALGORITHM

public static final java.lang.String RANDOM_ALGORITHM
See Also:
Constant Field Values

RSA_ALGORITHM

public static final java.lang.String RSA_ALGORITHM
See Also:
Constant Field Values

TRIPLE_DES

public static final java.lang.String TRIPLE_DES
See Also:
Constant Field Values

RSAKeyPairGenerator

java.security.KeyPairGenerator RSAKeyPairGenerator

RSAKeyFactory

java.security.KeyFactory RSAKeyFactory

secureRandom

java.security.SecureRandom secureRandom
Constructor Detail

EncryptionTool

public EncryptionTool()
               throws java.lang.Exception
Method Detail

ByteToString

java.lang.String ByteToString(byte[] b)

StringToByte

byte[] StringToByte(java.lang.String s)
              throws java.lang.Exception
Throws:
java.lang.Exception

genRSAKeyPair

public java.security.KeyPair genRSAKeyPair()
                                    throws java.lang.Exception
Throws:
java.lang.Exception

genRSAKeyPair

public java.security.KeyPair genRSAKeyPair(int size)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getRSAPrivateKey

public java.security.interfaces.RSAPrivateKey getRSAPrivateKey(byte[] chave)
                                                        throws java.security.spec.InvalidKeySpecException
Throws:
java.security.spec.InvalidKeySpecException

getRSAPublicKey

public java.security.interfaces.RSAPublicKey getRSAPublicKey(byte[] chave)
                                                      throws java.security.spec.InvalidKeySpecException
Throws:
java.security.spec.InvalidKeySpecException

ObjectToByteArray

public byte[] ObjectToByteArray(java.lang.Object obj)
                         throws java.lang.Exception
Throws:
java.lang.Exception

ByteArrayToObject

public java.lang.Object ByteArrayToObject(byte[] object_bytes)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

getTripleDESkeyString

public java.lang.String getTripleDESkeyString()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getTripleDESkey

public javax.crypto.SecretKey getTripleDESkey()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getTripleDESkey

public javax.crypto.SecretKey getTripleDESkey(java.lang.String key)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getTripleDESkey

public javax.crypto.SecretKey getTripleDESkey(byte[] key)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

EncryptTripleDES

public byte[] EncryptTripleDES(java.lang.Object obj,
                               javax.crypto.SecretKey key)
                        throws java.lang.Exception
Throws:
java.lang.Exception

EncryptTripleDES

public byte[] EncryptTripleDES(byte[] data,
                               javax.crypto.SecretKey key)
                        throws java.lang.Exception
Throws:
java.lang.Exception

DecryptTripleDES

public byte[] DecryptTripleDES(byte[] object_encrypted,
                               javax.crypto.SecretKey key)
                        throws java.lang.Exception
Throws:
java.lang.Exception

EncryptMixCipherMode

public MixCipherEnvelope EncryptMixCipherMode(java.lang.Object obj,
                                              java.security.interfaces.RSAKey key)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

EncryptMixCipherMode

public MixCipherEnvelope EncryptMixCipherMode(byte[] data,
                                              java.security.interfaces.RSAKey key)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

DecryptMixCipherMode

public byte[] DecryptMixCipherMode(MixCipherEnvelope envelope,
                                   java.security.interfaces.RSAKey key)
                            throws java.lang.Exception
Throws:
java.lang.Exception

EncryptRSA_NoPad

public java.math.BigInteger EncryptRSA_NoPad(java.math.BigInteger data,
                                             java.security.interfaces.RSAKey key)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

EncryptRSA_NoPad

public byte[] EncryptRSA_NoPad(byte[] data,
                               java.security.interfaces.RSAKey key)
                        throws java.lang.Exception
Throws:
java.lang.Exception

DecryptRSA_NoPad

public java.math.BigInteger DecryptRSA_NoPad(java.math.BigInteger data,
                                             java.security.interfaces.RSAKey key)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

DecryptRSA_NoPad

public byte[] DecryptRSA_NoPad(byte[] data,
                               java.security.interfaces.RSAKey key)
                        throws java.lang.Exception
Throws:
java.lang.Exception

RSAEncryption

public java.math.BigInteger RSAEncryption(java.math.BigInteger data,
                                          java.security.interfaces.RSAKey key)
                                   throws java.lang.Exception
Throws:
java.lang.Exception