Worth a looka fix or feature you may wantThe PKCS#8 pull request reports successful Delphi 7 and Delphi 13 tests but says FPC was not run by its contributor. The implementation is pure Pascal and adds no OpenSSL runtime dependency, but FPC services should still run their own key-loading and signing regression tests.
Standard key encryption and modern PDF security land together
This edition removes two interoperability gaps: password-protected private keys can use standard PKCS#8 without loading OpenSSL, and the PDF engine gains AES-256 plus PDF 2.0 output. The private-key save format changes by default, so Delphi and FPC services that exchange encrypted keys with older mORMot2 builds should review compatibility. The remaining commits integrate the PDF branch with current master and extend its regression coverage.
TL;DR
- TCryptPrivateKey now loads standard PBES2/PBKDF2 PKCS#8 keys and saves password-protected keys as standard PKCS#8 by default.
- mormot.ui.pdf adds opt-in AES-256 revision 6 encryption and PDF 2.0 output, including XMP metadata and a required file identifier.
- The two rebase commits carry existing master PDF fixes and tests into the feature branch; they are not separate upgrade signals.
Upgrade advice
Land on merged revision c12b33766ebb3731ddda4eaeaf221e31ec578cec, build 2.4.17677. Services that persist password-protected keys should review the new TCryptPrivateKey.Save default and set PrivateKeySavePkcs8 to false only when an older mORMot2 version must read the result. PDF producers should test representative AES-256 and PDF 2.0 files; the raw payload lists no superseding fix for these commits.
5 of 5 entries · 8 commits upstream
1
Medium
PDF output gains AES-256 protection and an opt-in PDF 2.0 mode
mormot.ui.pdf adds TPdfEncryptionAes256 and elAES_256 for the ISO 32000-2 revision 6 security handler. Strings and streams use AES-256-CBC with a random IV and PKCS#7 padding, while TPdfEncryption.EncodeLength lets writers allocate the larger encrypted output before writing /Length. TPdfDocument.GeneratePdf20File switches the header to PDF 2.0, emits XMP metadata and a file ID, removes the Adobe extension for native AES-256, and rejects RC4 or PDF/A when saving in this mode.
New features
mormot.ui.pdf
5c94af95+366-30
pdf: AES-256 encryption and PDF 2.0 output
Impact
Delphi and FPC callers can keep existing PDF settings unchanged or explicitly select stronger encryption and PDF 2.0 output. The additions are source-compatible, but GeneratePdf20File deliberately raises EPdfInvalidOperation if combined with RC4 or PDF/A, and AES output is longer because every encrypted string or stream carries an IV and padding. Services should verify reader compatibility, permissions and document opening with representative files before enabling the mode.
Worth a look
For PDF-producing services, create test files with elAES_256 and GeneratePdf20File, then open them with every supported reader and verify user and owner passwords plus permission flags. Do not combine GeneratePdf20File with RC4 or PDF/A.
Public API
TPdfFileFormat.pdf20added — Adds PDF 2.0 to the internal file-format enumeration exposed by the unit.TPdfEncryptionLevel.elAES_256added — Selects the ISO 32000-2 revision 6 AES-256 security handler.TPdfEncryptionAes256added — Implements revision 6 document keys and AES-256-CBC encryption for PDF strings and streams.TPdfEncryption.EncodeLengthadded — Reports encrypted output size so AES IV and padding are reflected in stream lengths.TPdfDocument.GeneratePdf20Fileadded — Enables PDF 2.0 output and enforces its encryption and PDF/A restrictions when saving.
Units
2
Medium
Standard encrypted PKCS#8 keys now work without loading OpenSSL
mormot.crypt.secure adds Pkcs8DecryptPrivateKey for PBES2 with PBKDF2 over HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384 or HMAC-SHA512 and AES-128/192/256-CBC. Pkcs8EncryptPrivateKey emits PBES2 with PBKDF2-HMAC-SHA256, AES-256-CBC and 100000 rounds by default. TCryptPrivateKey.Load tries standard PKCS#8 before the legacy PrivateKeyDecrypt format, while TCryptPrivateKey.Save now emits standard PKCS#8 for password-protected keys unless PrivateKeySavePkcs8 is false.
Compiler & platform
mormot.crypt.secure+1
5cdbf675+320-6
crypt: standard PKCS#8 encrypted private keys without OpenSSL
Impact
Delphi and FPC backends can load OpenSSL 1.1/3.x default encrypted private keys through the pure-Pascal crypto engine, without deploying mormot.crypt.openssl or libcrypto. Existing encrypted keys remain readable, but newly saved password-protected keys are no longer readable by older mORMot2 versions unless PrivateKeySavePkcs8 is disabled. This is a wire-format compatibility change, not a source migration.
Worth a look
Check every TCryptPrivateKey.Save or TCryptCertX509.Save path that persists a password-protected key. Keep the new default for interoperability, or set PrivateKeySavePkcs8 to false before saving when an older mORMot2 consumer cannot be upgraded.
Public API
Pkcs8DecryptPrivateKeyadded — Decrypts supported PBES2/PBKDF2/AES-CBC PKCS#8 PEM or DER input without OpenSSL.Pkcs8EncryptPrivateKeyadded — Encrypts PKCS#8 PrivateKeyInfo with PBKDF2-HMAC-SHA256 and AES-256-CBC.PrivateKeySavePkcs8added — Global compatibility switch; false restores the proprietary encrypted-key output.TCryptPrivateKey.Savebehaviour-changed — Password-protected output is standard PKCS#8 by default instead of PrivateKeyEncrypt.
3
Low
The PDF branch imports the current master regression suite
The test.ui.pdf branch snapshot imports 1292 lines of the then-current master regression suite, including EMF alpha blending, path restore depth, scaled rotation, ANSI and stock-font code pages, retained DIBits, mirrored boxes, clipping and underline cases. It also retains the new EncryptionAes256 and Pdf20File methods. Upstream PR discussion confirms that this rebase commit carries master content into the feature branch rather than introducing a separate runtime change.
Tests
test.ui.pdf
40f34efd+1292-1
rebase on current master
Impact
There is no application-code or generated-PDF change attributable to this commit alone. It aligns the feature branch tests with coverage already present on master, so Delphi and FPC production backends have no action to take for this entry.
Units
4
Low
Regression tests verify AES-256 dictionaries and PDF 2.0 structure
test.ui.pdf adds EncryptionAes256 and Pdf20File. The tests inspect the revision 6 encryption dictionary, decrypt a protected string with the generated file key, verify the PDF 2.0 header, XMP metadata and file ID, confirm that native AES-256 omits the Adobe extension, and assert that RC4 is refused for PDF 2.0.
Tests
test.ui.pdf
a5c6feff+114-0
test: AES-256 and PDF 2.0 regression tests
Impact
This commit changes only the PDF regression suite. Delphi and FPC application code and generated documents are unchanged, but maintainers now have explicit checks for the security dictionary and the structural constraints of the new output modes.
Units
5
Low
The PDF implementation branch is synchronized with current master
This branch-synchronization commit brings mormot.ui.pdf up to the then-current master before the AES-256/PDF 2.0 merge. Its large diff carries existing printer, EMF, character-set and path-rendering work from master, including FontCharSetCodePage, StockFontCodePage and the reserved elAES_128 enum value. The final pull-request diff isolates AES-256 and PDF 2.0 as the new feature; upstream discussion explicitly identifies both rebase commits as copies of master content.
Housekeeping
mormot.ui.pdf
0e15a8de+626-120
rebase on current master
Impact
Applications already following mORMot2 master do not gain an independent API or behaviour change from this synchronization commit. It only makes the feature branch contain the same prior fixes as master before merge, so neither Delphi nor FPC backends need a separate migration or upgrade decision for it.