mORMot2 DailyDaily read of upstream commits

Crypto hardening reaches RSA, P-256 and authenticated tunnels

This complete Tuesday edition combines a broad RSA and CSPRNG hardening pass with strict validation of P-256 public keys. Tunnel handshakes now authenticate their JSON payloads and reject oversized or excessive queued frames. HTTP servers also emit the RFC-required Content-Range header on 416 responses. Direct TBigInt.IsPrime callers must migrate to the new TAesPrngAbstract argument.

TL;DR

  • Use build 2.4.17609 for the complete crypto, tunnel and HTTP hardening sequence.
  • P-256 ECDH and ECDSA now reject malformed, non-canonical and off-curve public keys before arithmetic.
  • Certificate-authenticated tunnel handshakes now cover their JSON payload and enforce frame and queue limits.
  • RSA padding, signatures, prime generation and OS-random failure handling receive additional safeguards.
  • TBigInt.IsPrime now accepts TAesPrngAbstract instead of PLecuyer; direct callers must migrate.
  • HTTP 416 responses now carry one correct Content-Range: bytes */<size> header.

Upgrade advice

Use build 2.4.17609 rather than stopping in the middle of this hardening sequence. Recompile direct TBigInt.IsPrime callers with TAesPrngAbstract, deploy both ends of certificate-authenticated tunnels together, and rerun RSA, P-256, tunnel and HTTP range tests on every Delphi/FPC target you ship.

Build2.4.17580 → 2.4.17609
Commits31
Lines+2301 -737
Read6 min

30 of 30 entries · 31 commits upstream

Stories
# Entry Category Units
1 Critical P-256 operations reject public points outside the curve The Pascal P-256 backend validates canonical coordinates and the curve equation before ECDH or ECDSA arithmetic, validates private scalars, rejects invalid compressed prefixes and zeroes failed outputs. Security mormot.crypt.ecc256r1 3a734d76+107-31

crypt: validate an affine P-256 point before using it for ECC operations

Impact

Untrusted malformed P-256 keys are rejected before scalar multiplication or signature verification in Delphi and FPC builds using the Pascal backend.

Public API

  • ecdh_shared_secret_pasbehaviour-changed — Returns false and a zeroed secret for malformed, off-curve or invalid-scalar inputs.

Arnaud Bouchez · 16:43 UTC · view the commit on GitHub →

2 High RSA primality tests switch from L'Ecuyer state to a NIST DRBG TBigInt.IsPrime replaces its optional PLecuyer parameter with TAesPrngAbstract. Internal prime generation now uses TAesPrng.Main for Miller-Rabin witnesses. Breaking changes mormot.crypt.rsa 9bce2b48+23-18

crypt: enhanced RSA compliance with NIST recommandations

Impact

Direct callers passing a PLecuyer pointer no longer compile; default callers silently move to the framework's AES-based DRBG on Delphi and FPC.

Migration required

Search for TBigInt.IsPrime calls with a third argument and pass a TAesPrngAbstract instance instead.

Public API

  • TBigInt.IsPrimesignature-changed — The third parameter is now TAesPrngAbstract instead of PLecuyer.

Arnaud Bouchez · 08:41 UTC · view the commit on GitHub →

3 High Tunnel certificates now authenticate the JSON handshake payload TTunnelLocal.OpenInternal appends JSON before FrameSign, verifies the signature over the fixed handshake plus JSON ciphertext, validates lengths first and decrypts only after authentication. Security mormot.net.tunnel 700b6ad5+42-28

net: tunnel authenticate its JSON handshake payload with certificates

Impact

Certificate-authenticated tunnels detect tampering with InfoNameValue data. Because the signed frame layout changed, both tunnel endpoints should run the same revision.

Arnaud Bouchez · 15:43 UTC · view the commit on GitHub →

4 High System-random failures now stop security-sensitive operations TAesPrngAbstract.GetEntropy, TSystemPrng.FillRandom and TCryptRandomSysPrng.Get raise on required OS API failure. TBigInt.FillPrime seeds through FillRandomTrusted and rejects an empty result. Security mormot.crypt.core+2 efdf73f3+32-17

