wolfcrypt-py/wolfcrypt/_ffi/lib.pyi

624 lines
24 KiB
Python

# lib.pyi
#
# Copyright (C) 2026 wolfSSL Inc.
#
# This file is part of wolfSSL. (formerly known as CyaSSL)
#
# wolfSSL is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# wolfSSL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from collections.abc import Callable
from dataclasses import dataclass
from typing import TypeAlias
from _cffi_backend import FFI
INVALID_DEVID: int
AES_ENABLED: int
AES_SIV_ENABLED: int
AESGCM_STREAM_ENABLED: int
ASN_ENABLED: int
CHACHA_ENABLED: int
CHACHA_STREAM_ENABLED: int
CHACHA20_POLY1305_ENABLED: int
CRYPTO_CB_ENABLED: int
DES3_ENABLED: int
ECC_ENABLED: int
ED25519_ENABLED: int
ED448_ENABLED: int
ERROR_STRINGS_ENABLED: int
FIPS_ENABLED: int
HMAC_ENABLED: int
KEYGEN_ENABLED: int
HKDF_ENABLED: int
ML_DSA_ENABLED: int
ML_DSA_NO_CTX_ENABLED: int
ML_KEM_ENABLED: int
MPAPI_ENABLED: int
PWDBASED_ENABLED: int
RSA_ENABLED: int
RSA_BLINDING_ENABLED: int
RSA_PSS_ENABLED: int
SHA_ENABLED: int
SHA3_ENABLED: int
SHA256_ENABLED: int
SHA384_ENABLED: int
SHA512_ENABLED: int
WC_RNG_SEED_CB_ENABLED: int
HASHDRBG_ENABLED: int
# Error codes
WC_FAILURE: int
MAX_CODE_E: int
WC_FIRST_E: int
WC_SPAN1_FIRST_E: int
MP_MEM: int
MP_VAL: int
MP_WOULDBLOCK: int
MP_NOT_INF: int
OPEN_RAN_E: int
READ_RAN_E: int
WINCRYPT_E: int
CRYPTGEN_E: int
RAN_BLOCK_E: int
BAD_MUTEX_E: int
WC_TIMEOUT_E: int
WC_PENDING_E: int
WC_NO_PENDING_E: int
MP_INIT_E: int
MP_READ_E: int
MP_EXPTMOD_E: int
MP_TO_E: int
MP_SUB_E: int
MP_ADD_E: int
MP_MUL_E: int
MP_MULMOD_E: int
MP_MOD_E: int
MP_INVMOD_E: int
MP_CMP_E: int
MP_ZERO_E: int
AES_EAX_AUTH_E: int
KEY_EXHAUSTED_E: int
MEMORY_E: int
VAR_STATE_CHANGE_E: int
FIPS_DEGRADED_E: int
FIPS_CODE_SZ_E: int
FIPS_DATA_SZ_E: int
RSA_WRONG_TYPE_E: int
RSA_BUFFER_E: int
BUFFER_E: int
ALGO_ID_E: int
PUBLIC_KEY_E: int
DATE_E: int
SUBJECT_E: int
ISSUER_E: int
CA_TRUE_E: int
EXTENSIONS_E: int
ASN_PARSE_E: int
ASN_VERSION_E: int
ASN_GETINT_E: int
ASN_RSA_KEY_E: int
ASN_OBJECT_ID_E: int
ASN_TAG_NULL_E: int
ASN_EXPECT_0_E: int
ASN_BITSTR_E: int
ASN_UNKNOWN_OID_E: int
ASN_DATE_SZ_E: int
ASN_BEFORE_DATE_E: int
ASN_AFTER_DATE_E: int
ASN_SIG_OID_E: int
ASN_TIME_E: int
ASN_INPUT_E: int
ASN_SIG_CONFIRM_E: int
ASN_SIG_HASH_E: int
ASN_SIG_KEY_E: int
ASN_DH_KEY_E: int
KDF_SRTP_KAT_FIPS_E: int
ASN_CRIT_EXT_E: int
ASN_ALT_NAME_E: int
ASN_NO_PEM_HEADER: int
ED25519_KAT_FIPS_E: int
ED448_KAT_FIPS_E: int
PBKDF2_KAT_FIPS_E: int
WC_KEY_MISMATCH_E: int
ECC_BAD_ARG_E: int
ASN_ECC_KEY_E: int
ECC_CURVE_OID_E: int
BAD_FUNC_ARG: int
NOT_COMPILED_IN: int
UNICODE_SIZE_E: int
NO_PASSWORD: int
ALT_NAME_E: int
BAD_OCSP_RESPONDER: int
CRL_CERT_DATE_ERR: int
AES_GCM_AUTH_E: int
AES_CCM_AUTH_E: int
ASYNC_INIT_E: int
COMPRESS_INIT_E: int
COMPRESS_E: int
DECOMPRESS_INIT_E: int
DECOMPRESS_E: int
BAD_ALIGN_E: int
ASN_NO_SIGNER_E: int
ASN_CRL_CONFIRM_E: int
ASN_CRL_NO_SIGNER_E: int
ASN_OCSP_CONFIRM_E: int
BAD_STATE_E: int
BAD_PADDING_E: int
REQ_ATTRIBUTE_E: int
PKCS7_OID_E: int
PKCS7_RECIP_E: int
FIPS_NOT_ALLOWED_E: int
ASN_NAME_INVALID_E: int
RNG_FAILURE_E: int
HMAC_MIN_KEYLEN_E: int
RSA_PAD_E: int
LENGTH_ONLY_E: int
IN_CORE_FIPS_E: int
AES_KAT_FIPS_E: int
DES3_KAT_FIPS_E: int
HMAC_KAT_FIPS_E: int
RSA_KAT_FIPS_E: int
DRBG_KAT_FIPS_E: int
DRBG_CONT_FIPS_E: int
AESGCM_KAT_FIPS_E: int
THREAD_STORE_KEY_E: int
THREAD_STORE_SET_E: int
MAC_CMP_FAILED_E: int
IS_POINT_E: int
ECC_INF_E: int
ECC_PRIV_KEY_E: int
ECC_OUT_OF_RANGE_E: int
SRP_CALL_ORDER_E: int
SRP_VERIFY_E: int
SRP_BAD_KEY_E: int
ASN_NO_SKID: int
ASN_NO_AKID: int
ASN_NO_KEYUSAGE: int
SKID_E: int
AKID_E: int
KEYUSAGE_E: int
CERTPOLICIES_E: int
WC_INIT_E: int
SIG_VERIFY_E: int
BAD_COND_E: int
SIG_TYPE_E: int
HASH_TYPE_E: int
FIPS_INVALID_VER_E: int
WC_KEY_SIZE_E: int
ASN_COUNTRY_SIZE_E: int
MISSING_RNG_E: int
ASN_PATHLEN_SIZE_E: int
ASN_PATHLEN_INV_E: int
BAD_KEYWRAP_ALG_E: int
BAD_KEYWRAP_IV_E: int
WC_CLEANUP_E: int
ECC_CDH_KAT_FIPS_E: int
DH_CHECK_PUB_E: int
BAD_PATH_ERROR: int
ASYNC_OP_E: int
ECC_PRIVATEONLY_E: int
EXTKEYUSAGE_E: int
WC_HW_E: int
WC_HW_WAIT_E: int
PSS_SALTLEN_E: int
PRIME_GEN_E: int
BER_INDEF_E: int
RSA_OUT_OF_RANGE_E: int
RSAPSS_PAT_FIPS_E: int
ECDSA_PAT_FIPS_E: int
DH_KAT_FIPS_E: int
AESCCM_KAT_FIPS_E: int
SHA3_KAT_FIPS_E: int
ECDHE_KAT_FIPS_E: int
AES_GCM_OVERFLOW_E: int
AES_CCM_OVERFLOW_E: int
RSA_KEY_PAIR_E: int
DH_CHECK_PRIV_E: int
WC_AFALG_SOCK_E: int
WC_DEVCRYPTO_E: int
ZLIB_INIT_ERROR: int
ZLIB_COMPRESS_ERROR: int
ZLIB_DECOMPRESS_ERROR: int
PKCS7_NO_SIGNER_E: int
WC_PKCS7_WANT_READ_E: int
CRYPTOCB_UNAVAILABLE: int
PKCS7_SIGNEEDS_CHECK: int
PSS_SALTLEN_RECOVER_E: int
CHACHA_POLY_OVERFLOW: int
ASN_SELF_SIGNED_E: int
SAKKE_VERIFY_FAIL_E: int
MISSING_IV: int
MISSING_KEY: int
BAD_LENGTH_E: int
ECDSA_KAT_FIPS_E: int
RSA_PAT_FIPS_E: int
KDF_TLS12_KAT_FIPS_E: int
KDF_TLS13_KAT_FIPS_E: int
KDF_SSH_KAT_FIPS_E: int
DHE_PCT_E: int
ECC_PCT_E: int
FIPS_PRIVATE_KEY_LOCKED_E: int
PROTOCOLCB_UNAVAILABLE: int
AES_SIV_AUTH_E: int
NO_VALID_DEVID: int
IO_FAILED_E: int
SYSLIB_FAILED_E: int
USE_HW_PSK: int
ENTROPY_RT_E: int
ENTROPY_APT_E: int
ASN_DEPTH_E: int
ASN_LEN_E: int
SM4_GCM_AUTH_E: int
SM4_CCM_AUTH_E: int
WC_SPAN1_LAST_E: int
WC_SPAN1_MIN_CODE_E: int
WC_SPAN2_FIRST_E: int
DEADLOCK_AVERTED_E: int
ASCON_AUTH_E: int
WC_ACCEL_INHIBIT_E: int
BAD_INDEX_E: int
INTERRUPTED_E: int
WC_SPAN2_LAST_E: int
WC_LAST_E: int
WC_SPAN2_MIN_CODE_E: int
MIN_CODE_E: int
# end of the error codes
FIPS_VERSION: int
WC_MGF1NONE: int
WC_MGF1SHA1: int
WC_MGF1SHA224: int
WC_MGF1SHA256: int
WC_MGF1SHA384: int
WC_MGF1SHA512: int
WC_ALGO_TYPE_NONE: int
WC_ALGO_TYPE_HASH: int
WC_ALGO_TYPE_CIPHER: int
WC_ALGO_TYPE_PK: int
WC_ALGO_TYPE_RNG: int
WC_ALGO_TYPE_SEED: int
WC_ALGO_TYPE_HMAC: int
WC_ALGO_TYPE_CMAC: int
WC_ALGO_TYPE_CERT: int
WC_ALGO_TYPE_KDF: int
WC_ALGO_TYPE_COPY: int
WC_ALGO_TYPE_FREE: int
WC_ALGO_TYPE_MAX: int
WC_HASH_TYPE_NONE: int
WC_HASH_TYPE_MD2: int
WC_HASH_TYPE_MD4: int
WC_HASH_TYPE_MD5: int
WC_HASH_TYPE_SHA: int
WC_HASH_TYPE_SHA224: int
WC_HASH_TYPE_SHA256: int
WC_HASH_TYPE_SHA384: int
WC_HASH_TYPE_SHA512: int
WC_HASH_TYPE_MD5_SHA: int
WC_HASH_TYPE_SHA3_224: int
WC_HASH_TYPE_SHA3_256: int
WC_HASH_TYPE_SHA3_384: int
WC_HASH_TYPE_SHA3_512: int
WC_HASH_TYPE_BLAKE2B: int
WC_HASH_TYPE_BLAKE2S: int
WC_ML_KEM_512: int
WC_ML_KEM_768: int
WC_ML_KEM_1024: int
WC_ML_DSA_44: int
WC_ML_DSA_65: int
WC_ML_DSA_87: int
WC_KEYTYPE_ALL: int
PRIVATEKEY_TYPE: int
PUBLICKEY_TYPE: int
CERT_TYPE: int
MAX_DER_DIGEST_SZ: int
SHAh: int
SHA256h: int
SHA384h: int
SHA512h: int
DILITHIUM_SEED_SZ: int
ECC_TIMING_RESISTANCE_ENABLED: int
WC_RSA_OAEP_PAD: int
MIN_AUTH_TAG_SZ: int
RNG: TypeAlias = FFI.CData
def wc_SetSeed_Cb(cb: FFI.CData) -> int: ...
def wolfCrypt_SetPrivateKeyReadEnable_fips(enable: int, key_type: int) -> int: ...
def wc_GetErrorString(error: int) -> FFI.CData: ...
def wolfCrypt_Init() -> int: ...
def wc_InitRngNonce_ex(rng: RNG, nonce: bytes, nonce_size: int, heap: FFI.CData, device_id: int) -> int: ...
def wc_RNG_GenerateByte(rng: RNG, buffer: FFI.CData) -> int: ...
def wc_RNG_GenerateBlock(rng: RNG, buffer: FFI.CData, len: int) -> int: ...
def wc_RNG_DRBG_Reseed(rng: RNG, seed: bytes, seed_size: int) -> int: ...
def wc_FreeRng(rng: RNG) -> None: ...
DerBufferPtr: TypeAlias = FFI.CData
EncryptedInfo: TypeAlias = FFI.CData
IntPtr: TypeAlias = FFI.CData
BytePtr: TypeAlias = FFI.CData
def wc_PemToDer(buff: bytes, buf_size: int, type: int, der: DerBufferPtr, heap: FFI.CData, info: EncryptedInfo,
key_format: IntPtr) -> int: ...
def wc_DerToPemEx(der: bytes, der_size: int, output: FFI.CData, output_size: int, cipher_info: FFI.CData,
type: int) -> int: ...
def wc_FreeDer(der: DerBufferPtr) -> None: ...
def wc_EncodeSignature(out: BytePtr, digest: bytes, digest_size: int, hash_oid: int) -> int: ...
def wc_PBKDF2(out: BytePtr, passwd: bytes, pass_len: int, salt: bytes, salt_len: int, iterations: int, keylen: int,
hash_type: int) -> int: ...
def wc_InitSha_ex(obj: FFI.CData, heap: FFI.CData, device_id: int) -> int: ...
def wc_ShaCopy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_ShaUpdate(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_ShaFinal(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_ShaFree(obj: FFI.CData) -> None: ...
def wc_InitSha256(obj: FFI.CData) -> int: ...
def wc_Sha256Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha256Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha256Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha256Free(obj: FFI.CData) -> None: ...
def wc_InitSha384(obj: FFI.CData) -> int: ...
def wc_Sha384Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha384Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha384Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha384Free(obj: FFI.CData) -> None: ...
def wc_InitSha512(obj: FFI.CData) -> int: ...
def wc_Sha512Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha512Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha512Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha512Free(obj: FFI.CData) -> None: ...
def wc_InitSha3_224(obj: FFI.CData, heap: FFI.CData, dev_id: int) -> int: ...
def wc_Sha3_224_Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha3_224_Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha3_224_Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha3_224_Free(obj: FFI.CData) -> None: ...
def wc_InitSha3_256(obj: FFI.CData, heap: FFI.CData, dev_id: int) -> int: ...
def wc_Sha3_256_Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha3_256_Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha3_256_Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha3_256_Free(obj: FFI.CData) -> None: ...
def wc_InitSha3_384(obj: FFI.CData, heap: FFI.CData, dev_id: int) -> int: ...
def wc_Sha3_384_Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha3_384_Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha3_384_Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha3_384_Free(obj: FFI.CData) -> None: ...
def wc_InitSha3_512(obj: FFI.CData, heap: FFI.CData, dev_id: int) -> int: ...
def wc_Sha3_512_Copy(src: FFI.CData, dst: FFI.CData) -> int: ...
def wc_Sha3_512_Update(obj: FFI.CData, data: bytes, size: int) -> int: ...
def wc_Sha3_512_Final(obj: FFI.CData, ret: FFI.CData) -> int: ...
def wc_Sha3_512_Free(obj: FFI.CData) -> None: ...
def wc_HmacInit(hmac: FFI.CData, heap: FFI.CData, dev_id: int) -> int: ...
def wc_HmacSetKey(hmac: FFI.CData, type: int, key: bytes, length: int) -> int: ...
def wc_HmacUpdate(hmac: FFI.CData, data: bytes, size: int) -> int: ...
def wc_HmacFinal(hmac: FFI.CData, hash: FFI.CData) -> int: ...
def wc_HmacFree(hmac: FFI.CData) -> None: ...
def wc_HKDF(type: int, in_key: bytes, in_key_size: int, salt: bytes, salt_size: int, info: bytes, info_size: int, out: FFI.CData, out_size: int) -> int: ...
def wc_HKDF_Extract(type: int, salt: bytes, salt_size: int, in_key: bytes, in_key_size: int, out: FFI.CData) -> int: ...
def wc_HKDF_Expand(type: int, in_key: bytes, in_key_size: int, info: bytes, info_size: int, out: FFI.CData, out_size: int) -> int: ...
CAes: TypeAlias = FFI.CData
CAesSivAssoc: TypeAlias = FFI.CData
def wc_AesInit(aes: CAes, heap: FFI.CData, dev_id: int) -> int: ...
def wc_AesFree(aes: CAes) -> int: ...
def wc_AesSetKey(aes: CAes, key: bytes, len: int, iv: bytes, dir: int) -> int: ...
def wc_AesCbcEncrypt(aes: CAes, ciphertext_out: BytePtr, plaintext_in: bytes, plaintext_len: int) -> int: ...
def wc_AesCbcDecrypt(aes: CAes, plaintext_out: BytePtr, ciphertext_in: bytes, ciphertext_len: int) -> int: ...
def wc_AesCtrEncrypt(aes: CAes, ciphertext_out: BytePtr, plaintext_in: bytes, plaintext_len: int) -> int: ...
def wc_AesSivEncrypt_ex(key: bytes, key_len: int, assoc: CAesSivAssoc, num_assoc: int, nonce: bytes, nonce_len: int, plaintext: bytes, plaintext_len: int, siv: BytePtr, ciphertext: BytePtr) -> int: ...
def wc_AesSivDecrypt_ex(key: bytes, key_len: int, assoc: CAesSivAssoc, num_assoc: int, nonce: bytes, nonce_len: int, ciphertext: bytes, ciphertext_len: int, siv: bytes, plaintext: BytePtr) -> int: ...
def wc_AesGcmInit(aes: CAes, key: bytes, key_len: int, iv: bytes, iv_len: int) -> int: ...
def wc_AesGcmEncryptUpdate(aes: CAes, ciphertext: BytePtr, plaintext: bytes, plaintext_len: int, auth: bytes, auth_len: int) -> int: ...
def wc_AesGcmEncryptFinal(aes: CAes, auth_tag: BytePtr, auth_tag_len: int) -> int: ...
def wc_AesGcmDecryptUpdate(aes: CAes, plaintext: BytePtr, ciphertext: bytes, ciphertext_len: int, auth: bytes, auth_len: int) -> int: ...
def wc_AesGcmDecryptFinal(aes: CAes, auth: bytes, auth_len: int) -> int: ...
ChaCha: TypeAlias = FFI.CData
def wc_Chacha_SetKey(ctx: ChaCha, key: bytes, key_len: int) -> int: ...
def wc_Chacha_SetIV(ctx: ChaCha, iv: bytes, counter: int) -> int: ...
def wc_Chacha_Process(ctx: ChaCha, cipher: BytePtr, plain: bytes, msg_len: int) -> int: ...
def wc_ChaCha20Poly1305_Encrypt(key: bytes, iv: bytes, aad: bytes, aad_len: int, plaintext: bytes, plaintext_len: int, cipher_out: BytePtr, auth_tag: BytePtr) -> int: ...
def wc_ChaCha20Poly1305_Decrypt(key: bytes, iv: bytes, aad: bytes, aad_len: int, ciphertext: bytes, ciphertext_len: int, auth_tag: bytes, plaintext_out: BytePtr) -> int: ...
DesKey: TypeAlias = FFI.CData
def wc_Des3_SetKey(des: DesKey, key: bytes, iv: bytes, dir: int) -> int: ...
def wc_Des3_CbcEncrypt(des: DesKey, out: BytePtr, message: bytes, message_len: int) -> int: ...
def wc_Des3_CbcDecrypt(des: DesKey, out: BytePtr, encrypted: bytes, encrypted_len: int) -> int: ...
RsaKey: TypeAlias = FFI.CData
def wc_InitRsaKey(key: RsaKey, heap: FFI.CData) -> int: ...
def wc_RsaSetRNG(key: RsaKey, rng: RNG) -> int: ...
def wc_FreeRsaKey(key: RsaKey) -> int: ...
def wc_RsaPublicKeyDecode(input: bytes, in_out_idx: IntPtr, key: RsaKey, input_len:int ) -> int: ...
def wc_RsaPublicEncrypt(plaintext: bytes, plaintext_len: int, out: BytePtr, out_len: int, key: RsaKey, rng: RNG) -> int: ...
def wc_RsaPublicEncrypt_ex(plaintext: bytes, plaintext_len: int, out: BytePtr, out_len: int, key: RsaKey, rng: RNG, pad_type: int, hash_type: int, mgf: int, label: bytes | BytePtr, label_len: int) -> int: ...
def wc_RsaSSL_Verify(signature: bytes, signature_len: int, out: BytePtr, out_len: int, key: RsaKey) -> int: ...
def wc_RsaPSS_Verify(signature: bytes, signature_len: int, out: BytePtr, out_len: int, hash_type: int, mgf: int, key: RsaKey) -> int: ...
def wc_RsaPSS_CheckPadding(digest: bytes, digest_len: int, sig: bytes | BytePtr, sig_len: int, hash_type: int) -> int: ...
def wc_MakeRsaKey(key: RsaKey, size: int, e: int, rng: RNG) -> int: ...
def wc_RsaPrivateKeyDecode(input: bytes, in_out_idx: IntPtr, key: RsaKey, in_len: int) -> int: ...
def wc_RsaEncryptSize(key: RsaKey) -> int: ...
def wc_RsaKeyToDer(key: RsaKey, output: BytePtr, in_len: int) -> int: ...
def wc_RsaPrivateDecrypt(ciphertext: bytes, ciphertext_len: int, out: BytePtr, out_len: int, key: RsaKey) -> int: ...
def wc_RsaPrivateDecrypt_ex(ciphertext: bytes, ciphertext_len: int, out: BytePtr, out_len: int, key: RsaKey, pad_type: int, hash_type: int, mgf: int, label: bytes | BytePtr, label_len: int) -> int: ...
def wc_RsaSSL_Sign(plaintext: bytes, plaintext_len: int, out: BytePtr, out_len: int, key: RsaKey, rng: RNG) -> int: ...
def wc_RsaPSS_Sign(digest: bytes, digest_len: int, out: BytePtr, out_len: int, hash_type: int, mgf: int, key: RsaKey, rng: RNG) -> int: ...
def wc_GetPkcs8TraditionalOffset(input: BytePtr, in_out_idx: IntPtr, size: int) -> int: ...
def wc_RsaKeyToPublicDer(key: RsaKey, output: BytePtr, in_len: int) -> int: ...
MpInt: TypeAlias = FFI.CData
def mp_init(a: MpInt) -> int: ...
def mp_clear(a: MpInt) -> None: ...
def mp_read_unsigned_bin(a: MpInt, uns: bytes, uns_len: int) -> int: ...
def mp_to_unsigned_bin_len(a: MpInt, out: BytePtr, out_len: int) -> int: ...
EccKey: TypeAlias = FFI.CData
def wc_ecc_init(key: EccKey) -> int: ...
def wc_ecc_free(key: EccKey) -> int: ...
def wc_ecc_size(key: EccKey) -> int: ...
def wc_ecc_sig_size(key: EccKey) -> int: ...
def wc_ecc_get_curve_size_from_id(curve_id: int) -> int: ...
def wc_ecc_import_unsigned(key: EccKey, qx: bytes, qy: bytes, d: bytes | FFI.CData, curve_id: int) -> int: ...
def wc_ecc_export_public_raw(key: EccKey, qx: BytePtr, qx_len: IntPtr, qy: BytePtr, qy_len: IntPtr) -> int: ...
def wc_ecc_import_x963(x963: bytes, x963_len: int, key: EccKey) -> int: ...
def wc_ecc_export_x963(key: EccKey, out: BytePtr, out_len: IntPtr) -> int: ...
def wc_ecc_verify_hash(sig: bytes, sig_len: int, hash: bytes, hash_len: int, res: IntPtr, key: EccKey) -> int: ...
def wc_ecc_verify_hash_ex(r: MpInt, s: MpInt, hash: bytes, hash_len: int, res: IntPtr, key: EccKey) -> int: ...
def wc_ecc_make_key(rng: RNG, key_size: int, key: EccKey) -> int: ...
def wc_ecc_set_rng(key: EccKey, rng: RNG) -> int: ...
def wc_ecc_sign_hash(hash: bytes, hash_len: int, out: BytePtr, out_len: IntPtr, rng: RNG, key: EccKey) -> int: ...
def wc_ecc_sign_hash_ex(hash: bytes, hash_len: int, rng: RNG, key: EccKey, r: MpInt, s: MpInt) -> int: ...
def wc_ecc_shared_secret(private_key: EccKey, public_key: EccKey, out: BytePtr, out_len: IntPtr) -> int: ...
def wc_ecc_export_private_raw(key: EccKey, qx: BytePtr, qx_len: IntPtr, qy: BytePtr, qy_len: IntPtr, d: BytePtr, d_len: IntPtr) -> int: ...
def wc_EccPublicKeyDecode(pub_der: bytes, in_out_idx: IntPtr, key: EccKey, pub_der_len: int) -> int: ...
def wc_EccPrivateKeyDecode(priv_der: bytes, in_out_idx: IntPtr, key: EccKey, priv_der_len: int) -> int: ...
def wc_EccPublicKeyToDer(key: EccKey, pub_der: BytePtr, pub_der_len: int, with_alg_curve: int) -> int: ...
def wc_EccKeyToDer(key: EccKey, priv_key_der: BytePtr, priv_key_len: int) -> int: ...
Ed25519Key: TypeAlias = FFI.CData
def wc_ed25519_make_public(key: Ed25519Key, pub_key: BytePtr, pub_key_len: int) -> int: ...
def wc_ed25519_make_key(rng: RNG, keysize: int, key: Ed25519Key) -> int: ...
def wc_ed25519_sign_msg(msg: bytes, msg_len: int, out: BytePtr, out_len: IntPtr, key: Ed25519Key) -> int: ...
def wc_ed25519_verify_msg(sig: bytes, sig_len: int, msg: bytes, msg_len: int, res: IntPtr, key: Ed25519Key) -> int: ...
def wc_ed25519_init(key: Ed25519Key) -> int: ...
def wc_ed25519_free(key: Ed25519Key) -> None: ...
def wc_ed25519_import_public(pub: bytes | BytePtr, pub_len: int, key: Ed25519Key) -> int: ...
def wc_ed25519_import_private_only(priv: bytes | BytePtr, priv_len: int, key: Ed25519Key) -> int: ...
def wc_ed25519_import_private_key(priv: bytes, priv_len: int, pub: bytes, pub_len: int, key: Ed25519Key) -> int: ...
def wc_ed25519_export_public(key: Ed25519Key, pub: BytePtr, pub_len: IntPtr) -> int: ...
def wc_ed25519_export_private_only(key: Ed25519Key, priv: BytePtr, priv_len: IntPtr) -> int: ...
def wc_ed25519_size(key: Ed25519Key) -> int: ...
def wc_ed25519_priv_size(key: Ed25519Key) -> int: ...
def wc_ed25519_pub_size(key: Ed25519Key) -> int: ...
def wc_ed25519_sig_size(key: Ed25519Key) -> int: ...
Ed448Key: TypeAlias = FFI.CData
def wc_ed448_make_public(key: Ed448Key, pub_key: BytePtr, pub_key_len: int) -> int: ...
def wc_ed448_make_key(rng: RNG, keysize: int, key: Ed448Key) -> int: ...
def wc_ed448_sign_msg(msg: bytes, msg_len: int, out: BytePtr, out_len: IntPtr, key: Ed448Key, context: bytes | FFI.CData, context_len: int) -> int: ...
def wc_ed448_verify_msg(sig: bytes, sig_len: int, msg: bytes, msg_len: int, res: IntPtr, key: Ed448Key, context: bytes | FFI.CData, context_len: int) -> int: ...
def wc_ed448_init(key: Ed448Key) -> int: ...
def wc_ed448_free(key: Ed448Key) -> None: ...
def wc_ed448_import_public(pub: bytes | BytePtr, pub_len: int, key: Ed448Key) -> int: ...
def wc_ed448_import_private_only(priv: bytes | BytePtr, priv_len: int, key: Ed448Key) -> int: ...
def wc_ed448_import_private_key(priv: bytes, priv_len: int, pub: bytes, pub_len: int, key: Ed448Key) -> int: ...
def wc_ed448_export_public(key: Ed448Key, pub: BytePtr, pub_len: IntPtr) -> int: ...
def wc_ed448_export_private_only(key: Ed448Key, priv: BytePtr, priv_len: IntPtr) -> int: ...
def wc_ed448_size(key: Ed448Key) -> int: ...
def wc_ed448_priv_size(key: Ed448Key) -> int: ...
def wc_ed448_pub_size(key: Ed448Key) -> int: ...
def wc_ed448_sig_size(key: Ed448Key) -> int: ...
MlKemKey: TypeAlias = FFI.CData
def wc_KyberKey_Init(type: int, key: MlKemKey, heap: FFI.CData, dev_id: int) -> int: ...
def wc_KyberKey_Free(key: MlKemKey) -> int: ...
def wc_KyberKey_MakeKey(key: MlKemKey, rng: RNG) -> int: ...
def wc_KyberKey_MakeKeyWithRandom(key: MlKemKey, rand: bytes, len: int) -> int: ...
def wc_KyberKey_CipherTextSize(key: MlKemKey, len: IntPtr) -> int: ...
def wc_KyberKey_SharedSecretSize(key: MlKemKey, len: IntPtr) -> int: ...
def wc_KyberKey_Encapsulate(key: MlKemKey, ct: BytePtr, ss: BytePtr, rng: RNG) -> int: ...
def wc_KyberKey_EncapsulateWithRandom(key: MlKemKey, ct: BytePtr, ss: BytePtr, rand: bytes, len: int) -> int: ...
def wc_KyberKey_Decapsulate(key: MlKemKey, ss: BytePtr, ct: bytes, len: int) -> int: ...
def wc_KyberKey_DecodePrivateKey(key: MlKemKey, private_key: bytes, private_key_len: int) -> int: ...
def wc_KyberKey_DecodePublicKey(key: MlKemKey, public_key: bytes, public_key_len: int) -> int: ...
def wc_KyberKey_PublicKeySize(key: MlKemKey, len: IntPtr) -> int: ...
def wc_KyberKey_PrivateKeySize(key: MlKemKey, len: IntPtr) -> int: ...
def wc_KyberKey_EncodePrivateKey(key: MlKemKey, out: BytePtr, len: int) -> int: ...
def wc_KyberKey_EncodePublicKey(key: MlKemKey, out: BytePtr, len: int) -> int: ...
DilithiumKey: TypeAlias = FFI.CData
def wc_dilithium_init_ex(key: DilithiumKey, heap: FFI.CData, dev_id: int) -> int: ...
def wc_dilithium_set_level(key: DilithiumKey, level: int) -> int: ...
def wc_dilithium_free(key: DilithiumKey) -> None: ...
def wc_dilithium_import_public(public: bytes, public_len: int, key: DilithiumKey) -> int: ...
def wc_dilithium_export_public(key: DilithiumKey, public: BytePtr, public_len: IntPtr) -> int: ...
def wc_dilithium_verify_ctx_msg(sig: bytes, sig_len: int, ctx: bytes, ctx_len: int, msg: bytes, msg_len: int, res: IntPtr, key: DilithiumKey) -> int: ...
def wc_dilithium_verify_msg(sig: bytes, sig_len: int, msg: bytes, msg_len: int, res: IntPtr, key: DilithiumKey) -> int: ...
def wc_dilithium_make_key(key: DilithiumKey, rng: RNG) -> int: ...
def wc_dilithium_make_key_from_seed(key: DilithiumKey, seed: bytes | list[int] | tuple[int]) -> int: ...
def wc_dilithium_export_private(key: DilithiumKey, out: BytePtr, out_len: IntPtr) -> int: ...
def wc_dilithium_import_private(priv: bytes, priv_size: int, key: DilithiumKey) -> int: ...
def wc_dilithium_sign_ctx_msg(ctx: bytes, ctx_len: int, msg: bytes, msg_len: int, sig: BytePtr, sig_len: IntPtr, key: DilithiumKey, rng: RNG) -> int: ...
def wc_dilithium_sign_msg(msg: bytes, msg_len: int, sig: BytePtr, sig_len: IntPtr, key: DilithiumKey, rng: RNG) -> int: ...
def wc_dilithium_sign_ctx_msg_with_seed(ctx: bytes, ctx_len: int, msg: bytes, msg_len: int, sig: BytePtr, sig_len: IntPtr, key: DilithiumKey, seed: bytes | list[int] | tuple[int]) -> int: ...
def wc_dilithium_sign_msg_with_seed(msg: bytes, msg_len: int, sig: BytePtr, sig_len: IntPtr, key: DilithiumKey, seed: bytes | list[int] | tuple[int]) -> int: ...
def wc_MlDsaKey_GetPrivLen(key: DilithiumKey, len: IntPtr) -> int: ...
def wc_MlDsaKey_GetPubLen(key: DilithiumKey, len: IntPtr) -> int: ...
def wc_MlDsaKey_GetSigLen(key: DilithiumKey, len: IntPtr) -> int: ...
@dataclass
class wc_HashInfo:
type: int
data: FFI.CData
data_size: int
digest: FFI.CData
sha: FFI.CData
sha256: FFI.CData
sha384: FFI.CData
sha512: FFI.CData
sha3: FFI.CData
ctx: FFI.CData
@dataclass
class wc_RngInfo:
rng: RNG
out: FFI.CData
sz: int
@dataclass
class wc_CryptoInfo:
algo_type: int
hash: wc_HashInfo
rng: wc_RngInfo
def wc_CryptoCb_RegisterDevice(dev_id: int, cb: Callable[[int, wc_CryptoInfo, FFI.CData], int], ctx: FFI.CData) -> int: ...
def wc_CryptoCb_UnRegisterDevice(dev_id: int) -> None: ...
def wc_CryptoCb_DefaultDevID() -> int: ...
def py_wc_crypto_callback(dev_id: int, info: wc_CryptoInfo, ctx: FFI.CData) -> int: ...