Skip to content

HashML-DSA: Replace enum by #define #591

@mkannwischer

Description

@mkannwischer

Currently we are using an enum to specify which pre-hashing hash function to be used:

mldsa-native/mldsa/sign.h

Lines 495 to 499 in 1d7ed8d

int crypto_sign_verify_pre_hash_internal(const uint8_t *sig, size_t siglen,
const uint8_t *ph, size_t phlen,
const uint8_t *ctx, size_t ctxlen,
const uint8_t *pk,
mld_hash_alg_t hashAlg)

typedef enum
{
MLD_SHA2_224,
MLD_SHA2_256,
MLD_SHA2_384,
MLD_SHA2_512,
MLD_SHA2_512_224,
MLD_SHA2_512_256,
MLD_SHA3_224,
MLD_SHA3_256,
MLD_SHA3_384,
MLD_SHA3_512,
MLD_SHAKE_128,
MLD_SHAKE_256
} mld_hash_alg_t;

This leads to problems when introducing a separate mldsa_native.h specifying the public API that can be included multiple times as it introduces clashes. #537 works around this guarding it by an #ifndef to only define it once.
Futhermore, there is a (theoretical) concern about the type of the enum being implementation-defined in C90: #537 (comment).

We should eliminate the enum and instead use #defines to define numerical values for each possible value.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions