Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/api_ref/pubkey.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,13 @@ width defined by the corresponding parameter set. Choosing `XMSS-SHA2_10_256`
for instance will use the SHA2-256 hash function to generate a tree of height
ten.

Besides the secret, the private key encoding holds 1024 nodes from the upper
part of the tree, which avoids recomputing the tree when signing, at the cost of
between 24 and 64 KiB of encoding. Keys in the older encoding, which lacks this data, are
still accepted, but keys are always written in the new encoding. It uses a
different PKCS #8 algorithm identifier, which older versions of Botan do not
recognize.

.. _xmss_example:

Code Example: XMSS
Expand Down Expand Up @@ -2523,3 +2530,12 @@ and `draft-fluhrer-lms-more-parm-sets-11 <https://datatracker.ietf.org/doc/html/
- hash: ``SHA-256``, ``Truncated(SHA-256,192)``, ``SHAKE-256(256)``, ``SHAKE-256(192)``
- h: ``5``, ``10``, ``15``, ``20``, ``25``
- w: ``1``, ``2``, ``4``, ``8``

Besides the secret, the private key encoding holds public data about the LMS
trees currently in use: the root of the top tree, the upper nodes of each tree,
and the signatures which link each tree to its parent. This avoids recomputing
the trees when a key is loaded or used for signing, at the cost of up to about
40 KiB of encoding per level. Keys in the older encoding, which lacks this data,
are still accepted, but keys are always written in the new encoding. It uses a
different PKCS #8 algorithm identifier, which older versions of Botan do not
recognize.
5 changes: 4 additions & 1 deletion doc/dev_ref/oids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ Values currently assigned are::
SphincsPlus-haraka-256s-r3.1 OBJECT IDENTIFIER ::= { SphincsPlus-haraka 5 }
SphincsPlus-haraka-256f-r3.1 OBJECT IDENTIFIER ::= { SphincsPlus-haraka 6 }

HSS-LMS-Private-Key OBJECT IDENTIFIER ::= { publicKey 13 }
HSS-LMS-Private-Key-legacy OBJECT IDENTIFIER ::= { publicKey 13 }
HSS-LMS-Private-Key OBJECT IDENTIFIER ::= { publicKey 19 }

XMSS-Private-Key OBJECT IDENTIFIER ::= { publicKey 20 }

mceliece OBJECT IDENTIFIER ::= { publicKey 18 }

Expand Down
11 changes: 9 additions & 2 deletions src/build-data/oids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@
1.2.840.113549.1.9.16.3.17 = HSS-LMS

# HSS-LMS private key (since the format of an HSS-LMS private key is not specified,
# we define an OID for the one we use)
1.3.6.1.4.1.25258.1.13 = HSS-LMS-Private-Key
# we define an OID for the one we use). The original format, containing only the
# secret, is HSS-LMS-Private-Key-legacy; .19 adds the root and cached tree data.
1.3.6.1.4.1.25258.1.13 = HSS-LMS-Private-Key-legacy
1.3.6.1.4.1.25258.1.19 = HSS-LMS-Private-Key

# SPHINCS+ OIDs are currently in Botan's private arc
1.3.6.1.4.1.25258.1.12.1.1 = SphincsPlus-shake-128s-r3.1
Expand Down Expand Up @@ -128,6 +130,11 @@
# draft-vangeest-x509-hash-sigs-03
0.4.0.127.0.15.1.1.13.0 = XMSS

# XMSS private key (since the format of an XMSS private key is not specified,
# we define an OID for the one we use, which includes cached tree data). The
# original format, containing only the secret, used the OID XMSS.
1.3.6.1.4.1.25258.1.20 = XMSS-Private-Key

# X9.62 ecPublicKey, valid for ECDSA and ECDH (RFC 3279 sec 2.3.5)
1.2.840.10045.2.1 = ECDSA
1.3.132.1.12 = ECDH
Expand Down
12 changes: 12 additions & 0 deletions src/cli/perf_pk_sig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ class PerfTest_PKSig : public PerfTest {

while(ver_timer->under(msec) || sig_timer->under(msec)) {
if(signature.empty() || sig_timer->under(msec)) {
if(sk->remaining_operations().value_or(1) == 0) {
// A stateful key ran out of signatures; continue with a new one
sig.reset();
ver.reset();
sk = Botan::create_private_key(alg, rng, param);
pk = sk->public_key();
if(!one_shot) {
sig.emplace(make_signer());
ver.emplace(make_verifier());
}
}

/*
Length here is kind of arbitrary, but 48 bytes fits into a single
hash block so minimizes hashing overhead versus the PK op itself.
Expand Down
14 changes: 11 additions & 3 deletions src/lib/asn1/static_oids.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file was automatically generated by ./src/scripts/dev_tools/gen_oids.py on 2026-09-28
* This file was automatically generated by ./src/scripts/dev_tools/gen_oids.py on 2026-11-24
* All manual changes will be lost. Edit the script instead.
*
* Botan is released under the Simplified BSD License (see license.txt)
Expand Down Expand Up @@ -624,7 +624,11 @@ std::optional<std::string_view> OID_Map::lookup_static_oid(const OID& oid) {
case 0xA0D66:
return if_match(oid, {1, 3, 6, 1, 4, 1, 25258, 1, 8}, "XMSS-draft12");
case 0xA0D6B:
return if_match(oid, {1, 3, 6, 1, 4, 1, 25258, 1, 13}, "HSS-LMS-Private-Key");
return if_match(oid, {1, 3, 6, 1, 4, 1, 25258, 1, 13}, "HSS-LMS-Private-Key-legacy");
case 0xA0D71:
return if_match(oid, {1, 3, 6, 1, 4, 1, 25258, 1, 19}, "HSS-LMS-Private-Key");
case 0xA0D72:
return if_match(oid, {1, 3, 6, 1, 4, 1, 25258, 1, 20}, "XMSS-Private-Key");
case 0xA0EE1:
return if_match(oid, {1, 3, 6, 1, 4, 1, 25258, 3, 1}, "Serpent/CBC");
case 0xA0EE2:
Expand Down Expand Up @@ -1117,6 +1121,8 @@ std::optional<OID> OID_Map::lookup_static_oid_name(std::string_view req) {
return if_match(req, "ECDSA", {1, 2, 840, 10045, 2, 1});
case 0x6BD26:
return if_match(req, "GOST.INN", {1, 2, 643, 3, 131, 1, 1});
case 0x6C21B:
return if_match(req, "HSS-LMS-Private-Key-legacy", {1, 3, 6, 1, 4, 1, 25258, 1, 13});
case 0x6CB3B:
return if_match(req, "Camellia-192/OCB", {1, 3, 6, 1, 4, 1, 25258, 3, 2, 7});
case 0x6E602:
Expand Down Expand Up @@ -1252,7 +1258,7 @@ std::optional<OID> OID_Map::lookup_static_oid_name(std::string_view req) {
case 0x8E0C1:
return if_match(req, "X509v3.CertificatePolicies", {2, 5, 29, 32});
case 0x8E39A:
return if_match(req, "HSS-LMS-Private-Key", {1, 3, 6, 1, 4, 1, 25258, 1, 13});
return if_match(req, "HSS-LMS-Private-Key", {1, 3, 6, 1, 4, 1, 25258, 1, 19});
case 0x8EC51:
return if_match(req, "Kyber-768-r3", {1, 3, 6, 1, 4, 1, 25258, 1, 7, 2});
case 0x8F94A:
Expand Down Expand Up @@ -1409,6 +1415,8 @@ std::optional<OID> OID_Map::lookup_static_oid_name(std::string_view req) {
return if_match(req, "gost_512B", {1, 2, 643, 7, 1, 2, 1, 2, 2});
case 0xBA1D8:
return if_match(req, "X520.StreetAddress", {2, 5, 4, 9});
case 0xBC6A5:
return if_match(req, "XMSS-Private-Key", {1, 3, 6, 1, 4, 1, 25258, 1, 20});
case 0xBCB45:
return if_match(req, "PKCS12.CRLBag", {1, 2, 840, 113549, 1, 12, 10, 1, 4});
case 0xBCC82:
Expand Down
Loading
Loading