diff options
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_test_supported.c | 26 |
1 files changed, 24 insertions, 2 deletions
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 */ |
