### Fixed

- Unpaired UTF-16 surrogates in string input produced wrong digests and consumed the following code unit. They are now encoded as U+FFFD, matching `TextEncoder` and Node.js `crypto` (also applies to cSHAKE/KMAC function names, customization strings, and keys, TupleHash, and ParallelHash)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yi-Cyuan Chen
2026-11-16 21:19:12 +08:00
co-authored by Claude Opus 5.5
parent 054f47e636
commit 290d679fbd
14 changed files with 190 additions and 28 deletions
+28
View File
@@ -44,6 +44,13 @@
key: key,
s: 'My Tagged Application',
output: '1f5b4e6cca02209e0dcb5ca635b89a15e271ecc760071dfd805faa38f9729230'
},
{
input: 'a\ud83db',
bits: 256,
key: '\ud800',
s: '\udc00x',
output: '6ced45b8c304287973b0af2866e7d8679daf4ad6827b5072fc5c5d7fa44cb131'
}
]
},
@@ -78,6 +85,13 @@
key: [],
s: [8, 79, 237, 8, 185, 120, 175, 77, 125, 25, 106, 116, 70, 168, 107, 88, 0, 158, 99, 107, 97, 29, 177, 98, 17, 182, 90, 154, 173, 255, 41, 197, 8, 79, 237, 8, 185, 120, 175, 77, 125, 25, 106, 116, 70, 168, 107, 88, 0, 158, 99, 107, 97, 29, 177, 98, 17, 182, 90, 154, 173, 255, 41, 197, 8, 79, 237, 8, 185, 120, 175, 77, 125, 25, 106, 116, 70, 168, 107, 88, 0, 158, 99, 107, 97, 29, 177, 98, 17, 182, 90, 154, 173, 255, 41, 197, 8, 79, 237, 8, 185, 120, 175, 77, 125, 25, 106, 116, 70, 168, 107, 88, 0, 158, 99, 107, 97, 29, 177, 98, 17, 182, 90, 154, 173],
output: '031801b0b50ebeef772fbe7a279bc144'
},
{
input: 'a\ud83db',
bits: 512,
key: '\ud800',
s: '\udc00x',
output: '8831d05374e0a1ee9daba2b44fb15c28b932a3cbd38df54f4981152d4a8d4a7eb6be7f44a67fb65be06fd2312216ad6df76de46e4a3767c0ab56f22a5264d012'
}
]
},
@@ -105,6 +119,13 @@
key: key,
s: 'My Tagged Application',
output: '47026c7cd793084aa0283c253ef658490c0db61438b8326fe9bddf281b83ae0f'
},
{
input: 'a\ud83db',
bits: 256,
key: '\ud800',
s: '\udc00x',
output: 'ee996214db121dc0704999849ea2bc73ca3171d5cbda3f536ed84b3763675f7b'
}
]
},
@@ -132,6 +153,13 @@
key: key,
s: 'My Tagged Application',
output: 'd5be731c954ed7732846bb59dbe3a8e30f83e77a4bff4459f2f1c2b4ecebb8ce67ba01c62e8ab8578d2d499bd1bb276768781190020a306a97de281dcc30305d'
},
{
input: 'a\ud83db',
bits: 512,
key: '\ud800',
s: '\udc00x',
output: '80b28e96b077368d5148398424be5ffb4450b15e2e852443bb74a9140799d49471609ce2bd2fcd04294539cf27439aa51f6619d224eacfcc98c1de27e2b59b02'
}
]
}