Skip to content

Commit

Permalink
test: add explanation for offset modulo
Browse files Browse the repository at this point in the history
  • Loading branch information
csirianni committed Dec 10, 2023
1 parent 8119c02 commit e00650f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<crow::CORSHandler> app;

Expand Down
6 changes: 4 additions & 2 deletions backend/tests/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> encrypted_passwords = cryptography::encrypt(passwords, b, offset);

// 3. insert into database
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e00650f

Please sign in to comment.