Skip to content

Commit b4fd9c4

Browse files
committed
fix(*): hkdf is not approved by FIPS, use PBKDF2 instead on FIPS-mode
### Summary It turned out that HDKF is only allowed by FIPS in TLS context. This changes the crypto in this library to use PBKDF2 with SHA-256 using a single iteration in places where it used HDKF before when in FIPS-mode. This change does not affect non-fips. Effectively it makes cookies created on FIPS mode incompatible with cookies created on non-FIPS mode, which is most likely a good thing.
1 parent 2817b43 commit b4fd9c4

17 files changed

+88
-24
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ Header fields explained:
12621262
1. derive IKM from `secret` by hashing `secret` with SHA-256, or
12631263
2. use 32 byte IKM when passed to library with `ikm`
12641264
2. Generate 32 bytes of crypto random session id (`sid`)
1265-
3. Derive 32 byte encryption key and 12 byte initialization vector with HKDF using SHA-256
1265+
3. Derive 32 byte encryption key and 12 byte initialization vector with HKDF using SHA-256 (on FIPS-mode it uses PBKDF2 with SHA-256 instead)
12661266
1. Use HKDF extract to derive a new key from `ikm` to get `key` (this step can be done just once per `ikm`):
12671267
- output length: `32`
12681268
- digest: `"sha256"`
@@ -1292,7 +1292,8 @@ Header fields explained:
12921292
6. Data Size
12931293

12941294
There is a variation for `remember` cookies on step 3, where we may use `PBKDF2`
1295-
instead of `HKDF`, depending on `remember_safety` setting. The `PBKDF2` settings:
1295+
instead of `HKDF`, depending on `remember_safety` setting (we also use it in FIPS-mode).
1296+
The `PBKDF2` settings:
12961297

12971298
- output length: `44`
12981299
- digest: `"sha256"`
@@ -1306,7 +1307,7 @@ if `remember_safety` is set to `"None"`, we will use the HDKF as above.
13061307

13071308
# Cookie Header Authentication
13081309

1309-
1. Derive 32 byte authentication key (`mac_key`) with HKDF using SHA-256:
1310+
1. Derive 32 byte authentication key (`mac_key`) with HKDF using SHA-256 (on FIPS-mode it uses PBKDF2 with SHA-256 instead):
13101311
1. Use HKDF extract to derive a new key from `ikm` to get `key` (this step can be done just once per `ikm` and reused with encryption key generation):
13111312
- output length: `32`
13121313
- digest: `"sha256"`

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ <h2>Modules</h2>
120120
</div> <!-- id="main" -->
121121
<div id="about">
122122
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
123-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
123+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
124124
</div> <!-- id="about" -->
125125
</div> <!-- id="container" -->
126126
</body>

docs/modules/resty.session.dshm.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ <h3>Returns:</h3>
390390
</div> <!-- id="main" -->
391391
<div id="about">
392392
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
393-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
393+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
394394
</div> <!-- id="about" -->
395395
</div> <!-- id="container" -->
396396
</body>

docs/modules/resty.session.file.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ <h3>Returns:</h3>
360360
</div> <!-- id="main" -->
361361
<div id="about">
362362
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
363-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
363+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
364364
</div> <!-- id="about" -->
365365
</div> <!-- id="container" -->
366366
</body>

docs/modules/resty.session.file.thread.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ <h3>Returns:</h3>
324324
</div> <!-- id="main" -->
325325
<div id="about">
326326
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
327-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
327+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
328328
</div> <!-- id="about" -->
329329
</div> <!-- id="container" -->
330330
</body>

docs/modules/resty.session.file.utils.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ <h3>Returns:</h3>
343343
</div> <!-- id="main" -->
344344
<div id="about">
345345
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
346-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
346+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
347347
</div> <!-- id="about" -->
348348
</div> <!-- id="container" -->
349349
</body>

docs/modules/resty.session.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ <h3>Usage:</h3>
13001300
</div> <!-- id="main" -->
13011301
<div id="about">
13021302
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
1303-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
1303+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
13041304
</div> <!-- id="about" -->
13051305
</div> <!-- id="container" -->
13061306
</body>

docs/modules/resty.session.memcached.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ <h3>Returns:</h3>
393393
</div> <!-- id="main" -->
394394
<div id="about">
395395
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
396-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
396+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
397397
</div> <!-- id="about" -->
398398
</div> <!-- id="container" -->
399399
</body>

docs/modules/resty.session.mysql.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ <h3>Usage:</h3>
473473
</div> <!-- id="main" -->
474474
<div id="about">
475475
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
476-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
476+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
477477
</div> <!-- id="about" -->
478478
</div> <!-- id="container" -->
479479
</body>

docs/modules/resty.session.postgres.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ <h3>Usage:</h3>
469469
</div> <!-- id="main" -->
470470
<div id="about">
471471
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
472-
<i style="float:right;">Last updated 2023-02-01 21:57:55 </i>
472+
<i style="float:right;">Last updated 2023-02-15 16:31:40 </i>
473473
</div> <!-- id="about" -->
474474
</div> <!-- id="container" -->
475475
</body>

0 commit comments

Comments
 (0)