Giter Site home page Giter Site logo

maandree / sha3sum Goto Github PK

View Code? Open in Web Editor NEW
172.0 11.0 51.0 340 KB

[Feature complete] SHA-3 and Keccak checksum utility

Home Page: https://codeberg.org/maandree/sha3sum

License: ISC License

Makefile 10.79% C 51.67% Roff 6.60% Shell 30.95%
sha3 keccak shake rawshake checksum integrity authenticity security sha3sum cryptographic-hash

sha3sum's Introduction

NAME
	sha3sum - Keccak, SHA-3, SHAKE, and RawSHAKE checksum utilities

SYNOPSIS
	keccaksum      [option ...] [file ...]
	keccak-224sum  [option ...] [file ...]
	keccak-256sum  [option ...] [file ...]
	keccak-384sum  [option ...] [file ...]
	keccak-512sum  [option ...] [file ...]
	sha3-224sum    [option ...] [file ...]
	sha3-256sum    [option ...] [file ...]
	sha3-384sum    [option ...] [file ...]
	sha3-512sum    [option ...] [file ...]
	shake128sum    [option ...] [file ...]
	shake256sum    [option ...] [file ...]
	shake512sum    [option ...] [file ...]
	rawshake128sum [option ...] [file ...]
	rawshake256sum [option ...] [file ...]
	rawshake512sum [option ...] [file ...]

DESCRIPTION
	Fully configurable byte-orientated checksum utilities
	for Keccak and its close derivatives SHA-3, SHAKE and
	RawSHAKE.

	This utilities can generate checksums or verify the
	checksums of files.

OPTIONS

	-u
		Use upper-case output.

	-l
		Use lower-case output.

	-b
		Use binary output.

	-c
		Check checksums.

	-x
		Use hexadecimal input.

	-v
		Be verbose.

	-R rate
		Select rate.

	-C capacity
		Select capacity.

	-N, -O output-size
		Select output size.

	-S, -B state-size
		Select state size.

	-W word-size
		Select word size.

	-Z squeeze-count
		Select squeeze count.

RATIONALE
	We probably do not need this, but it is nice to have
	in case SHA-2 gets compromised.

SEE ALSO
	libkeccak(7), sum(1), cksum(1), md5sum(1), md6sum(1),
	sha1sum(1), sha224sum(1), sha256sum(1), sha384sum(1),
	sha512sum(1)

PERFORMANCE
	Performance comparison on a 1 GiB file (yes, that is
	quite large) with /dev/urandom data:

	$ keccak-224sum		│	$ keccak-256sum
	real	0m9.550s	│	real	0m9.841s
	user	0m9.223s	│	user	0m9.560s
	sys	0m0.320s	│	sys	0m0.260s
				│
	$ keccak-384sum		│	$ keccak-512sum
	real	0m12.902s	│	real	0m18.084s
	user	0m12.580s	│	user	0m17.823s
	sys	0m0.313s	│	sys	0m0.243s
				│
	$ keccaksum		│	$ sha1sum
	real	0m10.438s	│	real	0m3.421s
	user	0m10.140s	│	user	0m3.157s
	sys	0m0.287s	│	sys	0m0.253s
				│
	$ sha224sum		│	$ sha256sum
	real	0m8.196s	│	real	0m9.361s
	user	0m7.910s	│	user	0m9.097s
	sys	0m0.263s	│	sys	0m0.257s
				│
	$ sha384sum		│	$ sha512sum
	real	0m5.450s	│	real	0m4.507s
	user	0m5.223s	│	user	0m4.247s
	sys	0m0.220s	│	sys	0m0.257s
				│
	$ md5sum		│	$ md6sum
	real	0m2.987s	│	real	1m28.873s
	user	0m2.703s	│	user	1m28.470s
	sys	0m0.283s	│	sys	0m0.360s

	Note: The times are a bit random, and only one run
	has been made. "user" is the most interesting data.
	Additionally, only the pure keccak variants have been
	tested because the difference is between them and the
	other are quite small; and of course the other hashing
	utilities from other packages using other
	algorithm-families.

