WIP: GCM IV length silliness... maybe.

This commit is contained in:
2026-08-26 14:52:16 +09:00
parent 64c592285a
commit 9287cbb4b7
@@ -62,16 +62,10 @@ public final class Vault {
byte[] iv = new byte[IV_LENGTH];
new SecureRandom().nextBytes(iv);
Cipher cipher = Cipher.getInstance(AES_GCM);
GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH, iv);
cipher.init(Cipher.ENCRYPT_MODE, key, spec);
byte[] ciphertext = cipher.doFinal(plaintext);
byte[] ciphertext = encrypt(key, iv, plaintext);
return new Ciphertext(iv, ciphertext);
} catch (Exception e) {
String msg = e.getMessage();
if (msg == null) msg = e.toString();
throw new Exception("Vault.encrypt failed: " + msg, e);
throw new Exception("Vault.encrypt failed: " + e.getMessage(), e);
}
}
@@ -101,7 +95,7 @@ public final class Vault {
} catch (Exception e) {
String msg = e.getMessage();
if (msg == null) msg = e.toString();
throw new Exception("Vault.decrypt failed: " + msg, e);
throw new Exception("Vault.decrypt failed [" + e.getClass().getSimpleName() + "]: " + msg, e);
}
}
}