Changelog - 2026-08-06
AES Keys Derive with PBKDF2, and Ciphertext Carries a Key Id
Breaking Change Security New FeatureIn one line. Every AES ciphertext written by an earlier IGNIS stops decrypting with AES, and you either point those reads at LegacyAES or re-encrypt them.
What changed
- Stronger key derivation. IGNIS used to build the AES-256 key by padding or truncating your secret, so
'abc'became'abc00000000000000000000000000000'. It now runs PBKDF2-SHA256 for 100,000 iterations, so any secret produces a full-entropy key and each guess costs 100,000 hashes. Derived keys are memoised per secret. - Self-describing ciphertext. The layout is now
[version(1)][idLen(1)][id(idLen)][iv(16)][authTag(16, gcm only)][ciphertext]. - Key rotation.
secretaccepts a keyring as well as a string. Encryption uses the first entry; decryption resolves the id in the envelope. Rotating means prepending an entry, not re-encrypting your data. decryptno longer takes aniv.IAESDecryptOptionsomits it, so passing one is a compile error.normalizeSecretKeynow returns aBuffer, and thepadEndoption is gone.
const KEYRING = [
{ id: '2', secret: CURRENT_SECRET }, // everything new is written with this
{ id: '1', secret: RETIRED_SECRET }, // kept only so older rows still read
];
aes.encrypt({ message, secret: KEYRING });
aes.decrypt({ message: olderRow, secret: KEYRING });Who is affected
| You | Impact |
|---|---|
Store AES ciphertext (a column, a cache entry, a file via encryptFile) | Those reads fail until you switch them to LegacyAES or re-encrypt |
Set applicationSecret on a bearer-token service | Every already-issued token fails verification as TOKEN_INVALID |
Call normalizeSecretKey yourself | Signature changed - Buffer, and no padEnd |
Use AES only for data written after upgrading | No action |
Use ECDH, RSA or hashing | No action |
The token case is the loud one: at deploy, every active session ends at once, and the log shows the ordinary Invalid or expired token warning, which looks exactly like normal expiry.
Breaking changes
WARNING
Data written by an earlier IGNIS no longer decrypts with AES.
Before:
normalizeSecretKey(opts: { secret: string; length: number; padEnd?: string }): stringAfter:
normalizeSecretKey(opts: { secret: string; length: number }): BufferRead data written before the upgrade
LegacyAES reproduces the old derivation and layout exactly. Point the read at it - no re-encryption needed.
import { LegacyAES } from '@venizia/ignis-helpers';
const legacy = LegacyAES.withAlgorithm('aes-256-cbc');
const plaintext = legacy.decrypt({ message: oldRow, secret: APPLICATION_SECRET });The two formats never cross-decrypt, and neither falls back on its own.
Keep already-issued tokens valid
The bearer-token services take a cipher. Hand them LegacyAES and existing sessions keep working:
new JWSTokenService({
jwtSecret,
getTokenExpiresFn,
applicationSecret,
cipher: LegacyAES.withAlgorithm('aes-256-cbc'),
});IJWSTokenServiceOptions, IJWKSIssuerOptions and IJWKSVerifierOptions all accept it. Omit it and you get AES, so an app with no old tokens needs no change. Plan the switch back to AES yourself: issue new tokens under AES once the old ones have expired.
Re-encrypt instead
Read with LegacyAES, write with AES, in one pass over the data. Give the new writes a keyring from the start so the next rotation costs nothing.
Details
DEFAULT_PAD_ENDis still exported and is now@deprecated.- A keyring entry with an empty
secretis refused by name on both encrypt and decrypt. - The PBKDF2 salt is a fixed constant, so the key can be derived from the secret alone with no salt stored beside the ciphertext. The iteration count is what makes guessing expensive.