mORMot2 Daily每日上游提交速读

Windows CNG 与 PKCS#11 扩展,同时修复 JSON 和 socket 安全缺陷

本期以密码学为主:新增 Windows CNG 证书存储后端,完成通过 CNG 与 PKCS#11 私钥解密 RSA envelope,并修复一系列 PKCS#11 导入、签名和生命周期问题。此外还修复 JSON 日志越界读取、限制 socket 重试循环、修正反向代理后的会话 cookie 选择,并拆分 HTTP connect/send/receive timeout。

要点

  • 应采用 build 2.4.17268 的 80bc2689df777dadbe1f8af745096eeb13205ef7。
  • 若代码引用 TAesAbstractApi 或其 CryptoAPI AES 子类,请在 uses 中加入 mormot.crypt.win;这些类型已从 mormot.crypt.core 移出。
  • Windows 新增 TCryptCertAlgoCng、ICryptCertCng 与 TCryptCertCng.LoadPkcs12,支持系统 store、smart card/KSP 和临时 PFX identity。
  • PKCS#11 新增 RSA envelope 解密与更多签名支持,但 TPkcs11 明确不再 thread-safe;共享 catalog 必须使用 TCryptCertAlgoPkcs11.Lock/UnLock。
  • 应尽快升级以修复 TJsonWriter.AddEscapeBuffer 越界读取、TCrtSocket.TrySockRecv 无限重试、CNG/PKCS#11 GPF 及 OpenSSL ABI 问题。
  • THttpClientSocket.SetTimeouts 现在分别设置 connect、send 与 receive 时限;TRestHttpClientSocket 会应用三者。

升级建议

请采用 build 2.4.17268。若生产环境记录不可信或二进制文本,或使用 blocking/TLS socket、Windows IOCP、反向代理后的 REST 认证、OpenSSL、Windows CNG 或 PKCS#11,应尽快升级。为受影响的 uses 加入 mormot.crypt.win。审查直接共享 TPkcs11 的代码:它不再内部加锁,请用 TCryptCertAlgoPkcs11.Lock/UnLock 保护 catalog 操作。测试硬件 token 导入、PSS/ECC 签名、后台发现期间关闭、RSA Open 与三类 HTTP timeout。原始 payload 没有 superseded_by,因此不声明避开区间。

版本号2.4.17208 → 2.4.17268
提交60
行数+2851 -1493
阅读5 分钟

56 条中的 56 条 · 上游 60 次提交

主题
# 条目 类别 单元
1 严重 JSON 转义停止读取输入 buffer 之外内容 TJsonWriter.AddEscapeBuffer 修正颠倒的 MaxLen 比较:当 Len 超过 MaxLen 时截断,而非把 Len 扩大到 MaxLen。 安全 mormot.core.json c955c837+2-2

core: TJsonWriter.AddEscapeBuffer() did read beyond the input buffer

影响

记录无效 UTF-8 或二进制内容时不再把无关 heap byte 写入日志,也不再在持有 log lock 时触发 access violation。

公开 API

  • TJsonWriter.AddEscapeBufferbehaviour-changed

Stefan Diestelmann · 18:17 UTC · 在 GitHub 上查看该提交 →

2 高 PKCS#11 加锁从低层 engine 移至 catalog TPkcs11 从 TObjectOSLock 改继承 TSynPersistent,并移除内部加锁;TCryptCertAlgoPkcs11 新增可重入 TOSLock 与公开 Lock/UnLock,保护共享 engine 与后台加载。 破坏性变更 mormot.crypt.pkcs11+1 fdbd6e9f+197-220

crypt: simplified PKCS#11 threading model

影响

直接 TPkcs11 instance 明确不再 thread-safe;依赖 Engine.Safe 或隐式 session 串行化的并发调用可能竞态或破坏共享 session 状态。

需要迁移

搜索共享 TPkcs11 与 Engine.Safe;用 TCryptCertAlgoPkcs11.Lock/UnLock 串行化 catalog 操作,或每线程使用独立 engine。

公开 API

  • TPkcs11behaviour-changed
  • TCryptCertAlgoPkcs11.Lockadded
  • TCryptCertAlgoPkcs11.UnLockadded

Arnaud Bouchez · 15:50 UTC · PR #11 · 在 GitHub 上查看该提交 →

3 高 不支持的证书 factory 返回 nil 且不再解引用 TCryptCertAlgo.New 与 FromHandle 改为默认返回 nil 的 virtual 方法,Load、Generate、CreateSelfSignedCsr 与 GenerateFromCsr 在调用前检查接口。CNG 与 PKCS#11 删除重复 override。 修复 mormot.crypt.secure+2 11f136ba+31-61

crypt: fixed potential GPF in TCryptCertAlgo misuse

影响

对 catalog 型算法调用通用 factory 不再可能触发 access violation。受支持的证书实现保持原有 factory。

公开 API

  • TCryptCertAlgo.Newbehaviour-changed
  • TCryptCertAlgo.FromHandlebehaviour-changed

Arnaud Bouchez · 08:12 UTC · 在 GitHub 上查看该提交 →

4 高 PKCS#11 shutdown 等待后台发现完成 TCryptCertAlgoPkcs11 保留带 manual wait 的 TLoggedWorkThread,在释放 engine 前先 free/wait,并在持锁 finally 中设置完成状态。 修复 mormot.crypt.pkcs11 d74a0234+48-42

