forked from mtusi2026/mtusi2026lab7
ЛР 7: TLS, mTLS, OpenBao и безопасность — на 3
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"""Time the actual verification settings with synthetic values."""
|
||||
import json
|
||||
import statistics
|
||||
import time
|
||||
|
||||
from argon2 import Type, extract_parameters
|
||||
|
||||
from src.security import hasher
|
||||
|
||||
password = "Synthetic training password 7!"
|
||||
one = hasher.hash(password)
|
||||
assert one != hasher.hash(password)
|
||||
params = extract_parameters(one)
|
||||
assert params.type is Type.ID and params.memory_cost >= 19456 and params.time_cost >= 2
|
||||
samples = []
|
||||
for _ in range(12):
|
||||
start = time.perf_counter()
|
||||
assert hasher.verify(one, password)
|
||||
samples.append(1000 * (time.perf_counter() - start))
|
||||
print(json.dumps({"type": params.type.name, "memory_kib": params.memory_cost, "iterations": params.time_cost,
|
||||
"parallelism": params.parallelism, "salt_bytes": params.salt_len, "runs": len(samples),
|
||||
"median_ms": round(statistics.median(samples), 2), "max_ms": round(max(samples), 2),
|
||||
"unique_salts": True}))
|
||||
Reference in New Issue
Block a user