NOTES
	Packagers are advised to separate sha3sum(1) into its
	own packages, apart from the other commands, as it is
	mearly provided for compatibility and it could cause
	package conflict with other implementations that only
	provide sha3sum(1) such as busybox.

sha3sum's People

Contributors

kseistrup avatar limeth avatar maandree avatar traneptora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sha3sum's Issues

Compilation error

Hello, I can't seem to compile this project.
I've manually compiled (make) and installed sudo make install) argparser, auto-auto-complete and libkeccak. I believe I have all of the required dependencies.
I am running Ubuntu 16.04.

$ make
cc -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -std=gnu99 -O3 -c -o obj/keccak-224sum.o src/keccak-224sum.c
cc -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -std=gnu99 -O3 -c -o obj/common.o src/common.c
cc -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -std=gnu99  -lkeccak -largparser -o bin/keccak-224sum obj/keccak-224sum.o obj/common.o
obj/keccak-224sum.o: In function `main':
keccak-224sum.c:(.text.startup+0x60): undefined reference to `args_standard_abbreviations'
keccak-224sum.c:(.text.startup+0x65): undefined reference to `args_init'
obj/common.o: In function `generalised_sum_fd_hex':
common.c:(.text+0x45): undefined reference to `libkeccak_state_initialise'
common.c:(.text+0x128): undefined reference to `libkeccak_fast_update'
common.c:(.text+0x196): undefined reference to `libkeccak_fast_digest'
obj/common.o: In function `hash':
common.c:(.text+0x23e): undefined reference to `libkeccak_generalised_sum_fd'
common.c:(.text+0x308): undefined reference to `libkeccak_fast_squeeze'
common.c:(.text+0x317): undefined reference to `libkeccak_squeeze'
obj/common.o: In function `check_checksums':
common.c:(.text+0x7a4): undefined reference to `libkeccak_unhex'
obj/common.o: In function `print_checksum':
common.c:(.text+0x945): undefined reference to `libkeccak_behex_lower'
common.c:(.text+0x985): undefined reference to `libkeccak_behex_upper'
obj/common.o: In function `run':
common.c:(.text+0x9e3): undefined reference to `args_new_argumentless'
common.c:(.text+0xa15): undefined reference to `args_add_option'
common.c:(.text+0xa44): undefined reference to `args_new_argumented'
common.c:(.text+0xa8e): undefined reference to `args_add_option'
common.c:(.text+0xab8): undefined reference to `args_new_argumented'
common.c:(.text+0xb02): undefined reference to `args_add_option'
common.c:(.text+0xb36): undefined reference to `args_new_argumented'
common.c:(.text+0xb83): undefined reference to `args_add_option'
common.c:(.text+0xbb7): undefined reference to `args_new_argumented'
common.c:(.text+0xc04): undefined reference to `args_add_option'
common.c:(.text+0xc33): undefined reference to `args_new_argumented'
common.c:(.text+0xc7d): undefined reference to `args_add_option'
common.c:(.text+0xca7): undefined reference to `args_new_argumented'
common.c:(.text+0xcf1): undefined reference to `args_add_option'
common.c:(.text+0xd20): undefined reference to `args_new_argumentless'
common.c:(.text+0xd6b): undefined reference to `args_add_option'
common.c:(.text+0xd9a): undefined reference to `args_new_argumentless'
common.c:(.text+0xde5): undefined reference to `args_add_option'
common.c:(.text+0xe0a): undefined reference to `args_new_argumentless'
common.c:(.text+0xe57): undefined reference to `args_add_option'
common.c:(.text+0xe81): undefined reference to `args_new_argumentless'
common.c:(.text+0xecc): undefined reference to `args_add_option'
common.c:(.text+0xef1): undefined reference to `args_new_argumentless'
common.c:(.text+0xf3e): undefined reference to `args_add_option'
common.c:(.text+0xf63): undefined reference to `args_new_argumentless'
common.c:(.text+0xfb0): undefined reference to `args_add_option'
common.c:(.text+0xfbe): undefined reference to `args_parse'
common.c:(.text+0xfc8): undefined reference to `args_opts_used'
common.c:(.text+0xfda): undefined reference to `args_opts_used'
common.c:(.text+0xfec): undefined reference to `args_opts_used'
common.c:(.text+0xffe): undefined reference to `args_opts_used'
common.c:(.text+0x1010): undefined reference to `args_opts_used'
obj/common.o:common.c:(.text+0x1022): more undefined references to `args_opts_used' follow
obj/common.o: In function `run':
common.c:(.text+0x10ab): undefined reference to `libkeccak_degeneralise_spec'
common.c:(.text+0x10d4): undefined reference to `args_opts_used'
common.c:(.text+0x1135): undefined reference to `args_dispose'
common.c:(.text+0x119e): undefined reference to `args_opts_get'
common.c:(.text+0x11ab): undefined reference to `args_opts_get_count'
common.c:(.text+0x11d6): undefined reference to `args_opts_get'
common.c:(.text+0x11e3): undefined reference to `args_opts_get_count'
common.c:(.text+0x120e): undefined reference to `args_opts_get'
common.c:(.text+0x121b): undefined reference to `args_opts_get_count'
common.c:(.text+0x1246): undefined reference to `args_opts_get'
common.c:(.text+0x1253): undefined reference to `args_opts_get_count'
common.c:(.text+0x127e): undefined reference to `args_opts_get'
common.c:(.text+0x128b): undefined reference to `args_opts_get_count'
common.c:(.text+0x12b6): undefined reference to `args_opts_get'
common.c:(.text+0x12c3): undefined reference to `args_opts_get_count'
common.c:(.text+0x12e5): undefined reference to `args_help'
common.c:(.text+0x12ea): undefined reference to `args_dispose'
common.c:(.text+0x1495): undefined reference to `args_dispose'
common.c:(.text+0x1504): undefined reference to `args_dispose'
collect2: error: ld returned 1 exit status
Makefile:83: recipe for target 'bin/keccak-224sum' failed
make: *** [bin/keccak-224sum] Error 1
rm obj/keccak-224sum.o obj/common.o

