Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure s_mp_rand_source is defined for all its uses #583

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion mp_rand_source.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "tommath_private.h"
#ifdef MP_RAND_C
/* MP_RAND_C relates to mp_rand.c, MP_PRIME_RAND_C relates tp mp_prime_rand.c
Both use s_mp_rand_source */
#if defined(MP_RAND_C) || defined(MP_PRIME_RAND_C)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#if defined(MP_RAND_C) || defined(MP_PRIME_RAND_C)
#if defined(MP_RAND_SOURCE_C) || defined(S_MP_RAND_SOURCE_C)

This should be selected automagically via tommath_class.h, but if we change it as proposed this won't be the case. My suggestion is also not correct ... I guess the really correct way would be if the file looked as follows!? What do you think?

#include "tommath_private.h"
#ifdef S_MP_RAND_SOURCE_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */

mp_err(*s_mp_rand_source)(void *out, size_t size) = s_mp_rand_platform;
#endif

#ifdef MP_RAND_SOURCE_C
void mp_rand_source(mp_err(*source)(void *out, size_t size))
{
   s_mp_rand_source = (source == NULL) ? s_mp_rand_platform : source;
}
#endif

Or maybe this should even be two files?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Yeah that works too. I suggest you merge that, then close this PR

/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */

Expand Down
Loading