按规范「注释只讲解作用,不掺杂历史原因,尽量英文」:把 includes 下 75 个 .vp 的中文 # 注释与三引号 docstring 改写为英文,每个注释块压到 2 行以内。 保留要点:作用、约束、危险警告(不得/必须/注意)、ABI 与类型约定(如 BYTEPTR | t.CPtr = i8** 的跨模块坍缩坑)、位宽/长度约定、fail-fast 要求、内存与句柄所有权。 未动:文件头注释(规范豁免,仍是中文)、运行时中文字符串常量(printf / fatal_error / MlirFail 等用户可见消息,属代码字面量)。 验证:独立脚本比对 HEAD 与工作区的代码骨架(剥离 # 注释与三引号 docstring 后的非空行)——75 个文件逐字节一致;行尾 CRLF/LF 未被改动;全文剩余中文仅 547 行头注释、0 条行尾注释。bootstrap 三重重编 SUCCESS;全量 77/77 顺序回归通过。
33 lines
1.5 KiB
Plaintext
33 lines
1.5 KiB
Plaintext
import t, c
|
|
from openssl.types import *
|
|
|
|
# ============================================================
|
|
# openssl/hmac.vp — HMAC(一次性 + 上下文)
|
|
# 对应头文件: hmac.h
|
|
# ============================================================
|
|
|
|
# ---- One-shot HMAC ----
|
|
# unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
|
|
# const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len)
|
|
extern def HMAC(evp_md: EvpMdPtr, key: bytes, key_len: int,
|
|
d: bytes, n: sizet, md: bytes, md_len: bytes) -> bytes
|
|
|
|
# ---- Incremental HMAC context (provided by OpenSSL 3.x) ----
|
|
# HMAC_CTX *HMAC_CTX_new(void)
|
|
extern def HMAC_CTX_new() -> HmacCtxPtr
|
|
# void HMAC_CTX_free(HMAC_CTX *ctx)
|
|
extern def HMAC_CTX_free(ctx: HmacCtxPtr)
|
|
# int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md, ENGINE *impl)
|
|
extern def HMAC_Init_ex(ctx: HmacCtxPtr, key: bytes, len: int,
|
|
md: EvpMdPtr, impl: bytes) -> int
|
|
# int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len)
|
|
extern def HMAC_Update(ctx: HmacCtxPtr, data: bytes, len: sizet) -> int
|
|
# int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
|
|
extern def HMAC_Final(ctx: HmacCtxPtr, md: bytes, len: bytes) -> int
|
|
# int HMAC_CTX_reset(HMAC_CTX *ctx)
|
|
extern def HMAC_CTX_reset(ctx: HmacCtxPtr) -> int
|
|
# size_t HMAC_size(const HMAC_CTX *e)
|
|
extern def HMAC_size(e: HmacCtxPtr) -> sizet
|
|
# int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
|
|
extern def HMAC_CTX_copy(dctx: HmacCtxPtr, sctx: HmacCtxPtr) -> int
|