crypt: hardened FillSystemRandom() API usage

Impact

Delphi and FPC backends fail explicitly instead of continuing after unavailable OS randomness; RSA key generation now depends on a compliant source being present.

Public API

  • TAesPrngAbstract.GetEntropybehaviour-changed — System-only modes now raise ESynCrypto when the operating-system source fails.
  • TSystemPrng.FillRandombehaviour-changed — The method now raises ESynCrypto instead of ignoring an OS random-source failure.

Arnaud Bouchez · 14:21 UTC · view the commit on GitHub →

5 High RSA verification rejects non-exact DER and PSS signatures keep fixed width TRsa.Verify now compares the recovered DigestInfo with the exact DER produced by RsaSignHashToDer. TRsaPss.Sign serializes the CRT result with SaveFixed(fModulusLen). Security mormot.crypt.rsa 118b6572+16-26

crypt: some RSA hardening

Impact

Malformed, truncated or extended PKCS#1 v1.5 DigestInfo encodings are rejected, and native PSS signatures retain modulus width across Delphi and FPC.

Arnaud Bouchez · 11:55 UTC · view the commit on GitHub →

6 High Tunnels reject oversized frames and handshake queue floods TTunnelLocal.TunnelSend enforces a 72 KB frame ceiling and a 128-frame handshake queue limit. The Info key derivation also gains an explicit domain-separation label. Security mormot.net.tunnel 7a471dd7+30-10

net: defensive limits against malformed or excessive tunnel frames

Impact

Malformed relays or peers can no longer enqueue unbounded handshake data or send frames beyond the local receive contract; excessive input now raises ETunnel.

Arnaud Bouchez · 16:33 UTC · view the commit on GitHub →

7 High Miller-Rabin witnesses now follow FIPS 186-5 sampling TBigInt.FillMillerRabinWitness uses rejection sampling across the candidate's full bit width, then maps accepted values into the FIPS 186-5 B.3.1 witness interval. Security mormot.crypt.rsa 319cd63e+19-18

crypt: RSA Miller-Rabin witness selection as described in FIPS 186-5 B.3.1

Impact

RSA prime testing no longer biases witnesses through a truncated modulus; Delphi and FPC key generation gain the final standards-compliance correction.

Arnaud Bouchez · 09:06 UTC · view the commit on GitHub →

8 High Certificate key decompression failures can no longer pass silently Ecc256r1Uncompress now documents zero output on failure. TEccCertificate.LoadFromStream rejects that output, constructors raise, and Ecc256r1UncompressAsn1 returns an empty result for invalid input. Security mormot.crypt.ecc+1 74778eda+17-6

crypt: ensure public keys decompression is validated

Impact

Malformed compressed P-256 certificate keys fail loading or construction instead of leaving a zero public point available to later verification code.

Public API

  • Ecc256r1Uncompressbehaviour-changed — Invalid input is represented by a zeroed uncompressed output and is checked by certificate callers.

Arnaud Bouchez · 17:01 UTC · view the commit on GitHub →

9 High PKCS#1 v1.5 encryption padding now uses nonzero CSPRNG bytes TRsa.Pkcs1Pad replaces SharedRandom.Fill plus byte adjustment with GetDrbg.FillRandomNotZero for EME-PKCS1-v1_5 block type 2 padding. Security mormot.crypt.rsa 6a8ede59+8-11

crypt: EME-PKCS1-v1_5 requires non zero unpredictable random padding

Impact

Native RSA encryption no longer derives its mandatory nonzero padding from the lightweight shared generator; ciphertext format and calling APIs remain unchanged.

Arnaud Bouchez · 11:38 UTC · view the commit on GitHub →

10 High Native RSA signatures verify themselves before returning TRsa.Sign and TRsaPss.Sign immediately call Verify on each nonempty result and raise ERsaException when the generated signature fails verification. Security mormot.crypt.rsa d4303584+11-3

