iz
Clone
https://git.tahinli.com/Tahinli/iz.git
0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits
| 1 | //! Random tokens and their hashes. A token is shown once; only its SHA-256 hex is stored, and |
| 2 | //! comparisons use `subtle` so that timing does not reveal matching prefixes. |
| 3 | |
| 4 | use ; |
| 5 | use ; |
| 6 | use ConstantTimeEq; |
| 7 | |
| 8 | /// A fresh token: 32 random bytes as unpadded base64url (43 characters). |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | /// Lowercase hex SHA-256 of the token. This is what the database stores. |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | /// Compares two byte strings in time that depends only on their lengths. |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 |