Skip to content

RFC 8702: RSA-PSS-SHAKE128/256 and ECDSA-SHAKE128/256#754

Merged
sjaeckel merged 1 commit intodevelopfrom
pr/shake128-256
May 6, 2026
Merged

RFC 8702: RSA-PSS-SHAKE128/256 and ECDSA-SHAKE128/256#754
sjaeckel merged 1 commit intodevelopfrom
pr/shake128-256

Conversation

@karel-m
Copy link
Copy Markdown
Member

@karel-m karel-m commented May 3, 2026

Implemented RFC 8702 support for:

  • RSA-PSS-SHAKE128 / RSA-PSS-SHAKE256
  • ECDSA-SHAKE128 / ECDSA-SHAKE256

At first this looked like a small change, but the RSA-PSS part turned out to be less clean than expected.

Added SHAKE128/256 support through:

  • sha3_shake128_init / sha3_shake128_process / sha3_shake128_done
  • sha3_shake256_init / sha3_shake256_process / sha3_shake256_done

Also added the corresponding descriptors: shake128_desc, shake256_desc (these descriptors have fixed digest lengths set according to RFC 8702 - shake128 outputs 32 bytes, shake256 outputs 64 bytes).

The ECDSA-SHAKE128/256 implementation was fairly straightforward.

The RSA-PSS-SHAKE128/256 implementation required a few workarounds because SHAKE is also used directly for MGF [not like MGF1(shakeNNN)]. Therefore I added a new direct_shake_mgf flag to struct ltc_rsa_parameters and a few IFs in the code.

The result works but the implementation is not as clean as I would have liked.

Checklist

  • documentation is added or updated
  • tests are added or updated

@sjaeckel sjaeckel changed the base branch from develop to more-fixes-and-improvements May 3, 2026 18:19
Copy link
Copy Markdown
Member

@sjaeckel sjaeckel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Bascially LGTM, besides that one remark.

Comment thread src/headers/tomcrypt_pk.h Outdated
Comment on lines +75 to +76
/** Direct SHAKE MGF strength for RFC 8702 PSS-SHAKE: 0, 128 or 256 */
int direct_shake_mgf;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the fact that it's now ambiguous and one could also do mgf1_hash_idx = find_hash("shakeXXX"); and the result of the operation would be different. I believe it'd be better if this were resolved internally, even if it makes the implementation more complicated than via this approach.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the whole logic around mgf1_hash_idx and direct_shake_mgf is hard to follow and full of unexpected surprises.

I expected this PR to be a simple/easy addition. As I mentioned, I am not satisfied with the result either.

@karel-m karel-m force-pushed the pr/shake128-256 branch from b68c206 to 258bcd7 Compare May 4, 2026 05:39
@karel-m
Copy link
Copy Markdown
Member Author

karel-m commented May 4, 2026

UPDATE: removed direct_shake_mgf, all "magic" now takes place inside ltc_pkcs_1_mgf1(..) - which is now slightly misleadingly named as it is not always MGF1 (but it is only an internal function, not part of the public API)

@sjaeckel sjaeckel force-pushed the more-fixes-and-improvements branch 5 times, most recently from 9a60bbf to a724483 Compare May 4, 2026 12:45
Base automatically changed from more-fixes-and-improvements to develop May 4, 2026 13:33
@sjaeckel sjaeckel force-pushed the pr/shake128-256 branch from 0f4b0ec to f95e548 Compare May 4, 2026 13:33
Comment thread src/pk/pkcs1/pkcs_1_mgf1.c Outdated
@sjaeckel sjaeckel force-pushed the pr/shake128-256 branch from 12cbc9f to 1e4d471 Compare May 6, 2026 07:48
@sjaeckel sjaeckel merged commit 8b5af49 into develop May 6, 2026
0 of 202 checks passed
@sjaeckel sjaeckel deleted the pr/shake128-256 branch May 6, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants