This commit is contained in:
2026-11-26 23:34:55 +03:00
parent 20afc2c790
commit a25f357314
167 changed files with 33202 additions and 89 deletions
+19
View File
@@ -0,0 +1,19 @@
#include "auth.hpp"
#include <sodium.h>
#include <cassert>
#include <chrono>
#include <iostream>
int main() {
const auto start = std::chrono::steady_clock::now();
const auto hash = hash_password("correct horse battery staple");
assert(hash.rfind("$argon2id$v=19$m=65536,t=2,p=1$",0)==0);
assert(verify_password("correct horse battery staple",hash));
assert(!verify_password("wrong",hash));
assert(!verify_password("wrong","$argon2id$malformed"));
assert(!password_needs_rehash(hash));
char old[crypto_pwhash_STRBYTES];
assert(crypto_pwhash_str_alg(old,"password",8,1,19*1024*1024,crypto_pwhash_ALG_ARGON2ID13)==0);
assert(password_needs_rehash(old));
std::cout << "PASS: Argon2id m=65536 KiB,t=2,p=1; verify/malformed/rehash; total_ms="
<< std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now()-start).count() << '\n';
}