crypt: self-verification of the RSA/RSA-PSS signature

Impact

Faults or internal arithmetic errors can no longer silently emit an invalid PKCS#1 or PSS signature, at the cost of an additional public-key verification.

Arnaud Bouchez · 12:31 UTC · view the commit on GitHub →

11 High The new exponent-65537 filter handles negative accumulators correctly TBigInt.PrimeAllowedFor65537 changes i, v and sum from PtrUInt to PtrInt because its limb reduction deliberately subtracts values and may produce a negative sum. Fixes mormot.crypt.rsa a580c994+3-3

crypt: fixed previous commit accumulator sign

Impact

The immediately preceding RSA prime-candidate optimization no longer interprets a negative accumulator as unsigned on Delphi or FPC targets.

Arnaud Bouchez · 12:51 UTC · view the commit on GitHub →

12 High XorRandom now advances through buffers larger than 8 KB TAesPrngAbstract.XorRandom increments its Buffer pointer after each temporary chunk. Previously every loop XORed the first chunk again while reducing Len. Fixes mormot.crypt.core 768b8f66+3-2

crypt: fixed TAesPrngAbstract.XorRandom method

Impact

Calls longer than the internal 8 KB temporary buffer now randomize the complete destination instead of repeatedly modifying only its beginning.

Public API

  • TAesPrngAbstract.XorRandombehaviour-changed — Buffers larger than the internal chunk size are now processed in full.

Arnaud Bouchez · 13:11 UTC · view the commit on GitHub →

13 Medium RSA consistently resolves its configured CSPRNG before use TRsa.GetDrbg lazily assigns TAesPrng.Main when fDrbg is nil. The Drbg property, hybrid sealing and PSS salt generation now use that accessor and FillRandom. Security mormot.crypt.rsa 2f93121c+17-12

crypt: use our CSPRNG for RSA padding/DRBG

Impact

RSA padding and salt paths always operate through a concrete TAesPrngAbstract instance on Delphi and FPC; configured custom generators remain supported.

Public API

  • TRsa.Drbgbehaviour-changed — Reading the property now materializes and returns TAesPrng.Main instead of returning nil by default.

Arnaud Bouchez · 11:37 UTC · view the commit on GitHub →

14 Medium RSA prime worker secrets are wiped by their destructor TRsaPrimeWorker.Destroy now calls FillZero(NewPrime), centralizing cleanup for success and early-exit paths instead of wiping only after the normal handoff. Security mormot.crypt.rsa 351645ad+10-4

crypt: hardened TRsaPrimeWorker cleanup

Impact

Temporary generated prime material has a narrower lifetime in memory during native RSA generation; application APIs and generated keys are unchanged.

Arnaud Bouchez · 12:20 UTC · view the commit on GitHub →

15 Medium HTTP 416 responses report the unsatisfied representation size THttpRequestContext.RangeNotSatisfiable adds Content-Range: bytes */<size>, clears rfRange and rfWantRange, and is used by stream, file and progressive static-file paths. Fixes mormot.net.http+1 652183f7+71-16

net: send Content-Range: bytes */<size> with a 416 response

Impact

Range clients receive the RFC 9110 size hint and no longer risk a second incorrect Content-Range derived from the generated HTML error body.

Public API

  • THttpRequestContext.RangeNotSatisfiableadded — Adds the RFC 9110 Content-Range header, clears range flags and returns HTTP_RANGENOTSATISFIABLE.

Sven Harazim · 14:35 UTC · view the commit on GitHub →

16 Medium Password generation has a bounded retry loop MakeStrongPassWord accepts an optional iteration counter and raises ESynCrypto after 128 failed quality checks. TAesPrngAbstract.RandomPassword and TCryptRandom.GetPassword pass counters into it. Fixes mormot.crypt.core+1 cb709f73+28-14

crypt: hardened MakeStrongPassWord()

Impact

A weak or broken random provider can no longer keep the standard AES password generator in an unbounded loop; normal generated passwords are unchanged.

Public API

  • MakeStrongPassWordsignature-changed — An optional PInteger retry counter was added; existing one-argument calls remain source-compatible.

Arnaud Bouchez · 14:45 UTC · view the commit on GitHub →

17 Medium RSA prime generation initializes its DRBG before parallel work TRsa.Generate resolves GetDrbg once before starting prime workers and passes that instance to both sequential and local FillPrime calls; FillPrime removes a redundant nil check. Fixes mormot.crypt.rsa 14502d3f+7-7

crypt: some RSA fixed of DRBG

Impact

Custom or default random generators are initialized consistently before RSA prime searches on Delphi and FPC; public key-generation calls do not change.

Arnaud Bouchez · 12:07 UTC · view the commit on GitHub →

18 Medium The AES CSPRNG can now fill buffers without zero bytes TAesPrngAbstract.FillRandomNotZero first fills the requested buffer, replaces any zero octets from fresh 16-byte blocks, wipes temporary material and raises ESynCrypto if a zero remains. New features mormot.crypt.core+1 626baa30+87-28

crypt: new TAesPrngAbstract.FillRandomNotZero method

Impact

Delphi and FPC code that needs PKCS-style nonzero random padding can use one checked CSPRNG operation; existing callers are unchanged.

Public API

  • TAesPrngAbstract.FillRandomNotZeroadded — Fills a supplied buffer with CSPRNG bytes and guarantees that no byte is zero.

Arnaud Bouchez · 11:31 UTC · view the commit on GitHub →

19 Medium A new helper combines operating-system and hardware randomness TAesPrngAbstract.FillRandomTrusted requests blocking system randomness and, on supported Intel or AMD CPUs, XORs RDRAND output; it returns an empty string when no accepted source is available. New features mormot.core.os+1 fcaa3d81+33-3

crypt: new TAesPrngAbstract.FillRandomTrusted() method

Impact

Native cryptographic seeding can explicitly require combined trusted sources and detect their absence; normal TAesPrng filling remains unchanged.

Public API

  • TAesPrngAbstract.FillRandomTrustedadded — Returns random bytes from accepted external sources for key seeding, or an empty string on failure.

Arnaud Bouchez · 14:20 UTC · view the commit on GitHub →

20 Medium RSA key generation computes its two primes on separate cores TRsa.Generate runs p and q prime searches in two worker tasks, coordinates completion and preserves the existing timeout and cleanup paths. Performance mormot.crypt.rsa 0f2aa131+103-27

crypt: compute p/q RSA primes in parallel in two CPU cores

Impact

RSA key creation can use two CPU cores and complete faster; generated key formats and application calls are unchanged.

Worth a look

Benchmark key generation and confirm worker-thread limits in constrained services.

Arnaud Bouchez · 08:09 UTC · view the commit on GitHub →

21 Low A base-two pretest rejects composite RSA candidates sooner TBigInt.IsPrime performs one strong probable-prime test with witness 2 before allocating and running the requested random Miller-Rabin rounds. Performance mormot.crypt.rsa 5be3ad0c+46-18

crypt: faster TBigInt.IsPrime by using base-2 pretest

Impact

RSA generation discards many composite candidates more cheaply, improving key-generation time with no application change.

Arnaud Bouchez · 07:03 UTC · view the commit on GitHub →

22 Low RSA prime candidates get a direct exponent-65537 filter TBigInt.PrimeAllowedFor65537 computes the candidate modulo 65537 directly from its limbs and replaces allocation-heavy Modulo and Compare calls in both prime-generation paths. Performance mormot.crypt.rsa 0df7461d+30-5

crypt: new TBigInt.PrimeAllowedFor65537 method

Impact

Native RSA key generation performs less temporary BigInt work when rejecting candidates incompatible with exponent 65537; no public API changes.

Arnaud Bouchez · 12:44 UTC · view the commit on GitHub →

23 Low The common RSA exponent gets a dedicated fast path TRsaContext detects exponent 65537 and uses a short fixed square-and-multiply sequence instead of the generic exponent loop. Performance mormot.crypt.rsa 4f07c5c3+16-12

