Class SecretVault

java.lang.Object
io.github.jbastgen.stemma.app.credential.SecretVault

public final class SecretVault extends Object
A file with secrets (access tokens, passwords, key passphrases), encrypted with a master password: AES-256 in GCM mode, the key derived from the password with PBKDF2 (HmacSHA256, many rounds, random salt). Everything is authenticated, so a changed or damaged file is detected. The master password is never stored; the derived key stays in memory while the vault is unlocked.

File layout: "STEMMAVAULT1", iterations (4 bytes), salt (16), IV (12), ciphertext with tag.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A wrong master password, or a file that was changed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    A vault with the usual number of key derivation rounds.
    SecretVault(Path file, int iterations)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    changePassword(char[] oldPassword, char[] newPassword)
    Re-encrypts with a new master password; the old one is checked first.
    void
    create(char[] password)
    Creates an empty vault protected by password and leaves it unlocked.
    boolean
    Whether a vault file exists, i.e. a master password has been set.
    void
    Forgets the key and the secrets; the file stays.
    void
    unlock(char[] password)
    Opens the vault.
    boolean
    Whether the vault is open: the key is in memory.

    Methods inherited from class java.lang.Object

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

    • SecretVault

      public SecretVault(Path file)
      A vault with the usual number of key derivation rounds.
    • SecretVault

      public SecretVault(Path file, int iterations)
      Parameters:
      iterations - PBKDF2 rounds for a new vault; tests use few. An existing file keeps its own number.
  • Method Details