Compiler error: 'libkeccak.h' file not found

Getting error for libkeccak.h file not being found, when I run make install-all. Could be the wrong way to do a build. Did not find any instructions for building.

%> make install-all
cc -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs
-Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations
-Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default
-Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow
-Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wlogical-op
-Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance
-Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn
-Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -std=gnu99 -O3 -c
-o obj/keccak-224sum.o src/keccak-224sum.c
warning: unknown warning option '-Wtrampolines' [-Wunknown-warning-option]
warning: unknown warning option '-Wsync-nand' [-Wunknown-warning-option]
warning: unknown warning option '-Wunsafe-loop-optimizations'; did you mean '-Wunavailable-declarations'? [-Wunknown-warning-option]
warning: unknown warning option '-Wlogical-op'; did you mean '-Wliblto'? [-Wunknown-warning-option]
warning: unknown warning option '-Wvector-operation-performance' [-Wunknown-warning-option]
warning: unknown warning option '-Wunsuffixed-float-constants' [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=const' [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=pure'; did you mean '-WNSObject-attribute'? [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
warning: unknown warning option '-Wnormalized=nfkc'; did you mean '-Wformat-pedantic'? [-Wunknown-warning-option]
In file included from src/keccak-224sum.c:19:
src/common.h:23:10: fatal error: 'libkeccak.h' file not found
#include <libkeccak.h>
         ^
11 warnings and 1 error generated.
make: *** [obj/keccak-224sum.o] Error 1

C: “sha3sum -h” doesn't show help text

For some reason sha3sum -h doesn't show the help text (and instead waits for input on stdin) while sha2sum --help does.

I'm sorry, but I don't have the energy to find out how the roll-your-own argument parser works…

the result is true ?

i use this command

./keccak-224sum -l test.txt

my text is empty

why my result is not
f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd?

sha3sum 1.2 osx build issue

👋 trying to keep sha3sum formula keep to date, but failed to do so. Here is some error log for reference:

printf '%s\n' '#include "common.h"' 'SHAKE_MAIN(512)' > shake512sum.c
u=$(printf '%s\n' keccaksum | tr a-z A-Z); \
	sed -e 's/xsum/keccaksum/g' -e 's/XSUM/'"$u"'/g' -e 's/Xsum/Keccak[]/g' < xsum.man > keccaksum.1
u=$(printf '%s\n' keccak-224sum | tr a-z A-Z); \
	sed -e 's/xsum/keccak-224sum/g' -e 's/XSUM/'"$u"'/g' -e 's/Xsum/Keccak-224/g' < xsum.man > keccak-224sum.1
u=$(printf '%s\n' keccak-256sum | tr a-z A-Z); \
	sed -e 's/xsum/keccak-256sum/g' -e 's/XSUM/'"$u"'/g' -e 's/Xsum/Keccak-256/g' < xsum.man > keccak-256sum.1
if test keccaksum = sha3sum; then \
		sed -i 's/^\\# ONLY SHA3: //' keccaksum.1; \
	else \
		sed -i '/^\\# ONLY SHA3: /d' keccaksum.1; \
	fi
if test keccak-256sum = sha3sum; then \
		sed -i 's/^\\# ONLY SHA3: //' keccak-256sum.1; \
	else \
		sed -i '/^\\# ONLY SHA3: /d' keccak-256sum.1; \
	fi
if test keccak-224sum = sha3sum; then \
		sed -i 's/^\\# ONLY SHA3: //' keccak-224sum.1; \
	else \
		sed -i '/^\\# ONLY SHA3: /d' keccak-224sum.1; \
	fi
sed: 1: "keccak-256sum.1": invalid command code k
sed: 1: "keccaksum.1": invalid command code k
sed: 1: "keccak-224sum.1": invalid command code k
make: *** [keccak-256sum.1] Error 1
make: *** Waiting for unfinished jobs....
make: *** [keccaksum.1] Error 1
make: *** [keccak-224sum.1] Error 1
rm shake256sum.c keccak-512sum.c sha3-384sum.c shake512sum.c sha3-256sum.c rawshake256sum.c sha3-224sum.c rawshake512sum.c keccak-384sum.c keccak-256sum.c keccaksum.o keccak-224sum.c sha3sum.o sha3-512sum.c

Full build log, https://github.com/Homebrew/homebrew-core/runs/1310622903
relates to Homebrew/homebrew-core#63504

Let me know if I can provide more info, thanks!

sha3sum gives different hash between file on same partition or on a mount point

I found an effect when downloading sqlite and tryong to calculate the sha3-256sum hash but I have shown it applies to any file.

If I have a file on the same partition as I am working on I get one sha3-256 sum and that matches the result from the website that the file is being downloaded from. If that same file is copied to my nfs fileserver which is on a mount point on /mnt then the sha3-256 hash is different. This applies consistently irrespective of the file being used and where on the mountpoint filesystem the file is stored.

If I calculate the sha256sum on the same files then the result is the same on the partition being worked on and the mountpoint.

Something is changing in the file that the sha3-256sum algorithm includes but that the sha256sum algorithm doesn't.

I have downloaded sqlite several times in the past and did not have this problem. The files I download always go to the fileserver and the hash is then checked on the file there. In the past the sha3-256 hash always matched the one from the website.

I am running arch linux.

Let me know if any additional information is needed.

performance boost

This requires c99.

Use static inline instead of inline.
Use restrict on pointer parameters.

Wrong hashes?

When I do echo 'asdf' | keccak-256sum I get

30a730f7c2718bbcfa3dc40523a288a6d5f802c1ef75116eb0f42b241318a159

but various online tools say the keccak-256 hash of asdf is

4c8f18581c0167eb90a761b4a304e009b924f03b619a0c0e8ea3adfce20aee64

Same thing for the other hash functions. What's going on?

Testing

This is only a request.

Would a test suite be helpful? Perhaps someone would like to validate your implementation.

*** buffer overflow detected ***: terminated with GCC 12 and -D_FORTIFY_SOURCE=3

Can be seen with:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/marxin/Programming/gcc/configure --enable-languages=c,c++,fortran,jit --prefix=/home/marxin/bin/gcc --disable-multilib --enable-host-shared --disable-libsanitizer --enable-valgrind-annotations --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220325 (experimental) (GCC) 
$ gcc  common.c -std=c99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -O2 -D_FORTIFY_SOURCE=3 -g  sha3-224sum.c -lkeccak
$ ./a.out -c .testdir/sums-1
blksize=4096, size=4096, ptr=0
blksize=4096, size=4096, ptr=276
*** buffer overflow detected ***: terminated
Aborted (core dumped)

one can see it with the following debugging patch:

diff --git a/common.c b/common.c
index dda8683..2b1143d 100644
--- a/common.c
+++ b/common.c
@@ -320,6 +320,7 @@ check_checksums(const char *restrict filename, const struct libkeccak_spec *rest
 		if (ptr + blksize < size)
 			buf = erealloc(buf, size <<= 1);
 
+    fprintf (stderr, "blksize=%ld, size=%ld, ptr=%ld\n", blksize, size, ptr);
 		got = read(fd, buf + ptr, blksize);
 		if (got < 0)
 			eperror();

So read is called with blksize == 4096, which buf + ptr does not have enough space.

Unable to make

When I make libkeccak, I get the following log output

libkeccak/mac/../state.h:93:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/mac/../state.h:131:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/mac/../state.h:131:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/mac/../state.h:139:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/mac/../state.h:139:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/mac/../state.h:147:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/mac/../state.h:156:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/../state.h:204:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/../state.h:227:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/mac/../state.h:270:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/mac/../state.h:281:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/mac/../state.h:292:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure)))
                                  ^
