aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorCollin Funk2026-02-23 00:20:46 -0800
committerPaul Eggert2026-02-23 00:22:17 -0800
commit29440eedac7968580e35e751c6cdf94af337a95a (patch)
tree511fa2df3d1459c9e3d53d088856194d2123af38 /test/src
parentccaa4a07f093428241cbcc81379c3ea3d84b38ee (diff)
downloademacs-29440eedac7968580e35e751c6cdf94af337a95a.tar.gz
emacs-29440eedac7968580e35e751c6cdf94af337a95a.zip
Add SHA-3 support to secure-hash
* admin/merge-gnulib (GNULIB_MODULES): Add crypto/sha3-buffer. * lib/sha3.c: New file, imported by running admin/merge-gnulib. * lib/sha3.h: Likewise. * m4/sha3.m4: Likewise. * lib/gnulib.mk.in: Updated by admin/merge-gnulib. * m4/gnulib-comp.m4: Likewise. * src/fns.c: Include sha3.h (Fsecure_hash_algorithms): Add Qsha3_224, Qsha3_256, Qsha3_384, and Qsha3_512. (secure_hash): Likewise. (Fsecure_hash): List the SHA-3 algorithms in the docstring. (syms_of_fns): Define Qsha3_224, Qsha3_256, Qsha3_384, and Qsha3_512. * test/lisp/net/gnutls-tests.el (gnutls-tests-internal-macs-upcased): Filter out the new SHA-3 algorithms since they are currently not implemented in gnutls. * test/src/fns-tests.el (test-secure-hash): Add test cases for the new algorithms. * doc/lispref/text.texi (Checksum/Hash): List the SHA-3 algorithms. Mention that they are considered secure. * etc/NEWS: Mention the new feature.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/fns-tests.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index fa00cec6118..2d7d410318b 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -1402,6 +1402,18 @@
1402 (concat "0a50261ebd1a390fed2bf326f2673c145582a6342d5" 1402 (concat "0a50261ebd1a390fed2bf326f2673c145582a6342d5"
1403 "23204973d0219337f81616a8069b012587cf5635f69" 1403 "23204973d0219337f81616a8069b012587cf5635f69"
1404 "25f1b56c360230c19b273500ee013e030601bf2425"))) 1404 "25f1b56c360230c19b273500ee013e030601bf2425")))
1405 (should (equal (secure-hash 'sha3-224 "foobar")
1406 "1ad852ba147a715fe5a3df39a741fad08186c303c7d21cefb7be763b"))
1407 (should (equal (secure-hash 'sha3-256 "foobar")
1408 (concat "09234807e4af85f17c66b48ee3bca89d"
1409 "ffd1f1233659f9f940a2b17b0b8c6bc5")))
1410 (should (equal (secure-hash 'sha3-384 "foobar")
1411 (concat "0fa8abfbdaf924ad307b74dd2ed183b9a4a398891a2f6bac"
1412 "8fd2db7041b77f068580f9c6c66f699b496c2da1cbcc7ed8")))
1413 (should (equal (secure-hash 'sha3-512 "foobar")
1414 (concat "ff32a30c3af5012ea395827a3e99a13073c3a8d8410"
1415 "a708568ff7e6eb85968fccfebaea039bc21411e9d43"
1416 "fdb9a851b529b9960ffea8679199781b8f45ca85e2")))
1405 ;; Test that a call to getrandom returns the right format. 1417 ;; Test that a call to getrandom returns the right format.
1406 ;; This does not test randomness; it's merely a format check. 1418 ;; This does not test randomness; it's merely a format check.
1407 (should (string-match "\\`[0-9a-f]\\{128\\}\\'" 1419 (should (string-match "\\`[0-9a-f]\\{128\\}\\'"