crypt: fixed PKCS#11 background loading

影响

在缓慢 library 初始化期间销毁 catalog 不再允许 loader 访问已释放内存并导致 GPF。

Arnaud Bouchez · 16:05 UTC · PR #11 · 在 GitHub 上查看该提交 →

5 高 PKCS#11 导入返回已存证书并在失败时回滚 TCryptCertAlgoPkcs11.Import 验证十六进制 ID,创建证书与私钥对象,重新加载实际证书并加入 catalog;失败时按逆序销毁部分对象。 修复 mormot.crypt.pkcs11 f4ba19f2+55-29

crypt: fixed TCryptCertAlgoPkcs11.Import() method

影响

成功导入后可立即使用;失败不再留下孤立 token object。

公开 API

  • TCryptCertAlgoPkcs11.Importbehaviour-changed

Arnaud Bouchez · 16:22 UTC · 在 GitHub 上查看该提交 →

6 高 PKCS#11 RSA-PSS 签名提供所需参数 Pkcs11SetPssParams 构造包含匹配 hash、MGF1 与 salt length 的 CK_RSA_PKCS_PSS_PARAMS;SignDigest 对 PSS 发送 raw digest,而非 PKCS#1 DigestInfo。 修复 mormot.crypt.pkcs11+1 639e45ff+75-5

crypt: fixed PSS support in TCryptPrivateKeyPkcs11.SignDigest

影响

硬件 token 现在可生成有效 PS256、PS384 与 PS512 签名,不再拒绝或错误编码操作。

公开 API

  • Pkcs11SetPssParamsadded

Arnaud Bouchez · 15:08 UTC · 在 GitHub 上查看该提交 →

7 高 PKCS#11 公钥从算法特定属性重建 Pkcs11PublicKey 先尝试 CKA_PUBLIC_KEY_INFO,再从 modulus/exponent 重建 RSA、从 CKA_EC_POINT 重建 EC,并从 raw 或旧 DER point 重建 Ed25519;TCryptCertPkcs11.Create 不再把 CKA_VALUE 当公钥材料。 修复 mormot.crypt.pkcs11 4be9e812+65-10

crypt: fixed TCryptCertPkcs11.Create() key import

影响

没有 CKO_CERTIFICATE 或 CKA_VALUE 受限的 token identity 现在公开正确公钥,避免不可用的 fake X.509 instance。

公开 API

  • Pkcs11PublicKeyadded

Arnaud Bouchez · 19:30 UTC · 在 GitHub 上查看该提交 →

8 高 Ed25519 PKCS#8 私钥按 RFC 8410 嵌套解析 SeqToEccPrivKey 现在按 RFC 8410 解析 PKCS#8 Ed25519:id-Ed25519 后是外层 privateKey OCTET STRING,其中包含内层 OCTET STRING;同时保留 RFC 5915 EC 处理。 修复 mormot.crypt.secure 80bc2689+34-36

crypt: fixed ckaEdDSA private key extraction

影响

Ed25519 私钥提取现在得到实际 32-byte key,不再失败或误解 ASN.1 结构,从而可正确导入 PKCS#11。

Arnaud Bouchez · 19:46 UTC · 在 GitHub 上查看该提交 →

9 高 PKCS#11 object 枚举始终 finalize 搜索 TPkcs11.GetObjects 用 try/finally 包裹 FindObjects,记录并始终调用 C_FindObjectsFinal,清理后验证最终状态。 修复 mormot.lib.pkcs11 4f5f3b32+35-29

lib: fixed TPkcs11.GetObjects error handling

影响

枚举失败不再留下 active find operation 而破坏后续 token 调用。

Arnaud Bouchez · 17:09 UTC · 在 GitHub 上查看该提交 →

10 高 临时 CNG 证书不再解引用缺失 owner TCryptCertCng 保存显式 TSynLogClass,允许 PFX instance 使用 nil TCryptCertAlgoCng owner,并从 owner 是否存在判断 system-store 状态。 修复 mormot.crypt.win+1 3736871b+22-33

crypt: fixed GPF in TCryptCertCng

影响

TCryptCertCng.LoadPkcs12 在构造或记录临时证书时不再可能 GPF。

Arnaud Bouchez · 11:55 UTC · 在 GitHub 上查看该提交 →

11 高 PKCS#11 UnLoad 仅 finalize 已初始化 library TPkcs11.Load 在 C_Initialize 后跟踪 fInitialized,清理每个失败阶段;UnLoad 仅在初始化确实成功时调用 C_Finalize。 修复 mormot.lib.pkcs11 dfbd2889+28-20

lib: fixed TPkcs11.Load/UnLoad error handling

影响

library 加载失败不再 finalize 未初始化 API,也不再泄漏部分打开的 library handle。

Arnaud Bouchez · 16:52 UTC · 在 GitHub 上查看该提交 →

12 高 PKCS#11 拒绝与实际 key 不兼容的签名算法 TCryptCertPkcs11.SetAsymAlgo 检查 X.509 SubjectPublicKeyAlgorithm:普通 RSA 接受 RS/PSS,RSA-PSS 仅允许 PSS,ECC 必须保持曲线兼容。 修复 mormot.crypt.pkcs11 978ba78c+30-7

crypt: fixed TCryptCertPkcs11.SetAsymAlgo logic

影响

算法切换不再仅因 enum family 映射相同而错误允许无效 signing mechanism。

公开 API

  • TCryptCertPkcs11.SetAsymAlgobehaviour-changed

Arnaud Bouchez · 16:30 UTC · 在 GitHub 上查看该提交 →

13 高 REST 认证忽略无关反向代理 cookie TRestClientAuthentication.ClientGetSessionKey 仅对 HTTP-based scheme 解析 Set-Cookie,并在所有 header 中查找 Model.Root cookie,不再采用第一个代理 cookie。 修复 mormot.rest.client 477811c6+26-9

rest: only use the session cookie for HTTP-based authentication

影响

Azure App Proxy 等代理后的 signed-URI 认证不再使用错误 session ID,后续请求不会因此返回 403。

公开 API

  • TRestClientAuthentication.ClientGetSessionKeybehaviour-changed

TobiasKnoke · 10:19 UTC · 在 GitHub 上查看该提交 →

14 高 PKCS#11 签名在 size query 时发送数据并始终关闭 session TPkcs11.Sign 首次 C_Sign 调用改传 Data/Len,而非 nil/zero。SignDigest 捕获异常记录 trace,并在 finally 中关闭 engine;CAA_PSS 集中定义 PSS 集合。 修复 mormot.crypt.pkcs11+3 b7c75631+17-12

crypt: fixed PKCS#11 signing

影响

需要真实输入来计算签名长度的 token 现可正常工作,签名失败也不再泄漏开放 session。

公开 API

  • CAA_PSSadded

Arnaud Bouchez · 16:39 UTC · PR #11 · 在 GitHub 上查看该提交 →

15 高 Socket receive 重试遵守配置 timeout TCrtSocket.TrySockRecv 保留 nrRetry 状态直到 RecvPending/WaitFor,计算已用时间并仅传递剩余 TimeOut,不再把 retry 改为 nrOk 后无限 recv。 修复 mormot.net.sock bb4110fa+14-3

net: fixed TCrtSocket.TrySockRecv endless recv() retry on nrRetry - now honors TimeOut

影响

反复返回 retry 的 blocking 或 TLS read 不再能无限超过调用方 timeout。

公开 API

  • TCrtSocket.TrySockRecvbehaviour-changed

je · 10:50 UTC · 在 GitHub 上查看该提交 →

16 高 PKCS#11 导入使用普通 user PIN TCryptCertAlgoPkcs11.Import 将 SoPinCode 改名为 PinCode,并在创建证书和私钥对象前打开 read/write CKU_USER session,而非 Security Officer session。 修复 mormot.crypt.pkcs11 bb4dc3c1+9-8

fixed TCryptCertAlgoPkcs11.Import to use normal user PIN

影响

拒绝在 SO 角色下创建 object 的 HSM 现在可用预期普通用户凭据导入。

公开 API

  • TCryptCertAlgoPkcs11.Importbehaviour-changed

Arnaud Bouchez · 17:02 UTC · 在 GitHub 上查看该提交 →

17 高 GenerateFromCsr 改为委托新证书而非递归自身 TCryptCertAlgo.GenerateFromCsr 现在对 New 返回的实例调用 result.GenerateFromCsr,而不再递归调用 factory 自身;注释同时澄清 void factory 与 CNG 子类。 修复 mormot.crypt.secure+2 1be7a731+8-7

crypt: several ICryptCert fixes and precisions

影响

通过基础 factory 从 CSR 生成证书不再无限递归或导致 stack overflow;现有有效 override 行为不变。

Arnaud Bouchez · 08:34 UTC · 在 GitHub 上查看该提交 →

18 高 PKCS#11 GetObject 返回唯一匹配 record TPkcs11.GetObject 先 finalize/清空输出,要求 GetObjects 恰有一个结果,并在复制可选 value 前把该 record 赋给 Info。 修复 mormot.lib.pkcs11 15a2bdfd+7-5

lib: fixed TPkcs11.GetObject wrapper

影响

import 与 lookup 调用方现在获得初始化的 object 元数据,不再成功返回却留下过期或空 Info。

公开 API

  • TPkcs11.GetObjectbehaviour-changed

Arnaud Bouchez · 16:48 UTC · 在 GitHub 上查看该提交 →

19 高 IOCP AcceptEx socket 在 shutdown 前继承 listener context GetNextAccept 在释放 accept state 前用监听 socket 设置 SO_UPDATE_ACCEPT_CONTEXT,setsockopt 失败时记录 warning。 修复 mormot.net.sock.windows 0c84326d+11-0

net: set SO_UPDATE_ACCEPT_CONTEXT on IOCP AcceptEx sockets so that shutdown() sends a FIN

影响

服务器端 IOCP 关闭可成功调用 shutdown 并发送 FIN,不再因 WSAENOTCONN 失败而让 client 等待。

je · 10:50 UTC · 在 GitHub 上查看该提交 →

20 高 PKCS#11 证书导入使用正确 flag 并识别 P-521 AddSessionCertificate 不再强制 posExtractable,始终提供 CKA_SUBJECT 与必需 private/ID 值;Pkcs11KeyAlgorithm 将 secp521r1 的 528-bit coordinate storage 识别为 xkaEcc512。 修复 mormot.crypt.pkcs11+1 7a3e2370+5-6

