Passwords are normalized with (std unicode normalize), not String.Normalize
Its tables are its own, so every platform gives the same bytes for a password. String.Normalize follows the ICU of each platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2b42abb6d9
commit
7ccda5d917
2 changed files with 8 additions and 4 deletions
|
|
@ -84,6 +84,9 @@ default, and the data would not open. Store the cost with the data.
|
||||||
as different code points: ~é~ as one, or as ~e~ and a combining accent. Both
|
as different code points: ~é~ as one, or as ~e~ and a combining accent. Both
|
||||||
are normalized to Unicode NFC before Argon2id, so they give the same key. It
|
are normalized to Unicode NFC before Argon2id, so they give the same key. It
|
||||||
is NFC and not NFKC, as in RFC 8265: ~fi~ and ~fi~ are different passwords.
|
is NFC and not NFKC, as in RFC 8265: ~fi~ and ~fi~ are different passwords.
|
||||||
|
The normalization is ~string-nfc~ of ~(std unicode normalize)~, which has
|
||||||
|
its own tables, so a phone and a desktop give the same bytes. It needs a
|
||||||
|
Bjolang with that module, which is newer than 0.3.0.
|
||||||
|
|
||||||
| Cipher | Key | Nonce | Tag |
|
| Cipher | Key | Nonce | Tag |
|
||||||
|---------------------+-----+-------+-----|
|
|---------------------+-----+-------+-----|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
random-bytes wipe!)
|
random-bytes wipe!)
|
||||||
|
|
||||||
(import (std prelude))
|
(import (std prelude))
|
||||||
|
(import (only (std unicode normalize) string-nfc))
|
||||||
|
|
||||||
(type (: Cipher (Union Aegis256 XChaCha20Poly1305)))
|
(type (: Cipher (Union Aegis256 XChaCha20Poly1305)))
|
||||||
|
|
||||||
|
|
@ -81,8 +82,6 @@
|
||||||
;; random salt.
|
;; random salt.
|
||||||
(clr-argon2-hash (: LibSodium.CryptoPasswordHashArgon.HashPassword (-> (RoSpan byte) int int string)))
|
(clr-argon2-hash (: LibSodium.CryptoPasswordHashArgon.HashPassword (-> (RoSpan byte) int int string)))
|
||||||
(clr-argon2-verify (: LibSodium.CryptoPasswordHashArgon.VerifyPassword (-> string (RoSpan byte) bool)))
|
(clr-argon2-verify (: LibSodium.CryptoPasswordHashArgon.VerifyPassword (-> string (RoSpan byte) bool)))
|
||||||
;; String.Normalize() with no argument: Unicode normalization form C.
|
|
||||||
(clr-nfc (: System.String.Normalize (-> string string)))
|
|
||||||
(clr-arm-aes? (: System.Runtime.Intrinsics.Arm.Aes.IsSupported #:get))
|
(clr-arm-aes? (: System.Runtime.Intrinsics.Arm.Aes.IsSupported #:get))
|
||||||
(clr-x86-aes? (: System.Runtime.Intrinsics.X86.Aes.IsSupported #:get))
|
(clr-x86-aes? (: System.Runtime.Intrinsics.X86.Aes.IsSupported #:get))
|
||||||
(clr-x86-avx? (: System.Runtime.Intrinsics.X86.Avx.IsSupported #:get)))
|
(clr-x86-avx? (: System.Runtime.Intrinsics.X86.Avx.IsSupported #:get)))
|
||||||
|
|
@ -369,9 +368,11 @@
|
||||||
|
|
||||||
;; The UTF-8 bytes of `password` in Unicode NFC. The same password typed on
|
;; The UTF-8 bytes of `password` in Unicode NFC. The same password typed on
|
||||||
;; two devices can come as different code points: "é" as one, or as "e" and
|
;; two devices can come as different code points: "é" as one, or as "e" and
|
||||||
;; a combining accent. NFC makes them the same bytes.
|
;; a combining accent. NFC makes them the same bytes. (std unicode normalize)
|
||||||
|
;; has its own tables, so every platform gives the same bytes; .NET's
|
||||||
|
;; String.Normalize would follow the ICU of each platform.
|
||||||
(: (-> string (Array byte)))
|
(: (-> string (Array byte)))
|
||||||
(defun (password-bytes password) (string->bytes (clr-nfc password)))
|
(defun (password-bytes password) (string->bytes (string-nfc password)))
|
||||||
|
|
||||||
;; The value of a thread's result, or its exception raised again.
|
;; The value of a thread's result, or its exception raised again.
|
||||||
(: (-> (Result Exception %a) %a))
|
(: (-> (Result Exception %a) %a))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue