Allow the cipher() function also work without prefix aegis

This commit is contained in:
Leo Vasanko
2026-01-04 14:25:39 +00:00
parent 70f64fe288
commit 8a5e342905
+2
View File
@@ -11,6 +11,8 @@ def cipher(alg: CipherName) -> Cipher:
name = alg.lower().replace("-", "") name = alg.lower().replace("-", "")
if name == "aegis128": if name == "aegis128":
name = "aegis128l" # AEGIS-128 is dead, the user meant AEGIS-128L name = "aegis128l" # AEGIS-128 is dead, the user meant AEGIS-128L
if not name.startswith("aegis"):
name = "aegis" + name
if name in CIPHERS.values(): if name in CIPHERS.values():
return importlib.import_module(f".{name}", __package__) # type: ignore[return-value] return importlib.import_module(f".{name}", __package__) # type: ignore[return-value]
raise ValueError(f"Unknown algorithm {alg!r}. Valid options: {', '.join(CIPHERS)}") raise ValueError(f"Unknown algorithm {alg!r}. Valid options: {', '.join(CIPHERS)}")