Class SecretVault
java.lang.Object
io.github.jbastgen.stemma.app.credential.SecretVault
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 ClassesModifier and TypeClassDescriptionstatic final classA wrong master password, or a file that was changed. -
Constructor Summary
ConstructorsConstructorDescriptionSecretVault(Path file) A vault with the usual number of key derivation rounds.SecretVault(Path file, int iterations) -
Method Summary
Modifier and TypeMethodDescriptionvoidchangePassword(char[] oldPassword, char[] newPassword) Re-encrypts with a new master password; the old one is checked first.voidcreate(char[] password) Creates an empty vault protected bypasswordand leaves it unlocked.booleanexists()Whether a vault file exists, i.e. a master password has been set.voidlock()Forgets the key and the secrets; the file stays.voidunlock(char[] password) Opens the vault.booleanunlocked()Whether the vault is open: the key is in memory.
-
Constructor Details
-
SecretVault
A vault with the usual number of key derivation rounds. -
SecretVault
- Parameters:
iterations- PBKDF2 rounds for a new vault; tests use few. An existing file keeps its own number.
-
-
Method Details
-
exists
public boolean exists()Whether a vault file exists, i.e. a master password has been set. -
unlocked
public boolean unlocked()Whether the vault is open: the key is in memory. -
create
Creates an empty vault protected bypasswordand leaves it unlocked.- Throws:
IOException
-
unlock
Opens the vault. @throws WrongPasswordException if the password is wrong or the file was tampered with -
lock
public void lock()Forgets the key and the secrets; the file stays. -
changePassword
public void changePassword(char[] oldPassword, char[] newPassword) throws IOException, SecretVault.WrongPasswordException Re-encrypts with a new master password; the old one is checked first.
-