Feature notes
Release notes 4.1.4.360
================================================================================
CHANGES - StreamSec Tools
(StreamSec Security Library for Embarcadero Delphi)
================================================================================
Grouped by subject and numbered straight through. Entries marked BEHAVIOUR
CHANGE alter what existing code does without any source change on your part -
read those before upgrading.
WHAT THIS FILE COVERS. Changes made SINCE release 4.1.3.359, which was
released on 2026-09-18. What that release itself brought is in
CHANGES_4.1.3.359.txt
and every earlier release is archived beside it the same way, one file per
version. So this file is always short: it is the difference between the zip
you have and the one you are looking at, and nothing else.
--------------------------------------------------------------------------------
SECURE DEFAULTS: WHAT THE LIBRARY DOES WHEN YOUR CODE DOES NOT CHOOSE - READ
THIS BEFORE UPGRADING
================================================================================
This block is first because it can change what an application does without a
line of the application being changed. Every setting the library chooses on
your behalf is now the secure one - in TLS, in signing, in verifying, in
PKCS#12 and in TstCipher's password path. Entry 1 goes through them one at a
time: what each was, who will notice, and what puts the old behaviour back.
Nothing that was possible before has been taken away.
1. BEHAVIOUR CHANGE - every default the library chooses for you is now the
secure setting
A FORM KEEPS WHAT IT STORES, and that decides whether an existing
application notices. A component on a form saved by an earlier release
keeps the value the form stores: every TLSOptions property of a TLS
component (stored explicitly since 4.1.2.355), DigestAlgorithm on the
certificate generators and ContentDigestAlg on the CMS components. Set
those in the Object Inspector. The hash properties of the key components
are the other way round: a form stores them only where they differ from
the default, so a form that left them alone loads the new default. A
component created at run time starts from the new defaults.
TLS 1.2 - TTLSOptions, the options of TsmStreamSecII and of every TLS
component:
- KeyAgreementDHE is prNotAllowed, where it was prAllowed. RFC 10015
deprecates the finite-field DHE suites in TLS 1.2: a client does not
offer them and a server does not select them. supported_groups no
longer lists ffdhe2048 to ffdhe8192 either, which a TLS 1.3
ClientHello listed without the library implementing them there.
- SignatureDSS is prNotAllowed, where it was prAllowed. DSA signs only
the DHE_DSS suites, and FIPS 186-5 keeps DSA for verifying existing
signatures only. signature_algorithms lists no DSA pair.
- signature_algorithms lists no MD5, SHA-1 or SHA-224 pair, which RFC
9155 section 2 bars from a client's list, and a server's
CertificateRequest lists none either (section 3). HashAlgorithmSHA1,
prNotAllowed by default already, now decides both, as its
documentation always said.
- The client refuses a ServerKeyExchange signed over MD5, SHA-1 or
SHA-224, and the server such a CertificateVerify, with
illegal_parameter (RFC 9155 sections 4 and 5). A client whose server
asked for nothing stronger signs its own CertificateVerify over
SHA-256.
- The server gives an RSA-signed suite only to a client that offers RSA
over SHA-256, SHA-384 or SHA-512, and an ECDSA suite to a client that
offers ECDSA over all three. The ECDSA test used to demand SHA-1 and
SHA-224 as well, which no client that follows RFC 9155 offers - so a
server with an ECDSA certificate now serves such clients ECDSA suites.
WHO NOTICES: a TLS 1.2 peer that can do nothing but DHE, DSA or SHA-1
signatures. A TLS 1.3 handshake is not affected by these switches, beyond
the ffdhe groups; certificate chains are, in both versions - see the hash
floor below. To put one back, set KeyAgreementDHE, SignatureDSS or
HashAlgorithmSHA1 to prAllowed.
TsmTLSClient, THE HTTPS AND REST CLIENTS AND TsmAsyncTLSServer are built
on TsmCustomSimpleTLSInternalServer, which set options of its own over the
defaults: the CBC suites (AES-128 preferred, AES-256 allowed), DHE
preferred to ECDHE, and P-256 for ECDHE. It now takes TTLSOptions as they
stand - the AEAD suites over ECDHE in TLS 1.2, the curve chosen from
SupportedGroups - which is what entry 63 of the 4.1.2.355 notes said every
new TLS engine did. To put it back, set those Options on the component.
SIGNING - SHA-256 WHERE IT WAS SHA-1:
- TstCertificateGenerator and TstRequestCertificateGenerator:
DigestAlgorithm.
- TstRSAKey: PSS over SHA-256 with MGF1-SHA-256 and a 32-octet salt,
where it was PSS over SHA-1 with MGF1-SHA-1 and 20 octets.
- TstECDSAKey and TstDSSKey: DigestAlgorithm.
- CMS SignedData - TstMPSignedData and what is built on it, S/MIME and
CAdES among them: ContentDigestAlg is haDefault, which picks per
signer - the hash its RFC prescribes for an EdDSA or ML-DSA signer,
otherwise the key's own SignatureDigestAlg when that is SHA-256 or
stronger, otherwise SHA-256. It was haSHA1.
To put one back, set the property. A caller that names the hash itself is
not affected.
VERIFYING - THE SIGNATURE HASH FLOOR. A signature made over MD2, MD5 or
SHA-1 is refused: by tSigned.CheckSignature, for a certificate, a CRL, an
OCSP response or a PKCS#10 request, with pcvUnsupportedHashAlgorithm; by
CMS verification, for a signer and for a countersignature; and in an RFC
3161 time-stamp token. RSASSA-PSS with its default parameters counts as
SHA-1. One case is exempt, an object checked against itself: a
self-signed trust anchor checked as its own issuer, or a PKCS#10
request's proof of possession. A collision gains nothing there, because
only the holder of the key can sign; and an anchor is trusted for being in
the trust store, not for its signature. The chain filter refuses such a
certificate even to an OnInvalidCertificate handler that grants trust, and
a TLS certificate chain that holds one fails with crcInvalidSignature.
WHO NOTICES: a chain with a SHA-1 intermediate, a CRL or OCSP response
signed over SHA-1, a message signed over SHA-1, a time-stamp authority
that still signs over SHA-1. For material that has no replacement,
SelectLegacySignatureHashes (StreamSec.DSI.PkixSigned) lets them through,
process-wide, and SelectSignatureHashFloor puts the floor back.
PKCS#12 - PBES2 WHERE IT WAS TRIPLE DES AND 40-BIT RC2. A PFX written
without saying how is protected with PBES2 - PBKDF2 over HMAC-SHA-256 at
131072 iterations, and AES-256-CBC - for the key and for the
certificates. It used pbeWithSHAAnd3-KeyTripleDES-CBC for the key and
pbeWithSHAAnd40BitRC2-CBC for the certificates, both at 2000 iterations.
That is tPFX and iKeyAndCertStore (StorePrivateKey, StorePrivateKeyEx and
ImposeAuthSafeContent), the key stores of the TLS servers and of the ACME
client, and TstCertificateManager.ExportToPFXFile, whose aUsePBES2 is now
True and whose certificates get the protection its key gets - they got
40-bit RC2 even with aUsePBES2 True. tPFX writes version 3, the one RFC
7292 defines, where the key manager's export wrote 0. Reading is
unchanged: both kinds are read.
THE PASSWORD'S ENCODING IS THE CALLER'S, and the key object passed says
what it is. A tDualSecretKey (tDualSecretKey.CreateForPFX) gives the
PKCS#12 schemes and the PFX MAC the password as a BMPString with a NULL
terminator, as RFC 7292 appendix B.1 specifies for every password in a
PFX, and gives PBES2 and PBMAC1 its UTF-8 octets - the form OpenSSL writes
PBES2 in, and the one RFC 9879 requires for PBMAC1. Any other iSecretKey
is used as the octet string it is, for every scheme:
tSecretKey.CreateBMPStr gives RFC 7292's encoding throughout.
ExportToPFXFile and the ACME key store pass a tDualSecretKey.
AN OLDER RELEASE READING A PFX WRITTEN NOW under a tDualSecretKey finds
two PBES2 parts in it, the key bag and the certificate safe, keyed with
the UTF-8 octets. Releases 4.0.1.337 to 4.1.3.359 misread about one such
file in 128 - the defect entry 29 fixes, which is why this change needs
it - and releases before 4.0.1.337 cannot open it at all. Keyed with the
BMPString instead, its PBES2 parts are the ones releases before 4.0.1.337
wrote, and releases from 4.0.1.337 try that key first.
WHO NOTICES: an importer that reads only the legacy schemes, and an older
release of this library. To put it back, pass aCompatibility True, or
aUsePBES2 False.
TstCipher'S PASSWORD PATH. SetKeyPassword derives the key with PBKDF2 over
HMAC-SHA-256 at 131072 iterations (tPBKDF2_HMAC), where it used the
StreamSec tWPKDF2 at one iteration. Data keyed through SetKeyPassword by
an earlier release does not decrypt under the new default: set
PBKDFClass := tWPKDF2 before SetKeyPassword to read it. tWPKDF2 is
deprecated - entry 32.
Test\securedefaults\SecureDefaultsTest (82 checks) holds each default
above - the TLS 1.2 ClientHello read back by a parser of its own, a PFX
judged by its octets and opened again - and the hash floor through
CheckSignature, the chain filter and CMS, on Win32, Win64 and Linux64.
With any one of the defaults put back, its checks fail and no other.
2. FIXED - TstCertificateManager.ExportToPFXFile did not return for a
certificate whose chain reached a self-issued certificate in the manager
The export stores the certificate, then walks up its chain storing each
issuer until GetCACertificate answers nil. GetCACertificate answers a
self-issued certificate with the certificate itself - that is how the
chain filter reports a root - so once the walk reached a root it stored
that root again and again until memory ran out, and the call ended in
EOutOfMemory. That is every export whose chain reaches a root the manager
holds, and a self-signed certificate at once. The walk now stops at a
self-issued certificate, after storing it once, and after 16 certificates
should cross-certificates ever form a cycle. The harness of entry 1,
Test\securedefaults\SecureDefaultsTest, exports a self-signed identity -
one certificate in the PFX - and a leaf under a root - two. With the walk
as it was, it ends in EOutOfMemory at the first.
--------------------------------------------------------------------------------
SINGLE-SERVER PRIVATE INFORMATION RETRIEVAL: A CLIENT CAN READ ONE RECORD OUT
OF A SERVER'S TABLE WITHOUT THE SERVER LEARNING WHICH RECORD IT READ
================================================================================
A private-information-retrieval scheme answers a lookup without learning what
was looked up. The server holds a table; the client fetches record r; the
server ends the exchange knowing no more about r than before it began. These
are the SimplePIR and DoublePIR schemes of Henzinger and others, over
learning-with-errors, and both are new in this release.
What makes the privacy hold is the shape of the work, not secrecy about it. The
server's entire per-lookup computation is ONE matrix-vector product over EVERY
cell of the table, so a query for record 7 and a query for record 70000 are the
same instructions over the same octets, and take the same time. The query
itself is a vector of LWE samples: there is nothing in it to correlate with
anything, and two queries for the SAME record share essentially no word,
because the client draws a fresh secret and a fresh error vector each time.
The price is the hint. Once per epoch the client downloads a matrix that
depends on the table but not on any query - megabytes, where a query and an
answer are kilobytes - and neither scheme is worth its cost unless a client
makes many lookups against a table that changes rarely. Budget for the hint
before anything else.
THE TWO SCHEMES DIFFER IN WHAT THE HINT COSTS AND IN NOTHING ELSE THAT A
CALLER SEES. SimplePIR's hint grows with the square root of the table and is
cheap for short and long records alike; when one record changes, the server
recomputes only the hint rows that record occupies and ships those, rather
than a new hint. DoublePIR's hint does not grow with the record count at all -
that is the whole reason it exists - but it grows with the record LENGTH, and
it has no rows a server can push, so any change to the table means a new hint
and a new download. Short records and a large table are DoublePIR's case; long
records, or a table that is edited often, are SimplePIR's. Entries 4 and 5 give
the arithmetic for both.
3. NEW - StreamSec.PIR.Scan, the scan kernel
The matrix-vector product the whole scheme rests on, over UInt32 with
arithmetic modulo 2^32 - which is what the type already does, so no line in
the unit reduces. tPirScan.MatVec and tPirScan.MatVecT are class methods
over plain pointers, and both walk their matrix in storage order, so the
transposed product streams as well as the forward one.
The product is bound by memory bandwidth rather than by arithmetic: it
touches every cell once and does two operations per cell. That is worth
knowing before sizing hardware for it, because a faster core does not help
a kernel that is already waiting on RAM.
There is an AVX2 arm, and IT IS NOT ON EVERY BUILD THAT HAS THE HARDWARE.
It is used on 64-bit Windows with Delphi 11 Alexandria or later - earlier
dcc64 releases do not know the AVX instructions - on Delphi Linux64, which
this library supports from 10.3 Rio, and under Free Pascal on x86-64 away
from Windows. Every other build has the portable kernel and nothing else,
Win32 always and Win64 on the eleven compilers before Delphi 11. So a Win64
build on XE3 through 10.4 Sydney reports tPirScan.Avx2Available as False on
a machine that plainly has AVX2, and that is the compiler, not the
processor. SetUseAvx2 forces the portable arm where both exist, for
comparison.
How much the AVX2 arm buys depends entirely on what the memory system is
doing: where bandwidth is the limit it buys little, and on a machine with a
core to itself it is worth around a fifth.
ON LINUX64 THE BUILD NEEDS stPirAvx2Func.o ON THE OBJECT PATH, exactly as
it already needs stAESNIFunc.o and stGHashFunc.o - put it on -O or on
DCC_ObjPath. Without it the link fails rather than falling back to the
portable arm, with
E2597 dcc-ld.lld: error: cannot open stPirAvx2Func.o: no such file or
directory
The object ships in the Source folder. Or define ST4_NO_AVX2 - or
ST4_NO_ASM, which removes all of the library's assembler - and the arm is
compiled out: that build needs no object, on any platform, and keeps the
portable kernel.
4. NEW - StreamSec.PIR.Simple, the SimplePIR scheme
tPirParams.Resolve turns a record count and a record length into a working
parameter set - the plaintext modulus, the matrix shape, the record layout -
and REFUSES a shape it cannot decode correctly rather than returning one
that decodes most of the time. tSimplePirServer holds the table, builds the
hint and answers queries; tSimplePirClient holds the hint, forms queries and
recovers records. PutRecord writes one record; BuildHint recomputes the
hint over the whole table and UpdateHintRow recomputes one row of it - a
record occupies LimbCount rows - which is how a change reaches clients
without a new hint. tPirParams reports HintLen, QueryLen and AnswerLen, so
the cost of a deployment can be read off before any of it is built.
Five things in it are worth knowing because they are deliberate:
THE ERROR SAMPLER IS CONSTANT TIME. It is a cumulative-distribution-table
sampler, not rejection sampling, because a rejection sampler's loop count
and its comparison both depend on the sample - and the sample is the
client's secret. Every sample consumes exactly sixteen octets and scans
every threshold with no early exit.
A STALE HINT IS REFUSED, NOT DECODED. A client that recovers an answer
against a hint which does not describe the table that answer came from
gets plausible-looking wrong octets and no exception, which is the worse
failure, so both ends of the exchange refuse that case instead. Three
public values do the work: the hint VERSION, a counter the server moves
whenever it recomputes a hint; the hint DIGEST, the SHA-256 the server
takes over the hint as it builds it; and the server's own WRITTEN MARK,
which records that the table has moved since. A client is handed the
version and the digest with its hint, and both travel in both directions:
fServer.Answer(lQuery,fClient.HintVersion,fClient.HintDigest,lAnswer);
lRecord := lClient.Recover(lAnswer,lServer.HintVersion,
lServer.HintDigest);
Recover raises ePirHintVersionMismatch when the version it is handed is
not the one this client was given, and ePirHintMismatch when the digest
the answer is stamped with is not the digest over the hint this client
holds. Both comparisons are between two things the client can see, and
both are made on every call, whatever the server did with the same two
values, because a dishonest server can answer anything and stamp it
anything.
THE SERVER REFUSES BEFORE IT READS THE TABLE. Answer makes those same two
comparisons against the pair the query carries, so the scan - which is the
whole cost of a lookup - is never started on an exchange that cannot end.
Ahead of both it raises ePirHintStale when the table has been written since
the hint was built: PutRecord marks what it wrote, BuildHint clears every
mark and UpdateHintRow clears the row it recomputed, so a row push that
stopped part way is refused as well. With no hint built at all it raises
ePirDimensionMismatch, because an answer computed then is one Recover
refuses for want of a hint. A client that declines to name its hint - an
empty digest - is served exactly as though the arguments were not there, at
the cost of the scan: the server refuses what it KNOWS will fail, and about
an unidentified query it knows nothing. A deployment that wants
identification to be mandatory refuses the empty stamp itself, before the
call.
None of this is authentication. The three values tell one hint from
another, not an honest server from a dishonest one, and a deployment that
needs the second authenticates the RECORD, above these units. The version
on its own binds an answer to nothing but a counter: two servers over
different tables are both at version 1 until one of them rebuilds, and a
PutRecord that no rebuild follows moves the table under a version that did
not move. It is the digest and the mark that catch those two. The pair
costs 4 octets for the version and 32 for the digest, on a query that is
28.0 kB at the smallest shipped shape, and one pass over the HINT when the
hint moves - never over the table. It tells a server nothing about any
record: the hint is public and byte-for-byte the same for every client at a
version, so two clients on one hint asking for different records put the
same version and the same 32 octets on the wire.
ANY NUMBER OF THREADS MAY ANSWER FROM ONE SERVER. Answer assigns to no
field of the instance - it reads the parameters, the table, the marks and
the hint, and writes only the caller's answer - and the digest is sealed by
whichever call last moves the hint, BuildHint or the UpdateHintRow that
leaves no row outstanding, so nothing on the serving path computes one.
Reading HintDigest computes nothing either; between the first call of a row
push and the one that leaves nothing outstanding it reads EMPTY, rather
than a digest over a hint part way through a push, which describes no table
the server ever held.
That covers the serving path and not the build one, and this release gives
the build side no threading contract. PutRecord, BuildHint and
UpdateHintRow write the table, the hint, the marks and the stamp; they take
no lock and are safe against neither each other nor a concurrent Answer. A
deployment that builds while it answers serialises that itself, or builds a
second server and swaps it in. A client is not shared either: Query and
Recover are one state machine over one secret.
THE PARAMETERS ARE NOT THE PAPER'S, AND WHAT THEY ARE WORTH IS MEASURED.
The instance is plain unstructured learning-with-errors - no ring, no
module, no algebraic structure of any kind - at a secret dimension of 1280,
a ciphertext modulus of 2^32, secrets uniform over the whole of Z_q and
errors discrete Gaussian at sigma 6.4. Against the lattice estimator at
commit 53da5982 the winning attack on it costs 2^153.7 under the RC.MATZOV
cost model and 2^157.2 under RC.BDGL16. Those are measurements of this
instance, taken here, and not a figure carried over from the scheme's
paper, which cites a 2015 methodology and names no estimator version, cost
model or attack.
The dimension is 1280 where the paper uses 1024 because of the query
budget. The scheme's own Corollary E.5 bounds an adversary's advantage over
a sequence of Q queries by 2*Q*eps, so a budget of 2^k queries against one
public matrix costs about k bits - and that subtraction is arithmetic on
top of the figures above, which no estimator models. A day at a million
lookups against one matrix is 2^20 queries and leaves 133.7 bits; the same
accounting at 1024 leaves 101.5, which is why this library does not ship
1024. HOW OFTEN YOU RESEED THE PUBLIC MATRIX IS WORTH MORE BITS THAN ANY
OTHER CHOICE YOU CAN MAKE HERE.
What the dimension costs you is the hint and nothing else: it is
HintLen = RowCount * 1280 * 4 octets, a quarter larger than it would be at
1024, and a query costs the same factor more arithmetic on the client. The
plaintext modulus, the matrix shape and the rate are unaffected, because
the correctness inequality the modulus table solves has no secret dimension
in it.
Two limits on the above, stated here rather than left to be discovered.
The public matrix is expanded from a seed with AES-128, which is outside
the theorems of the scheme's paper - those are stated for a uniform matrix;
the covering argument is FrodoKEM's, which expands its own public matrix
the same way, and it is an argument in an idealised model rather than a
reduction. And any post-quantum reading of these parameters is ours: the
paper makes no quantum claim, and what ours rests on is that plain
unstructured LWE is the conservative end of the lattice family.
The client never materialises the public matrix. At the sizes this is used
at it would be tens of megabytes, so it is consumed a block of rows at a
time straight from the expander.
5. NEW - StreamSec.PIR.Double, the DoublePIR scheme
SimplePIR's client downloads a hint that grows with the table: HintLen is
RowCount * SecretDim * 4 octets, and RowCount follows the square root of
the database. DoublePIR removes that growth. It runs the same scheme a
second time, over the first level's own hint, so that what the client
downloads is a function of the secret dimension and the record LENGTH and
of nothing else. A table of a thousand records and a table of a billion
hand out hints of the same size.
tPirDoubleParams.Resolve turns a record count and a record length into a
working parameter set exactly as tPirParams.Resolve does, and refuses a
shape it cannot decode. tDoublePirServer holds the tables, builds both
levels of hint and answers queries; tDoublePirClient holds the hint, forms
queries and recovers records. The shapes of the two schemes are directly
comparable: the same limb width, the same limb count, the same record rule.
WHAT IT COSTS, BECAUSE THE TRADE IS THE WHOLE POINT. The hint is
d * kappa * n * n words, where d is the number of Z_p elements one record
maps to and kappa is ceil(log q / log p), which is 4 on eight of the nine
table rows. At the shipped dimension that is 26 214 400 octets for a record
of one element. It does not grow with the record COUNT. It does grow
linearly with the record LENGTH, and SO DOES THE ANSWER: that is
d * (2*kappa*n + kappa) words and carries the same factor d for the same
reason, 40 976 octets at a one-element record and 447 580 848 at a
12 288-octet one. The second of those is not a footnote to the first,
because the two are paid at different times - the hint once per EPOCH, the
answer once per QUERY. So DoublePIR is a scheme for SHORT records - the
regime its paper measures - and a 12 288-octet record would need a hint of
a quarter of a terabyte besides. THAT ROW IS AN ARITHMETIC EXAMPLE OF WHAT
THE SCHEME COSTS AT THAT RECORD LENGTH AND NOT A SHAPE YOU CAN ASK FOR: on
a 32-bit target both Resolve and ForModulus REFUSE it with
ePirParamsOutOfRange, because its hint is 71 584 972 800 words and that
does not fit a 32-bit NativeInt. A 64-bit target resolves the shape and
then fails at the allocation instead, because a quarter of a terabyte of
hint is not a deployable object either. Read tPirDoubleParams.HintLen AND
tPirDoubleParams.AnswerLen before you build anything. The query, m + l
words against SimplePIR's m, is the one object that does not move with the
record length at all.
Two matrices, and they must be independent. The server and the client both
take two sixteen-octet seeds, and both REFUSE the same seed twice: the
scheme samples A1 and A2 independently, and one seed used for both would
make them equal. The two client secrets are drawn independently as well.
What that buys is stated precisely in the unit, because the short version
of it is wrong: the second level's database DOES carry the first level's
secret, since the first level's answer is a product with the first half of
the query. What it does not carry is the second level's OWN secret, and a
message depending on the key it is encrypted under is what a
circular-security assumption would be about. So none enters - and because
nothing on the wire would show it if the two secrets were ever the same,
the client exposes a protected seam and the test suite fences the
independence through it.
THE HINT HAS NO ROW A SERVER CAN PUSH, unlike SimplePIR's. Every entry of
the client's hint is a sum over every column of the first level's, so a
changed record can reach ANY entry of it and there is no row a change is
known to spare. That is not the same as the whole hint moving, and it
would be wrong to say it was: a column whose digits did not change
contributes the words it contributed before. Measured at 64 records and a
dimension of 16, a record replaced WHOLE still leaves 96 of the 3072 hint
words standing, and a one-bit change - which lands in one limb and no
other - leaves the hint-planes of the limbs it did not move identical word
for word. What the server cannot do is tell the client WHICH entries it
left alone without shipping the answer to that question, which is the
hint. So BuildHint is the only builder this class offers, a changed record
is a new hint version and a new download, and there is no UpdateHintRow
here and there cannot be one. BuildHint is therefore also the only moment
this class's hint digest can be taken.
THE HINT VERSION IS NOT AN INTEGRITY CHECK, and it is stated here
because a reader will otherwise assume that it is. Recover raises
ePirHintVersionMismatch when the version it is handed is not the one this
client was given with its hint, ePirHintMismatch when the digest the answer
was stamped with is not the digest over the hint this client holds,
ePirDimensionMismatch when there is no hint or the answer is the wrong
length, and ePirError - the BASE class, which ePirDimensionMismatch
descends from - when there is no outstanding query. That is the whole list,
and the last of the four is the one a caller reaches by accident: a Recover
that DECODED clears the state that decoded it, so a second call on the same
answer raises ePirError and not ePirDimensionMismatch, and a handler
written for the leaves alone lets that past. A Recover that REFUSED clears
nothing, and the next call on the same query decodes. SimplePIR's Recover
names the same four classes on the same five paths.
The VERSION binds an answer to nothing but a counter: two servers holding
different tables are both at version 1 until one of them rebuilds, and a
server that writes a record with PutRecord and then answers without
rebuilding is at the version its client holds as well. What binds an answer
to the hint it was computed against is the digest, and what refuses an
answer over a table written since the hint was built is the server.
Entry 4 states both in full, and the signatures they give Answer and
Recover, the refusals Answer makes before it reads a table, and what a
caller may and may not do from more than one thread are the same here. A
deployment that needs to know it read the record it asked for still
authenticates the RECORD, above this unit.
CORRECTNESS IS NOT SIMPLEPIR'S BOUND REUSED. SimplePIR's client rounds one
Z_p element per recovered cell; DoublePIR's rounds kappa*(n+1)+1 of them,
and all of them have to land. The scheme's own equation (3) puts that count
inside a logarithm, which at the shipped dimension makes the requirement
about 14 per cent larger at the same modulus and shape.
THAT HAS A CONSEQUENCE FOR THE MODULUS TABLE THAT IS WORTH STATING. The
one-level correctness inequality has no secret dimension in it, which is
why the plaintext moduli of entry 4 are the same at any n. The two-level
one does have it. Measured against equation (3) at the top of each row's
range, the two-level moduli published for a secret dimension of 1024 hold
on all nine rows there and fail on the first three at the 1280 this library
ships - by 0.08 per cent on the first of them. So this unit does not read a
modulus off the table and trust it: PirDoubleLookupModulus returns the
first modulus that satisfies equation (3) AT THE SHAPE IN HAND, which keeps
the published modulus everywhere except a band thirteen rows wide at the
top of one table row - the record counts 66 896 042 through 67 108 864,
which step to the modulus the NEXT table row carries anyway. That step
costs nothing: the two moduli have the same limb width, so a record inside
the band is sliced into the same number of limbs as one on either side of
it and the hint, the query and the answer are the same length across it.
tPirDoubleParams.CheckCorrectness then asserts the inequality for whatever
was chosen.
The security of the parameter set is entry 4's, unchanged. The second level
is the same LWE instance at a different sample count - same n, same
modulus, same error width, an independent secret - and the scheme's own
Theorem E.1 asks for security at max(m, l), which is one condition covering
both levels rather than two. The measured figures and the query-budget
deduction of entry 4 therefore apply here as they stand, and so do its two
stated limits: the public matrices are expanded with AES-128, which is
outside the theorems, and any post-quantum reading is ours.
ONE LAYOUT DIFFERENCE FROM SimplePIR, and it is visible in the wire sizes
rather than in the API. SimplePIR runs the limbs of a record down a column
of one table; DoublePIR puts limb k of every record into its own table and
answers all of them with one query, which is the scheme's own extension for
records longer than one Z_p element. That is why d appears in the hint and
the answer sizes above and why it does not appear in the query size.
WHAT IS NOT HERE. The demo of entry 6 shows the one-level scheme only, and
nothing in this unit is reachable from a palette.
6. NEW - a demo, in Demos\Delphi <version>\PIR\
PIRDemo builds a table, fetches a record out of it without disclosing which,
and shows the two things a description cannot: two queries for the same
record side by side, sharing no word; and what happens when the table
changes under a client still holding the old hint. It also measures the scan
kernel on both arms, so the figure comes from your machine rather than from
a table in a document. Its readme.txt says what each panel is for.
7. What this release does not contain
This is the single-server family: the kernel, the one-level scheme and the
two-level one. Keyword lookup by something other than a record index, and
the oblivious pseudo-random function that would hide the keyword itself,
are not here. Nothing in what does ship depends on them, and nothing in the
API above changes shape when they arrive.
8. Package membership
Everything above is compiled by every supported compiler, and all three
units are in the contains clause of all fourteen runtime packages,
StrSecIV170 (XE3) through StrSecIV370 (Delphi 13):
the scan kernel StreamSec.PIR.Scan
the SimplePIR scheme StreamSec.PIR.Simple
the DoublePIR scheme StreamSec.PIR.Double
So a project that already uses the library reaches them by naming them in a
uses clause, with no search path into the Source folder and nothing to
install. The demo ships for the same fourteen, Delphi XE3 through Delphi 13.
Nothing is added to the design packages and there is no palette icon to
look for. The subsystem registers no component: it is a class API called
from code, and the design packages see the units through the runtime
package they already require.
Three more files ship beside those three and are not units themselves:
PirAvx2RowDot.inc and PirAvx2RowAxpy.inc, the AVX2 bodies the Win64
built-in assembler includes, and stPirAvx2Func.o, the same two bodies
assembled as an object for Delphi Linux64 - see entry 3 for where that one
has to be, and for how to build without it.
Beyond Win32 and Win64, all three units compile for Linux64, OSX64,
OSXARM64, iOSDevice64, iOSSimARM64, Android and Android64.
--------------------------------------------------------------------------------
QR CODES: READ AND WRITE THEM, INCLUDING FROM A PHOTOGRAPH, WITH NOTHING
LINKED THAT THE LIBRARY DOES NOT ALREADY SHIP
================================================================================
A QR symbol is a way to move a few hundred octets between two devices that
share nothing but a screen and a camera. The library now writes them, reads
them back from a matrix, and finds one in a picture. The first use is an
alternative to e-mailing a one-time code, but nothing here is specific to
that: it is ISO/IEC 18004, so a phone's own camera app reads what this writes
and this reads what a phone writes.
The units are framework-free as far as they possibly can be, which is further
than it sounds: the detector - the part that turns a photograph into a matrix
- takes a width, a height and one byte a pixel, and knows nothing about
TBitmap, FireMonkey, the VCL or a camera. Only the two adapters know about a
framework, and they are thirty lines each.
9. NEW - StreamSec.QR.Encode, the encoder
QrEncode and QrEncodeText turn octets or a string into a tQrCode: versions
1 to 40, error correction levels L, M, Q and H, byte mode. The version and
the mask are chosen for you unless you name them. tQrCode.Dark(x,y) asks
about one module and tQrCode.AsLines renders the whole symbol as text,
which is enough to put one in a log or a console.
The block and error-correction tables are the only data in the unit that
cannot be derived, and one mistyped number gives a symbol that is well
formed and undecodable at exactly one version and level. They are verified
against two unrelated Python encoders rather than proofread.
10. NEW - StreamSec.QR.Decode, the decoder
QrDecode takes a matrix of modules and gives back the octets, the version,
the level, the mask, and how many codewords the error correction had to
repair. That last figure is worth watching: a symbol that spends most of
its budget on every read is a symbol that is about to stop reading.
IT FAILS CLOSED. Reed-Solomon does not announce failure - handed more
errors than it can carry it produces a different, equally well-formed
block - so every repair is checked by recomputing the syndromes, and a
block that still has any is refused with eQrUnreadable. A decoder that
returned a plausible payload from an unreadable symbol would be worse than
one that returned nothing, because nothing downstream would notice.
11. NEW - StreamSec.QR.Image, from a photograph to a matrix
QrReadImage takes a grey raster and gives back the payload; QrLocateImage
stops at the matrix, and QrRenderImage goes the other way and draws one.
In between: a block-adaptive threshold, so one badly lit edge does not
cost the symbol; a search for the three finder patterns; the module width
measured along the symbol's own axis rather than across the picture, so
rotation is free; the bottom-right alignment pattern, so a camera held at
an angle still reads; and a perspective correction onto the module grid.
WHAT IT WILL NOT DO, stated here rather than found later. It reads ONE
symbol - a picture of two is not a case it answers. It wants the whole
symbol, with its quiet zone, inside the frame; one running off the edge is
refused rather than half-read. And it corrects a plane, so a symbol
photographed at a steep angle will start failing while it still looks
readable to a person. Every one of those is a refusal, never a guess:
eQrNotFound when there is no symbol, eQrUnreadable when there is one and
it is too far gone.
Below about three pixels to the module there is not enough of the finder
pattern left to measure. It is allowed to refuse there. It is not allowed
to be wrong, and that is what the harness asserts.
12. NEW - StreamSec.QR.Image.FMX and StreamSec.QR.Image.VCL
One adapter per framework, over the same detector. Both draw as well as
read, because a program needs to put a symbol on screen before it ever
needs to read one back:
QrDrawText / QrDrawCode a symbol into a bitmap, sized to fit
QrReadBitmap a bitmap back to a payload
QrTryReadBitmap the same, returning False instead of raising
That last one is for the caller pulling frames from a camera: most frames
have no symbol in them, and that is ordinary rather than exceptional.
The VCL adapter also reads any TGraphic - a PNG, a JPEG, a TPicture's
Graphic - because on that side a picture usually arrives from a file or
the clipboard rather than from a camera. It never changes the bitmap you
lend it: a source that is not 24-bit is copied, not converted in place.
The FireMonkey adapter composites transparency over white, correctly for
premultiplied colour.
13. All QR exceptions now share one ancestor
eQrError is the root of the layer. eQrEncode, eQrDecode (with
eQrUnreadable under it) and eQrImage (with eQrNotFound under it) all
descend from it, so a caller driving the whole pipeline needs one handler
for anything QR instead of one per unit, and does not acquire another the
next time the layer grows a unit.
14. Package membership
Four of the five units are in the contains clause of all fourteen runtime
packages, StrSecIV170 (XE3) through StrSecIV370 (Delphi 13):
the encoder StreamSec.QR.Encode
the decoder StreamSec.QR.Decode
the detector StreamSec.QR.Image
the VCL adapter StreamSec.QR.Image.VCL
So a project that already uses the library reaches them by naming them in
a uses clause, with no search path into the Source folder and nothing to
install.
StreamSec.QR.Image.FMX is deliberately NOT in them. The runtime packages
require the VCL; putting a FireMonkey unit in one would make every project
that uses the library drag FireMonkey in with it. A FireMonkey project
compiles the adapter into itself instead, which needs no package and no
setting - the unit is in the same folder as the rest.
StreamSec.DSI.CertificateViewer meets the same constraint the other way
round, which is worth knowing if you are choosing between the two shapes
for your own code: it is ONE unit that compiles as a VCL control or as a
FireMonkey one according to FRAMEWORK_FMX, and it is therefore in all
fourteen runtime packages, which build its VCL form.
Nothing is added to the design packages and there is no palette icon to
look for. The subsystem registers no component: it is a set of functions
and records called from code.
Beyond Win32 and Win64, the encoder, the decoder and the detector compile
for Linux64, OSX64, OSXARM64, iOSDevice64, iOSSimARM64, Android and
Android64. The two adapters follow their own framework.
15. NEW - a demo, in Demos\Delphi <version>\QR\
QRDemo writes a symbol, reads it back THROUGH the image pipeline rather
than around it - the picture on screen is thresholded, searched for its
finder patterns and sampled, the same path a camera frame takes - and
then damages it.
The damage slider is the reason the demo exists. Flip modules and two
numbers move: the corrections the error correction has to spend, and
then nothing, because past its budget the reader REFUSES. On the text it
starts with, at level M, which encodes as a version 6 symbol: 10 flips
cost 10 corrections, 30 cost 28, and at 40 it declines to answer. Switch
to level H and the cliff moves a long way right, which is the argument
for the higher levels in one gesture rather than a paragraph.
It flips modules of the DATA region and leaves the finder patterns, the
timing lines and the alignment patterns alone. Damage scattered over the
whole symbol destroys a finder within the first twenty flips, and from
then on there is nothing to locate and every further flip says so - true,
and it hides the part worth watching. It is also the realistic case: a
scratch lands in the middle of a printed code far more often than on all
three corners at once.
It reads a PNG, JPEG or BMP from disk as well, which is the case the
round trip cannot cover - a symbol that has been through a screenshot, a
printer or a JPEG encoder. Its readme.txt says what each control is for.
The demo ships for the same fourteen, Delphi XE3 through Delphi 13.
16. What this release does not contain
There is no camera capture and no component. Getting a frame from a device
is the platform's job - TCameraComponent on FireMonkey, a capture filter
on Windows - and what this library supplies is everything after that
frame.
The encoder writes byte mode only. Numeric and alphanumeric modes pack
digits and upper-case text more tightly, and a symbol carrying a URL or a
one-time code is byte mode in any case. Kanji mode is not implemented.
Nothing in the API above changes shape if those arrive.
--------------------------------------------------------------------------------
KEYS STORED ENCRYPTED: A KEY MANAGER NO LONGER DECRYPTS THE SAME KEY OVER AND
OVER TO STORE OR FIND ANOTHER, AND EACH DECRYPTION IS A THIRD OF THE WORK
================================================================================
A key manager over a file store that keeps its private keys in a
PKCS8-Encrypted-* format spent seconds of CPU on every key or certificate it
stored and on every CMS message it opened. One application measured 2.0 to
2.6 s per SetPrivateKey and 5 to 6 s per message, on Win32 and Win64 alike.
Nearly all of it was the password key derivation - PBKDF2 with HMAC-SHA256
and 131072 iterations, about 0.2 s a time on the development box - run many
times over: eleven times to store one private key under two indexes, nine to
store a certificate under three, twenty-four to open one message.
Two things multiplied it, and both are fixed. Neither needs a source change on
your part. The iteration count is not among them: it is still 131072, and a
key is written as the same bytes as before, apart from its random salt and IV.
Keys written by earlier releases read exactly as they did.
TOGETHER, in the application above, measured before and after in turn on one
machine: storing a private key takes about 0.5 s where it took 2 to 3 s, a
certificate 0.2 s where it took about 2 s, and opening a message 0.7 to 0.8 s
where it took 5 to 6.5 s; its whole test run went from 60 to 68 s to 10 s.
The derivation still runs seven times to store a private key under two caching
indexes - once to write it, twice while the store picks its format, and twice
per index when the index reads the key back - and a later read-back still
loads the store's first key once, before the key it asks for. Entry 17 says
what each of those is for; this release leaves them as they are.
17. FIXED - an index reading a key back from its store loaded the store's
first key three times before the key it asked for
An index that caches its keys reads every key back from the store as the
key is filed - every private key and every certificate, once per such
index - and an index that does not cache reads one back whenever a lookup
lands on it. That read-back is TstKeyManager.GetKeyFromStore, and it made
sure the store was open by reading the store's Enabled property three
times. Enabled on a store is True only when the store's FIRST key loads -
it is the Enabled every key component has, which asks the component for
its default key - so each of those reads loaded that key from disk, and
decrypted it when it was stored encrypted. The read-back now reads Enabled
once when the store is open, and opens a closed store as it always has.
WHAT IT LOOKED LIKE. SetPrivateKey, SetCACertificate, ImportFromCMS, and
verifying or decrypting CMS through the key manager were all slow, in
proportion to the number of indexes over the store - and just as slow when
the key being stored or found was a CERTIFICATE, because the key decrypted
was the store's first, not the one asked for. Which key is first depends on
what sorts first among the store's internal identifiers, and those begin
with the key family: once a store holds one encrypted composite ML-DSA
private key, it decrypts that key on every read-back. That is also why
choosing a plain format for one key family can seem to help or not to: it
helps when a key of that family is the one that sorts first.
NONE OF THESE WAS INVOLVED: the key format, the password, CacheKind, the
random number generator or the garbage collector. A store of plain PKCS#8
keys paid for the same three loads, too cheaply to notice.
EVERY ANSWER IS THE SAME. A closed store is opened and the key comes back;
an empty store answers nil and still counts as closed, because it has no
first key to load; a store whose first key cannot be decrypted answers nil.
What does change is that OnPassword fires once for every key actually read:
twice for a read-back, where it fired four times.
IF YOU HAVE WRITTEN A KEY STORE CLASS OF YOUR OWN that overrides GetKey, a
read-back no longer goes through that override. GetKey on a store is now
CheckEnabled followed by the new protected virtual FindKey, and the
read-back calls FindKey after its own check; override FindKey instead. The
stores in the library override neither.
What remains, and is left alone: Enabled still loads the first key once per
read-back, because an empty store and a store whose first key will not
decrypt count as closed and nothing else in the store says so; an index
that caches reads back the key it has just been handed, which also proves
the store can read what it wrote; and the store settles which format to
write a key in by writing it, which for an encrypted format means
encrypting it, once in SetPrivateKey's check and once in SetKey's.
Test\keymanager\KeyStoreOpeningTest (20 checks) holds every answer above
and the password count. Built against the code before this change, only the
two count checks fail.
18. FIXED - PBKDF2 with HMAC recomputed the HMAC key blocks at every
iteration
Every HMAC in a PBKDF2 derivation is keyed with the password, and HMAC
hashes the key padded to one block, xor ipad, ahead of the message and the
same block xor opad ahead of the inner digest. tPBKDF2_HMAC hashed both
blocks again, and made its hash objects again, at every iteration. It now
hashes them once per derivation and restarts from their states at every
iteration, which halves the hash compressions: 131072 iterations of
HMAC-SHA256 take 0.063 s where they took 0.19 s, Win32 and Win64 alike.
That is every derivation made through tPBKDF2_HMAC - PKCS#8 and PKCS#12
PBES2, the PBMAC1 integrity MAC, the SSH password verifier, and the two
PBKDF2 steps inside scrypt.
THE BYTES ARE THE SAME - this entry changes how PBKDF2 computes, not what.
(For SHA-512/224, SHA-512/256, SHA-3 and BLAKE2b the HMAC underneath does
change, on purpose: that is entry 20.) Test\scryptinterop\Pbkdf2HmacTest
(176 checks) holds the new path to 156 vectors from OpenSSL for fourteen
hashes - among them those of RFC 6070 and RFC 7914 section 11, and 131072
iterations with an empty and a non-empty password - and to the old
per-iteration path on random inputs for every hash the library registers.
OpenSSL reads the PKCS#12 files and decrypts the encrypted key files the
library now writes. Hashes outside stBaseHash (SHA-3, SHAKE, BLAKE2b,
Whirlpool, MD2) take the per-iteration path as before.
New in stSecUtils: HMACOuterBegin, which starts a hash on the outer HMAC
block - the key padded to the block, xor opad. New in stBaseHash:
tBaseHash.AssignState, which copies a running hash state into another
instance of the same class - what Clone copies, without the allocation;
Clone now calls it.
--------------------------------------------------------------------------------
HMAC KEYS: A KEY LONGER THAN THE HASH'S BLOCK IS NO LONGER REWRITTEN IN THE
OBJECT THE CALLER PASSED
================================================================================
19. FIXED - a key longer than the HMAC block, assigned to a hash's Key, was
replaced by its own hash in the caller's object
HMAC uses a key longer than the hash's block - 64 bytes for SHA-1 and
SHA-256, 128 for SHA-384 and SHA-512 - by hashing it first. tHash.Key,
which is iKeyedHash.Key, did that hashing IN the key object it was given:
the object came back as long as the digest and holding the digest. The
MAC that hash computed was right; what went wrong was any later use of the
same object. The hash of the key now goes into a key the hash holds
itself, and the caller's object is left as it was.
WHAT IT LOOKED LIKE. One key object keying HMAC-SHA256 and then
HMAC-SHA512 gave a wrong HMAC-SHA512: by then the object held the SHA-256
of the key, where SHA-512, whose block is 128 bytes, takes a 100-byte key
as it is. A key given to TstHash.SetKeyIntf came back from the first SetUp
as its own hash, and so did the pseudorandom key given to HKDF-Expand
(stKDF.tHKDFExpand) when it was longer than the block. A key used
afterwards as a cipher key, or written out, was not the key that had been
set.
YOU WERE NOT AFFECTED if the keys you give a hash fit its block, or if you
do not use them again. The library's own uses are all one or the other:
the TLS and SSH record MAC keys, the TLS 1.3 Finished keys, HKDF over the
hash's own output and the SSL 3.0 master secret fit; the TLS PRF secret,
the PKCS#12 and PBMAC1 MAC keys and the ACME account-binding key are made
for the one hash and dropped. SetKeyBuf, SetKeyPtr and SetKeyStr on
TstHash copy the key first, so a key given that way was never touched.
What is unchanged: a key that fits the block is still held by the hash as
the object you passed, not as a copy, so changing or wiping that object
between SetUp and Done changes the MAC.
Test\hashkey\HashSetKeyTest (31 checks) holds the caller's key for every
hash the library registers, the two-hash case, HKDF-Expand and TstHash,
and every MAC against Python's hmac module. Built against the code before
this change, 23 fail - the 22 that look at the caller's key, and the
HMAC-SHA512 of the two-hash case - and the other 8 pass.
--------------------------------------------------------------------------------
THE HASH'S INPUT BLOCK IS tHash.Rate: HMAC PADS ITS KEY TO THE BLOCK THE
STANDARDS DEFINE, IN BOTH OF THE LIBRARY'S HMACS, AND PKCS#12 DERIVES WITH IT
================================================================================
The library has two HMACs - the functions in stSecUtils and a tHash in keyed
mode - and both now take the block they pad the key to from tHash.Rate, which
now gives the block the standards give for every hash. For SHA-1, SHA-2 up to
SHA-512, MD5, RIPEMD-160, Whirlpool and MD2 nothing changes; for SHA-512/224,
SHA-512/256, SHA-3, BLAKE2b and SHAKE every HMAC value does. The PKCS#12 key
derivation takes its block from Rate too, which moves no value a PFX file can
reach, and now pads a password that fills whole blocks as RFC 7292 does - so
a PFX under a password of 31 or 63 characters now opens between this library
and OpenSSL - while one that an earlier release wrote under such a password
still opens here.
20. BEHAVIOUR CHANGE - HMAC over SHA-512/224, SHA-512/256, SHA-3, BLAKE2b and
SHAKE pads its key to the hash's own block, as RFC 2104 and FIPS 198-1
define it
HMAC pads its key to B, which RFC 2104 section 2 defines as the
byte-length of the blocks the hash's compression function takes, and FIPS
198-1 section 2.3 as the "Block size (in bytes) of the input to the
Approved hash function". That is 128 bytes for SHA-512/224 and SHA-512/256
(FIPS 180-4, Figure 1: 1024 bits, as for SHA-384 and SHA-512); 144, 136,
104 and 72 for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 (FIPS 202, Table
3, "Input block sizes for HMAC"); and 128 for BLAKE2b-512 (RFC 7693, bb).
The library padded all of these to 64. OpenSSL follows the standards, and
so do NIST's own worked HMAC-SHA3 examples; this library now agrees with
both.
WHERE IT WAS WRONG. The block is tHash.Rate, and Rate said 64 for
SHA-512/224, SHA-512/256 and BLAKE2b-512. The HMAC functions in stSecUtils
(HMAC, HMACBegin, HMACEnd and HMACString, HMACStream and HMACFile) never
asked Rate: they kept a table of their own. A tHash in keyed mode asked
Rate for its outer pad, but its own table for the inner pad and for when to
hash a long key - so for SHA-3 and SHAKE the library's two HMACs did not
agree even with each other, and HKDF, which extracts with one and expands
with the other, mixed them. Rate now gives the block for every hash, and
both HMACs take the block from Rate and from nowhere else.
WHAT CHANGES FOR YOU is every HMAC, HKDF and PBKDF2 value computed over
one of those hashes. SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, MD5,
RIPEMD-160, Whirlpool and MD2 give the bytes they always gave. Nothing the
library picks for itself uses an affected hash: TLS, the SSH MACs, PKCS#8
and PKCS#12 encryption, PBMAC1 and CMS all stop at SHA-512, and an
encrypted PKCS#8 file whose PRF names SHA-512/224, SHA-512/256 or SHA-3 is
refused, as before. It reaches you only where you chose the hash:
- An SSH server password verifier whose hash - DefaultHash, or Hash= in
the user file - is one of these no longer matches what it stored; those
users set their password again. The default, SHA-512, is not affected.
- A MAC you computed and kept - a TstHash given a MAC key, HMAC(),
HMACString, a keyed tHash, HKDF (tHKDFExtract, tHKDFExpand), or DLIES
and ECIES with one of these as HashAlgorithm - does not match the same
computation now. The Simple Schemes demo MACs its message file with
HMAC-SHA512/256, so a file it wrote before will not verify.
- A deterministic (RFC 6979) DSA or ECDSA nonce for a signature made
with one of these hashes is a different number now. Signatures made
before still verify; only a test holding the old signature bytes sees
it.
SHAKE128 AND SHAKE256 HAVE NO HMAC IN ANY STANDARD. NIST's keyed XOF is
KMAC (SP 800-185), and OpenSSL refuses HMAC over an XOF. The library now
pads to their rate, 168 and 136 bytes - the reading of RFC 2104 that
applies to a sponge, whose input block is its rate (FIPS 202, section 7)
- and does so in both of its HMACs, which used to differ here too. There
is nothing for it to be compatible with: do not use it where another
implementation has to agree.
NOT CHANGED: the DLIES and ECIES MAC key length, and WeakPasswordKDFv2, a
key derivation of this library's own, keep sizes of their own - neither is
the HMAC block - and their bytes. The PKCS#12 key derivation, which had its
own copy of the block table, is entry 21.
Test\hmac\HmacRateTest (270 checks) holds Rate to the blocks above, NIST's
16 HMAC-SHA3 examples and 97 MACs from OpenSSL to BOTH HMACs, the two
HMACs to each other for every hash the library registers, and HKDF to RFC
5869. Built against the code before this change it fails 160 of those
checks: every comparison with a reference for SHA-512/224, SHA-512/256,
SHA-3 and BLAKE2b, and the two HMACs disagreeing for SHA-3 and SHAKE.
Every other check passes.
21. CHANGED - the PKCS#12 key derivation takes its block, v, from tHash.Rate
tPKCS12KDF (RFC 7292 appendix B.2) kept a copy of the block table of its
own: 128 bytes for SHA-384 and SHA-512, 64 for every other hash. It now
takes v from tHash.Rate, as both HMACs of entry 20 do, and rounds the
password and salt with a remainder rather than a bit mask, which only
worked while every block was a power of two.
NO VALUE A PFX FILE CAN REACH CHANGES WITH v. The MAC of a PFX can name
MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 or RIPEMD-160, and its
password-based encryption uses SHA-1; for every one of those Rate is the
value the table gave. OpenSSL's PKCS12KDF takes v from the digest's block
size in the same way, and Test\pkcs12kdf\Pkcs12KdfTest holds this
derivation to 72 of its outputs over six of those hashes, all three IDs,
and passwords, salts, counts and lengths of several kinds. Entry 22 is the
one kind of length where the two used to part.
The one hash tPKCS12KDF accepts whose v moves is MD2, and only for a
caller that uses tPKCS12KDF directly: Rate is MD2's 16-byte block, where
the table said 64. RFC 7292's own table gives MD2 512 bits, which
contradicts its own definition of v as the input to the hash's compression
function - 128 bits for MD2. No other implementation at hand has MD2 to
compare with. Which hashes SetHashClass admits is unchanged.
22. BEHAVIOUR CHANGE - a PKCS#12 password that fills whole blocks now derives
as RFC 7292 does, and a PFX an earlier release wrote under one still opens
RFC 7292 appendix B.2 builds S and P by concatenating copies of the salt,
and of the password - its BMPString encoding, terminator included - and
truncating the final copy at v * ceil(length / v) bits. That is never less
than the length, so the first copy is always whole and every character
goes in; when the password is a whole number of blocks, P is the password
itself. Releases up to 4.1.3.359 made P length + v - (length mod v) bits:
the same for every other length, and for a whole number of blocks the
password followed by one more block, a copy of its first. Both used every
character of the password at every length; the extra block was the only
difference.
WHERE IT SHOWED. A BMPString is two bytes per character plus a two-byte
terminator, so the lengths are 31, 63, 95 ... characters where the MAC is
over SHA-1, SHA-224 or SHA-256 (v = 64 bytes), and 63, 127 ... where it is
over SHA-384 or SHA-512 (v = 128); a character outside the Basic
Multilingual Plane counts twice. A PFX that OpenSSL wrote under such a
password failed its MAC here, which looked exactly like a wrong password,
and OpenSSL refused one written here with "Mac verify error: invalid
password?" - measured with OpenSSL 3.5 for MACs over SHA-1, SHA-256 and
SHA-512. A 30-character password opened both ways. Certificates wrapped
with pbeWithSHAAnd40BitRC2-CBC (ImposeAuthSafeContent's default) and key
bags wrapped with pbeWithSHAAnd3-KeyTripleDES-CBC (StorePrivateKeyEx in
compatibility mode) take their keys from the same derivation.
NOW, everything written derives as B.2 says, and OpenSSL opens it, key and
certificates included. Reading tries B.2 first. Only when that fails - the
MAC does not match, or a safe contents or key bag does not decrypt to what
it must be - and the password or salt is a whole number of blocks, it
tries once more with the key those releases derived. So a PFX that a
release up to 4.1.3.359 wrote under such a password still opens, and
nothing else is read differently. The retry costs one more key derivation,
only ever on a PFX that has already failed once.
NOT INVOLVED: what the password says, how it is encoded, the iteration
count, the MAC's hash, PBMAC1, or key bags under PBES2 (PBKDF2). Nor the
salt as either side chooses it: 8 to 64 bytes, never a whole block of the
hash it is used with.
FOR CODE THAT CALLS INTO IT: iPKCS12EncryptionAlgorithmIdentifier.
MakeCipher takes a third parameter, aLegacyPadding (default False), and
the interface has a new GUID; tPKCS12KDF has LegacyPadding and
LegacyPaddingDiffers. Set LegacyPadding only to read.
Test\pkcs12kdf\Pkcs12KdfTest (218 checks) holds the derivation to 90
outputs of OpenSSL's PKCS12KDF, 18 of them whole-block inputs, and
LegacyPadding to OpenSSL's output for such an input followed by a copy of
its first block. It opens six PFX files - three written by 4.1.3.359 code
under 31, 63 and 30 characters, three by OpenSSL - checking MAC, key and
certificate, and checks that one written now carries B.2's MAC and not the
old one. With any one of the three retries switched off, exactly the old
files' MACs, certificates or keys fail.
--------------------------------------------------------------------------------
CERTIFICATE SIGNATURES: THE CHAIN FILTER NEVER ACCEPTS A CERTIFICATE WHOSE
SIGNATURE DOES NOT HOLD, AND tSigned.CheckSignature SAYS HOW TO ASK IT
================================================================================
23. BEHAVIOUR CHANGE - the chain filter examines a certificate's signature
also when other problems were found first, and a grant of trust in
OnInvalidCertificate no longer admits a certificate whose signature does
not hold
TstKeyFilterChain calls OnInvalidCertificate at three stages - the
certificate has expired, its issuer cannot be found, or its verification
against the issuer found fails - with aErrorCodes holding the problems
found up to that stage. It might not have been obvious that aErrorCodes
did not always cover ALL the problems with the certificate: when a
problem had already been found - a validity period outside the issuer's,
an unsupported critical extension, and before 4.1.3.358 an expired
certificate - the verification stopped before the signature was
examined, and aErrorCodes said nothing about the signature. That is why
both aCert and aCACert are passed to the handler: to make further
investigation possible.
Now the signature is examined at the third stage whenever it can be,
also when other problems were found first, and aErrorCodes includes
pcvInvalidSignature when it does not verify. A certificate whose
signature does not verify - or cannot be verified: a certificate that
did not load, an unsupported algorithm, the wrong issuer, an issuer key
that cannot be used - is refused WHATEVER THE HANDLER DECIDES. A grant
still covers every other problem the handler is shown, and at the second
stage a certificate issued by an unknown CA or a self-signed one, as
before. TsmX509TrustedCertificates, which the TLS engine uses, already
draws the line there: explicit trust covers an issuer it cannot find,
never a signature that fails against one it found.
WHO SEES A DIFFERENCE. An application whose handler granted trust at the
third stage to a certificate whose signature does not hold: that
certificate is now refused. A correctly signed certificate is accepted
exactly as before. The comment at OnInvalidCertificate documents all of
this, and the legacy stPkixKeyFilter carries the same change.
Test\keyfilter\ChainExpiredTest (42 checks) adds a certificate whose
validity starts before its issuer's, a handler that tolerates exactly
that, and a handler that grants trust to everything, and checks that no
handler admits a certificate whose signature does not hold.
24. FIXED - a stateful CheckSignature on an object reloaded with new content
carried over a state from the previous content; the contract of the
CheckSignature overloads is documented
tSigned.CheckSignature with svsStateful behaves as a full verification
until a call on the object has found problems, and as
svsVerifySignatureOnly after that: the signature is then examined although
the pre-checks found problems, and the result is its verdict alone.
LoadFromStream reset the cached message and codes but not that state, so
after an object was reloaded with new content, a stateful call began as if
the new content's problems were already known - and could return True for
a correctly signed object whose pre-checks fail. The state is now reset
with the rest. An object that is not reloaded, and every
svsFullVerification or svsVerifySignatureOnly call, behaves as before.
DOCUMENTED at the overloads, in StreamSec.DSI.PkixSigned and the legacy
stPkixSigned: what the pre-checks are and that expiry is not one of them,
what each aState does when they find a problem, that a False without
pcvInvalidSignature means the signature was not examined - call again
with svsVerifySignatureOnly to learn whether it holds - and that codes
already in a set handed in count as problems already found.
25. BEHAVIOUR CHANGE - a stateful CheckSignature carries on from the error
codes the stateful calls before it recorded
tSigned.CheckSignature with svsStateful - the default of every overload -
now starts, in the overloads without an aErrorCodes parameter, from the
codes the stateful calls before it recorded in ErrorCodes, and adds what
it finds to them. The first stateful call after an object is loaded
starts from nothing, as before, and repeating a call against the same
issuer certificate gives the same verdict and the same codes as before.
What changes is a stateful call against a DIFFERENT issuer certificate:
what was found against the first counts as problems already found
against the second, and can stop the second's signature from being
examined at all. Before checking an object against another issuer, call
ClearErrors (entry 26), or ask with svsFullVerification or
svsVerifySignatureOnly, which neither read nor change what stateful calls
have recorded. The library does so itself where one object meets several
issuer certificates: in the chain filter's issuer lookup (entry 27), and
where TsmX509TrustedCertificates checks a CRL it holds against the CA
certificate in hand. The overloads that take aErrorCodes work from the
caller's set, as before.
ErrorMsg says what the latest stateful call found itself; ErrorCodes also
keeps what the calls before it found. The declarations say so, and which
overloads update ErrorMsg and ErrorCodes.
26. NEW - iSigned.ClearErrors, and new IIDs for iSigned and every interface
derived from it
ClearErrors forgets what stateful CheckSignature calls have recorded -
ErrorMsg, ErrorCodes and the state svsStateful goes by - so the next
stateful call starts as the first one after loading does. LoadFromStream
calls it. It does not forget that the content failed to load: every
CheckSignature reports that again until new content is loaded.
INTERFACE CHANGE. A new method changes iSigned, so iSigned, iCertificate,
iCertificateList, iCertificationRequest and iBasicOCSPResponse have new
IIDs; rebuild everything that uses them. A class of your own that
implements one of them directly must add ClearErrors; a class derived
from tSigned inherits it. The iCertificateList and iCertificationRequest
of StreamSec.DSI.PkixCRL and StreamSec.DSI.Pkcs10 no longer share their
IIDs with the legacy interfaces of the same names in stPkixCRL and
stPkcs10.
27. BEHAVIOUR CHANGE - the chain filter judges every candidate issuer afresh
when it matches a certificate to its issuer by name
When a certificate has no authority key identifier the key manager can
resolve, TstKeyFilterChain tries each CA certificate with the issuer's
name and takes the first whose check passes. It now calls ClearErrors on
the certificate before each candidate, so every candidate gets a full
verification of its own. Before, how a candidate was judged depended on
what the checks before it had recorded on the certificate object: after
one candidate failed a pre-check, the next was judged on its signature
alone, so a version of a CA certificate that fails the pre-checks - an
expired version of one renewed under the same name and key - could be
taken where a current version was also a candidate, and the verification
that follows then refused the certificate. Stateful checks a caller had
made on the same object counted too, and with entry 25 a failed signature
against one candidate would have stopped the next candidate's signature
from being examined at all.
WHO SEES A DIFFERENCE. A caller that reads ErrorMsg or ErrorCodes of a
certificate object after the filter has matched it to its issuer by name
now reads what the filter's last check of it found, not what the caller's
own earlier stateful checks had recorded.
Test\keyfilter\ChainExpiredTest (63 checks) adds a certificate without
an authority key identifier under a CA re-keyed under the same name,
checked against the old key before the filter sees it; a CA renewed under
the same name and key, held in an expired and a current version; and the
stateful record itself - codes carried from call to call, ClearErrors,
and a reload clearing them.
--------------------------------------------------------------------------------
SFTP SERVER: A LINK IN THE SERVED FOLDER NO LONGER LEADS OUT OF THE ROOT
================================================================================
28. FIXED - the SFTP server followed a junction or symbolic link in the served
folder out of its root, for every request but opening an existing file
tSFTPJail.MapToPhysical, which every request's path goes through, answered
from stFileJail.Resolve, which is lexical: it never looks at the disk. The
requests then acted on the path by name, and only opening an existing file
went through the jail's verifying open. So a junction or symbolic link in
the served folder - put there by anyone with local write access to it, or
there already - took requests out of the root: an SFTP user could list
directories and stat files outside it, and remove, rename, create and
truncate files there. Reading an existing file outside the root was
refused, by the verifying open. Releases 4.1.1.354 to 4.1.3.359 are
affected.
MapToPhysical now also checks on disk that the path - or, for a name that
does not exist yet, its nearest existing parent - lies inside the root, by
the rules the verifying open applies: on Windows every link is followed and
what it reaches must lie inside the root; on POSIX a symbolic link anywhere
below the root is refused. A link whose target is gone is refused too. A
file DoOpen creates or truncates is checked again once it is open, so
nothing is written to one that a link put in the way since has redirected.
The check does not open ordinary files for reading, so a locked or
unreadable file stays within reach of stat and remove. FileJail.txt
section 11 and SFTP.txt sections 5 and 9 say what remains: a race with a
link put in between the check and the request.
WHO SEES A DIFFERENCE. A request through a link that leads out of the root
now fails with "invalid path". On POSIX so does a request through any
symbolic link below the root, as opening a file through one already did.
Test\sftpinterop\SftpJailLinkTest builds its own fixture - a link out of
the root, one whose target is gone, one that stays inside, a file link, and
a root reached through a link - and checks every one. Against the code
before this change it fails 7 checks on Windows and 9 on Linux; after it,
none, on Win32, Win64 and Linux64. The SFTP self-test and the interop runs
against third-party clients and OpenSSH pass unchanged.
--------------------------------------------------------------------------------
PKCS#12: ABOUT ONE PBES2 KEY BAG OR SAFE CONTENTS IN 255 NO LONGER REFUSES THE
PASSWORD IT WAS WRITTEN UNDER
================================================================================
29. FIXED - reading a PFX, the key bag or safe contents decrypt skipped the
password's second key when the first key's wrong decryption happened to
pass the padding check
A PFX password reaches the reader as a tDualSecretKey
(tDualSecretKey.CreateForPFX, which ImportFromPFXFile and the other
routines that open a PFX from a password string use). It carries two keys:
the password as a BMPString, which the PKCS#12 key derivation and MAC
take, and the password's UTF-8 octets, which a PBES2 key bag or safe
contents (PBKDF2 or scrypt) is written under. OpenSSL 3 writes both the
key bag and the certificate safe of a PFX with PBES2 by default, and since
entry 1 so does this library. Releases up to 4.1.3.359 did so for the key
bag of an EdDSA, ML-DSA, ML-KEM, SLH-DSA or composite key always, and for
an RSA, DSA, DH or EC key bag, and for the certificate safe, only when
told to (aCompatibility = False).
THE STEP THAT FAILED. The reader decrypts a shrouded key bag or an
encrypted safe contents with the first key, and tried the second key only
when that decryption failed its padding check. A PBES2 part written under
the UTF-8 octets, as OpenSSL writes it, does not open with the first key,
which decrypts it to noise. About once in 255 that noise ends in valid
block padding - a last byte of 01, or 02 02, and so on. The first key's
result was then taken, and the second key, which would have opened the
part, was never tried:
- in a key bag the noise does not parse as a private key, so
DecryptPrivateKeyInfo returned nil. The certificates opened and the key
was missing, reported as a file with no usable private key.
- in a safe contents the noise was passed on as the contents, and opening
the file raised a decoding exception after the MAC had verified
(EAbort "Too large field:" for the file in the test below), so nothing
in it opened.
Whether it happens depends only on the salt and IV the writer chose, so an
affected file failed every time it was opened. The file itself is sound:
OpenSSL opens it under the same password. Written again, under the same
password and key, it almost always opened.
WHERE IT SHOWED. An application that writes a new key to a PFX and opens
it again at once found 13 of 3000 fresh key files "without a usable
private key": 8 of 1500 on Win32, 5 of 1500 on Win64. Each of them opens
with the second key alone, and with this change with the password, on
both platforms. A PFX that OpenSSL 3 wrote has two parts that can be the
one, the certificate safe and the key bag, so about one such file in 128
is expected to have failed here. Releases 4.0.1.337 to 4.1.3.359 are
affected.
NOW, the second key is tried whenever the first gives no result the part
can hold. For a key bag that means no private key that parses. For a safe
contents it means not exactly one DER SEQUENCE, which a SafeContents
always is. The second key's result is taken on the same terms. The first
key is still tried first and still wins when it gives a key, so a PBES2
part written under the BMPString opens as before. The read-only retry of
entry 22, with the key releases up to 4.1.3.359 derived, comes after both
keys have failed. A wrong password gives no key, as before, including one
whose decryption happens to pass the padding check.
NOT INVOLVED: the password's text, length or encoding, the iteration
count, PBKDF2 against scrypt, the key type, the MAC, and the whole-block
padding of entry 22. Also unaffected: parts under the PKCS#12 schemes (3DES,
RC2, RC4), which the first key opens, and a password given as a plain
iSecretKey rather than a tDualSecretKey, which has no second key to try.
Test\pkcs12kdf\Pkcs12KdfTest adds 22 checks (240 in all). Its fixtures
were written with Python's cryptography package, which uses OpenSSL:
- a PBES2 key bag under the UTF-8 password, at the first of a fixed series
of salts and IVs for which the BMPString key's decryption passes the
padding check;
- the same key under the BMPString, and under the UTF-8 password with a
salt for which that check fails;
- three wrong passwords - one passing the padding check under neither key,
one under the first key only and one under the second - each of which
must give no key;
- two PFX files that OpenSSL's PKCS#12 writer produced, one with the case
in its certificate safe and one with it in its key bag, each opened MAC,
key and certificate.
Each fixture is checked first to be the case it stands for. Against the
code before this change 4 checks fail: the key bag and both PFX files.
With only the key-bag half reverted 2 fail, and with only the
safe-contents half reverted 2 fail. With a key bag that does not parse
left as the result, the wrong-password checks fail. Results are the same
on Win32 and Win64.
--------------------------------------------------------------------------------
THE DOCUMENTS: WHAT THE RELEASE TELLS YOU ABOUT ITSELF, AND TWO SUBSYSTEM NOTES
THAT NOW REACH THE HELP FILE
================================================================================
Three documents change in this release, and one of them is new. They are
listed here because a document is part of what an upgrade delivers, and
because the new one answers questions that were previously answered only by
writing to us.
30. NEW - PRODUCTINFO.txt, the information that accompanies the product
Who made the library, where to report a vulnerability, what it is for, how
long it is supported, and - the part that matters most for a library that
goes inside somebody else's application - what the defaults are and which
decisions stay with you.
It is arranged as the items of Annex II of Regulation (EU) 2024/2847, the
Cyber Resilience Act, so that an integrator assembling their own conformity
work can find each item where they expect it. Those obligations bind
products placed on the market from 2027-12-11; this release is earlier, so
the document is supplied ahead of the date rather than because it is yet
required, and it says plainly that no declaration of conformity is issued
or claimed for this release.
TWO THINGS IN IT ARE STATED FOR THE FIRST TIME. The support period: each
release is supported for five years from its own publication date, and
every security update issued in that window stays obtainable for at least
ten years after it is issued. And what is NOT a security fix - an algorithm
or protocol that becomes obsolete, the arrival of a cryptographically
relevant quantum computer, a default that was right when it shipped and is
no longer recommended. Those are answered by migration advice and by the
current release's own defaults, not by a patch to an older release. An
implementation error in a deprecated algorithm is still a defect and is
still fixed.
SECTION 9 IS THE ONE TO READ IF YOU READ ONE. It collects the defaults the
library sets and the basis for each - the TLS named groups including why
the ML-KEM hybrids are on rather than opt-in, forward-secret-only key
agreement, the digests refused for TLS, SHA-256 for signing and the floor
that refuses signatures over MD5 and SHA-1, PBES2 for the PKCS#12 export
and what it costs, the range and overflow checks being off throughout,
client certificates being required by default - beside the
decisions the library deliberately leaves to the application: explicit
trust, post-quantum group selection, revocation policy, and whether to
enable the automatic CRL and issuer-certificate fetch, which is a request
to an address a peer can choose. The compile-time opt-outs are listed in
the same place.
The document ships beside the other notes and is a topic in the help file.
31. The PIR and QR notes reach the help file, and a topic that was never
product documentation does not
PIR.txt and QR.txt shipped with the subsystems they describe but had no
topic in StreamSecTools.chm, so the help file carried API pages for units
whose own notes were only in the folder. Both are topics now, attached to
their units, as the other subsystem notes have always been.
Removed in the same pass: a "Project build notes" topic that was generated
from an internal working file. It was never product documentation, and what
a reader actually needs from it - the compiler, the packages and how to
build them - is in README_<version>.txt.
--------------------------------------------------------------------------------
DEPRECATED: FOUR CONSTRUCTIONS OF THIS LIBRARY'S OWN, KEPT SO THAT WHAT THEY
PROTECTED CAN STILL BE READ
================================================================================
32. DEPRECATED - the PCFB cipher modes, the keyed-IV ciphers, the
WeakPassword key derivations and the SET3 cipher-stream container
Each is a StreamSec construction with no specification outside this
library, and each works exactly as it did. Deprecated means: do not use it
for new data. The declarations carry the word, and what to use instead.
- cmPCFB and cmPipedPCFB (tCipherMode). Use cmGCM, cmCCM or cmEAX.
- The keyed-IV (KIV) ciphers, which take the IV from the key material
and are named by StreamSec's own OIDs under 1.3.6.1.4.1.13085.1: the
KeyedIV property of TstCipher and of an S/MIME capability item,
tCipher.KeyedIVOID, id_kivcipher, and the ca*KIV* values of
TsmStreamSecII's TCipherAlgorithm. Give a fresh IV per message
instead. The S/MIME capabilities the CMS components fill in by
default have never included them.
- tWPKDF and tWPKDF2, the WeakPasswordToPrivKey, WeakPasswordKDFv2 and
WeakPasswordKeySplit families, StrSecIISecureSetup, and the
kdfWeakPassword and kdfWPv2 values of TKeyDerivation. Use PBKDF2
(tPBKDF2_HMAC) over HMAC-SHA-256, or scrypt. tWPKDF2 was TstCipher's
default until entry 1.
- The SET3 container that tEncryptStream writes and tDecryptStream
reads (stCipherStream). Use a standard format such as CMS.
ABC (cmABC) is NOT deprecated. It is Accumulated Block Chaining as L. R.
Knudsen defined it in "Block chaining modes of operation", Reports in
Informatics 207, Department of Informatics, University of Bergen, October
2000, and the declaration now cites it.