From 266ffbc3e61570d08ec0ec84394ab49eb9b44e7d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 10 May 2026 22:05:40 +0200 Subject: Misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- librecrypt_test_supported.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'librecrypt_test_supported.c') diff --git a/librecrypt_test_supported.c b/librecrypt_test_supported.c index a0f7d73..520ab68 100644 --- a/librecrypt_test_supported.c +++ b/librecrypt_test_supported.c @@ -33,7 +33,7 @@ librecrypt_test_supported(const char *phrase, size_t len, int text, const char * phrase = NULL; text = 0; - /* Goto next algorithm */ + /* Go to next algorithm */ settings = &settings[n]; /* conf */ settings++; /* '>' */ } @@ -43,16 +43,38 @@ librecrypt_test_supported(const char *phrase, size_t len, int text, const char * #else +#define NSA "$~no~such~algorithm~$" + + +#define CHECK(ALGO, VALID, INVALID)\ + do {\ + EXPECT(librecrypt_test_supported(NULL, 4096u, 0, ALGO VALID) == 1);\ + EXPECT(librecrypt_test_supported(NULL, 4096u, 0, ALGO VALID">"NSA) == 0);\ + EXPECT(librecrypt_test_supported(NULL, 4096u, 0, NSA">"ALGO VALID) == 0);\ + EXPECT(librecrypt_test_supported(NULL, 4096u, 0, ALGO VALID">"ALGO VALID) == 1);\ + EXPECT(librecrypt_test_supported(NULL, 4096u, 0, ALGO INVALID) == 0);\ + } while (0) + + int main(void) { SET_UP_ALARM(); INIT_RESOURCE_TEST(); + EXPECT(librecrypt_test_supported("abcdefgh", 8u, 1, NSA) == 0); + EXPECT(librecrypt_test_supported("abcdefgh", 8u, 1, NSA">") == 0); + EXPECT(librecrypt_test_supported("abcdefgh", 8u, 1, ">"NSA) == 0); + EXPECT(librecrypt_test_supported("abcdefgh", 8u, 1, NSA">"NSA) == 0); + + IF__argon2i__SUPPORTED(CHECK("$argon2i$v=19$", "m=8,t=1,p=1$*16$*40", "m=0,t=0,p=0$*1$*1")); + IF__argon2d__SUPPORTED(CHECK("$argon2d$v=19$", "m=8,t=1,p=1$*16$*40", "m=0,t=0,p=0$*1$*1")); + IF__argon2id__SUPPORTED(CHECK("$argon2id$v=19$", "m=8,t=1,p=1$*16$*40", "m=0,t=0,p=0$*1$*1")); + IF__argon2ds__SUPPORTED(CHECK("$argon2ds$v=19$", "m=8,t=1,p=1$*16$*40", "m=0,t=0,p=0$*1$*1")); + STOP_RESOURCE_TEST(); return 0; } #endif -/* TODO test */ -- cgit v1.2.3-70-g09d2