crypt: fixed CKO_CERTIFICATE import

影响

token 获得有效 CKO_CERTIFICATE template,P-521 公钥在导入与发现时得到正确分类。

Arnaud Bouchez · 19:14 UTC · 在 GitHub 上查看该提交 →

21 高 OpenSSL C long 声明改用平台匹配的 Pascal 类型 mormot.lib.openssl11 的数十个声明与 wrapper 返回值从 integer/cardinal 改为 clong 或 PtrInt,以匹配 C long 参数、长度、版本、mode 与 callback。 编译器与平台 mormot.lib.openssl11 c60c6b66+93-93

lib: fixed OpenSSL API clong usage

影响

修复 64-bit POSIX ABI 不匹配。把这些公开返回值存入 32-bit 变量的低层调用方可能需要显式转换。

公开 API

  • OpenSSL C API declarationssignature-changed

Arnaud Bouchez · 09:30 UTC · 在 GitHub 上查看该提交 →

22 高 OpenSSL option mask 使用正确的 1.1 与 3.x 宽度 SSL_CTX_set_options 与 SSL_CTX_clear_options 公开 QWord mask,并按 OpenSSL 1.1 的 32-bit 或 OpenSSL 3 的 64-bit signature 分派;新增 culong。 编译器与平台 mormot.lib.openssl11 bee62163+16-15

lib: fixed SSL_CTX_set_options/SSL_CTX_clear_options for OpenSSL

影响

OpenSSL 3 option bit 不再被截断,同时 OpenSSL 1.1 保持其原生 ABI。

公开 API

  • SSL_CTX_set_optionssignature-changed
  • SSL_CTX_clear_optionssignature-changed

Arnaud Bouchez · 12:12 UTC · 在 GitHub 上查看该提交 →

23 高 Windows C long 在 Win64 上保持 32-bit Windows clong 别名从 PtrInt 改为 integer,timeval 字段使用 clong,修正 Win64 OpenSSL 的 LLP64 ABI。 编译器与平台 mormot.lib.openssl11 e7edab5c+6-6

lib: long is 32-bit on Windows even on Win64

影响

Win64 OpenSSL 调用不再在 C ABI 期望四字节时传递或接收八字节值。

Arnaud Bouchez · 09:43 UTC · 在 GitHub 上查看该提交 →

24 高 Delphi Darwin 不再链接 FPC 专用 C symbol 名为 GetTickCount64 的 mach_absolute_time external alias 现在仅在 FPC Darwin 下声明;Delphi 不使用它却曾尝试解析 c library。 编译器与平台 mormot.core.base 96914740+2-0

core: fixed Delphi Darwin linking

影响

Delphi iOS 与 iOS Simulator 链接不再因 “ld: file not found: c” 失败;FPC Darwin entropy 行为不变。

Stefan Diestelmann · 10:27 UTC · 在 GitHub 上查看该提交 →

25 中 Windows CryptoAPI AES 类迁移到独立 unit TAesAbstractApi、TAesEcbApi、TAesCbcApi、TAesCfbApi 与 TAesOfbApi 从 mormot.crypt.core 移至新的 mormot.crypt.win,并加入 Lazarus package。 破坏性变更 mormot.crypt.core+1 c2a321d8+315-238

crypt: new mormot.crypt.win.pas unit

影响

直接引用这些公开类型且未导入 mormot.crypt.win 的项目将无法编译;AES 行为不变。非 Windows 目标可安全包含该空操作 unit。

需要迁移

搜索这五个 TAes*Api 类,并在相应 uses 中加入 mormot.crypt.win。

公开 API

  • mormot.crypt.winadded — 新 unit 现承载公开 Windows CryptoAPI AES 类。

Arnaud Bouchez · 06:51 UTC · 在 GitHub 上查看该提交 →

26 中 X.509 查找接受人类可读 thumbprint TX509.FingerPrintCompare 改为大小写不敏感,InternalFind 规范化空格或冒号分隔的 Windows clipboard ccmSha1/ccmSha256 thumbprint。 修复 mormot.crypt.x509+5 8f741a59+19-11

crypt: normalize X509 ccmSha1/ccmSha256 finding

影响

证书搜索现在接受常见管理员输入 thumbprint 格式,不再静默找不到证书。

公开 API

  • TX509.FingerPrintComparebehaviour-changed

Arnaud Bouchez · 14:45 UTC · 在 GitHub 上查看该提交 →

27 中 Thumbprint 规范化覆盖所有证书后端 TCryptCert.InternalFind、Compare 与 TX509.FingerPrintCompare 使用 HumanHexCompare 进行 SHA-1/SHA-256 匹配,统一处理分隔符与大小写。 修复 mormot.crypt.secure+1 fd0b9854+7-14

crypt: global X.509 thumbprint normalization

影响

人类格式 digest 匹配在 X.509、CNG 与 PKCS#11 证书实现间保持一致。

Arnaud Bouchez · 14:55 UTC · 在 GitHub 上查看该提交 →

