Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"stubs/tensorflow",
"stubs/tqdm",
"stubs/vobject",
"stubs/wolfcrypt",
"stubs/workalendar",
"stubs/xmldiff",
],
Expand Down
2 changes: 2 additions & 0 deletions stubs/wolfcrypt/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "5.8.*"
upstream_repository = "https://github.com/wolfssl/wolfcrypt-py"
30 changes: 30 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from wolfcrypt._version import __version__ as __version__

__all__ = [
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
"__copyright__",
"ciphers",

Check failure on line 12 in stubs/wolfcrypt/wolfcrypt/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"ciphers" is specified in __all__ but is not present in module (reportUnsupportedDunderAll)
"hashes",

Check failure on line 13 in stubs/wolfcrypt/wolfcrypt/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"hashes" is specified in __all__ but is not present in module (reportUnsupportedDunderAll)
"random",

Check failure on line 14 in stubs/wolfcrypt/wolfcrypt/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"random" is specified in __all__ but is not present in module (reportUnsupportedDunderAll)
"pwdbased",

Check failure on line 15 in stubs/wolfcrypt/wolfcrypt/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

"pwdbased" is specified in __all__ but is not present in module (reportUnsupportedDunderAll)
]

__title__: str
__summary__: str
__uri__: str
__author__: str
__email__: str
__license__: str
__copyright__: str

# Names in __all__ with no definition:
# ciphers
# hashes
# pwdbased
# random
3 changes: 3 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/_ffi.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import _cffi_backend

ffi: _cffi_backend.FFI
2 changes: 2 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__wolfssl_version__: str
__version__: str
7 changes: 7 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/asn.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from wolfcrypt.hashed import _Hash

Check failure on line 1 in stubs/wolfcrypt/wolfcrypt/asn.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Import "wolfcrypt.hashed" could not be resolved (reportMissingImports)

def pem_to_der(pem:bytes, pem_type:int)->bytes: ...
def der_to_pem(der:bytes, pem_type:int)->bytes: ...
def hash_oid_from_class(hash_cls: type[_Hash])->int: ...
def make_signature(data: bytes, hash_cls:type[_Hash], key:str|bytes=None)->bytes: ...

Check failure on line 6 in stubs/wolfcrypt/wolfcrypt/asn.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Expression of type "None" cannot be assigned to parameter of type "str | bytes"   Type "None" is not assignable to type "str | bytes"     "None" is not assignable to "str"     "None" is not assignable to "bytes" (reportArgumentType)
def check_signature(signature: bytes, data:bytes, hash_cls:type[_Hash], pub_key)->bool: ...
280 changes: 280 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/ciphers.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
from _typeshed import Incomplete
from enum import IntEnum

MODE_ECB: int
MODE_CBC: int
MODE_CFB: int
MODE_OFB: int
MODE_CTR: int
ECC_CURVE_INVALID: int
ECC_CURVE_DEF: int
ECC_SECP192R1: int
ECC_PRIME192V2: int
ECC_PRIME192V3: int
ECC_PRIME239V1: int
ECC_PRIME239V2: int
ECC_PRIME239V3: int
ECC_SECP256R1: int
ECC_SECP112R1: int
ECC_SECP112R2: int
ECC_SECP128R1: int
ECC_SECP128R2: int
ECC_SECP160R1: int
ECC_SECP160R2: int
ECC_SECP224R1: int
ECC_SECP384R1: int
ECC_SECP521R1: int
ECC_SECP160K1: int
ECC_SECP192K1: int
ECC_SECP224K1: int
ECC_SECP256K1: int
ECC_BRAINPOOLP160R1: int
ECC_BRAINPOOLP192R1: int
ECC_BRAINPOOLP224R1: int
ECC_BRAINPOOLP256R1: int
ECC_BRAINPOOLP320R1: int
ECC_BRAINPOOLP384R1: int
ECC_BRAINPOOLP512R1: int
MGF1NONE: Incomplete
MGF1SHA1: Incomplete
MGF1SHA224: Incomplete
MGF1SHA256: Incomplete
MGF1SHA384: Incomplete
MGF1SHA512: Incomplete
HASH_TYPE_NONE: Incomplete
HASH_TYPE_MD2: Incomplete
HASH_TYPE_MD4: Incomplete
HASH_TYPE_MD5: Incomplete
HASH_TYPE_SHA: Incomplete
HASH_TYPE_SHA224: Incomplete
HASH_TYPE_SHA256: Incomplete
HASH_TYPE_SHA384: Incomplete
HASH_TYPE_SHA512: Incomplete
HASH_TYPE_MD5_SHA: Incomplete
HASH_TYPE_SHA3_224: Incomplete
HASH_TYPE_SHA3_256: Incomplete
HASH_TYPE_SHA3_384: Incomplete
HASH_TYPE_SHA3_512: Incomplete
HASH_TYPE_BLAKE2B: Incomplete
HASH_TYPE_BLAKE2S: Incomplete

