Skip to content

Commit 4c125ec

Browse files
committed
LMS: cleanup INSTALL, and cap threads to 4.
1 parent d7c3a17 commit 4c125ec

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

INSTALL

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,10 @@ We also have vcpkg ports for wolftpm, wolfmqtt and curl.
258258
17. Building with hash-sigs lib for LMS/HSS support [EXPERIMENTAL]
259259

260260
Using LMS/HSS requires that the hash-sigs lib has been built on
261-
your system. At present we support the current master branch of
262-
the hash-sigs project.
261+
your system. We support hash-sigs lib at this git commit:
262+
b0631b8891295bf2929e68761205337b7c031726
263+
At the time of writing this, this is the HEAD of the master
264+
branch of the hash-sigs project.
263265

264266
Currently the hash-sigs project only builds static libraries:
265267
- hss_lib.a: a single-threaded static lib.
@@ -282,6 +284,7 @@ We also have vcpkg ports for wolftpm, wolfmqtt and curl.
282284
$ cd ~/hash_sigs
283285
$ git clone https://github.com/cisco/hash-sigs.git src
284286
$ cd src
287+
$ git checkout b0631b8891295bf2929e68761205337b7c031726
285288

286289
In sha256.h, set USE_OPENSSL to 0:
287290
#define USE_OPENSSL 0

wolfcrypt/src/ext_lms.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
#include <wolfcrypt/src/misc.c>
3838
#endif
3939

40+
/* If built against hss_lib_thread.a, the hash-sigs lib will spawn
41+
* worker threads to parallelize cpu intensive tasks. This will mainly
42+
* speedup key generation and signing, and to a lesser extent
43+
* verifying for larger levels values.
44+
*
45+
* Their default max is 16 worker threads, but can be capped with
46+
* hss_extra_info_set_threads(). To be safe we are capping at 4 here.
47+
* */
48+
#define EXT_LMS_MAX_THREADS (4)
49+
4050
/* The hash-sigs hss_generate_private_key API requires a generate_random
4151
* callback that only has output and length args. The RNG struct must be global
4252
* to the function. Maybe there should be a wc_LmsKey_SetRngCb. */
@@ -347,7 +357,9 @@ int wc_LmsKey_Init_ex(LmsKey * key, int levels, int height,
347357
key->lm_ots_type[i] = ots;
348358
}
349359

360+
/* Set the max number of worker threads that hash-sigs can spawn. */
350361
hss_init_extra_info(&key->info);
362+
hss_extra_info_set_threads(&key->info, EXT_LMS_MAX_THREADS);
351363

352364
key->working_key = NULL;
353365
key->write_private_key = NULL;

0 commit comments

Comments
 (0)