28 中 PKCS#11 私钥在使用前验证算法与 digest TCryptPrivateKeyPkcs11 从 X.509 初始化 fKeyAlgo,拒绝不匹配的签名算法或 digest 长度,并根据 key algorithm 而非选中 signature algorithm 判断 RSA modulus。 修复 mormot.crypt.pkcs11+1 eb075586+14-6

crypt: some TCryptPrivateKeyPkcs11 fixes

影响

无效组合在打开 token session 前安全失败;适用时 RSA-PSS key 仍可用于 envelope Open。

Arnaud Bouchez · 15:25 UTC · 在 GitHub 上查看该提交 →

29 中 PKCS#11 私钥属性按各 X.509 算法转换 CryptCertToPkcs11PrivKeyAttributes 在将 ICryptCert 转为 token import 时修正 RSA/ECC 属性与 key-usage flag。 修复 mormot.crypt.pkcs11 b47c9353+9-6

crypt: fixed X.509 attributes to PKCS#11 conversion

影响

导入 token 的 key 属性与证书算法保持一致,提高 HSM 接受度与后续查找可靠性。

Arnaud Bouchez · 16:27 UTC · PR #11 · 在 GitHub 上查看该提交 →

30 中 PKCS#11 错误签名长度返回 false 而非抛异常 TPkcs11.Verify 将 CKR_SIGNATURE_LEN_RANGE 与 CKR_SIGNATURE_INVALID 一样处理并返回 false;其他 token 错误仍抛 EPkcs11。 修复 mormot.lib.pkcs11 4788f9a7+7-5

lib: fixed TPkcs11.Verify

影响

长度异常签名现在是普通验证失败,而非 HSM 操作异常。

公开 API

  • TPkcs11.Verifybehaviour-changed

Arnaud Bouchez · 17:00 UTC · 在 GitHub 上查看该提交 →

31 中 OpenSSL 证书有效期保留负起始偏移 X509.SetValidity 不再把负 ValidDays 强制为零,因为受支持的 X509_gmtime_adj 接受负偏移。 修复 mormot.lib.openssl11 bae3c61c+3-4

lib: adjust X509.SetValidity() to the current OpenSSL state

影响

生成的 OpenSSL 证书可再次在当前时间之前生效,保留预期 clock-skew 容忍。

值得一看

若 ValidDays 为负,请重新测试生成证书的 notBefore。

公开 API

  • X509.SetValiditybehaviour-changed

Arnaud Bouchez · 08:42 UTC · 在 GitHub 上查看该提交 →

32 中 REST cookie 查找匹配 slash 转 underscore 规则 ClientGetSessionKey 在比较 cookie 名之前用 StringReplaceChars('/', '_') 规范化 Model.Root,与 TRestUriContext.SetOutCookie 一致。 修复 mormot.rest.client 5f3c8069+3-2

rest: match the session cookie name as SetOutCookie() computes it

影响

对于 api/v1 这类实际 cookie 名为 api_v1 的 root,HTTP 认证现可正常工作。

Stefan Diestelmann · 10:23 UTC · 在 GitHub 上查看该提交 →

33 中 REST HTTP client 应用全部三个 timeout TRestHttpClientSocket 创建 THttpClientSocket 后立即调用 fSocket.SetTimeouts(fConnectTimeout, fSendTimeout, fReceiveTimeout)。 修复 mormot.rest.http.client 9013722a+3-2

rest: fixed #624 in TRestHttpClientSocket

影响

配置的 REST send/receive timeout 不再在底层 socket 上被折叠为 connect timeout。

Arnaud Bouchez · 19:10 UTC · PR #624 · 在 GitHub 上查看该提交 →

34 中 Windows 证书存储公开 CNG 支持的 identity mormot.crypt.win 新增 TWinCertStoreLocations、ICryptCertCng、TCryptCertAlgoCng 与 TCryptCertCng,用于枚举 CurrentUser/LocalMachine store、查找证书并通过 CNG KSP 签名。 新功能 mormot.core.os.security+2 51d635d7+653-5

crypt: High-Level Windows CNG Certificate Store Integration

影响

Windows 后端可使用系统 store、smart card 与硬件 KSP identity,无需导出私钥。其他平台的 Delphi/FPC 不受影响。

值得一看

对于当前加载可导出 PFX 的 Windows 服务,请评估 TCryptCertAlgoCng.Cert、Find 或 FindOne。

公开 API

  • TCryptCertAlgoCngadded
  • ICryptCertCngadded
  • TWinCertStoreLocationsadded

Arnaud Bouchez · 07:41 UTC · 在 GitHub 上查看该提交 →

35 中 临时 PFX 加载改为 CNG 证书 class factory LoadPkcs12 从 TCryptCertAlgoCng 移至 class function TCryptCertCng.LoadPkcs12,接受可选 log class,并创建无 catalog owner 的临时 identity。 新功能 mormot.crypt.win 274091d4+81-76

crypt: proper TCryptCertCng.LoadPkcs12 factory

影响

PFX 加载不再需要枚举或保留 Windows store catalog;使用本期早期 algorithm method 的代码需改调 class factory。

值得一看

临时 identity 请使用 TCryptCertCng.LoadPkcs12(Pfx, Password, LogClass)。

公开 API

  • TCryptCertCng.LoadPkcs12added

Arnaud Bouchez · 11:42 UTC · 在 GitHub 上查看该提交 →

