aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-08-19 17:51:50 +0300
committerEli Zaretskii2024-08-19 17:51:50 +0300
commitfc7581ae2ee9db1e3189b76c66be9cd13f72f004 (patch)
treef01e33e951b0a75828e5f90d8d84553176289ee5
parent21be5cadaf1e43cf886f38cb14fa25b96d8b551d (diff)
downloademacs-fc7581ae2ee9db1e3189b76c66be9cd13f72f004.tar.gz
emacs-fc7581ae2ee9db1e3189b76c66be9cd13f72f004.zip
; Fix documentation of secure-hash functions
* src/fns.c (Fsecure_hash): * doc/lispref/text.texi (Checksum/Hash): * lisp/subr.el (sha1): Fix documentation wrt to the number of bytes 'secure-hash' and its variants return when BINARY is non-nil. Reported by Pip Cet <pipcet@protonmail.com>.
-rw-r--r--doc/lispref/text.texi14
-rw-r--r--lisp/subr.el2
-rw-r--r--src/fns.c4
3 files changed, 11 insertions, 9 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 196fe89a092..278b53d7f65 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4992,22 +4992,22 @@ of the returned string depends on @var{algorithm}:
4992 4992
4993@itemize 4993@itemize
4994@item 4994@item
4995For @code{md5}: 32 characters (32 bytes if @var{binary} is 4995For @code{md5}: 32 characters (16 bytes if @var{binary} is
4996non-@code{nil}). 4996non-@code{nil}).
4997@item 4997@item
4998For @code{sha1}: 40 characters (40 bytes if @var{binary} is 4998For @code{sha1}: 40 characters (20 bytes if @var{binary} is
4999non-@code{nil}). 4999non-@code{nil}).
5000@item 5000@item
5001For @code{sha224}: 56 characters (56 bytes if @var{binary} is 5001For @code{sha224}: 56 characters (28 bytes if @var{binary} is
5002non-@code{nil}). 5002non-@code{nil}).
5003@item 5003@item
5004For @code{sha256}: 64 characters (64 bytes if @var{binary} is 5004For @code{sha256}: 64 characters (32 bytes if @var{binary} is
5005non-@code{nil}). 5005non-@code{nil}).
5006@item 5006@item
5007For @code{sha384}: 96 characters (96 bytes if @var{binary} is 5007For @code{sha384}: 96 characters (48 bytes if @var{binary} is
5008non-@code{nil}). 5008non-@code{nil}).
5009@item 5009@item
5010For @code{sha512}: 128 characters (128 bytes if @var{binary} is 5010For @code{sha512}: 128 characters (64 bytes if @var{binary} is
5011non-@code{nil}). 5011non-@code{nil}).
5012@end itemize 5012@end itemize
5013 5013
@@ -5062,7 +5062,7 @@ This function is equivalent to calling @code{secure-hash} like this:
5062@end lisp 5062@end lisp
5063 5063
5064It returns a 40-character string if @var{binary} is @code{nil}, or a 5064It returns a 40-character string if @var{binary} is @code{nil}, or a
506540-byte unibyte string otherwise. 506520-byte unibyte string otherwise.
5066@end defun 5066@end defun
5067 5067
5068@node Suspicious Text 5068@node Suspicious Text
diff --git a/lisp/subr.el b/lisp/subr.el
index a8e3df14cd3..28ba30f584e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4481,7 +4481,7 @@ Otherwise, return nil."
4481 "Return the SHA-1 (Secure Hash Algorithm) of an OBJECT. 4481 "Return the SHA-1 (Secure Hash Algorithm) of an OBJECT.
4482OBJECT is either a string or a buffer. Optional arguments START and 4482OBJECT is either a string or a buffer. Optional arguments START and
4483END are character positions specifying which portion of OBJECT for 4483END are character positions specifying which portion of OBJECT for
4484computing the hash. If BINARY is non-nil, return a 40-byte unibyte 4484computing the hash. If BINARY is non-nil, return a 20-byte unibyte
4485string; otherwise return a 40-character string. 4485string; otherwise return a 40-character string.
4486 4486
4487Note that SHA-1 is not collision resistant and should not be used 4487Note that SHA-1 is not collision resistant and should not be used
diff --git a/src/fns.c b/src/fns.c
index cb3e25811ea..6133c20573a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -6402,7 +6402,9 @@ whole OBJECT.
6402 6402
6403The full list of algorithms can be obtained with `secure-hash-algorithms'. 6403The full list of algorithms can be obtained with `secure-hash-algorithms'.
6404 6404
6405If BINARY is non-nil, returns a string in binary form. 6405If BINARY is non-nil, returns a string in binary form. In this case,
6406the function returns a unibyte string whose length is half the number
6407of characters it returns when BINARY is nil.
6406 6408
6407Note that MD5 and SHA-1 are not collision resistant and should not be 6409Note that MD5 and SHA-1 are not collision resistant and should not be
6408used for anything security-related. For these applications, use one 6410used for anything security-related. For these applications, use one