class _Cipher:
mode: Incomplete
def __init__(self, key, mode, IV=None) -> None: ...
@classmethod
def new(cls, key, mode, IV=None, **kwargs): ...
def encrypt(self, string): ...
def decrypt(self, string): ...

class Aes(_Cipher):
block_size: int
key_size: Incomplete

class AesGcmStream:
block_size: int
def __init__(self, key, IV, tag_bytes: int = 16) -> None: ...
def set_aad(self, data) -> None: ...
def get_aad(self): ...
def encrypt(self, data): ...
def decrypt(self, data): ...
def final(self, authTag=None): ...

class ChaCha(_Cipher):
block_size: int
key_size: Incomplete
def __init__(self, key: str = "", size: int = 32) -> None: ...
def set_iv(self, nonce, counter: int = 0) -> None: ...

class ChaCha20Poly1305:
block_size: int
def __init__(self, key, IV, aad, tag_bytes: int = 16) -> None: ...
def set_aad(self, data) -> None: ...
def get_aad(self): ...
def encrypt(self, inPlainText): ...
def decrypt(self, inGeneratedAuthTag, inGeneratedCipher): ...
def checkTag(self, authTag) -> None: ...
def final(self, authTag=None): ...

class Des3(_Cipher):
block_size: int
key_size: int

class _Rsa:
RSA_MIN_PAD_SIZE: int
native_object: Incomplete
def __init__(self) -> None: ...
def __del__(self) -> None: ...
def set_mgf(self, mgf) -> None: ...

class RsaPublic(_Rsa):
output_size: Incomplete
size: Incomplete
def __init__(self, key=None, hash_type=None) -> None: ...
@classmethod
def from_pem(cls, file, hash_type=None): ...
def encrypt(self, plaintext): ...
def encrypt_oaep(self, plaintext, label: str = ""): ...
def verify(self, signature): ...
def verify_pss(self, plaintext, signature): ...

class RsaPrivate(RsaPublic):
@classmethod
def make_key(cls, size, rng=..., hash_type=None): ...
size: Incomplete
output_size: Incomplete
def __init__(self, key=None, hash_type=None) -> None: ...
@classmethod
def from_pem(cls, file, hash_type=None): ...
def encode_key(self): ...
def decrypt(self, ciphertext): ...
def decrypt_oaep(self, ciphertext, label: str = ""): ...
def sign(self, plaintext): ...
def sign_pss(self, plaintext): ...

class _Ecc:
native_object: Incomplete
def __init__(self) -> None: ...
def __del__(self) -> None: ...
@property
def size(self): ...
@property
def max_signature_size(self): ...

class EccPublic(_Ecc):
def __init__(self, key=None) -> None: ...
def decode_key(self, key) -> None: ...
def decode_key_raw(self, qx, qy, curve_id=7) -> None: ...
def encode_key(self, with_curve: bool = True): ...
def encode_key_raw(self): ...
def import_x963(self, x963) -> None: ...
def export_x963(self): ...
def verify(self, signature, data): ...
def verify_raw(self, R, S, data): ...

class EccPrivate(EccPublic):
@classmethod
def make_key(cls, size, rng=...): ...
def decode_key(self, key) -> None: ...
def decode_key_raw(self, qx, qy, d, curve_id=7) -> None: ...
def encode_key(self): ...
def encode_key_raw(self): ...
def shared_secret(self, peer): ...
def sign(self, plaintext, rng=...): ...
def sign_raw(self, plaintext, rng=...): ...

class _Ed25519:
native_object: Incomplete
def __init__(self) -> None: ...
def __del__(self) -> None: ...
@property
def size(self): ...
@property
def max_signature_size(self): ...

class Ed25519Public(_Ed25519):
def __init__(self, key=None) -> None: ...
def decode_key(self, key) -> None: ...
def encode_key(self): ...
def verify(self, signature, data): ...

class Ed25519Private(Ed25519Public):
def __init__(self, key=None, pub=None) -> None: ...
@classmethod
def make_key(cls, size, rng=...): ...
def decode_key(self, key, pub=None) -> None: ...
def encode_key(self): ...
def sign(self, plaintext): ...

class _Ed448:
native_object: Incomplete
def __init__(self) -> None: ...
def __del__(self) -> None: ...
@property
def size(self): ...
@property
def max_signature_size(self): ...

class Ed448Public(_Ed448):
def __init__(self, key=None) -> None: ...
def decode_key(self, key) -> None: ...
def encode_key(self): ...
def verify(self, signature, data, ctx=None): ...

