Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/basic/test_only_rng/notrandombytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void surf(void)
}
}

void randombytes(uint8_t *buf, size_t n)
int randombytes(uint8_t *buf, size_t n)
{
while (n > 0)
{
Expand All @@ -110,4 +110,5 @@ void randombytes(uint8_t *buf, size_t n)
++buf;
--n;
}
return 0;
}
2 changes: 1 addition & 1 deletion examples/basic/test_only_rng/notrandombytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
*/

void randombytes_reset(void);
void randombytes(uint8_t *buf, size_t n);
int randombytes(uint8_t *buf, size_t n);

#endif /* !NOTRANDOMBYTES_H */
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -354,9 +355,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void surf(void)
}
}

void randombytes(uint8_t *buf, size_t n)
int randombytes(uint8_t *buf, size_t n)
{
while (n > 0)
{
Expand All @@ -110,4 +110,5 @@ void randombytes(uint8_t *buf, size_t n)
++buf;
--n;
}
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
*/

void randombytes_reset(void);
void randombytes(uint8_t *buf, size_t n);
int randombytes(uint8_t *buf, size_t n);

#endif /* !NOTRANDOMBYTES_H */
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void surf(void)
}
}

void randombytes(uint8_t *buf, size_t n)
int randombytes(uint8_t *buf, size_t n)
{
while (n > 0)
{
Expand All @@ -110,4 +110,5 @@ void randombytes(uint8_t *buf, size_t n)
++buf;
--n;
}
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
*/

void randombytes_reset(void);
void randombytes(uint8_t *buf, size_t n);
int randombytes(uint8_t *buf, size_t n);

#endif /* !NOTRANDOMBYTES_H */
6 changes: 4 additions & 2 deletions examples/monolithic_build/config_44.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -352,9 +353,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
6 changes: 4 additions & 2 deletions examples/monolithic_build/config_65.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -352,9 +353,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
6 changes: 4 additions & 2 deletions examples/monolithic_build/config_87.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -352,9 +353,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
6 changes: 4 additions & 2 deletions examples/monolithic_build_multilevel/multilevel_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -353,9 +354,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -360,9 +361,9 @@
#include <stdint.h>
#include "sys.h"
#include "test_only_rng/notrandombytes.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
randombytes(ptr, len);
return randombytes(ptr, len);
}
#endif /* !__ASSEMBLER__ */

Expand Down
6 changes: 4 additions & 2 deletions examples/monolithic_build_native/config_44.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -350,9 +351,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
6 changes: 4 additions & 2 deletions examples/monolithic_build_native/config_65.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -350,9 +351,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
6 changes: 4 additions & 2 deletions examples/monolithic_build_native/config_87.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -350,9 +351,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
5 changes: 3 additions & 2 deletions integration/liboqs/config_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
* consumer.
*
* If this option is not set, mlkem-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
*
* Set this option and define `mlk_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -174,9 +174,10 @@
#include <oqs/rand.h>
#include <stdint.h>
#include "../../mldsa/src/sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
OQS_randombytes(ptr, len);
return 0;
}
#endif /* !__ASSEMBLER__ */

Expand Down
5 changes: 3 additions & 2 deletions integration/liboqs/config_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
* consumer.
*
* If this option is not set, mlkem-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
*
* Set this option and define `mlk_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -178,9 +178,10 @@
#include <oqs/rand.h>
#include <stdint.h>
#include "../../mldsa/src/sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
OQS_randombytes(ptr, len);
return 0;
}
#endif /* !__ASSEMBLER__ */

Expand Down
5 changes: 3 additions & 2 deletions integration/liboqs/config_x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
* consumer.
*
* If this option is not set, mlkem-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
*
* Set this option and define `mlk_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -176,9 +176,10 @@
#include <oqs/rand.h>
#include <stdint.h>
#include "../../mldsa/src/sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
OQS_randombytes(ptr, len);
return 0;
}
#endif /* !__ASSEMBLER__ */

Expand Down
6 changes: 4 additions & 2 deletions mldsa/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@
* consumer.
*
* If this option is not set, mldsa-native expects a function
* void randombytes(uint8_t *out, size_t outlen).
* int randombytes(uint8_t *out, size_t outlen).
* This function should return 0 on success, non-zero on failure.
*
* Set this option and define `mld_randombytes` if you want to
* use a custom method to sample randombytes with a different name
Expand All @@ -338,9 +339,10 @@
#if !defined(__ASSEMBLER__)
#include <stdint.h>
#include "sys.h"
static MLD_INLINE void mld_randombytes(uint8_t *ptr, size_t len)
static MLD_INLINE int mld_randombytes(uint8_t *ptr, size_t len)
{
... your implementation ...
return 0; // 0 on success, non-zero on failure
}
#endif
*/
Expand Down
6 changes: 3 additions & 3 deletions mldsa/src/randombytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

#if !defined(MLD_CONFIG_NO_RANDOMIZED_API)
#if !defined(MLD_CONFIG_CUSTOM_RANDOMBYTES)
void randombytes(uint8_t *out, size_t outlen);
static MLD_INLINE void mld_randombytes(uint8_t *out, size_t outlen)
int randombytes(uint8_t *out, size_t outlen);
static MLD_INLINE int mld_randombytes(uint8_t *out, size_t outlen)
__contract__(
requires(memory_no_alias(out, outlen))
assigns(memory_slice(out, outlen))
) { randombytes(out, outlen); }
) { return randombytes(out, outlen); }
#endif /* !MLD_CONFIG_CUSTOM_RANDOMBYTES */
#endif /* !MLD_CONFIG_NO_RANDOMIZED_API */
#endif /* !MLD_RANDOMBYTES_H */
Loading