Skip to content
New issue

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

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

Already on GitHub? # to your account

Make sure s_mp_rand_source is defined for all its uses #583

Closed
wants to merge 1 commit into 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

sjaeckel added a commit that referenced this pull request Jan 30, 2025
In order to make `helper.pl` happy, change the ternary operator to an
if-else statement, otherwise it won't properly generate `tommath_class.h`.

This fixes #582
This closes #583

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
@sjaeckel sjaeckel mentioned this pull request Jan 30, 2025
@sjaeckel sjaeckel closed this in 48a3568 Jan 30, 2025
@levitte levitte deleted the fix-582 branch January 30, 2025 18:07
# for free to join this conversation on GitHub. Already have an account? # 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