mldsa.c File Reference

ML-DSA (Edwards-Curve Digital Signature Algorithm) More...

#include "core/crypto.h"
#include "pqc/mldsa.h"
#include "debug.h"
#include <oqs/oqs.h>

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

void mldsaInitPublicKey (MldsaPublicKey *key)
 Initialize an ML-DSA public key. More...
 
void mldsaFreePublicKey (MldsaPublicKey *key)
 Release an ML-DSA public key. More...
 
void mldsaInitPrivateKey (MldsaPrivateKey *key)
 Initialize an ML-DSA private key. More...
 
void mldsaFreePrivateKey (MldsaPrivateKey *key)
 Release an ML-DSA private key. More...
 
error_t mldsaImportPublicKey (MldsaPublicKey *key, uint_t level, const uint8_t *input, size_t length)
 Import an ML-DSA public key. More...
 
error_t mldsaExportPublicKey (const MldsaPublicKey *key, uint8_t *output, size_t *written)
 Export an ML-DSA public key. More...
 
error_t mldsaImportPrivateKey (MldsaPrivateKey *key, uint_t level, const uint8_t *input, size_t length)
 Import an ML-DSA private key. More...
 
error_t mldsaExportPrivateKey (const MldsaPrivateKey *key, uint8_t *output, size_t *written)
 Export an ML-DSA private key. More...
 
error_t mldsaImportSeed (MldsaPrivateKey *key, uint_t level, const uint8_t *input, size_t length)
 Import an ML-DSA seed. More...
 
error_t mldsaExportSeed (const MldsaPrivateKey *key, uint8_t *output, size_t *written)
 Export an ML-DSA seed. More...
 
error_t mldsa44GenerateSignature (const uint8_t *secretKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, uint8_t *signature)
 ML-DSA-44 signature generation. More...
 
error_t mldsa65GenerateSignature (const uint8_t *secretKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, uint8_t *signature)
 ML-DSA-65 signature generation. More...
 
error_t mldsa87GenerateSignature (const uint8_t *secretKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, uint8_t *signature)
 ML-DSA-87 signature generation. More...
 
error_t mldsa44VerifySignature (const uint8_t *publicKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, const uint8_t *signature)
 ML-DSA-44 signature verification. More...
 
error_t mldsa65VerifySignature (const uint8_t *publicKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, const uint8_t *signature)
 ML-DSA-65 signature verification. More...
 
error_t mldsa87VerifySignature (const uint8_t *publicKey, const void *message, size_t messageLen, const void *context, uint8_t contextLen, const uint8_t *signature)
 ML-DSA-87 signature verification. More...
 

Variables

const uint8_t MLDSA44_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x11}
 
const uint8_t MLDSA65_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x12}
 
const uint8_t MLDSA87_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x13}
 

Detailed Description

ML-DSA (Edwards-Curve Digital Signature Algorithm)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCRYPTO Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.4

Definition in file mldsa.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file mldsa.c.

Function Documentation

◆ mldsa44GenerateSignature()

error_t mldsa44GenerateSignature ( const uint8_t *  secretKey,
const void *  message,
size_t  messageLen,
const void *  context,
uint8_t  contextLen,
uint8_t *  signature 
)

ML-DSA-44 signature generation.

Parameters
[in]secretKeyPointer to the secret key (2560 bytes)
[in]messagePointer to the message to be signed
[in]messageLenLength of the message, in bytes
[in]contextContext string (a byte string of 255 or fewer bytes)
[in]contextLenLength of the context, in bytes
[out]signatureML-DSA-44 signature (2420 bytes)
Returns
Error code

Definition at line 542 of file mldsa.c.

◆ mldsa44VerifySignature()

error_t mldsa44VerifySignature ( const uint8_t *  publicKey,
const void *  message,
size_t  messageLen,
const void *  context,
uint8_t  contextLen,
const uint8_t *  signature 
)

ML-DSA-44 signature verification.

Parameters
[in]publicKeyPointer to the public key (1312 bytes)
[in]messageMessage whose signature is to be verified
[in]messageLenLength of the message, in bytes
[in]contextContext string (a byte string of 255 or fewer bytes)
[in]contextLenLength of the context, in bytes
[in]signatureML-DSA-44 signature (2420 bytes)
Returns
Error code

Definition at line 636 of file mldsa.c.

◆ mldsa65GenerateSignature()

error_t mldsa65GenerateSignature ( const uint8_t *  secretKey,
const void *  message,
size_t  messageLen,
const void *  context,
uint8_t  contextLen,
uint8_t *  signature 
)

ML-DSA-65 signature generation.

Parameters
[in]secretKeyPointer to the secret key (4032 bytes)
[in]messagePointer to the message to be signed
[in]messageLenLength of the message, in bytes
[in]contextContext string (a byte string of 255 or fewer bytes)
[in]contextLenLength of the context, in bytes
[out]signatureML-DSA-65 signature (3309 bytes)
Returns
Error code

Definition at line 574 of file mldsa.c.

◆ mldsa65VerifySignature()

error_t mldsa65VerifySignature ( const uint8_t *  publicKey,
const void *  message,
size_t  messageLen,
const void *  context,
uint8_t  contextLen,
const uint8_t *  signature 
)

ML-DSA-65 signature verification.

