Interface CryptoAlgorithm

All Known Implementing Classes:
AESCrypt, BlowfishCrypt, CleanCrypt, DigestCrypt, HmacCrypt, JavaCrypt

public interface CryptoAlgorithm
This interface describes the various Crypto Algorithms that are handed out by the Crypto Service.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decrypt(byte[] value, Key key)
     
    byte[]
    decrypt(char[] value, byte[] salt, int iteration)
     
    byte[]
    encrypt(byte[] value, byte[] salt, int iteration)
    Performs the actual encryption.
    byte[]
    encrypt(char[] value, byte[] salt, int iteration)
    Performs the actual encryption.
    byte[]
    encrypt(char[] value, Key key)
    DOCUMENT ME!
    encrytedFullPassword(char[] test)
     
    int
     
    getKey(byte[] key)
     
    byte[]
    getRandom(int length)
     
    byte[]
    Returns a salt value.
    boolean
    isValid(char[] test, String stored)
    for hashing mechanism
    boolean
    isValid(char[] test, String stored, char[] salt, int iterate)
    for enc-dec mechanism
    void
    setCipher(String cipher)
    Algorithms that perform multiple ciphers get told with setCipher, which cipher to use.
    void
    setKeyLength(int length)
    64 * length value of key
    void
    setSaltSize(int size)
     
    void
    Allows the user to set a salt value whenever the algorithm is used.
  • Method Details

    • setCipher

      void setCipher(String cipher)
      Algorithms that perform multiple ciphers get told with setCipher, which cipher to use. This should be called before any other method call. If called after any call to encrypt or setSeed, the CryptoAlgorithm may choose to ignore this or to reset and use the new cipher. If any other call is used before this, the algorithm should use a default cipher and not throw an error.
      Parameters:
      cipher - The cipher to use.
    • setSeed

      void setSeed(String seed)
      Allows the user to set a salt value whenever the algorithm is used. Setting a new salt should invalidate all internal state of this object.

      Algorithms that do not use a salt are allowed to ignore this parameter.

      Algorithms must be able to deal with the null value as salt. They should treat it as "use a random salt".

      Parameters:
      seed - The seed value
    • setKeyLength

      void setKeyLength(int length)
      64 * length value of key
      Parameters:
      length -
    • setSaltSize

      void setSaltSize(int size)
      Parameters:
      size -
    • encrypt

      byte[] encrypt(byte[] value, byte[] salt, int iteration) throws GeneralSecurityException
      Performs the actual encryption.
      Parameters:
      value - The value to be encrypted
      salt -
      iteration -
      Returns:
      The encrypted value
      Throws:
      GeneralSecurityException - various errors from the underlying ciphers.
    • encrypt

      byte[] encrypt(char[] value, byte[] salt, int iteration) throws GeneralSecurityException
      Performs the actual encryption.
      Parameters:
      value - The value to be encrypted
      salt -
      iteration -
      Returns:
      The encrypted value
      Throws:
      GeneralSecurityException - various errors from the underlying ciphers.
    • encrypt

      byte[] encrypt(char[] value, Key key) throws GeneralSecurityException
      DOCUMENT ME!
      Parameters:
      value - DOCUMENT ME!
      key - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
      Throws:
      GeneralSecurityException - DOCUMENT ME!
    • decrypt

      byte[] decrypt(char[] value, byte[] salt, int iteration) throws GeneralSecurityException
      Parameters:
      value -
      salt -
      iteration -
      Returns:
      Throws:
      GeneralSecurityException
    • decrypt

      byte[] decrypt(byte[] value, Key key) throws GeneralSecurityException
      Parameters:
      value - the value to be decrypted
      key - DOCUMENT ME!
      Throws:
      GeneralSecurityException
    • getKey

      Key getKey(byte[] key)
      Parameters:
      key - DOCUMENT ME!
    • getSalt

      byte[] getSalt() throws NoSuchAlgorithmException
      Returns a salt value.
      Returns:
      A salt value
      Throws:
      NoSuchAlgorithmException - If the requested algorithm is not available
    • getIteration

      int getIteration()
      Returns:
      int value for encryption iteration value
    • getRandom

      byte[] getRandom(int length) throws NoSuchAlgorithmException
      Parameters:
      length -
      Returns:
      Throws:
      NoSuchAlgorithmException
    • isValid

      boolean isValid(char[] test, String stored, char[] salt, int iterate) throws GeneralSecurityException
      for enc-dec mechanism
      Parameters:
      test -
      stored -
      salt -
      iterate -
      Returns:
      Throws:
      GeneralSecurityException
    • isValid

      boolean isValid(char[] test, String stored) throws GeneralSecurityException
      for hashing mechanism
      Parameters:
      test -
      stored -
      Returns:
      Throws:
      GeneralSecurityException
    • encrytedFullPassword

      String encrytedFullPassword(char[] test) throws GeneralSecurityException
      Parameters:
      test -
      Returns:
      Throws:
      GeneralSecurityException