36 中 RSA envelope 解密可委托私钥操作 mormot.crypt.rsa 新增 TRsaPkcs1Decrypt 与 RsaOpen,用于验证 envelope、委托 PKCS#1 v1.5 key 解密并完成 AES 解密;TRsa.Open 复用它。 新功能 mormot.crypt.rsa+1 634a72ff+77-56

crypt: introducing RsaOpen() reusable wrapper

影响

CNG 与 PKCS#11 等外部私钥 provider 可在不导出 RSA key 的情况下解密相同 TRsa.Seal 格式。

值得一看

仅应为 RsaOpen 提供执行 RSAES-PKCS1-v1_5 unpadding 并返回临时 key 的 callback。

公开 API

  • RsaOpenadded
  • TRsaPkcs1Decryptadded

Arnaud Bouchez · 12:57 UTC · 在 GitHub 上查看该提交 →

37 中 CNG 可从 PKCS#12 加载临时 identity 初版 TCryptCertAlgoCng.LoadPkcs12 以 PKCS12_NO_PERSIST_KEY 导入 PFX,查找可访问 CNG key 的证书,并创建 cached/silent ICryptCertCng。 新功能 mormot.crypt.win+1 7741fdc4+88-41

crypt: new TCryptCertAlgoCng.LoadPkcs12() method

影响

Windows 可使用 PFX identity 而不持久化私钥。本期后续 commit 将最终 factory 移至 TCryptCertCng.LoadPkcs12。

Arnaud Bouchez · 10:35 UTC · 在 GitHub 上查看该提交 →

38 中 CNG 私钥可解密框架 RSA 消息 TCryptPrivateKeyCng.Open 解码 AES cipher 名、取得 RSA modulus size,并结合 RsaOpen 与 TNCrypt.KeyDecryptPkcs1;key 获取与日志复用签名路径。 新功能 mormot.crypt.win+1 12e8ca5a+84-25

crypt: implemented TCryptPrivateKeyCng.Open()

影响

ICryptCertCng.Open 现在可用仍不可导出的 store 或硬件 key 解密兼容 TRsa.Seal 的消息。

值得一看

使用应用实际采用的每个 AES cipher 名与 CNG provider 测试 Open。

公开 API

  • TCryptPrivateKeyCng.Openbehaviour-changed

Arnaud Bouchez · 13:39 UTC · 在 GitHub 上查看该提交 →

39 中 HTTP socket 分别公开 connect、send 与 receive timeout THttpClientSocket 新增三个 timeout 字段与公开 SetTimeouts。OpenBind 临时应用 connect budget,随后设置 send/receive socket timeout 并恢复高层等待值。 新功能 mormot.net.client 157ccf6f+69-30

net: introduce 3 explicit timeouts for THttpClientSocket

影响

后端可给连接建立较短限制,同时为请求写入与响应读取配置不同预算;旧 constructor 仍把三者初始化为同一值。

值得一看

若连接与响应延迟不同,请设置各阶段明确预算,并测试 proxy CONNECT 与 retry。

公开 API

  • THttpClientSocket.SetTimeoutsadded

Arnaud Bouchez · 19:08 UTC · 在 GitHub 上查看该提交 →

40 中 PKCS#11 私钥可解密 RSA envelope TPkcs11.Decrypt 封装 C_DecryptInit/C_Decrypt;TCryptPrivateKeyPkcs11.Open 结合 CKM_RSA_PKCS 与 RsaOpen,通过 token 私钥解密框架 RSA/AES envelope。 新功能 mormot.crypt.pkcs11+1 64321f11+87-8

crypt: implement TCryptPrivateKeyPkcs11.Open() method

影响

硬件 token RSA key 可解密 ICryptPrivateKey.Open 消息,无需导出私钥材料。

值得一看

确认每个目标 token 允许所选 key 执行 CKM_RSA_PKCS 解密。

公开 API

  • TPkcs11.Decryptadded
  • TCryptPrivateKeyPkcs11.Openbehaviour-changed

Arnaud Bouchez · 14:19 UTC · 在 GitHub 上查看该提交 →

41 中 Windows CNG 解密单个 RSA PKCS#1 block TNCrypt.KeyDecryptPkcs1 封装 NCryptDecrypt,使用 PKCS#1 padding、可选 silent mode、单次硬件操作、受限输出并在错误时清理。 新功能 mormot.lib.sspi 894714e2+50-3

lib: new TNCrypt.KeyDecryptPkcs1() wrapper method

影响

CNG 支持的 RSA key(包括硬件 KSP)获得 envelope 解密所需 primitive,且无需额外 size query。

公开 API

  • TNCrypt.KeyDecryptPkcs1added

Arnaud Bouchez · 13:01 UTC · 在 GitHub 上查看该提交 →

42 中 Windows wrapper 导入 PFX 并擦除密码缓冲区 mormot.lib.sspi 新增 WinCertStoreImportPfx,将 SpiUtf8 转成 UTF-16,调用 PFXImportCertStore,捕获错误并擦除临时密码缓冲。 新功能 mormot.lib.sspi 33e5e920+46-3

lib: new WinCertStoreImportPfx() wrapper function

影响

Windows PFX 使用方获得基于错误码且显式清理密码的统一导入路径。现有直接 API 仍可用。

