You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,21 +12,23 @@
12
12
</a>
13
13
</p>
14
14
15
+
NOTE: NIST's February 2025 Draft 2 has entirely withdrawn FF3 from the NIST standard due to published vulnerabilities.
16
+
17
+
This software is provided for educational and experimental use and comes with no warranty of any kind.
18
+
It is intended for developers and researchers familiar with cryptographic standards.
19
+
15
20
# ff3 - Format Preserving Encryption in Java
16
21
17
-
java-fpe provides Format-Preserving Encryption (FPE) for Java, allowing sensitive data such as credit card numbers, account IDs, phone numbers, and dates to be encrypted **while preserving their original format**. This is useful in systems that require encrypted data to maintain fixed-length, numeric, or structured formats.
22
+
java-fpe provides Format-Preserving Encryption (FPE) for Java, allowing sensitive data such as numeric identifiers, account IDs, phone numbers, and dates to be encrypted **while preserving their original format**. This is useful in systems that require encrypted data to maintain fixed-length, numeric, or structured formats.
18
23
19
-
It implements the NIST-approved FF3 and FF3-1 algorithms as specified in NIST Special Publication 800-38G and includes the revisions on February 28th, 2019 with a draft update for FF3-1.
24
+
This package implements the FF3 and FF3-1 algorithms as specified in NIST Special Publication 800-38G (now withdrawn) and includes the revisions on February 28th, 2019 with a draft update for FF3-1 (now withdrawn). FF1 implementations are outside the scope of this open source project.
*[NIST SP 800-38G Revision 1 (2nd Public Draft)](https://csrc.nist.gov/pubs/sp/800/38/g/r1/2pd)
24
29
25
-
**NOTE:** NIST's Feburary 2025 Draft 2 has removed FF3 from the NIST standard. Contact me about a licensed version of FF1 in Java.
26
-
27
30
Changes to minimum domain size and revised tweak length have been implemented in this package with
28
-
both 64-bit and 56-bit tweaks are supported. NIST has only published official test vectors for 64-bit tweaks, but draft ACVP test vectors have been used for testing FF3-1. It is expected the final
29
-
NIST standard will provide updated test vectors with 56-bit tweak lengths.
31
+
both 64-bit and 56-bit tweaks are supported. NIST has only published official test vectors for 64-bit tweaks, but draft ACVP test vectors have been used for testing FF3-1.
30
32
31
33
## Use
32
34
@@ -65,12 +67,12 @@ Input plaintext has maximum length restrictions based upon the chosen radix (2 *
65
67
* radix 36: 36
66
68
* radix 62: 32
67
69
68
-
To work around string length, its possible to encode longer text in chunks.
70
+
To work around string length, it's possible to encode longer text in chunks.
69
71
70
-
The key length must be 128, 192, or 256 bits in length. The tweak is 7 bytes (FF3-1) or 8 bytes for the origingal FF3.
72
+
The key length must be 128, 192, or 256 bits in length. The tweak is 7 bytes (FF3-1) or 8 bytes for the original FF3.
71
73
72
74
As with any cryptographic package, managing and protecting the key(s) is crucial. The tweak is generally not kept secret.
73
-
This package does not store the key in memory after initializing the cipher.
75
+
This implementation does not intentionally retain key material beyond cipher initialization.
74
76
75
77
## Code Example
76
78
@@ -125,14 +127,14 @@ The FF3 round function uses AES encryption in ECB mode, which is performed each
125
127
on alternating halves of the text being encrypted. The*key* value is used only to initialize the AES cipher. Thereafter
126
128
the *tweak* is used together with the intermediate encrypted text as input to the round function.
127
129
128
-
FF3 uses a single-block encryption with an IV of 0, which is effectively ECB mode. AESECB is the only block cipher function which matches the requirement of the FF3 spec.
130
+
FF3 uses a single-block encryption with an IV of 0, which is effectively ECB mode. AESECB is the only block cipher function which matches the requirement of the FF3 spec.This does not imply that ECB mode is safe for general-purpose encryption; it is used here solely because it is required by the FF3 specification.
129
131
130
132
The domain size was revised in FF3-1 to radix<sup>minLen</sup>>=1,000,000 and is represented by the constant `DOMAIN_MIN` in `FF3Cipher.java`.
131
133
FF3-1 is in draft status and updated 56-bit test vectors are not yet available.
132
134
133
135
## OtherFPEAlgorithms
134
136
135
-
OnlyFF1 and FF3 have been approved by NISTfor format preserving encryption. There are patent claims on FF1 which allegedly include open source implementations. Given the issues raised in ["The Curse of Small Domains: New Attacks on Format-Preserving Encryption"](https://eprint.iacr.org/2018/556.pdf) by Hoang, Tessaro and Trieu in 2018, it is prudent to be very cautious about using any FPE that isn't a standard and hasn't stood up to public scrutiny.
137
+
OnlyFF1 and FF3 have been published by NISTfor format preserving encryption. There are patent claims on FF1 which allegedly include open source implementations. Given the issues raised in ["The Curse of Small Domains: New Attacks on Format-Preserving Encryption"](https://eprint.iacr.org/2018/556.pdf) by Hoang, Tessaro and Trieu in 2018, it is prudent to be very cautious about using any FPE that isn't a standard and hasn't stood up to public scrutiny.
136
138
137
139
## Build&Testing
138
140
@@ -149,7 +151,7 @@ To run the unit tests, including all test vectors from the NIST specification, r
149
151
150
152
## PerformanceBenchmarks
151
153
152
-
MystoFF3 was benchmarked on a MacBookAirM2 performing 105,000 tokenization per second with mixed 8 character data input.
154
+
MystoFF3 was benchmarked on a MacBookAirM2 performing 105,000 tokenization per second with mixed 8 character data input.Performance results are indicative only and depend on hardware, workload, and configuration
153
155
154
156
To run the performance tests:
155
157
@@ -164,15 +166,15 @@ This project was built and tested with Java 8 and 11. It uses the javax.crypto
164
166
## ReportingIssues and Contributing
165
167
166
168
Bug reports, feature requests, and pull requests are welcome. Please use the GitHubIssues page to report problems or ask questions:
167
-
https://github.com/mysto/java-fpe/issues
169
+
https://github.com/mysto/java-fpe/issues.
168
170
169
-
All documentation and issue discussions are conducted in English.
171
+
By contributing, you agree that your contributions are provided under the Apache2.0 license. All documentation and issue discussions are conducted in English.
170
172
171
173
## ImplementationNotes
172
174
173
175
This implementation follows the algorithm as outlined in the NIST specification as closely as possible, including naming.
174
176
175
-
FPE can be used forsensitive data tokenization, especially with PCI and cryptographically reversible tokens. This implementation does not provide any guarantees regarding PCIDSS or other validation.
177
+
FPE can be used for data tokenization of sensitive data which is cryptographically reversible. This implementation does not provide any guarantees regarding PCIDSS or other validation.
176
178
177
179
The tweak is required in the initial `FF3Cipher` constructor, but can optionally be overridden in each `encrypt` and `decrypt` call. This is similar to passing an IV or nonce when creating an encryptor object.
0 commit comments