In file included from libkeccak/mac/hmac.c:2:
libkeccak/mac/hmac.h:152:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/mac/hmac.h:181:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/hmac.h:218:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/hmac.c:21:23: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
static __attribute__((optimize("-O0"))) void
                      ^
16 warnings generated.
ar rc libkeccak.a libkeccak/digest.o libkeccak/files.o libkeccak/generalised-spec.o libkeccak/hex.o libkeccak/state.o libkeccak/mac/hmac.o
ar -s libkeccak.a
cc -shared -Wl,-soname,libkeccak.so.1 -o libkeccak.so libkeccak/digest.o libkeccak/files.o libkeccak/generalised-spec.o libkeccak/hex.o libkeccak/state.o libkeccak/mac/hmac.o -s
ld: warning: option -s is obsolete and being ignored
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libkeccak.so] Error 1
18:17:30 unicornfarmer$ git clone https://github.com/maandree/sha3sum.git
Cloning into 'sha3sum'...
remote: Counting objects: 1279, done.
remote: Total 1279 (delta 0), reused 0 (delta 0), pack-reused 1279
Receiving objects: 100% (1279/1279), 314.96 KiB | 0 bytes/s, done.
Resolving deltas: 100% (788/788), done.

However then, when I make sha3sum, I get the error ./common.h:2:10: fatal error: 'libkeccak.h' file not found