crypt: optimize exponent common prime 65537

Impact

RSA public operations with exponent 65537 become faster on Delphi and FPC without API or output changes.

Arnaud Bouchez · 07:05 UTC · view the commit on GitHub →

24 Low RSA modular powers use a four-bit sliding window TRsaContext.ModPower expands its precomputed odd-power table from three to four bits and adjusts the scanning loop accordingly. Performance mormot.crypt.rsa e1d2b232+6-6

crypt: use 4-bit sliding window for TRsaContext.ModPower

Impact

Large private-exponent RSA operations use fewer modular multiplications; callers and serialized results are unchanged.

Arnaud Bouchez · 07:04 UTC · view the commit on GitHub →

25 Low RSA BigInt cleanup makes release-and-nil behavior explicit TBigInt.IsPrime and TRsaContext.AllocateFromHex replace the legacy Release([@pointer]) overload with direct Release calls followed by explicit nil assignments. Under the hood mormot.crypt.rsa 12297671+8-5

crypt: minor RSA code cleanup

Impact

This clarifies ownership and failure cleanup inside the native RSA engine; application code, serialized values and runtime behavior are unchanged.

Arnaud Bouchez · 13:07 UTC · view the commit on GitHub →

26 Low ECC tests cover invalid prefixes, scalars and off-curve points TTestCoreEcc.ECC adds negative ECDH cases for invalid compressed markers, non-canonical X, a quadratic non-residue, a zero uncompressed point and a zero private scalar. Tests c9f379d8+33-2

tests: Validate invalid ecc public keys (out of the curve)

Impact

No application-code change. The Pascal ECC validation paths now have regression coverage for the malformed keys fixed earlier in the edition.

Arnaud Bouchez · 17:05 UTC · view the commit on GitHub →

27 Low Security notes are refreshed for the AES PRNG and native RSA The TAesPrng design document is rewritten against current trunk and a new mormot.crypt.rsa audit describes BigInt arithmetic, key generation, padding, signatures and trust boundaries. Docs c3e08fe8+626-381

doc: enhanced security audit documents

Impact

There is no runtime or application-code change; security reviewers gain current implementation guidance for Delphi and FPC deployments.

Arnaud Bouchez · 14:54 UTC · view the commit on GitHub →

28 Low Tunnel security guidance defines the relay threat boundary A new mormot.net.tunnel security review documents ECDHE, AES-128-GCM, signatures, AppSecret requirements, relay capabilities, deployment guidance and protocol limitations. Docs 5336ba7b+531-2

doc: Tunnel usage and security audit

Impact

No runtime change. Deployments gain explicit guidance that ECDHE alone does not authenticate against an active relay without a trusted certificate or strong independent AppSecret.

Worth a look

Audit tunnel deployments for trusted VerifyCert configuration or a confidential independently provisioned AppSecret with at least 128 bits of entropy.

Arnaud Bouchez · 17:42 UTC · view the commit on GitHub →

29 Low SChannel mutual TLS receives a focused security review A new SChannel-mTLS document records server certificate handling, client-certificate chain validation, callbacks, trust anchors, ownership and known Windows backend boundaries. Docs 4462e2f5+263-3

doc: new SChannel audit document

Impact

No executable code changes. Teams using native Windows TLS gain explicit deployment constraints for client authentication and callback overrides.

Arnaud Bouchez · 15:11 UTC · view the commit on GitHub →

30 Low Tunnel metadata is documented as obfuscated rather than secret The TTunnelLocal.Open contract now states that InfoNameValue is obfuscated with AppSecret but must not contain sensitive data. Docs mormot.net.tunnel b44fb747+4-3

doc: precisions about Tunnel Info name/value security expectations

Impact

No runtime change. Applications should keep credentials, tokens and other secrets out of InfoNameValue even when tunnel encryption is enabled.

Worth a look

Review every InfoNameValue payload and remove credentials or other sensitive values.

Arnaud Bouchez · 16:47 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-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: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28