Class CipherVault

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

public class CipherVault extends Object
  • Constructor Details

    • CipherVault

      public CipherVault(byte[] bytes)
      Initialize a CipherVault based on its byte representation
      Parameters:
      bytes - cipher representation of the vault
  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener) throws NullPlainVaultSyncException
      Throws:
      NullPlainVaultSyncException
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
    • unlock

      Get the PlainVault by decrypting the cipherVault All modifications made on the PlainVault are linked to the CipherVault object So when you get the byte representation of the CipherVault, it will represent the PlainVault encrypted with AES CBC

      When a CipherVault is unlocked, the vault key and the initialization vector is stored in the object in plain. To clean the memory use the lock method

      Parameters:
      k - Key to decrypt the Vault
      iv - Initialization vector used for CBC
      Returns:
      PlainVault representation of the CipherVault
      Throws:
      CipherException - If the decryption failed
      CipherVaultException - If the decryption succeeded but the decrypted byte do not represent a correct PlainVault
    • lock

      public void lock() throws VaultException, CipherException
      Clear the memory of the CipherVault. If it was unlocked before, will remove the key, iv and PlainVault from the memory.

      All PlainVault objects retrieved by unlock method will no longer work/be linked to the CipherVault

      Throws:
      VaultException - If the plainVault failed to be converted into byte for encryption
      CipherException - If an error occurred during the encryption
    • getBytes

      public byte[] getBytes() throws VaultException, CipherException
      Get the byte representation of the CipherVault. If modification where made on the PlainVault, the vault will be encrypted again.
      Returns:
      byte representation
      Throws:
      VaultException - If the plainVault failed to be converted into byte for encryption
      CipherException - If an error occurred during the encryption process
    • emptyCipherVault

      public static CipherVault emptyCipherVault(Key vaultKey, InitializationVector iv) throws VaultException, CipherException
      Get an empty cipher Vault that represent an empty PlainVault encrypted
      Parameters:
      vaultKey - key used for encryption
      iv - Initialization vector used for CBC
      Returns:
      CipherVault representing an empty PlainVault
      Throws:
      VaultException - If the plainVault failed to be converted into byte for encryption
      CipherException - If an error occurred during the encryption process
    • setFrom

      public void setFrom(CipherVault cipherVault) throws CipherException, VaultException
      Throws:
      CipherException
      VaultException