unescaped error texman

cd obj/info ; makeinfo ../../doc/sha3sum.texinfo
mv obj/info/sha3sum.info bin/sha3sum.info
cat doc/xsum.texman | sed -e 's/xsum/keccak-224sum/g' -e 's/XSUM/Keccak-224/g' | texman > bin/keccak-224sum.1
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/@{ <-- HERE / at /usr/bin/texman line 51.
make: *** [Makefile:124: bin/keccak-224sum.1] Error 255
rm obj/keccaksum.o obj/sha3-512sum.o obj/keccak-512sum.o obj/shake256sum.o obj/rawshake256sum.o obj/sha3-384sum.o obj/keccak-384sum.o obj/shake512sum.o obj/sha3-256sum.o obj/keccak-256sum.o obj/rawshake512sum.o obj/sha3-224sum.o obj/keccak-224sum.o obj/common.o
==> ERROR: A failure occurred in build().
Aborting...
:: failed to build sha3sum package(s)

sha3sum.c: reading from stdin outputs binary fluff to stdout

I compiled the C version like this:

$ gcc -s -O2 sha3sum.c sha3.c -o sha3sum

The binary seems to work fine when you supply a filename, but reading from stdin puts binary fluff between the SHA3 digest and the -:

$ echo hello world > test.txt
$ ./sha3sum test.txt
Bitrate: 1024
Capacity: 576
Word size: 0
State size: 1600
Output Size: 512
Iterations: 1
Squeezes: 1
F8689A17420D3C969EE5AFD1A0846EFD51C8632003CD05C1AAF25765A8B339BB89D2B033111B38DD795C998475AE04BAB73339949CCB4744E06A7973A6B3CFAF test.txt
$ ./sha3sum <test.txt 2>/dev/null | hexdump -C 
00000000  46 38 36 38 39 41 31 37  34 32 30 44 33 43 39 36  |F8689A17420D3C96|
00000010  39 45 45 35 41 46 44 31  41 30 38 34 36 45 46 44  |9EE5AFD1A0846EFD|
00000020  35 31 43 38 36 33 32 30  30 33 43 44 30 35 43 31  |51C8632003CD05C1|
00000030  41 41 46 32 35 37 36 35  41 38 42 33 33 39 42 42  |AAF25765A8B339BB|
00000040  38 39 44 32 42 30 33 33  31 31 31 42 33 38 44 44  |89D2B033111B38DD|
00000050  37 39 35 43 39 39 38 34  37 35 41 45 30 34 42 41  |795C998475AE04BA|
00000060  42 37 33 33 33 39 39 34  39 43 43 42 34 37 34 34  |B73339949CCB4744|
00000070  45 30 36 41 37 39 37 33  41 36 42 33 43 46 41 46  |E06A7973A6B3CFAF|
00000080  f8 68 9a 17 42 0d 3c 96  9e e5 af d1 a0 84 6e fd  |.h..B.<.......n.|
00000090  51 c8 63 20 03 cd 05 c1  aa f2 57 65 a8 b3 39 bb  |Q.c ......We..9.|
000000a0  89 d2 b0 33 11 1b 38 dd  79 5c 99 84 75 ae 04 ba  |...3..8.y\..u...|
000000b0  b7 33 39 94 9c cb 47 44  e0 6a 79 73 a6 b3 cf af  |.39...GD.jys....|
000000c0  70 4c cf 94 ff 7f 20 2d  0a                       |pL.... -.|
000000c9
$ 

Is this intentional?

Get different hash with special char

Hi,
I did the following command (with an UTF8 special char):
printf "zM3U!&OZyE5⇶bJLdV$wey" |sha3-512sum -l
I got

2ff1c292bc9254695c4c522fb052f9d88d5f01b675e0cd3f84f0c449aa111d1eced01916f6e62894d9e31b7bf3423e7e0bf1ecf79ab6b7cd1cdc8bf863007532

If I compare with some others implementation I got:
dc380e55487376a5471ada4968853932429ac80e254a64d1430679f6e0141bc34e57f29bc967bc74fe1a58fde953adb7f7da8c01582bd1583269778d4bf01667

If I use a ascii char string I got the same result with all implementation.

Note I have 1.1.5 version from opensuse leap 15.1

Thanks and best regards

compilation howto?

Hi guys, I'm trying to compile this - but frankly, compiling C isn't my thing. 😁

I'd like to make this into a package for QNAP NAS users, but I get an error when compiling the sha3sum project.

Using Debian Buster for making the binaries:

me@wstation:~/workspace$ git clone https://github.com/maandree/sha3sum.git
Cloning into 'sha3sum'...
remote: Enumerating objects: 43, done.
remote: Counting objects: 100% (43/43), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 1298 (delta 19), reused 37 (delta 17), pack-reused 1255
Receiving objects: 100% (1298/1298), 333.04 KiB | 515.00 KiB/s, done.
Resolving deltas: 100% (797/797), done.
me@wstation:~/workspace$ git clone https://github.com/maandree/libkeccak.git
Cloning into 'libkeccak'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 1531 (delta 2), reused 4 (delta 2), pack-reused 1523
Receiving objects: 100% (1531/1531), 307.04 KiB | 459.00 KiB/s, done.
Resolving deltas: 100% (1073/1073), done.
me@wstation:~/workspace$ cd sha3sum/
me@wstation:~/workspace/sha3sum$ make
cc -c -o common.o common.c -std=c99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -O3 
In file included from common.c:2:
common.h:2:10: fatal error: libkeccak.h: No such file or directory
 #include <libkeccak.h>
          ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:52: common.o] Error 1

