Making .env: Post-Quantum Encryption

Scott Motte ·

Cover image for Post-Quantum Encryption

Yesterday the NSA issued an advisory to accelerate the transition to post-quantum cryptography. [1]

We are taking this seriously. Two things:

  1. Dotenvx: This is not an immediate threat to you. Using dotenvx is currently secure, and we continue to use it throughout our own infrastructure and code in its default form (secp256k1 elliptic curve).
  2. Dotenv-Vault: This is not a threat to .env.vault files which use symmetric AES-256-GCM encryption. [2]

However, this advisory moved up our timeline on providing post-quantum encryption to you, and it's now optionally available via --algo mlkem768 in Dotenvx 3.0.0 RC4.


$ curl -sfS "https://dotenvx.sh?version=3.0.0-rc4" | sh
$ dotenvx encrypt --algo mlkem768
◈ encrypted .env (j1o +fV) via .env.keys ⛉

That's it. Same Dotenvx workflow.

Design

Our new key format in Dotenvx 3.0.0 made this possible. It looks like this:


# ◈ encrypted with Dotenvx
DOTENV_PUBLIC_KEY="DOTENV-PUBLIC-KEY-3-SECP256K1-02442373decbfa685d327a14d309ec949763bfa9ea1e150db709968abce6d17606?custody=.env.keys"

# .env
HELLO="DOTENV-CIPHERTEXT-3-SECP256K1-AES256GCM-02442373de-BOz+ELLhS2lXaxjCogNMtCQLUiJYgpI/Z6gQYW1+oCCNhs4ekejBtQ4wYCPbVIzgwepc2LnPQ/FzIuLJfTrfiemXp91RL1ygSsuaWG+qCucqAc8OKmHGoibfRTHwqmKiEDjiekn/"

# ⛉ private decryption keys (.env.keys)
DOTENV_PRIVATE_KEY=DOTENV-PRIVATE-KEY-3-SECP256K1-c78599247410b02ad5c6b5e4268cc089a102715ea286ca39cd9a3a1ee876633b

Broken down it is this:


DOTENV-PUBLIC-KEY-3-<algorithm>-<public-key>
DOTENV-PRIVATE-KEY-3-<algorithm>-<private-key>
DOTENV-CIPHERTEXT-3-<algorithm>-<cipher>-<key-id>-<encrypted-value>

Which we've now extended to post-quantum ML-KEM keys:


DOTENV-PUBLIC-KEY-3-MLKEM768-<base64-public-key>
DOTENV-PRIVATE-KEY-3-MLKEM768-<base64-seed>
DOTENV-CIPHERTEXT-3-MLKEM768-AES256GCM-<key-id>-<base64-payload>

What's Next

We are watching more of this news unfold and will inform you appropriately. Until then it is back to normal for us getting Dotenvx 3.0.0 out of release candidate and into general release.


[1] NSA advisory — Immediate transition to post-quantum cryptography

[2] NIST — Post-Quantum Cryptography FAQ (symmetric encryption)

markdown