https://gitlab.synchro.net/main/sbbs/-/commit/328f1a9ebfb5392cb7115bfd
Added Files:
exec/tests/file/hashes.js
Modified Files:
docs/v322_new.md exec/load/sha256.js exec/tests/global/except.js rtypes.js src/sbbs3/js_file.cpp js_global.cpp src/smblib/smblib.vcxproj
Log Message:
Add SHA-256 to the hash library and expose it to JavaScript
sha256.c was already built by the GNU make and CMake hash-library
builds, but not by MSVC, where the hash sources are compiled into
smblib.lib rather than into a hash project of their own.
Expose SHA-256 to JavaScript alongside the existing MD5 and SHA-1
digests:
- sha256_calc(text [,hex]) global, mirroring sha1_calc()
- File.sha256_hex and File.sha256_base64, streamed through the same
block loop, so a large file is never held in memory
The shared digest buffer in js_file_get() grows from SHA1_DIGEST_SIZE
to SHA256_DIGEST_SIZE, so the MD5 and SHA-1 base64 cases can no longer
pass sizeof(digest) to b64_encode() and now pass their own digest size.
For MD5 that was already wrong: 434232f05e (2021-03-20) widened the
buffer from MD5_DIGEST_SIZE to SHA1_DIGEST_SIZE and left the MD5 case
encoding all 20 bytes, so since v3.19 File.md5_base64 has returned a 28-character string with 4 bytes of uninitialized stack appended.
exec/tests/file/hashes.js covers all three algorithms in both encodings
against the published RFC 1321 and FIPS 180-2 vectors, plus a file
larger than the read block; it fails against the old md5_base64.
exec/load/sha256.js needs no code change - its "sha256_hex" in
File.prototype guard now finds the native getter and installs nothing -
but its header no longer claims Synchronet has no SHA-256.
Co-Authored-By: Claude Opus 5 (1M context) <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net