From 63104f0716dc2d60842f19fc145ea4bcb096292d Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Mon, 6 Jul 2026 23:20:17 +0200 Subject: initial commit --- .gitignore | 2 ++ argon-test.c | 39 +++++++++++++++++++++++++++++++++++++++ compile_flags.txt | 6 ++++++ makefile | 14 ++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 .gitignore create mode 100644 argon-test.c create mode 100644 compile_flags.txt create mode 100644 makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8cf8ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +argon-test +argon-test.o diff --git a/argon-test.c b/argon-test.c new file mode 100644 index 0000000..cd2dcff --- /dev/null +++ b/argon-test.c @@ -0,0 +1,39 @@ +// Standard C +#include +#include +#include +#include + +// PW-Hashing +#include + +int +main(void) +{ + const char pwd[] = "Hallo Welt"; + char salt[24]; + uint32_t t_cost = 20; + uint32_t m_cost = 1600; + uint32_t parallelism = 4; + uint32_t hashlength = 24; + char encoded[256] = { 0 }; + + arc4random_buf(salt, sizeof salt); + int res = argon2id_hash_encoded(t_cost, m_cost, parallelism, pwd, strlen(pwd), salt, sizeof salt, hashlength, encoded, sizeof encoded); + if ( res == ARGON2_OK ) { + printf("hash: %s\n", encoded); + + res = argon2id_verify(encoded, "Hallo Welt", 10); + if ( res == ARGON2_OK ) { + puts("Alles OK!"); + } + else { + fprintf(stderr, "Error: %s\n", argon2_error_message(res)); + } + } + else { + fprintf(stderr, "Error: %s\n", argon2_error_message(res)); + } + + return EXIT_SUCCESS; +} diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..ac8ad67 --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,6 @@ +-Wall +-Werror +-std=c99 +-pedantic +-g +-I/usr/local/include diff --git a/makefile b/makefile new file mode 100644 index 0000000..ff2440a --- /dev/null +++ b/makefile @@ -0,0 +1,14 @@ +.PHONY: clean all + +all: argon-test + +CFLAGS =-Wall -Werror -std=c99 -pedantic -g + +argon-test: argon-test.o + cc $(LDFLAGS) argon-test.o -largon2 -o $@ + +argon-test.o: argon-test.c + cc $(CFLAGS) -c $< -o $@ + +clean: + rm -f argon-test.o argon-test -- cgit v1.3