Encoding and security guides

AES-GCM: keep the IV unique and verify the authentication tag

Understand the key, IV, ciphertext and tag, and test that tampering fails instead of producing accepted plaintext.

Nav Tools ·

Keep all required components

Authenticated encryption protects confidentiality and detects tampering. Decryption requires the correct key, IV and authenticated ciphertext including its tag.

Base64 is only the transport representation. Losing an IV or tag cannot be repaired by trying a different text decoder.

Key + unique IV + plaintext → ciphertext with authentication tag
Key + same IV + authenticated ciphertext → plaintext or failure

Never reuse an IV with one key

GCM requires a unique IV for each encryption with a given key. A fresh random 96-bit IV is a common implementation choice.

The IV does not need secrecy, but its uniqueness is essential. Store it with the ciphertext and use a secure random generator.

A password is not a raw AES key

AES keys have defined byte lengths. A human password needs a proper key derivation procedure with explicit salt and cost parameters.

Nav Tools derives AES-256 keys from a passphrase using PBKDF2-SHA256, a random 16-byte salt and 210,000 iterations. Its JSON envelope must be preserved for decryption.

Test authentication failure

Encrypt a synthetic message, decrypt it, then alter one ciphertext byte or use another passphrase. Authentication must fail rather than return trusted plaintext.

Agree on tag length and additional authenticated data when interoperating with another library. This tool’s envelope is not a CryptoJS/OpenSSL password format; cryptographic key storage remains the application’s responsibility.

References

← Encoding and security guides