Class CipherKey

java.lang.Object
eirb.pub.app.vault.CipherKey

public class CipherKey extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    CipherKey(byte[] contentByte)
    Create a CipherKey object based on it's encrypted version (retrieved from a VaultFile for example) Decomposed as follows : hash|cipher The hash is 32 bytes long
    CipherKey(Key greenKeyToEncrypt, Key key, InitializationVector initVector)
    Create a cipherKey based on the information wanted inside.
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    concat(byte[] tab1, byte[] tab2)
    Concatenate two arrays together
    byte[]
    Get the byte representation of the ciphered key
    getIV(Key yellowKey)
    Retrieve the InitializationVector from the CipherKey
    getVaultKey(Key yellowKey)
    Retrieve the VaultKey from the CipherKey

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CipherKey

      public CipherKey(Key greenKeyToEncrypt, Key key, InitializationVector initVector) throws CipherException
      Create a cipherKey based on the information wanted inside. No plain is stored in this object, only the cipher version is stored in this object. Field can be retrieved with the appropriate methods (getIV, getVaultKey)
      Parameters:
      greenKeyToEncrypt - vaultKey that will be encrypted
      key - Key used for encryption of the fields
      initVector - Initialization vector that will be encrypted
      Throws:
      CipherException - when an encryption error occurred
    • CipherKey

      public CipherKey(byte[] contentByte)
      Create a CipherKey object based on it's encrypted version (retrieved from a VaultFile for example) Decomposed as follows : hash|cipher The hash is 32 bytes long
      Parameters:
      contentByte - byte representation of the ciphered JSON with VaultKey and Iv stored inside with the hash at the beginning
  • Method Details

    • getIV

      public InitializationVector getIV(Key yellowKey) throws KeyException
      Retrieve the InitializationVector from the CipherKey
      Parameters:
      yellowKey - key to decrypt the CipherKey
      Returns:
      Initialization vector stored in the cipher representation of the key
      Throws:
      KeyException - If the provided key is not able to decrypt the cipherKey
    • getVaultKey

      public Key getVaultKey(Key yellowKey) throws KeyException
      Retrieve the VaultKey from the CipherKey
      Parameters:
      yellowKey - key to decrypt the CipherKey
      Returns:
      Vault Key stored in the cipher representation of the key
      Throws:
      KeyException - If the provided key is not able to decrypt the cipherKey
    • concat

      public static byte[] concat(byte[] tab1, byte[] tab2)
      Concatenate two arrays together
      Parameters:
      tab1 - first array
      tab2 - second array
      Returns:
      array tab1|tab2
    • getBytes

      public byte[] getBytes()
      Get the byte representation of the ciphered key
      Returns:
      byte representation (hash|cipher) of the CipherKey