Commit 70faf07
authored
password-hash: expose salt generating helper functions (#2128)
Right now there's not a way to generate a random salt in the context of
MCF password hashes when not using the high-level
`PasswordHash::hash_password` API, e.g. for KDF usage, which is to say
that for PHC password hashes `phc::Salt::generate` is fine for this
purpose since it now provides raw bytes, but password hashes which use
MCF don't have access to that type.
This is often still documented as using some static value with a comment
saying it needs to be unique. Instead we should provide a reusable
solution in the rustdoc.
These can potentially be replaced with the `crypto_common::Generate`
trait and something like a `RecommendedLengthSalt` type after there's a
new `getrandom` crate prerelease, but in the meantime these helper
functions seem like a reasonable enough stopgap, and can potentially
stick around and use the `Generate` trait for you.1 parent 7ecfdeb commit 70faf07
2 files changed
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | | - | |
98 | | - | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
0 commit comments