diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | argon-test.c | 39 | ||||
| -rw-r--r-- | compile_flags.txt | 6 | ||||
| -rw-r--r-- | makefile | 14 |
4 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8cf8ef --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | argon-test | ||
| 2 | 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 @@ | |||
| 1 | // Standard C | ||
| 2 | #include <stdio.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <string.h> | ||
| 5 | #include <stdint.h> | ||
| 6 | |||
| 7 | // PW-Hashing | ||
| 8 | #include <argon2.h> | ||
| 9 | |||
| 10 | int | ||
| 11 | main(void) | ||
| 12 | { | ||
| 13 | const char pwd[] = "Hallo Welt"; | ||
| 14 | char salt[24]; | ||
| 15 | uint32_t t_cost = 20; | ||
| 16 | uint32_t m_cost = 1600; | ||
| 17 | uint32_t parallelism = 4; | ||
| 18 | uint32_t hashlength = 24; | ||
| 19 | char encoded[256] = { 0 }; | ||
| 20 | |||
| 21 | arc4random_buf(salt, sizeof salt); | ||
| 22 | int res = argon2id_hash_encoded(t_cost, m_cost, parallelism, pwd, strlen(pwd), salt, sizeof salt, hashlength, encoded, sizeof encoded); | ||
| 23 | if ( res == ARGON2_OK ) { | ||
| 24 | printf("hash: %s\n", encoded); | ||
| 25 | |||
| 26 | res = argon2id_verify(encoded, "Hallo Welt", 10); | ||
| 27 | if ( res == ARGON2_OK ) { | ||
| 28 | puts("Alles OK!"); | ||
| 29 | } | ||
| 30 | else { | ||
| 31 | fprintf(stderr, "Error: %s\n", argon2_error_message(res)); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | else { | ||
| 35 | fprintf(stderr, "Error: %s\n", argon2_error_message(res)); | ||
| 36 | } | ||
| 37 | |||
| 38 | return EXIT_SUCCESS; | ||
| 39 | } | ||
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 @@ | |||
| 1 | -Wall | ||
| 2 | -Werror | ||
| 3 | -std=c99 | ||
| 4 | -pedantic | ||
| 5 | -g | ||
| 6 | -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 @@ | |||
| 1 | .PHONY: clean all | ||
| 2 | |||
| 3 | all: argon-test | ||
| 4 | |||
| 5 | CFLAGS =-Wall -Werror -std=c99 -pedantic -g | ||
| 6 | |||
| 7 | argon-test: argon-test.o | ||
| 8 | cc $(LDFLAGS) argon-test.o -largon2 -o $@ | ||
| 9 | |||
| 10 | argon-test.o: argon-test.c | ||
| 11 | cc $(CFLAGS) -c $< -o $@ | ||
| 12 | |||
| 13 | clean: | ||
| 14 | rm -f argon-test.o argon-test | ||
