diff options
author | Mattias Andrée <maandree@kth.se> | 2017-10-14 01:01:14 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-10-14 01:01:14 +0200 |
commit | 3e1864aa14a33a3c917537a241f6a032cfcacf78 (patch) | |
tree | 25297b1363fa88c9f45b5102afa5e95d08e986c1 /man/libkeccak_sha3sum_fd.3 | |
parent | Change style and license (diff) | |
download | libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.gz libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.bz2 libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.xz |
General improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'man/libkeccak_sha3sum_fd.3')
-rw-r--r-- | man/libkeccak_sha3sum_fd.3 | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/man/libkeccak_sha3sum_fd.3 b/man/libkeccak_sha3sum_fd.3 new file mode 100644 index 0000000..e8c4fc0 --- /dev/null +++ b/man/libkeccak_sha3sum_fd.3 @@ -0,0 +1,111 @@ +.TH LIBKECCAK_SHA3SUM_FD 3 LIBKECCAK +.SH NAME +libkeccak_sha3sum_fd - Calculate a SHA-3 hashsum of a file +.SH SYNOPSIS +.LP +.nf +#include <libkeccak.h> +.P +int +libkeccak_sha3sum_fd(int \fIfd\fP, libkeccak_state_t *\fIstate\fP, long int \fIoutput\fP, + char *\fIhashsum\fP); +.fi +.P +Link with +.IR -lkeccak . +.SH DESCRIPTION +The +.BR libkeccak_sha3sum_fd () +function calculates a SHA-3 hashsum of a file, whose file +desriptor is specified by +.I fd +(and should be at the beginning of the file.) The hash +algorithm is tuned by the +.I output +parameter; it specifies the output size, in bits. +.PP +The hash is stored in binary form to +.IR hashsum . +.I hashsum +should have an allocation size of at least +.RI ((( output ++ 7) / 8) * sizeof(char)). +.PP +.I *state +should not be initialised. +.BR libkeccak_sha3sum_fd () +initialises +.I *state +itself. Therefore there would be a memory leak if +.I *state +is already initialised. +.SH RETURN VALUES +The +.BR libkeccak_sha3sum_fd () +function returns 0 upon successful completion. +On error, -1 is returned and +.I errno +is set to describe the error. +.SH ERRORS +The +.BR libkeccak_sha3sum_fd () +function may fail for any reason, except those resulting in +.I errno +being set to +.BR EINTR , +specified for the functions +.BR read (2), +.BR malloc (3), +and +.BR realloc (3). +.SH NOTES +Be aware, +.BR libkeccak_sha3sum_fd () +hashes the file until the end has been reached. For pipes +and sockets and this means until the file has been closed. +But for character devices, this usually means never. +Attempting to hash files in /dev is therefore usually a +bad idea. +.BR libkeccak_sha3sum_fd () +does not check for the file length or file type before +hashing as this could limit what you can do, and make +the library more complex. +.PP +.BR libkeccak_sha3sum_fd () +does not stop if interrupted +.RB ( read (2) +returns +.BR EINTR .) +.PP +.BR libkeccak_sha3sum_fd () +assumes all information is non-sensitive, and will +therefore not perform any secure erasure of information. +.PP +.BR libkeccak_sha3sum_fd () +does not validate the tuning of the algorithm. +.SH EXAMPLE +This example calculates the SHA3-256 hash of the input +from stdin, and prints the hash, in hexadecimal form, to stdout. +.LP +.nf +libkeccak_state_t state; +if (libkeccak_sha3sum_fd(STDIN_FILENO, &state, 256, binhash) < 0) + goto fail; +libkeccak_behex_lower(hexhash, binhash, sizeof(binhash)); +printf("%s\\n", hexhash); +libkeccak_state_destroy(&state); +.fi +.SH SEE ALSO +.BR libkeccak_behex_lower (3), +.BR libkeccak_behex_upper (3), +.BR libkeccak_generalised_sum_fd (3), +.BR libkeccak_keccaksum_fd (3), +.BR libkeccak_rawshakesum_fd (3), +.BR libkeccak_shakesum_fd (3), +.BR libkeccak_spec_sha3 (3), +.BR libkeccak_spec_check (3), +.BR libkeccak_generalised_spec_initialise (3), +.BR libkeccak_state_initialise (3) +.SH BUGS +Please report bugs to https://github.com/maandree/libkeccak/issues or to +maandree@kth.se |