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

Conversation

levitte
Copy link

@levitte levitte commented Nov 19, 2024

mp_prime_rand.c uses s_mp_rand_source as well, so ensure that the
latter is defined on the conditions of the former as well.

Fixes #582

mp_prime_rand.c uses s_mp_rand_source as well, so ensure that the
latter is defined on the conditions of the former as well.

Fixes libtom#582
#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[linux-error]undefined symbol: s_mp_rand_source
2 participants