Add pygost deps
This commit is contained in:
+101
@@ -0,0 +1,101 @@
|
||||
from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import Sequence
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
SBOXES = ... # type: Dict[str, Tuple[Tuple[int, ...], ...]]
|
||||
BLOCKSIZE = ... # type: int
|
||||
|
||||
Words = Tuple[int, int]
|
||||
|
||||
|
||||
def block2ns(data: bytes) -> Words: ...
|
||||
|
||||
|
||||
def ns2block(ns: Words) -> bytes: ...
|
||||
|
||||
|
||||
def validate_key(key: bytes) -> None: ...
|
||||
|
||||
|
||||
def validate_iv(iv: bytes) -> None: ...
|
||||
|
||||
|
||||
def validate_sbox(sbox: str) -> None: ...
|
||||
|
||||
|
||||
def xcrypt(seq: Sequence[int], sbox: str, key: bytes, ns: Words) -> Words: ...
|
||||
|
||||
|
||||
def encrypt(sbox: str, key: bytes, ns: Words) -> Words: ...
|
||||
|
||||
|
||||
def decrypt(sbox: str, key: bytes, ns: Words) -> Words: ...
|
||||
|
||||
|
||||
def ecb(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
action: Callable[[str, bytes, Words], Words],
|
||||
sbox: str = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def ecb_encrypt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
sbox: str = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def ecb_decrypt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
sbox: str = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def cbc_encrypt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
iv: bytes = ...,
|
||||
pad: bool = ...,
|
||||
sbox: str = ...,
|
||||
mesh: bool = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def cbc_decrypt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
pad: bool = ...,
|
||||
sbox: str = ...,
|
||||
mesh: bool = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def cnt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
iv: bytes = ...,
|
||||
sbox: str = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def cfb_encrypt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
iv: bytes = ...,
|
||||
sbox: str = ...,
|
||||
mesh: bool = ...,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def cfb_decrypt(
|
||||
key: bytes,
|
||||
data: bytes,
|
||||
iv: bytes = ...,
|
||||
sbox: str = ...,
|
||||
mesh: bool = ...,
|
||||
) -> bytes: ...
|
||||
@@ -0,0 +1,25 @@
|
||||
from pygost.iface import PEP247
|
||||
|
||||
|
||||
class MAC(PEP247):
|
||||
def __init__(
|
||||
self,
|
||||
key: bytes,
|
||||
data: bytes = ...,
|
||||
iv: bytes = ...,
|
||||
sbox: str = ...,
|
||||
) -> None: ...
|
||||
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
def copy(self) -> "MAC": ...
|
||||
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
def digest(self) -> bytes: ...
|
||||
|
||||
def hexdigest(self) -> str: ...
|
||||
|
||||
|
||||
def new(key: bytes, data: bytes = ..., iv: bytes = ..., sbox: str = ...) -> MAC: ...
|
||||
@@ -0,0 +1,72 @@
|
||||
from typing import Dict
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
DEFAULT_CURVE = ... # type: GOST3410Curve
|
||||
CURVES = ... # type: Dict[str, GOST3410Curve]
|
||||
PublicKey = Tuple[int, int]
|
||||
|
||||
|
||||
class GOST3410Curve(object):
|
||||
p = ... # type: int
|
||||
q = ... # type: int
|
||||
a = ... # type: int
|
||||
b = ... # type: int
|
||||
x = ... # type: int
|
||||
y = ... # type: int
|
||||
cofactor = ... # type: int
|
||||
e = ... # type: int
|
||||
d = ... # type: int
|
||||
name = ... # type: str
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
p: int,
|
||||
q: int,
|
||||
a: int,
|
||||
b: int,
|
||||
x: int,
|
||||
y: int,
|
||||
cofactor: int = 1,
|
||||
e: int = None,
|
||||
d: int = None,
|
||||
name: str = None,
|
||||
) -> None: ...
|
||||
|
||||
def pos(self, v: int) -> int: ...
|
||||
|
||||
def exp(self, degree: int, x: int = ..., y: int = ...) -> int: ...
|
||||
|
||||
def st(self) -> Tuple[int, int]: ...
|
||||
|
||||
@property
|
||||
def point_size(self) -> int: ...
|
||||
|
||||
def contains(self, point: Tuple[int, int]) -> bool: ...
|
||||
|
||||
|
||||
def public_key(curve: GOST3410Curve, prv: int) -> PublicKey: ...
|
||||
|
||||
|
||||
def sign(curve: GOST3410Curve, prv: int, digest: bytes, rand: bytes = None) -> bytes: ...
|
||||
|
||||
|
||||
def verify(curve: GOST3410Curve, pub: PublicKey, digest: bytes, signature: bytes) -> bool: ...
|
||||
|
||||
|
||||
def prv_unmarshal(prv: bytes) -> int: ...
|
||||
|
||||
|
||||
def prv_marshal(curve: GOST3410Curve, prv: int) -> bytes: ...
|
||||
|
||||
|
||||
def pub_marshal(pub: PublicKey) -> bytes: ...
|
||||
|
||||
|
||||
def pub_unmarshal(pub: bytes) -> PublicKey: ...
|
||||
|
||||
|
||||
def uv2xy(curve: GOST3410Curve, u: int, v: int) -> Tuple[int, int]: ...
|
||||
|
||||
|
||||
def xy2uv(curve: GOST3410Curve, x: int, y: int) -> Tuple[int, int]: ...
|
||||
@@ -0,0 +1,17 @@
|
||||
from pygost.gost3410 import GOST3410Curve
|
||||
from pygost.gost3410 import PublicKey
|
||||
|
||||
|
||||
def ukm_unmarshal(ukm: bytes) -> int: ...
|
||||
|
||||
|
||||
def kek(curve: GOST3410Curve, prv: int, pub: PublicKey, ukm: int) -> bytes: ...
|
||||
|
||||
|
||||
def kek_34102001(curve: GOST3410Curve, prv: int, pub: PublicKey, ukm: int) -> bytes: ...
|
||||
|
||||
|
||||
def kek_34102012256(curve: GOST3410Curve, prv: int, pub: PublicKey, ukm: int = ...) -> bytes: ...
|
||||
|
||||
|
||||
def kek_34102012512(curve: GOST3410Curve, prv: int, pub: PublicKey, ukm: int = ...) -> bytes: ...
|
||||
@@ -0,0 +1,18 @@
|
||||
from pygost.iface import PEP247
|
||||
|
||||
|
||||
class GOST34112012(PEP247):
|
||||
block_size = ... # type: int
|
||||
|
||||
def __init__(self, data: bytes = ..., digest_size: int = ...) -> None: ...
|
||||
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
def copy(self) -> "GOST34112012": ...
|
||||
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
def digest(self) -> bytes: ...
|
||||
|
||||
def hexdigest(self) -> str: ...
|
||||
@@ -0,0 +1,21 @@
|
||||
from pygost.iface import PEP247
|
||||
|
||||
|
||||
class GOST34112012256(PEP247):
|
||||
block_size = ... # type: int
|
||||
|
||||
def __init__(self, data: bytes = ...) -> None: ...
|
||||
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
def copy(self) -> "GOST34112012256": ...
|
||||
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
def digest(self) -> bytes: ...
|
||||
|
||||
def hexdigest(self) -> str: ...
|
||||
|
||||
|
||||
def new(data: bytes = ...) -> GOST34112012256: ...
|
||||
@@ -0,0 +1,24 @@
|
||||
from pygost.iface import PEP247
|
||||
|
||||
|
||||
class GOST34112012512(PEP247):
|
||||
block_size = ... # type: int
|
||||
|
||||
def __init__(self, data: bytes = ...) -> None: ...
|
||||
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
def copy(self) -> "GOST34112012512": ...
|
||||
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
def digest(self) -> bytes: ...
|
||||
|
||||
def hexdigest(self) -> str: ...
|
||||
|
||||
|
||||
def new(data: bytes = ...) -> GOST34112012512: ...
|
||||
|
||||
|
||||
def pbkdf2(password: bytes, salt: bytes, iterations: int, dklen: int) -> bytes: ...
|
||||
@@ -0,0 +1,25 @@
|
||||
from pygost.iface import PEP247
|
||||
|
||||
|
||||
class GOST341194(PEP247):
|
||||
sbox = ... # type: str
|
||||
block_size = ... # type: int
|
||||
|
||||
def __init__(self, data: bytes = ..., sbox: str = ...) -> None: ...
|
||||
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
def copy(self) -> "GOST341194": ...
|
||||
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
def digest(self) -> bytes: ...
|
||||
|
||||
def hexdigest(self) -> str: ...
|
||||
|
||||
|
||||
def new(data: bytes = ..., sbox: str = ...) -> GOST341194: ...
|
||||
|
||||
|
||||
def pbkdf2(password: bytes, salt: bytes, iterations: int, dklen: int) -> bytes: ...
|
||||
@@ -0,0 +1,18 @@
|
||||
class GOST3412Kuznechik(object):
|
||||
blocksize = ... # type: int
|
||||
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
|
||||
def encrypt(self, blk: bytes) -> bytes: ...
|
||||
|
||||
def decrypt(self, blk: bytes) -> bytes: ...
|
||||
|
||||
|
||||
class GOST3412Magma(object):
|
||||
blocksize = ... # type: int
|
||||
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
|
||||
def encrypt(self, blk: bytes) -> bytes: ...
|
||||
|
||||
def decrypt(self, blk: bytes) -> bytes: ...
|
||||
@@ -0,0 +1,81 @@
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def pad_size(data_size: int, blocksize: int) -> int: ...
|
||||
|
||||
|
||||
def pad1(data: bytes, blocksize: int) -> bytes: ...
|
||||
|
||||
|
||||
def pad2(data: bytes, blocksize: int) -> bytes: ...
|
||||
|
||||
|
||||
def unpad2(data: bytes, blocksize: int) -> bytes: ...
|
||||
|
||||
|
||||
def pad3(data: bytes, blocksize: int) -> bytes: ...
|
||||
|
||||
|
||||
def ecb_encrypt(encrypter: Callable[[bytes], bytes], bs: int, pt: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def ecb_decrypt(decrypter: Callable[[bytes], bytes], bs: int, ct: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def acpkm(encrypter: Callable[[bytes], bytes], bs: int) -> bytes: ...
|
||||
|
||||
|
||||
def ctr(encrypter: Callable[[bytes], bytes], bs: int, data: bytes, iv: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def ctr_acpkm(
|
||||
algo_class: object,
|
||||
encrypter: Callable[[bytes], bytes],
|
||||
section_size: int,
|
||||
bs: int,
|
||||
data: bytes,
|
||||
iv: bytes,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def ofb(encrypter: Callable[[bytes], bytes], bs: int, data: bytes, iv: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def cbc_encrypt(encrypter: Callable[[bytes], bytes], bs: int, pt: bytes, iv: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def cbc_decrypt(decrypter: Callable[[bytes], bytes], bs: int, ct: bytes, iv: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def cfb_encrypt(encrypter: Callable[[bytes], bytes], bs: int, pt: bytes, iv: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def cfb_decrypt(encrypter: Callable[[bytes], bytes], bs: int, ct: bytes, iv: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def mac(encrypter: Callable[[bytes], bytes], bs: int, data: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def acpkm_master(
|
||||
algo_class: object,
|
||||
encrypter: Callable[[bytes], bytes],
|
||||
key_section_size: int,
|
||||
bs: int,
|
||||
keymat_len: int,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def mac_acpkm_master(
|
||||
algo_class: object,
|
||||
encrypter: Callable[[bytes], bytes],
|
||||
key_section_size: int,
|
||||
section_size: int,
|
||||
bs: int,
|
||||
data: bytes,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def pad_iso10126(data: bytes, blocksize: int) -> bytes: ...
|
||||
|
||||
|
||||
def unpad_iso10126(data: bytes, blocksize: int) -> bytes: ...
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
from abc import ABCMeta
|
||||
from abc import abstractmethod
|
||||
|
||||
|
||||
class PEP247(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
@abstractmethod
|
||||
def copy(self) -> "PEP247": ...
|
||||
|
||||
@abstractmethod
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
@abstractmethod
|
||||
def digest(self) -> bytes: ...
|
||||
|
||||
def hexdigest(self) -> str: ...
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
from typing import Sequence
|
||||
from typing import Tuple
|
||||
|
||||
from pygost.gost3410 import GOST3410Curve
|
||||
|
||||
|
||||
PublicKey = Tuple[int, int]
|
||||
|
||||
|
||||
def kdf_gostr3411_2012_256(key: bytes, label: bytes, seed: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def kdf_tree_gostr3411_2012_256(
|
||||
key: bytes,
|
||||
label: bytes,
|
||||
seed: bytes,
|
||||
keys: int,
|
||||
i_len: int = 1,
|
||||
) -> Sequence[bytes]: ...
|
||||
|
||||
|
||||
def keg(curve: GOST3410Curve, prv: int, pub: PublicKey, h: bytes) -> bytes: ...
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def nonce_prepare(nonce: bytes) -> bytes: ...
|
||||
|
||||
|
||||
class MGM(object):
|
||||
def __init__(
|
||||
self,
|
||||
encrypter: Callable[[bytes], bytes],
|
||||
bs: int,
|
||||
tag_size: int = None,
|
||||
) -> None: ...
|
||||
|
||||
def seal(self, nonce: bytes, plaintext: bytes, additional_data: bytes) -> bytes: ...
|
||||
|
||||
def open(self, nonce: bytes, ciphertext: bytes, additional_data: bytes) -> bytes: ...
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
from typing import AnyStr
|
||||
|
||||
|
||||
def strxor(a: bytes, b: bytes) -> bytes: ...
|
||||
|
||||
|
||||
def hexdec(data: AnyStr) -> bytes: ...
|
||||
|
||||
|
||||
def hexenc(data: bytes) -> str: ...
|
||||
|
||||
|
||||
def bytes2long(raw: bytes) -> int: ...
|
||||
|
||||
|
||||
def long2bytes(n: int, size: int = ...) -> bytes: ...
|
||||
|
||||
|
||||
def modinvert(a: int, n: int) -> int: ...
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def wrap_gost(ukm: bytes, kek: bytes, cek: bytes, sbox: str = ...) -> bytes: ...
|
||||
|
||||
|
||||
def unwrap_gost(kek: bytes, data: bytes, sbox: str = ...) -> bytes: ...
|
||||
|
||||
|
||||
def wrap_cryptopro(ukm: bytes, kek: bytes, cek: bytes, sbox: str = ...) -> bytes: ...
|
||||
|
||||
|
||||
def unwrap_cryptopro(kek: bytes, data: bytes, sbox: str = ...) -> bytes: ...
|
||||
|
||||
|
||||
def kexp15(
|
||||
encrypter_key: Callable[[bytes], bytes],
|
||||
encrypter_mac: Callable[[bytes], bytes],
|
||||
bs: int,
|
||||
key: bytes,
|
||||
iv: bytes,
|
||||
) -> bytes: ...
|
||||
|
||||
|
||||
def kimp15(
|
||||
encrypter_key: Callable[[bytes], bytes],
|
||||
encrypter_mac: Callable[[bytes], bytes],
|
||||
bs: int,
|
||||
kexp: bytes,
|
||||
iv: bytes,
|
||||
) -> bytes: ...
|
||||
Reference in New Issue
Block a user