Expand description
HCTR2+FP (Format-Preserving) variant of HCTR2.
While standard HCTR2 operates on arbitrary bytes, HCTR2+FP ensures that ciphertext consists only of digits in a specified radix (e.g., decimal digits 0-9 for radix-10).
Use cases:
- Encrypting credit card numbers (decimal)
- Encrypting alphanumeric identifiers (hexadecimal or custom radix)
- Systems requiring format-preserving encryption
Security properties:
- Ciphertext length equals plaintext length
- All ciphertext digits are in range [0, radix)
- Requires unique (key, tweak) pairs for security
- No authentication - consider AEAD if integrity protection is needed
- Minimum message length depends on radix (e.g., 39 digits for decimal)
Structs§
- Hctr2Fp
- Generic HCTR2+FP cipher.
Functions§
- bits_
per_ digit - Compute bits per digit for power-of-2 radix.
- decode_
base_ radix - Decode base-radix digits (little-endian) to a 128-bit value.
- encode_
base_ radix - Encode a 128-bit value as base-radix digits (little-endian).
- first_
block_ length - Compute the minimum number of base-radix digits needed to represent 128 bits. This is: ceil(128 / log2(radix)) = smallest k where radix^k >= 2^128
- is_
power_ of_ two - Check if a number is a power of two.
Type Aliases§
- Hctr2
FpError Deprecated - Hctr2
Fp_ 128_ Base64 - HCTR2+FP with AES-128 and base-64 (radix-64) format preservation.
- Hctr2
Fp_ 128_ Decimal - HCTR2+FP with AES-128 and decimal (radix-10) format preservation.
- Hctr2
Fp_ 128_ Hex - HCTR2+FP with AES-128 and hexadecimal (radix-16) format preservation.
- Hctr2
Fp_ 256_ Base64 - HCTR2+FP with AES-256 and base-64 (radix-64) format preservation.
- Hctr2
Fp_ 256_ Decimal - HCTR2+FP with AES-256 and decimal (radix-10) format preservation.
- Hctr2
Fp_ 256_ Hex - HCTR2+FP with AES-256 and hexadecimal (radix-16) format preservation.