公开 API

  • WinCertStoreImportPfxadded

Arnaud Bouchez · 09:41 UTC · 在 GitHub 上查看该提交 →

43 中 PKCS#11 以 DER 格式签名 ES384、ES512 与 ES256K SignDigest 对 ES256、ES384、ES512 与 ES256K 使用 SetSignatureSecurityRaw 转换 raw r||s 输出,并确保设置 PSS mechanism。 新功能 mormot.crypt.pkcs11 9c9a402a+8-7

crypt: ES384 ES512 ES256K support for PKCS#11

影响

使用更大 EC 或 secp256k1 key 的 token 现在返回 ICryptPrivateKey 期望的 DER 签名格式。

值得一看

为每个启用的 ES 算法添加 token-backed 签名测试。

Arnaud Bouchez · 15:18 UTC · PR #11 · 在 GitHub 上查看该提交 →

44 中 第二轮 OpenSSL ABI 修正 control 与 mode 宽度 Windows 兼容类型移到 OpenSSL 声明之前,session-cache、mode、extra-chain 与 callback wrapper 统一使用 clong;Windows timeval 字段也采用 clong。 编译器与平台 mormot.lib.openssl11 cdec1b9d+33-33

lib: another pass to fix clong OpenSSL usage

影响

OpenSSL control wrapper 现匹配各 Delphi/FPC 目标的 C 调用约定;高层 TLS 代码保持源兼容。

公开 API

  • SSL_CTX_set_modesignature-changed
  • SSL_get_modesignature-changed

Arnaud Bouchez · 09:40 UTC · 在 GitHub 上查看该提交 →

45 中 OpenSSL 错误队列代码使用平台宽度类型 TErrQueueCode 作为 culong 别名;ERR_get_error、ERR_error_string_n 与 OpenSSL_error wrapper 改用该类型,EOpenSsl.LastError 改为 PtrInt。 编译器与平台 mormot.lib.openssl11 6b5cbea6+33-26

lib: introducing TErrQueueCode specific type

影响

64-bit POSIX 错误队列值不再截断为 32-bit;低层错误 helper signature 有变化。

值得一看

重编译调用 OpenSSL_error helper 或把 EOpenSsl.LastError 存入 integer 的代码。

公开 API

  • TErrQueueCodeadded
  • EOpenSsl.LastErrorsignature-changed

Arnaud Bouchez · 12:29 UTC · 在 GitHub 上查看该提交 →

46 中 其余 OpenSSL unsigned-long 声明得到修正 mormot.lib.openssl11 修正更多 culong signature,并区分 SSL integer error 与 TErrQueueCode;常量限制为 32-bit 的 flag 仍使用 cardinal。 编译器与平台 mormot.lib.openssl11 48dd6495+11-11

lib: minor OpenSSL API fixes

影响

OpenSSL 错误报告与 option wrapper 在各平台上对齐实际 C 类型域。

Arnaud Bouchez · 13:53 UTC · 在 GitHub 上查看该提交 →

47 中 CNG 证书构造收紧 ownership 与 store 元数据 TCryptCertCng 构造围绕复制的 context、provider record 与显式 key option 重组;GetSystemStore 报告 identity 是否来自系统 store。 内部重构 mormot.crypt.win 6b71ac9f+49-41

crypt: refined TCryptCertCng

影响

新的 CNG identity 获得更明确的 ownership 与元数据;这是对本期新 API 的完善。

Arnaud Bouchez · 09:58 UTC · 在 GitHub 上查看该提交 →

48 中 CNG 区分 store identity 与临时 PFX identity TCryptCertCng 将 context 初始化与 store 元数据分离,并让 ICryptCertCng.GetSystemStore 返回 boolean 以及 store/location 输出。 内部重构 mormot.crypt.win 5c0c3dec+34-21

crypt: refined ICryptCertCng usage

影响

调用方可可靠判断 CNG 证书来自持久 Windows store 还是内存 PFX。

公开 API

  • ICryptCertCng.GetSystemStoresignature-changed

Arnaud Bouchez · 11:19 UTC · 在 GitHub 上查看该提交 →

49 低 Windows 证书 provider 元数据新增专用 wrapper mormot.lib.sspi 新增 TWinCertKeyProviderInfo 与 WinCertCtxtKeyProvider 来解码 CERT_KEY_PROV_INFO_PROP_ID;CNG store 加载改用该精简 record。 新功能 mormot.lib.sspi+1 fe37aa9f+77-21

lib: new TWinCertKeyProviderInfo CNG API wrapper

影响

Windows 调用方获得更轻量的 provider 信息查询;现有 TWinCertInfo 解码仍可用,应用代码无需更改。

公开 API

  • TWinCertKeyProviderInfoadded
  • WinCertCtxtKeyProvideradded

Arnaud Bouchez · 08:14 UTC · 在 GitHub 上查看该提交 →

50 低 RSA envelope header 统一为单一定义 TRsaSealHeader 与 PRsaSealHeader 移至 mormot.core.os.security,使纯 Pascal RSA 与 OpenSSL 使用完全相同的 packed layout;RsaOpen callback 改为 const。 内部重构 mormot.core.os.security+3 e0f6cbb5+21-36

core: moved TRsaSealHeader to mormot.core.os.security

