Remove unused salt buffer from ltc_pkcs_1_pss_decode_mgf1 #796

Closed
opened 2026-08-19 03:43:49 -05:00 by headscott · 0 comments
headscott commented 2026-08-19 03:43:49 -05:00 (Migrated from github.com)

ltc_pkcs_1_pss_decode_mgf1 allocates a separate buffer for salt:

unsigned char *DB, *mask, *salt, *hash;
[...]
salt = XMALLOC(modulus_len);

However, the salt buffer is never written to or read from. The salt is already available directly within DB and is passed to the hash function using:

hash_descriptor[op_checked.hash_alg].process(&md, DB+x, saltlen)

At this point, DB + x points to the beginning of the salt portion of DB.

Suggested Fix:

Remove the unused salt buffer and all associated allocation, cleanup, and deallocation code.
The PSS verification logic itself does not need to change, as the salt can continue to be processed directly from DB + x.

`ltc_pkcs_1_pss_decode_mgf1` allocates a separate buffer for salt: ``` unsigned char *DB, *mask, *salt, *hash; [...] salt = XMALLOC(modulus_len); ``` However, the salt buffer is never written to or read from. The salt is already available directly within `DB` and is passed to the hash function using: `hash_descriptor[op_checked.hash_alg].process(&md, DB+x, saltlen)` At this point, `DB + x` points to the beginning of the salt portion of `DB`. ### Suggested Fix: Remove the unused `salt` buffer and all associated allocation, cleanup, and deallocation code. The PSS verification logic itself does not need to change, as the salt can continue to be processed directly from `DB + x`.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libtom/libtomcrypt#796
No description provided.