nonce
A value meant to be used only once, such as a unique number given to a cipher or a random token that marks trusted scripts in a web page.
In more detail
The name is short for number used once. In encryption, ciphers take a nonce alongside the key; it does not have to be secret, only never repeated with the same key. In a Content Security Policy, the server sends a fresh unpredictable nonce with every response and repeats it on each trusted script tag, so injected scripts without it are refused. In network protocols, nonces also stop old messages from being replayed.
Example
NONCE = bytes(12) # used once with this key, never againRelated terms
- nonce reuse — The mistake of encrypting two messages with the same key and the same nonce, which can expose both messages and allow forgeries.
- initialization vector — A random or unique value fed into encryption with the key, so the same plaintext encrypts differently each time.
- AES-GCM — AES in Galois/Counter Mode: the most widely used way to encrypt data so that it stays secret and any tampering is detected.
- CSPRNG — A cryptographically secure pseudorandom number generator: a source of random numbers that attackers cannot predict, used to create keys, nonces and salts.
- Content Security Policy — An HTTP response header that tells the browser which sources of scripts and other content a page may load, limiting what injected markup can do.
- inline script — JavaScript written directly inside a script tag or an event attribute such as onclick, rather than loaded from a file.
- CSP directive — One rule inside a Content Security Policy, such as script-src, that lists the allowed sources for one kind of resource.
Taught in
- Symmetric Encryption: AES-GCM & ChaCha20 — Cybersecurity Fundamentals, GRC & Cryptography
- Post-Quantum Cryptography & Key Lifecycles — Cybersecurity Fundamentals, GRC & Cryptography
- Content Security Policy (CSP), Trusted Types And XSS Defenses — Frontend Architecture & Web Platform