/** * 加密器接口 */ export interface IEncryptor { encrypt(plaintext: Uint8Array): Promise; decrypt(ciphertext: Uint8Array): Promise; name(): string; } /** * 签名器接口 */ export interface ISigner { sign(data: Uint8Array): Promise; verify(data: Uint8Array, signature: Uint8Array): Promise; } /** * 配置选项 */ export interface CryptoConfig { secretKey?: string; // 对称加密密钥 signKey?: string; // 签名密钥 publicKey?: string; // RSA公钥(PEM格式) privateKey?: string; // RSA私钥(PEM格式) timestampWindow?: number; // 时间戳窗口(毫秒) enableTimestamp?: boolean; // 是否启用时间戳验证 enableSignature?: boolean; // 是否启用签名 } /** * 加密请求体 */ export interface EncryptedRequest { data: string; // Base64编码的加密数据 signature?: string; // Base64编码的签名 timestamp: number; // 时间戳 request_id: string; // 请求ID algorithm: string; // 加密算法名称 } /** * 加密响应体 */ export interface EncryptedResponse { data: string; // Base64编码的加密数据 signature?: string; // Base64编码的签名 timestamp: number; // 时间戳 request_id: string; // 请求ID }