diff options
| author | Eli Zaretskii | 2024-08-19 17:51:50 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-08-19 17:51:50 +0300 |
| commit | fc7581ae2ee9db1e3189b76c66be9cd13f72f004 (patch) | |
| tree | f01e33e951b0a75828e5f90d8d84553176289ee5 | |
| parent | 21be5cadaf1e43cf886f38cb14fa25b96d8b551d (diff) | |
| download | emacs-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.texi | 14 | ||||
| -rw-r--r-- | lisp/subr.el | 2 | ||||
| -rw-r--r-- | src/fns.c | 4 |
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 |
| 4995 | For @code{md5}: 32 characters (32 bytes if @var{binary} is | 4995 | For @code{md5}: 32 characters (16 bytes if @var{binary} is |
| 4996 | non-@code{nil}). | 4996 | non-@code{nil}). |
| 4997 | @item | 4997 | @item |
| 4998 | For @code{sha1}: 40 characters (40 bytes if @var{binary} is | 4998 | For @code{sha1}: 40 characters (20 bytes if @var{binary} is |
| 4999 | non-@code{nil}). | 4999 | non-@code{nil}). |
| 5000 | @item | 5000 | @item |
| 5001 | For @code{sha224}: 56 characters (56 bytes if @var{binary} is | 5001 | For @code{sha224}: 56 characters (28 bytes if @var{binary} is |
| 5002 | non-@code{nil}). | 5002 | non-@code{nil}). |
| 5003 | @item | 5003 | @item |
| 5004 | For @code{sha256}: 64 characters (64 bytes if @var{binary} is | 5004 | For @code{sha256}: 64 characters (32 bytes if @var{binary} is |
| 5005 | non-@code{nil}). | 5005 | non-@code{nil}). |
| 5006 | @item | 5006 | @item |
| 5007 | For @code{sha384}: 96 characters (96 bytes if @var{binary} is | 5007 | For @code{sha384}: 96 characters (48 bytes if @var{binary} is |
| 5008 | non-@code{nil}). | 5008 | non-@code{nil}). |
| 5009 | @item | 5009 | @item |
| 5010 | For @code{sha512}: 128 characters (128 bytes if @var{binary} is | 5010 | For @code{sha512}: 128 characters (64 bytes if @var{binary} is |
| 5011 | non-@code{nil}). | 5011 | non-@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 | ||
| 5064 | It returns a 40-character string if @var{binary} is @code{nil}, or a | 5064 | It returns a 40-character string if @var{binary} is @code{nil}, or a |
| 5065 | 40-byte unibyte string otherwise. | 5065 | 20-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. |
| 4482 | OBJECT is either a string or a buffer. Optional arguments START and | 4482 | OBJECT is either a string or a buffer. Optional arguments START and |
| 4483 | END are character positions specifying which portion of OBJECT for | 4483 | END are character positions specifying which portion of OBJECT for |
| 4484 | computing the hash. If BINARY is non-nil, return a 40-byte unibyte | 4484 | computing the hash. If BINARY is non-nil, return a 20-byte unibyte |
| 4485 | string; otherwise return a 40-character string. | 4485 | string; otherwise return a 40-character string. |
| 4486 | 4486 | ||
| 4487 | Note that SHA-1 is not collision resistant and should not be used | 4487 | Note that SHA-1 is not collision resistant and should not be used |
| @@ -6402,7 +6402,9 @@ whole OBJECT. | |||
| 6402 | 6402 | ||
| 6403 | The full list of algorithms can be obtained with `secure-hash-algorithms'. | 6403 | The full list of algorithms can be obtained with `secure-hash-algorithms'. |
| 6404 | 6404 | ||
| 6405 | If BINARY is non-nil, returns a string in binary form. | 6405 | If BINARY is non-nil, returns a string in binary form. In this case, |
| 6406 | the function returns a unibyte string whose length is half the number | ||
| 6407 | of characters it returns when BINARY is nil. | ||
| 6406 | 6408 | ||
| 6407 | Note that MD5 and SHA-1 are not collision resistant and should not be | 6409 | Note that MD5 and SHA-1 are not collision resistant and should not be |
| 6408 | used for anything security-related. For these applications, use one | 6410 | used for anything security-related. For these applications, use one |