SafeAPI v1.20

com.safeapi
Class CryptoSym

java.lang.Object
  extended bycom.safeapi.CryptoCommon
      extended bycom.safeapi.CryptoSym

public final class CryptoSym
extends CryptoCommon

Symmetric Cryptography APIs Module


Constructor Summary
CryptoSym()
          Loads an instance of CryptoSym.
 
Method Summary
 byte[] decryptBuffer(String sKeyID, char[] caPassphrase, byte[] bBuffer)
          Decrypts a buffer with a secret key
 byte[] decryptBufferKey(String sAlgorithm, char[] caHexaKey, byte[] bBuffer)
          Decrypts a buffer with the key in hexadecimal format
 byte[] decryptBufferRawKey(String sAlgorithm, byte[] bSecretKey, byte[] bInitVector, byte[] bBuffer)
          Decrypts a buffer with the provided bytes used as key
 void decryptFile(String sKeyID, char[] caPassphrase, String sInputPath, String sOutputPath)
          Decrypts the specified file with a Key ID.
 byte[] encryptBuffer(String sKeyID, char[] caPassphrase, byte[] bBuffer)
          Encrypts a buffer with a secret key
 byte[] encryptBufferKey(String sAlgorithm, char[] caHexaKey, byte[] bBuffer)
          Encrypts a buffer with an hexadecimal key
 byte[] encryptBufferRawKey(String sAlgorithm, byte[] bSecretKey, byte[] bInitVector, byte[] bBuffer)
          Encrypts a buffer with the provided bytes used as key
 void encryptFile(String sKeyID, char[] caPassphrase, String sInputPath, String sOutputPath)
          Encrypt the specified file with a Key ID.
 void genSecretKey(String sAlgorithm, char[] caPassphrase, int nLength, byte[] bSeed, String sEmailSign, int nIndex)
          Generates a secret key for requested algorithm and length and with your seed.
 String getSecretKey(String sAlgorithm, char[] caPassphrase, String sEmail, int nIndex)
          Gets a secret key value in hexadecimal.
 
Methods inherited from class com.safeapi.CryptoCommon
createSeedFile, getParameter, getRandomBytes, getRawError, getRegisteredError, getVersion, isOperationOK, setParameter, wipe
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptoSym

public CryptoSym()
Loads an instance of CryptoSym.

Method Detail

genSecretKey

public void genSecretKey(String sAlgorithm,
                         char[] caPassphrase,
                         int nLength,
                         byte[] bSeed,
                         String sEmailSign,
                         int nIndex)
Generates a secret key for requested algorithm and length and with your seed. Key is then encrypted with your passphrase and stored.

Parameters:
sAlgorithm - The symmetric algorithm name (IDEA, Blowfish, CAST-128)
caPassphrase - The secret key passphrase protection
nLength - The length for the key to generate (128 bits)
bSeed - The seed for the random used for generation
sEmailSign - The Email of the owner
nIndex - The Index of this key

getSecretKey

public String getSecretKey(String sAlgorithm,
                           char[] caPassphrase,
                           String sEmail,
                           int nIndex)
Gets a secret key value in hexadecimal.

Parameters:
sAlgorithm - The symmetric algorithm name (IDEA, Blowfish, CAST-128)
caPassphrase - The secret key passphrase protection
sEmail - The Email of the owner
nIndex - The Index of this key

encryptBuffer

public byte[] encryptBuffer(String sKeyID,
                            char[] caPassphrase,
                            byte[] bBuffer)
Encrypts a buffer with a secret key

Parameters:
sKeyID - The Key ID
caPassphrase - The secret key passphrase protection
bBuffer - The buffer to encrypt
Returns:
The encrypted buffer in hexadecimal value

encryptBufferKey

public byte[] encryptBufferKey(String sAlgorithm,
                               char[] caHexaKey,
                               byte[] bBuffer)
Encrypts a buffer with an hexadecimal key

Parameters:
sAlgorithm - The encryption algorithm
caHexaKey - The key in hexadecimal format
bBuffer - The buffer to encrypt
Returns:
The encrypted buffer

encryptBufferRawKey

public byte[] encryptBufferRawKey(String sAlgorithm,
                                  byte[] bSecretKey,
                                  byte[] bInitVector,
                                  byte[] bBuffer)
Encrypts a buffer with the provided bytes used as key

Parameters:
sAlgorithm - The encryption algorithm
bSecretKey - The bytes used as secret key
bInitVector - The initalization vector
bBuffer - The buffer to encrypt
Returns:
The encrypted buffer

decryptBuffer

public byte[] decryptBuffer(String sKeyID,
                            char[] caPassphrase,
                            byte[] bBuffer)
Decrypts a buffer with a secret key

Parameters:
sKeyID - The Key ID
caPassphrase - The secret key passphrase protection
bBuffer - The buffer to decrypt
Returns:
The decrypted buffer

decryptBufferKey

public byte[] decryptBufferKey(String sAlgorithm,
                               char[] caHexaKey,
                               byte[] bBuffer)
Decrypts a buffer with the key in hexadecimal format

Parameters:
sAlgorithm - The encryption algorithm
caHexaKey - the key in hexadecimal format
bBuffer - The buffer to decrypt
Returns:
The plain/decrypted buffer

decryptBufferRawKey

public byte[] decryptBufferRawKey(String sAlgorithm,
                                  byte[] bSecretKey,
                                  byte[] bInitVector,
                                  byte[] bBuffer)
Decrypts a buffer with the provided bytes used as key

Parameters:
sAlgorithm - The encryption algorithm
bSecretKey - The bytes used as secret key
bInitVector - The initalization vector
bBuffer - The buffer to encrypt
Returns:
The decrypted buffer

encryptFile

public void encryptFile(String sKeyID,
                        char[] caPassphrase,
                        String sInputPath,
                        String sOutputPath)
Encrypt the specified file with a Key ID.

Parameters:
sKeyID - The Key ID
caPassphrase - The secret key passphrase protection
sInputPath - The full name of the file to encrypt
sOutputPath - The encrypted file to create

decryptFile

public void decryptFile(String sKeyID,
                        char[] caPassphrase,
                        String sInputPath,
                        String sOutputPath)
Decrypts the specified file with a Key ID.

Parameters:
sKeyID - The Key ID
caPassphrase - The passphrase for key protection
sInputPath - The full name of the file to decrypt
sOutputPath - The decrypted file to create

SafeAPI v1.20

Copyright © SafeLogic 2005