影响

envelope 兼容性得到集中定义,wire format 不变;需要公开 header 类型的代码应导入 mormot.core.os.security。

公开 API

  • TRsaSealHeaderadded

Arnaud Bouchez · 14:18 UTC · 在 GitHub 上查看该提交 →

51 低 CNG key 获取选项取代多个 boolean TWinCertCngKeyOption 与 TWinCertCngKeyOptions 表示 silent、key comparison 与 cache 选项;TWinCertCngKey.Init 和 TCryptCertCng 改用该 set。 内部重构 mormot.lib.sspi+1 08e67973+26-13

lib: introducing TWinCertCngKeyOptions

影响

新的 CNG 代码可显式组合 key 获取行为。该 API 在同一期内引入,不影响既有调用。

公开 API

  • TWinCertCngKeyOptionsadded

Arnaud Bouchez · 08:24 UTC · 在 GitHub 上查看该提交 →

52 低 Socket 重试时序改用单一 deadline TrySockRecv 计算结束 tick 与剩余时间,分离 nrOk 和 RecvPending 快速路径,并在 accept-state lock 内完成 AcceptEx context 设置;同时删除冗余 PKCS#11 initializer。 内部重构 mormot.net.sock+2 19ddf82e+15-19

net: minor simplification/cleanup of #622 PR

影响

此前 timeout 与 IOCP 修复保持行为不变,同时获得更清晰 invariant 与原子 accept finalization。

Arnaud Bouchez · 17:21 UTC · PR #622 · 在 GitHub 上查看该提交 →

53 低 SChannel PFX 加载复用安全 Windows importer TSChannelServerContext.LoadCertificate 用 WinCertStoreImportPfx 取代内联 PFXImportCertStore 与密码转换,然后擦除 UTF-8 密码并检查错误。 内部重构 mormot.net.sock.windows+2 18dca4de+8-22

net: simplified TSChannelServerContext.LoadCertificate

影响

SChannel 服务器证书加载的公开行为不变,但密码清理与错误处理得到统一。

Arnaud Bouchez · 09:52 UTC · 在 GitHub 上查看该提交 →

54 低 Windows CryptoAPI AES provider 初始化简化 mormot.crypt.win 简化 PROV_RSA_AES provider 状态检查与尾部 XOR helper,不改变公开 AES 类。 内部重构 mormot.crypt.win 7f601fcc+13-16

crypt: minor PROV_RSA_AES support refactoring on Windows

影响

应用代码无影响;公开的 CryptoAPI AES mode 与错误保持不变。

Arnaud Bouchez · 15:26 UTC · 在 GitHub 上查看该提交 →

55 低 SChannel Receive 设置明确 fatal 默认值 TLS Channel Receive 将 result 初始化为 nrFatalError,并简化 pending output 与异常捕获的 early exit,以避免 Delphi 7 warning。 内部重构 mormot.net.sock.windows 8df1fca0+6-10

net: refactored TLS Channel Receive() method

影响

这些不支持或错误路径仍返回 fatal;Delphi 7 不再警告 result 未初始化。

Arnaud Bouchez · 10:30 UTC · 在 GitHub 上查看该提交 →

56 低 ZIP 条件编译避免误导性的 FPC hint mormot.core.zip 调整 FPC 专用符号的条件声明与赋值,以消除错误 compiler hint,不改变执行逻辑。 杂项 mormot.core.zip 507833b7+9-9

core: circumvent some weird FPC compiler hints

影响

FPC 构建更安静;Delphi/FPC 后端行为与公开 API 不变。

Arnaud Bouchez · 08:32 UTC · 在 GitHub 上查看该提交 →

上游活动 每日提交数 · 最近 60 天
提交977
活跃天数44/60
最忙一天2026-09-30
峰值60
2026-08-15: 0 commits2026-08-16: 0 commits2026-08-17: 0 commits2026-08-18: 0 commits2026-08-19: 0 commits2026-08-20: 0 commits2026-08-21: 0 commits2026-08-22: 0 commits2026-08-23: 0 commits2026-08-24: 0 commits2026-08-25: 0 commits2026-08-26: 0 commits2026-08-27: 26 commits2026-08-28: 11 commits2026-08-29: 10 commits2026-08-30: 1 commit2026-08-31: 23 commits2026-09-01: 0 commits2026-09-02: 20 commits2026-09-03: 29 commits2026-09-04: 35 commits2026-09-05: 13 commits2026-09-06: 0 commits2026-09-07: 0 commits2026-09-08: 23 commits2026-09-09: 10 commits2026-09-10: 17 commits2026-09-11: 23 commits2026-09-12: 14 commits2026-09-13: 9 commits2026-09-14: 7 commits2026-09-15: 4 commits2026-09-16: 24 commits2026-09-17: 26 commits2026-09-18: 21 commits2026-09-19: 59 commits2026-09-20: 13 commits2026-09-21: 5 commits2026-09-22: 34 commits2026-09-23: 17 commits2026-09-24: 57 commits2026-09-25: 22 commits2026-09-26: 26 commits2026-09-27: 0 commits2026-09-28: 2 commits2026-09-29: 19 commits2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 33 commits2026-10-11: 9 commits2026-10-12: 11 commits2026-10-13: 35 commits
2026-08-152026-10-13