You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Mismatching docs for ML-DSA size functions #12040
The documentation of wc_MlDsaKey_Size and wc_MlDsaKey_PrivSize (and the related wc_MlDsaKey_GetPrivLen) is incorrect in doc/dox_comments/header_files/wc_mldsa.h.
It's currently stated that the former is equivalent to the latter and exists for API compatibility only and that both return the size of the private key.
However, the implementation (and documentation) in wolfcrypt/src/wc_mldsa.c shows that while wc_MlDsaKey_Size does, in fact, return the size of the private key, wc_MlDsaKey_PrivSize returns the size of both the private and public key.
So not only are the two functions not equivalent, their naming is quite counter-intuitive (i.e. ...Size would be more suitable for the private+public key size than ...PrivSize and vice-versa). But I guess that can't be changed anymore to remain backwards compatible. But at least the docs should match the actual implementation.
Hi @tobiasbrunner , thank you for the report and you wc_MlDsaKey_Size() is the private key alone (what wc_MlDsaKey_ExportPrivRaw() writes), and wc_MlDsaKey_PrivSize() / wc_MlDsaKey_GetPrivLen() are the private key with the public key appended, the encoding wc_MlDsaKey_ImportKey() and wc_MlDsaKey_PrivateKeyDecode() take. The names come from the original wc_dilithium_size() / wc_dilithium_priv_size() API, which still map onto them, so as you say they stay. The Doxygen and source comments were wrong; the fix (plus a test pinning PrivSize() == Size() + PubSize()) is in PR #12052.
Thanks, David Garske, wolfSSL
Activity
dgarske commentedon Nov 6, 2026
Hi @tobiasbrunner , thank you for the report and you
wc_MlDsaKey_Size()is the private key alone (whatwc_MlDsaKey_ExportPrivRaw()writes), andwc_MlDsaKey_PrivSize()/wc_MlDsaKey_GetPrivLen()are the private key with the public key appended, the encodingwc_MlDsaKey_ImportKey()andwc_MlDsaKey_PrivateKeyDecode()take. The names come from the originalwc_dilithium_size()/wc_dilithium_priv_size()API, which still map onto them, so as you say they stay. The Doxygen and source comments were wrong; the fix (plus a test pinningPrivSize() == Size() + PubSize()) is in PR #12052.Thanks, David Garske, wolfSSL