Skip to content

Commit 1e08bf5

Browse files
committed
SLH-DSA: add comments about side channel issue
Signed-off-by: Stephan Mueller <smueller@chronox.de>
1 parent ff78e99 commit 1e08bf5

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

slh-dsa/src/sphincs_sign.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@ LC_INTERFACE_FUNCTION(int, lc_sphincs_sign_ctx, struct lc_sphincs_sig *sig,
276276
CKINT(f_ctx->fors_sign(sig->sigfors, ws->root, ws->mhash, &ctx_int,
277277
ws->wots_addr));
278278

279+
/*
280+
* Timecop:
281+
*
282+
* According to the original authors of the Sphincs+ code, ws->root
283+
* is a public information (see
284+
* https://github.com/sphincs/sphincsplus/issues/63#issuecomment-2694902727). This would imply we could call
285+
* unpoison(ws->root, sizeof(ws->root)); at this point which would
286+
* remove the Valgrind side channel complaints in the wots_gen_leaf
287+
* functions. However, we try to err on the conservative side and
288+
* do want to have as little side channels as possible. This implies
289+
* that conditional code dependent on the ws->root is replaced.
290+
*/
291+
279292
for (i = 0; i < LC_SPX_D; i++) {
280293
set_layer_addr(ws->tree_addr, i);
281294
set_tree_addr(ws->tree_addr, ws->tree);

slh-dsa/src/sphincs_wotsx1.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,25 @@ void wots_gen_leafx1(unsigned char *dest, const spx_ctx *ctx, uint32_t leaf_idx,
8585

8686
/* Iterate down the WOTS chain */
8787
for (k = 0;; k++) {
88-
/* Check if this is the value that needs to be saved as a */
89-
/* part of the WOTS signature */
88+
/*
89+
*Check if this is the value that needs to be saved as
90+
* a part of the WOTS signature.
91+
*/
92+
93+
/*
94+
* The memcpy code path is from upstream but it is not
95+
* side-channel-free - it has side channels on the
96+
* ws->root (see lc_sphincs_sign_ctx).
97+
*/
98+
#if 0
99+
if (k == wots_k) {
100+
memcpy(info->wots_sig + i * LC_SPX_N,
101+
buffer, LC_SPX_N);
102+
}
103+
#else
90104
cmov(info->wots_sig + i * LC_SPX_N, buffer, LC_SPX_N,
91105
k == wots_k);
106+
#endif
92107

93108
/* Check if we hit the top of the chain */
94109
if (k == LC_SPX_WOTS_W - 1)

0 commit comments

Comments
 (0)