From e00650fed8668da635df94f1ad69def56b87c71b Mon Sep 17 00:00:00 2001 From: Cedric Sirianni Date: Sun, 10 Dec 2023 18:39:36 -0500 Subject: [PATCH] test: add explanation for offset modulo --- backend/src/main.cpp | 2 +- backend/tests/server.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/main.cpp b/backend/src/main.cpp index 829a48d..a5a45ce 100644 --- a/backend/src/main.cpp +++ b/backend/src/main.cpp @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) throw std::invalid_argument("Passwords and/or secret key table does not exist. Use --build to create a new database"); } } - + db.printTable("passwords"); // Enable CORS crow::App app; diff --git a/backend/tests/server.cpp b/backend/tests/server.cpp index 29089b7..d863295 100644 --- a/backend/tests/server.cpp +++ b/backend/tests/server.cpp @@ -38,7 +38,7 @@ TEST_CASE("Test endpoints using handler") crypto_core_ristretto255_scalar_random(b); // 2. encrypt each password with b (and hash to point) - const size_t offset = 5; + const size_t offset = 1; std::vector encrypted_passwords = cryptography::encrypt(passwords, b, offset); // 3. insert into database @@ -89,15 +89,17 @@ TEST_CASE("Test endpoints using handler") switch (offset % 3) { case 0: - // if offset is 0, then password is padded with a single '=' + // password is padded with single '=' CHECK(breached_password[breached_password.size() - 1] == '='); CHECK(breached_password[breached_password.size() - 2] != '='); break; case 1: + // password is not padded CHECK(breached_password[breached_password.size() - 1] != '='); CHECK(breached_password[breached_password.size() - 2] != '='); break; case 2: + // password is padded with two '=' CHECK(breached_password[breached_password.size() - 1] == '='); CHECK(breached_password[breached_password.size() - 2] == '='); break;