K033 / Cipher modes and AEAD
Format-Preserving Encryption FF1
Format-preserving encryption converts data into ciphertext with the same format and length as the original.
CRYPTOGRAPHY LAB / K033
Cryptography Lab · Format-Preserving Encryption FF1
Run real computations and inspect intermediate states step by step.
Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.
FF1 decimal AES (10 rounds, radix 10)
See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.Output
Previous state
- Definition and overview
- Format-preserving encryption converts data into ciphertext with the same format and length as the original. Source document ↗
- Classification and reversibility
- Reversible block-cipher mode with encryption/decryption functions. Source document ↗
- Key or secret requirements
- Requires a key for an approved symmetric block cipher. Source document ↗
- Operating principle and structure
- Ten-round Feistel structure with AES-CBC-MAC-based round function. Source document ↗
- Key size, block size and parameters
- Supports AES key lengths of 128/192/256 bits. Source document ↗
- Security strength and recommendation
- Not practically broken yet, but long-term FPE safety is a concern. Source document ↗
- Known attacks and vulnerabilities
- Cryptanalysis of FF3 led NIST to conclude it unsuitable for general FPE use. Source document ↗
- Standards and certification
- NIST SP 800-38G specifies FF1 and FF3. Source document ↗
- Typical uses
- Encrypt fields needing the same length and character set, e.g. card numbers and account IDs. Source document ↗
- Implementations, libraries and tools
- Implementations include Python libffx. Source document ↗
- Decryption or decoding
- Decrypt via FF1.Decrypt with the same key K and tweak T. Source document ↗
- Advantages
- Preserves format and thus compatibility with existing schemas and systems. Source document ↗
- Limitations and cautions
- Deterministic encryption with confidentiality only, no integrity protection. Source document ↗
- Distinguishing encryption, encoding and hashing
- FPE is encryption using a block cipher mode, not encoding or hashing. Source document ↗
Practical examples
Example
Transform a card-number-like digit string into ciphertext of identical length and digit alphabet, and recover it with the same key and tweak. Define format and radix beforehand; no actual secret keys in examples.
Procedure
Normalize plaintext to chosen radix, alphabet and length; prepare key and tweak and invoke FF1 encryption. Decrypt using the same key/tweak/radix, verify output format and recover original. Encoding such as Base64 has different purpose and process.
Scenario
In PCI environments convert card numbers into format-preserving tokens for legacy storage/transmission, decrypting only in authorized systems with matching key/tweak. Add separate authentication when integrity is required.
Pitfalls and alternatives
Deterministic and unauthenticated; consider separate MAC/AEAD. Losing key, tweak or radix prevents recovery; avoid FF3 and unvetted implementations.
References
- NIST SP 800-38Gr1 2pd, Recommendation for Block Cipher Modes of Operation: Methods for Format-Preserving Encryption ↗
- SP 800-38G, Recommendation for Block Cipher Modes of Operation: Methods for Format-Preserving Encryption | CSRC ↗
- purecrypto::fpe - Rust ↗
- ff1/ff1.go ↗
- NIST Update to Format Preserving Encryption Standard affects PCI Use Cases ↗
- Recent Cryptanalysis of FF3 | CSRC ↗
- kpdyer/libffx ↗
- src/org/fpe4j/FF1.java at master · zone1511/fpe4j ↗
- pjwerneck/fastfpe ↗
- Format Preserving Encryption: FF1, FF3-1 and NIST 800-38G ↗