summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-07-04 07:28:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-07-04 07:28:18 -0700
commitc7b508747347e8a17546140da64e5170b01e075e (patch)
tree857bb702a1171282afff5ae00d1a51b316fceea0 /txr.1
parentf47ad62b88bcff263c3f14b3107968efffd8378a (diff)
downloadtxr-c7b508747347e8a17546140da64e5170b01e075e.tar.gz
txr-c7b508747347e8a17546140da64e5170b01e075e.tar.bz2
txr-c7b508747347e8a17546140da64e5170b01e075e.zip
sha256: allow application to specify digest buffer.
* chksum.c (sha256_stream_impl): New static function, formed out of bulk of sha256_stream. Takes a pointer to a buffer where the digest is stored. (sha256_ensure_buf): New static function. (sha256_stream): Take buf argument; use sha256_ensure_buf to allocate a buffer if necessary, and to obtain the low-level buffer pointer. Implementation moved into sha256_stream_impl. (sha256_buf, sha256_str): Take pointer to digest buffer; don't allocate a buf object, don't return anything. (sha256): Take buf argument; use sha256_ensure_buf to allocate a buffer if necessary, and to obtain the low-level buffer pointer, which is passed to sha256_buf and sha256_str. (chksum_init): Update registrations of intrinsics with new optional parameters. * chksum.h (sha256_stream, sha256): Declarations updated. * txr.1: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.120
1 files changed, 16 insertions, 4 deletions
diff --git a/txr.1 b/txr.1
index 5bc1622c..b6844b4a 100644
--- a/txr.1
+++ b/txr.1
@@ -51969,7 +51969,7 @@ The CRC-32 is returned as a non-negative integer.
.coNP Function @ sha256-stream
.synb
-.mets (sha256-stream < stream <> [ nbytes ])
+.mets (sha256-stream < stream >> [ nbytes <> [ buf ]])
.syne
.desc
The
@@ -51985,11 +51985,17 @@ integer. It gives the number of bytes which should be read
and included in the digest. If the argument is omitted, then bytes are read
until the end of the stream.
-The 256 bit digest value is returned as a buffer containing 32 bytes.
+If the
+.meta buf
+argument is omitted, the 256 bit digest value is returned as a new,
+32-byte-long buffer object. If the
+.meta buf
+argument is specified, it must be a buffer that is at least 32 bytes long.
+The hash is placed into that buffer, which is then returned.
.coNP Function @ sha256
.synb
-.mets (sha256 << obj )
+.mets (sha256 < obj <> [ buf ])
.syne
.desc
The
@@ -52008,7 +52014,13 @@ If
is a character string, then the digest is calculated over the bytes
which constitute its UTF-8 representation.
-The 256 bit digest value is returned as a buffer containing 32 bytes.
+If the
+.meta buf
+argument is omitted, the 256 bit digest value is returned as a new,
+32-byte-long buffer object. If the
+.meta buf
+argument is specified, it must be a buffer that is at least 32 bytes long.
+The hash is placed into that buffer, which is then returned.
.SS* The Awk Utility