Parameters
[in]publicKeyPointer to the public key (1952 bytes)
[in]messageMessage whose signature is to be verified
[in]messageLenLength of the message, in bytes
[in]contextContext string (a byte string of 255 or fewer bytes)
[in]contextLenLength of the context, in bytes
[in]signatureML-DSA-65 signature (3309 bytes)
Returns
Error code

Definition at line 667 of file mldsa.c.

◆ mldsa87GenerateSignature()

error_t mldsa87GenerateSignature ( const uint8_t *  secretKey,
const void *  message,
size_t  messageLen,
const void *  context,
uint8_t  contextLen,
uint8_t *  signature 
)

ML-DSA-87 signature generation.

Parameters
[in]secretKeyPointer to the secret key (4896 bytes)
[in]messagePointer to the message to be signed
[in]messageLenLength of the message, in bytes
[out]signatureML-DSA-87 signature (4627 bytes)
Returns
Error code

Definition at line 604 of file mldsa.c.

◆ mldsa87VerifySignature()

error_t mldsa87VerifySignature ( const uint8_t *  publicKey,
const void *  message,
size_t  messageLen,
const void *  context,
uint8_t  contextLen,
const uint8_t *  signature 
)

ML-DSA-87 signature verification.

Parameters
[in]publicKeyPointer to the public key (2592 bytes)
[in]messageMessage whose signature is to be verified
[in]messageLenLength of the message, in bytes
[in]contextContext string (a byte string of 255 or fewer bytes)
[in]contextLenLength of the context, in bytes
[in]signatureML-DSA-87 signature (4627 bytes)
Returns
Error code

Definition at line 698 of file mldsa.c.

◆ mldsaExportPrivateKey()

error_t mldsaExportPrivateKey ( const MldsaPrivateKey key,
uint8_t *  output,
size_t *  written 
)

Export an ML-DSA private key.

Parameters
[in]keyML-DSA private key
[out]outputPointer to the octet string (optional parameter)
[out]writtenLength of the octet string, in bytes
Returns
Error code

Definition at line 357 of file mldsa.c.

◆ mldsaExportPublicKey()

error_t mldsaExportPublicKey ( const MldsaPublicKey key,
uint8_t *  output,
size_t *  written 
)

Export an ML-DSA public key.

Parameters
[in]keyML-DSA public key
[out]outputPointer to the octet string (optional parameter)
[out]writtenLength of the resulting octet string, in bytes
Returns
Error code

Definition at line 225 of file mldsa.c.

◆ mldsaExportSeed()

error_t mldsaExportSeed ( const MldsaPrivateKey key,
uint8_t *  output,
size_t *  written 
)

Export an ML-DSA seed.

Parameters
[in]keyML-DSA private key
[out]outputPointer to the octet string (optional parameter)
[out]writtenLength of the octet string, in bytes
Returns
Error code

Definition at line 489 of file mldsa.c.

◆ mldsaFreePrivateKey()

void mldsaFreePrivateKey ( MldsaPrivateKey key)

Release an ML-DSA private key.

Parameters
[in]keyPointer to the ML-DSA public key to free

Definition at line 114 of file mldsa.c.

◆ mldsaFreePublicKey()

void mldsaFreePublicKey ( MldsaPublicKey key)

Release an ML-DSA public key.

Parameters
[in]keyPointer to the ML-DSA public key to free

Definition at line 75 of file mldsa.c.

◆ mldsaImportPrivateKey()

error_t mldsaImportPrivateKey ( MldsaPrivateKey key,
uint_t  level,
const uint8_t *  input,
size_t  length 
)

Import an ML-DSA private key.

Parameters
[out]keyML-DSA private key
[in]levelSecurity level
[in]inputPointer to the octet string
[in]lengthLength of the octet string, in bytes
Returns
Error code

Definition at line 276 of file mldsa.c.

◆ mldsaImportPublicKey()

error_t mldsaImportPublicKey ( MldsaPublicKey key,
uint_t  level,
const uint8_t *  input,
size_t  length 
)

Import an ML-DSA public key.

Parameters
[out]keyML-DSA public key
[in]levelSecurity level
[in]inputPointer to the octet string
[in]lengthLength of the octet string, in bytes
Returns
Error code

Definition at line 144 of file mldsa.c.

◆ mldsaImportSeed()

error_t mldsaImportSeed ( MldsaPrivateKey key,
uint_t  level,
const uint8_t *  input,
size_t  length 
)

Import an ML-DSA seed.

Parameters
[out]keyML-DSA private key
[in]levelSecurity level
[in]inputPointer to the octet string
[in]lengthLength of the octet string, in bytes
Returns
Error code

Definition at line 408 of file mldsa.c.

◆ mldsaInitPrivateKey()

void mldsaInitPrivateKey ( MldsaPrivateKey key)

Initialize an ML-DSA private key.

Parameters
[in]keyPointer to the ML-DSA private key to initialize

Definition at line 94 of file mldsa.c.

◆ mldsaInitPublicKey()

void mldsaInitPublicKey ( MldsaPublicKey key)

Initialize an ML-DSA public key.

Parameters
[in]keyPointer to the ML-DSA public key to initialize

Definition at line 59 of file mldsa.c.

Variable Documentation

◆ MLDSA44_OID

const uint8_t MLDSA44_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x11}

Definition at line 47 of file mldsa.c.

◆ MLDSA65_OID

const uint8_t MLDSA65_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x12}

Definition at line 49 of file mldsa.c.

◆ MLDSA87_OID

const uint8_t MLDSA87_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x03, 0x13}

Definition at line 51 of file mldsa.c.