class Ed448Private(Ed448Public):
def __init__(self, key=None, pub=None) -> None: ...
@classmethod
def make_key(cls, size, rng=...): ...
def decode_key(self, key, pub=None) -> None: ...
def encode_key(self): ...
def sign(self, plaintext, ctx=None): ...

class MlKemType(IntEnum):
ML_KEM_512 = ...
ML_KEM_768 = ...
ML_KEM_1024 = ...

class _MlKemBase:
INVALID_DEVID: Incomplete
init_done: bool
native_object: Incomplete
def __init__(self, mlkem_type) -> None: ...
def __del__(self) -> None: ...
@property
def ct_size(self): ...
@property
def ss_size(self): ...

class MlKemPublic(_MlKemBase):
@property
def key_size(self): ...
def encode_key(self): ...
def decode_key(self, pub_key) -> None: ...
def encapsulate(self, rng=...): ...
def encapsulate_with_random(self, rand): ...

class MlKemPrivate(_MlKemBase):
@classmethod
def make_key(cls, mlkem_type, rng=...): ...
@classmethod
def make_key_with_random(cls, mlkem_type, rand): ...
@property
def pub_key_size(self): ...
@property
def priv_key_size(self): ...
def encode_pub_key(self): ...
def encode_priv_key(self): ...
def decode_key(self, priv_key: tuple[bytes, str]): ...
native_object: Incomplete
def decapsulate(self, ct): ...

class MlDsaType(IntEnum):
ML_DSA_44 = ...
ML_DSA_65 = ...
ML_DSA_87 = ...

class _MlDsaBase:
INVALID_DEVID: Incomplete
native_object: Incomplete
def __init__(self, mldsa_type) -> None: ...
def __del__(self) -> None: ...
@property
def sig_size(self): ...
def verify(self, signature, message): ...

class MlDsaPrivate(_MlDsaBase):
@classmethod
def make_key(cls, mldsa_type, rng=...): ...
@property
def pub_key_size(self): ...
@property
def priv_key_size(self): ...
def encode_pub_key(self): ...
def encode_priv_key(self): ...
def decode_key(self, priv_key, pub_key=None) -> None: ...
def sign(self, message, rng=...): ...

class MlDsaPublic(_MlDsaBase):
@property
def key_size(self): ...
def decode_key(self, pub_key): ...
def encode_key(self): ...
1 change: 1 addition & 0 deletions stubs/wolfcrypt/wolfcrypt/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class WolfCryptError(Exception): ...
49 changes: 49 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/hashes.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class _Hash:
def __init__(self, string: str|None=None) -> None: ...
@classmethod
def new(cls, string:str|None=None): ...
def copy(self): ...
def update(self, string: str|None) -> None: ...
def digest(self)->bytes: ...
def hexdigest(self)-> bytes: ...

class Sha(_Hash):
digest_size: int

class Sha256(_Hash):
digest_size: int

class Sha384(_Hash):
digest_size: int

class Sha512(_Hash):
digest_size: int

class Sha3(_Hash):
SHA3_224_DIGEST_SIZE: int
SHA3_256_DIGEST_SIZE: int
SHA3_384_DIGEST_SIZE: int
SHA3_512_DIGEST_SIZE: int
digest_size: int
def __init__(self) -> None: ...

Check failure on line 28 in stubs/wolfcrypt/wolfcrypt/hashes.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Method declaration "__init__" is obscured by a declaration of the same name (reportRedeclaration)
def __init__(self, string: str, size=...) -> None: ...

class _Hmac(_Hash):
digest_size: int
def __init__(self, key:str|bytes, string:str|None=None) -> None: ...
@classmethod
def new(cls, key:str|bytes, string:str|None=None): ...

class HmacSha(_Hmac):
digest_size: int

class HmacSha256(_Hmac):
digest_size: int

class HmacSha384(_Hmac):
digest_size: int

class HmacSha512(_Hmac):
digest_size: int

def hash_type_to_cls(hash_type: int)->type[_Hash]: ...
1 change: 1 addition & 0 deletions stubs/wolfcrypt/wolfcrypt/pwdbased.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def PBKDF2(password, salt, iterations, key_length, hash_type): ...
5 changes: 5 additions & 0 deletions stubs/wolfcrypt/wolfcrypt/random.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Random:
def __init__(self) -> None: ...
def __del__(self) -> None: ...
def byte(self): list[int]: ...

Check failure on line 4 in stubs/wolfcrypt/wolfcrypt/random.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type annotation not supported for this statement (reportInvalidTypeForm)
def bytes(self, length:int)-> list[int]: ...
1 change: 1 addition & 0 deletions stubs/wolfcrypt/wolfcrypt/utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def t2b(string: str| bytes) -> bytes: ...
Loading