mirror of
https://github.com/emn178/js-sha3.git
synced 2026-11-16 23:08:50 +08:00
### 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:
co-authored by
Claude Opus 5.5
parent
054f47e636
commit
290d679fbd
@@ -8,6 +8,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
context('with unpaired surrogates', function () {
|
||||
it('should be equal', function () {
|
||||
expect(shake128('\ud800', 256)).to.be('e222dd713a77e63b0ba5f39b311e77489f3c40fccc063ceb82c5c6ea860987c0');
|
||||
expect(shake128('a\ud83db', 256)).to.be('b45a441a78730b4c83adef9b362a99a6a2ca5a64460727eb32d817d3de34d36e');
|
||||
});
|
||||
});
|
||||
|
||||
context('with 8 output', function () {
|
||||
it('should be equal', function () {
|
||||
expect(shake128('', 8)).to.be('7f');
|
||||
@@ -56,6 +63,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
context('with unpaired surrogates', function () {
|
||||
it('should be equal', function () {
|
||||
expect(shake256('\ud800', 512)).to.be('36451a2c4c562eafae4f5d1cc0f030e59722e7efcb49194fe7d9dbe41f0adc9acbed8950d7bd20c1b5354072c9bb857ab5f982ea80aa005dd5d98102f57d6862');
|
||||
expect(shake256('a\ud83db', 512)).to.be('3859bbc4c5b31a5a173793a85ba90c9c189055adf8a12847c6051ee0890a1e8e63062acccfeedd38d053f8ad4080dd5af4356b6f62ad6b020f41b2f0bbfbd1af');
|
||||
});
|
||||
});
|
||||
|
||||
context('with 8 output', function () {
|
||||
it('should be equal', function () {
|
||||
expect(shake256('', 8)).to.be('46');
|
||||
|
||||
Reference in New Issue
Block a user