From a487a7820077ecf71a3c48d9f35b8c273d444200 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 5 Aug 2022 14:39:20 +0530 Subject: [PATCH] Add type definitions for the crypto data types --- kitty/fast_data_types.pyi | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 6196db42f..45c9d560a 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -1413,3 +1413,56 @@ def remove_signal_handlers() -> None: def getpeereid(fd: int) -> Tuple[int, int]: pass + + +X25519: int +SHA1_HASH: int +SHA224_HASH: int +SHA256_HASH: int +SHA384_HASH: int +SHA512_HASH: int + + +class Secret: + pass + + +class EllipticCurveKey: + + def __init__( + self, algorithm: int = 0 # X25519 + ): pass + + def derive_secret( + self, pubkey: bytes, hash_algorithm: int = 0 # SHA256_HASH + ) -> Secret: pass + + @property + def public(self) -> bytes: ... + + @property + def private(self) -> Secret: ... + + +class AES256GCMEncrypt: + + def __init__(self, key: Secret): ... + + def add_authenticated_but_unencrypted_data(self, data: bytes) -> None: ... + + def add_data_to_be_encrypted(self, data: bytes, finished: bool = False) -> bytes: ... + + @property + def iv(self) -> bytes: ... + + @property + def tag(self) -> bytes: ... + + +class AES256GCMDecrypt: + + def __init__(self, key: Secret, iv: bytes, tag: bytes): ... + + def add_data_to_be_authenticated_but_not_decrypted(self, data: bytes) -> None: ... + + def add_data_to_be_decrypted(self, data: bytes, finished: bool = False) -> bytes: ...