What is the correct way to compile this? I've tried copying libkeccak.h from the libkeccak project into the sha3sum project before compiling but still didn't work. Any advice?

Is there some link or environment variable that needs to be set first?

Thank you.

More than 1600?

I do not think constants are definied for above Keccak-ƒ[1600], but if it is, allow it.

compile error

==> Making package: sha3sum-git 0.235.1.0.4.g0fa6942-1 (Thu Jun 15 19:49:22 IST 2017)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
make: Nothing to be done for 'default'.
cat doc/xsum.texman | sed -e 's/xsum/keccak-256sum/g' -e 's/XSUM/Keccak-256/g' | texman > bin/keccak-256sum.1
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/@{ <-- HERE / at /usr/bin/texman line 51.
make: *** [Makefile:124: bin/keccak-256sum.1] Error 255
==> ERROR: A failure occurred in build().
Aborting...
:: failed to build sha3sum-git package(s)

sha3 and output

I would like to know how I can get a simple SHA-3/224 hash using this tool,

when I use the -o 224, it just get me a truncated version of 256.... ?
224 and 256 should be totally different
https://en.wikipedia.org/wiki/SHA-3#Examples_of_SHA-3_and_Keccak_variants

I use the python implementation btw.

/home/www# python3 sha3-224sum.py -o 256 test.txt
sha3-224sum
Bitrate: 448
Capacity: 1152
Word size: 0
State size: 1600
Output size: 256
Iterations: 1
Squeezes: 1
752924E4C1D45B2091812B093256517AA03436DE0E02978745657DF2630EF0BF test.txt
/home/www# python3 sha3-224sum.py -o 224 test.txt
sha3-224sum
Bitrate: 448
Capacity: 1152
Word size: 0
State size: 1600
Output size: 224
Iterations: 1
Squeezes: 1
752924E4C1D45B2091812B093256517AA03436DE0E02978745657DF2 blabla.txt

libkeccak.so.1 error

After installing libkeccak:
~/Desktop/test$ git clone https://github.com/maandree/libkeccak
~/Desktop/test$ cd libkeccak/
~/Desktop/test/libkeccak$ make

And after installing sha3sum:
~/Desktop/test$ git clone https://github.com/maandree/sha3sum.git
~/Desktop/test$ cd sha3sum/
~/Desktop/test/sha3sum$ make

There are no errors in installation logs but when I try to run:

~/Desktop/test/sha3sum$ keccak-256sum I get the following exception:
keccak-256sum: error while loading shared libraries: libkeccak.so.1: cannot open shared object file: No such file or directory

Could it be because I am using a 32bit Ubuntu but this is intended for 64bit?

More squeezing

Add an alternative to iterations where the sponing use squeezing instead, i.e. how you should do it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.