把 includes 下 64 个 .vp 的文件头注释(含 traceback.vp 第 13-427 行的整块文件级说明)以及 2 处漏网的正文中文注释(ast/lexer.vp、json/__writer.vp)与 1 处中文 docstring(memhub.vp)逐行译为英文;同步把 fltk/gen_ffi.py 的生成模板与其自身注释英文化,使重新生成仍为英文。 只改注释/文档串文字:行数与代码逐字节不变(骨架比对 140 文件漂移 0),运行时中文字符串字面量 305 处保持原样。验证:三重重编 SUCCESS(170.21s)+ 全量 77/77 顺序回归通过 + VET 编译 SUCCESS / --search-paths 7 条 exit 0。
233 lines
12 KiB
Plaintext
233 lines
12 KiB
Plaintext
import t, c
|
|
from openssl.types import *
|
|
|
|
# ============================================================
|
|
# openssl/evp.vp — EVP high-level crypto API
|
|
# Corresponding header: evp.h
|
|
#
|
|
# Includes: message digests (EVP_Digest*), symmetric encryption/decryption (EVP_Cipher*/Encrypt*/Decrypt*),
|
|
# Base64 encoding/decoding (EVP_EncodeBlock/DecodeBlock), asymmetric (EVP_PKEY* sign/verify/encrypt/decrypt)
|
|
# ============================================================
|
|
|
|
define EvpMaxMdSize = 64
|
|
define EvpMaxKeyLength = 64
|
|
define EvpMaxIvLength = 16
|
|
define EvpMaxBlockLength = 32
|
|
|
|
# ============================================================
|
|
# 1) Digest algorithm objects (const EVP_MD*)
|
|
# ============================================================
|
|
extern def EVP_md5() -> EvpMdPtr
|
|
extern def EVP_sha1() -> EvpMdPtr
|
|
extern def EVP_sha224() -> EvpMdPtr
|
|
extern def EVP_sha256() -> EvpMdPtr
|
|
extern def EVP_sha384() -> EvpMdPtr
|
|
extern def EVP_sha512() -> EvpMdPtr
|
|
extern def EVP_sha3_224() -> EvpMdPtr
|
|
extern def EVP_sha3_256() -> EvpMdPtr
|
|
extern def EVP_sha3_384() -> EvpMdPtr
|
|
extern def EVP_sha3_512() -> EvpMdPtr
|
|
extern def EVP_sm3() -> EvpMdPtr
|
|
# const EVP_MD *EVP_get_digestbyname(const char *name)
|
|
extern def EVP_get_digestbyname(name: str) -> EvpMdPtr
|
|
# int EVP_MD_get_size(const EVP_MD *md)
|
|
extern def EVP_MD_get_size(md: EvpMdPtr) -> int
|
|
# int EVP_MD_get_block_size(const EVP_MD *md)
|
|
extern def EVP_MD_get_block_size(md: EvpMdPtr) -> int
|
|
# int EVP_MD_get_type(const EVP_MD *md)
|
|
extern def EVP_MD_get_type(md: EvpMdPtr) -> int
|
|
|
|
# ============================================================
|
|
# 2) Digest contexts (incremental)
|
|
# ============================================================
|
|
# EVP_MD_CTX *EVP_MD_CTX_new(void)
|
|
extern def EVP_MD_CTX_new() -> EvpMdCtxPtr
|
|
# void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
|
|
extern def EVP_MD_CTX_free(ctx: EvpMdCtxPtr)
|
|
# int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
|
|
extern def EVP_MD_CTX_reset(ctx: EvpMdCtxPtr) -> int
|
|
# int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
|
|
extern def EVP_DigestInit_ex(ctx: EvpMdCtxPtr, type: EvpMdPtr, impl: bytes) -> int
|
|
# int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
|
|
extern def EVP_DigestInit(ctx: EvpMdCtxPtr, type: EvpMdPtr) -> int
|
|
# int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt)
|
|
extern def EVP_DigestUpdate(ctx: EvpMdCtxPtr, d: bytes, cnt: sizet) -> int
|
|
# int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s)
|
|
extern def EVP_DigestFinal_ex(ctx: EvpMdCtxPtr, md: bytes, s: bytes) -> int
|
|
# int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s)
|
|
extern def EVP_DigestFinal(ctx: EvpMdCtxPtr, md: bytes, s: bytes) -> int
|
|
# int EVP_MD_CTX_get_size(const EVP_MD_CTX *ctx)
|
|
extern def EVP_MD_CTX_get_size(ctx: EvpMdCtxPtr) -> int
|
|
# One-shot digest: int EVP_Digest(const void *data, size_t count, unsigned char *md,
|
|
# unsigned int *size, const EVP_MD *type, ENGINE *impl)
|
|
extern def EVP_Digest(data: bytes, count: sizet, md: bytes, size: bytes,
|
|
type: EvpMdPtr, impl: bytes) -> int
|
|
|
|
# ============================================================
|
|
# 3) Symmetric cipher objects (const EVP_CIPHER*)
|
|
# ============================================================
|
|
extern def EVP_aes_128_ecb() -> EvpCipherPtr
|
|
extern def EVP_aes_128_cbc() -> EvpCipherPtr
|
|
extern def EVP_aes_128_cfb() -> EvpCipherPtr
|
|
extern def EVP_aes_128_ofb() -> EvpCipherPtr
|
|
extern def EVP_aes_128_ctr() -> EvpCipherPtr
|
|
extern def EVP_aes_128_gcm() -> EvpCipherPtr
|
|
extern def EVP_aes_192_ecb() -> EvpCipherPtr
|
|
extern def EVP_aes_192_cbc() -> EvpCipherPtr
|
|
extern def EVP_aes_192_ctr() -> EvpCipherPtr
|
|
extern def EVP_aes_192_gcm() -> EvpCipherPtr
|
|
extern def EVP_aes_256_ecb() -> EvpCipherPtr
|
|
extern def EVP_aes_256_cbc() -> EvpCipherPtr
|
|
extern def EVP_aes_256_cfb() -> EvpCipherPtr
|
|
extern def EVP_aes_256_ofb() -> EvpCipherPtr
|
|
extern def EVP_aes_256_ctr() -> EvpCipherPtr
|
|
extern def EVP_aes_256_gcm() -> EvpCipherPtr
|
|
extern def EVP_des_ede3_cbc() -> EvpCipherPtr
|
|
extern def EVP_chacha20() -> EvpCipherPtr
|
|
extern def EVP_rc4() -> EvpCipherPtr
|
|
# const EVP_CIPHER *EVP_get_cipherbyname(const char *name)
|
|
extern def EVP_get_cipherbyname(name: str) -> EvpCipherPtr
|
|
# Parameter queries
|
|
extern def EVP_CIPHER_get_block_size(cipher: EvpCipherPtr) -> int
|
|
extern def EVP_CIPHER_get_key_length(cipher: EvpCipherPtr) -> int
|
|
extern def EVP_CIPHER_get_iv_length(cipher: EvpCipherPtr) -> int
|
|
extern def EVP_CIPHER_get_nid(cipher: EvpCipherPtr) -> int
|
|
extern def EVP_CIPHER_get_type(cipher: EvpCipherPtr) -> int
|
|
|
|
# ============================================================
|
|
# 4) Symmetric cipher contexts
|
|
# ============================================================
|
|
# EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void)
|
|
extern def EVP_CIPHER_CTX_new() -> EvpCipherCtxPtr
|
|
# void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c)
|
|
extern def EVP_CIPHER_CTX_free(c: EvpCipherCtxPtr)
|
|
# int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c)
|
|
extern def EVP_CIPHER_CTX_reset(c: EvpCipherCtxPtr) -> int
|
|
# int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
|
|
extern def EVP_CIPHER_CTX_copy(out: EvpCipherCtxPtr, inn: EvpCipherCtxPtr) -> int
|
|
|
|
# Unified interface (enc: 1 encrypt / 0 decrypt)
|
|
# int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
|
# ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc)
|
|
extern def EVP_CipherInit_ex(ctx: EvpCipherCtxPtr, cipher: EvpCipherPtr,
|
|
impl: bytes, key: bytes, iv: bytes, enc: int) -> int
|
|
# int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
|
# const unsigned char *in, int inl)
|
|
extern def EVP_CipherUpdate(ctx: EvpCipherCtxPtr, out: bytes, outl: bytes,
|
|
inn: bytes, inl: int) -> int
|
|
# int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl)
|
|
extern def EVP_CipherFinal_ex(ctx: EvpCipherCtxPtr, outm: bytes, outl: bytes) -> int
|
|
# int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
|
# const unsigned char *key, const unsigned char *iv, int enc)
|
|
extern def EVP_CipherInit(ctx: EvpCipherCtxPtr, cipher: EvpCipherPtr,
|
|
key: bytes, iv: bytes, enc: int) -> int
|
|
|
|
# Split encrypt/decrypt (specializations of the unified interface above)
|
|
# int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
|
# ENGINE *impl, const unsigned char *key, const unsigned char *iv)
|
|
extern def EVP_EncryptInit_ex(ctx: EvpCipherCtxPtr, cipher: EvpCipherPtr,
|
|
impl: bytes, key: bytes, iv: bytes) -> int
|
|
# int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
|
# const unsigned char *in, int inl)
|
|
extern def EVP_EncryptUpdate(ctx: EvpCipherCtxPtr, out: bytes, outl: bytes,
|
|
inn: bytes, inl: int) -> int
|
|
# int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
|
extern def EVP_EncryptFinal_ex(ctx: EvpCipherCtxPtr, out: bytes, outl: bytes) -> int
|
|
|
|
# int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
|
# ENGINE *impl, const unsigned char *key, const unsigned char *iv)
|
|
extern def EVP_DecryptInit_ex(ctx: EvpCipherCtxPtr, cipher: EvpCipherPtr,
|
|
impl: bytes, key: bytes, iv: bytes) -> int
|
|
# int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
|
# const unsigned char *in, int inl)
|
|
extern def EVP_DecryptUpdate(ctx: EvpCipherCtxPtr, out: bytes, outl: bytes,
|
|
inn: bytes, inl: int) -> int
|
|
# int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl)
|
|
extern def EVP_DecryptFinal_ex(ctx: EvpCipherCtxPtr, outm: bytes, outl: bytes) -> int
|
|
|
|
# Context query / control
|
|
extern def EVP_CIPHER_CTX_set_padding(c: EvpCipherCtxPtr, pad: int) -> int
|
|
extern def EVP_CIPHER_CTX_set_key_length(c: EvpCipherCtxPtr, keylen: int) -> int
|
|
extern def EVP_CIPHER_CTX_ctrl(ctx: EvpCipherCtxPtr, type: int, arg: int, ptr: bytes) -> int
|
|
extern def EVP_CIPHER_CTX_key_length(ctx: EvpCipherCtxPtr) -> int
|
|
extern def EVP_CIPHER_CTX_iv_length(ctx: EvpCipherCtxPtr) -> int
|
|
extern def EVP_CIPHER_CTX_get_block_size(ctx: EvpCipherCtxPtr) -> int
|
|
extern def EVP_CIPHER_CTX_get_key_length(ctx: EvpCipherCtxPtr) -> int
|
|
extern def EVP_CIPHER_CTX_get_iv_length(ctx: EvpCipherCtxPtr) -> int
|
|
# int EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, void *iv, size_t len)
|
|
extern def EVP_CIPHER_CTX_get_iv(ctx: EvpCipherCtxPtr, iv: bytes, len: sizet) -> int
|
|
# int EVP_CIPHER_CTX_set_iv(EVP_CIPHER_CTX *ctx, const void *iv, size_t len)
|
|
extern def EVP_CIPHER_CTX_set_iv(ctx: EvpCipherCtxPtr, iv: bytes, len: sizet) -> int
|
|
|
|
# ---- GCM ctrl constants (used with EVP_CIPHER_CTX_ctrl) ----
|
|
define EvpCtrlGcmSetIvl = 0x9# EVP_CTRL_AEAD_SET_IVLEN
|
|
define EvpCtrlGcmGetTag = 0x10# EVP_CTRL_AEAD_GET_TAG
|
|
define EvpCtrlGcmSetTag = 0x11# EVP_CTRL_AEAD_SET_TAG
|
|
|
|
# ============================================================
|
|
# 5) Base64 (EVP encode/decode block functions)
|
|
# ============================================================
|
|
# int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n)
|
|
extern def EVP_EncodeBlock(t: bytes, f: bytes, n: int) -> int
|
|
# int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n)
|
|
extern def EVP_DecodeBlock(t: bytes, f: bytes, n: int) -> int
|
|
|
|
# ============================================================
|
|
# 6) Asymmetric (EVP_PKEY / EVP_PKEY_CTX)
|
|
# ============================================================
|
|
# EVP_PKEY *EVP_PKEY_new(void) / void EVP_PKEY_free(EVP_PKEY *pkey)
|
|
extern def EVP_PKEY_new() -> EvpPkeyPtr
|
|
extern def EVP_PKEY_free(pkey: EvpPkeyPtr)
|
|
# int EVP_PKEY_get_size(const EVP_PKEY *pkey) (signature/ciphertext length)
|
|
extern def EVP_PKEY_get_size(pkey: EvpPkeyPtr) -> int
|
|
extern def EVP_PKEY_get_id(pkey: EvpPkeyPtr) -> int
|
|
extern def EVP_PKEY_get_base_id(pkey: EvpPkeyPtr) -> int
|
|
extern def EVP_PKEY_eq(a: EvpPkeyPtr, b: EvpPkeyPtr) -> int
|
|
|
|
# EVP_PKEY_CTX
|
|
# EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e)
|
|
extern def EVP_PKEY_CTX_new(pkey: EvpPkeyPtr, e: bytes) -> EvpPkeyCtxPtr
|
|
# void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
|
|
extern def EVP_PKEY_CTX_free(ctx: EvpPkeyCtxPtr)
|
|
|
|
# Sign / verify (raw RSA/EC)
|
|
extern def EVP_PKEY_sign_init(ctx: EvpPkeyCtxPtr) -> int
|
|
extern def EVP_PKEY_verify_init(ctx: EvpPkeyCtxPtr) -> int
|
|
extern def EVP_PKEY_encrypt_init(ctx: EvpPkeyCtxPtr) -> int
|
|
extern def EVP_PKEY_decrypt_init(ctx: EvpPkeyCtxPtr) -> int
|
|
# int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
|
|
# const unsigned char *tbs, size_t tbslen)
|
|
extern def EVP_PKEY_sign(ctx: EvpPkeyCtxPtr, sig: bytes, siglen: bytes,
|
|
tbs: bytes, tbslen: sizet) -> int
|
|
extern def EVP_PKEY_verify(ctx: EvpPkeyCtxPtr, sig: bytes, siglen: sizet,
|
|
tbs: bytes, tbslen: sizet) -> int
|
|
extern def EVP_PKEY_encrypt(ctx: EvpPkeyCtxPtr, out: bytes, outlen: bytes,
|
|
inn: bytes, inlen: sizet) -> int
|
|
extern def EVP_PKEY_decrypt(ctx: EvpPkeyCtxPtr, out: bytes, outlen: bytes,
|
|
inn: bytes, inlen: sizet) -> int
|
|
|
|
# Digest sign/verify (DigestSign*: mostly RSA-PSS/ECDSA)
|
|
# int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type,
|
|
# ENGINE *e, EVP_PKEY *pkey)
|
|
extern def EVP_DigestSignInit(ctx: EvpMdCtxPtr, pctx: bytes, type: EvpMdPtr,
|
|
e: bytes, pkey: EvpPkeyPtr) -> int
|
|
extern def EVP_DigestSignUpdate(ctx: EvpMdCtxPtr, data: bytes, dsize: sizet) -> int
|
|
# int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
|
|
extern def EVP_DigestSignFinal(ctx: EvpMdCtxPtr, sigret: bytes, siglen: bytes) -> int
|
|
# int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type,
|
|
# ENGINE *e, EVP_PKEY *pkey)
|
|
extern def EVP_DigestVerifyInit(ctx: EvpMdCtxPtr, pctx: bytes, type: EvpMdPtr,
|
|
e: bytes, pkey: EvpPkeyPtr) -> int
|
|
extern def EVP_DigestVerifyUpdate(ctx: EvpMdCtxPtr, data: bytes, dsize: sizet) -> int
|
|
extern def EVP_DigestVerifyFinal(ctx: EvpMdCtxPtr, sig: bytes, siglen: sizet) -> int
|
|
|
|
# ============================================================
|
|
# 7) Key derivation / helpers
|
|
# ============================================================
|
|
# int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
|
|
# const unsigned char *salt, const unsigned char *data, int datal, int count,
|
|
# unsigned char *key, unsigned char *iv)
|
|
extern def EVP_BytesToKey(type: EvpCipherPtr, md: EvpMdPtr, salt: bytes,
|
|
data: bytes, datal: int, count: int,
|
|
key: bytes, iv: bytes) -> int
|