[Git][NTPsec/ntpsec][master] fix build with libressl
Hal Murray (@hal.murray)
gitlab at mg.gitlab.com
Sun Aug 14 18:21:54 UTC 2022
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
128b66ae by Fabrice Fontaine at 2022-08-14T01:30:35-07:00
fix build with libressl
Fix the following build failure with libressl:
/home/buildroot/autobuild/instance-0/output-1/host/lib/gcc/armeb-buildroot-linux-gnueabi/11.3.0/../../../../armeb-buildroot-linux-gnueabi/bin/ld: libntp/libntp.a(ntp_random.c.1.o): in function `ntp_RAND_priv_bytes':
ntp_random.c:(.text+0xac): undefined reference to `RAND_priv_bytes'
Fixes:
- http://autobuild.buildroot.org/results/a6a825b7f0efc7c82e8ecf792a1f9951ffb047c5
Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>
- - - - -
3 changed files:
- attic/cmac-timing.c
- attic/random.c
- libntp/ntp_random.c
Changes:
=====================================
attic/cmac-timing.c
=====================================
@@ -204,7 +204,9 @@ static void DoPKEY(
printf("## Oops, EVP_MD_CTX_new() failed.\n");
return;
}
+#ifdef EVP_MD_CTX_FLAG_FINALISE
EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_FINALISE);
+#endif
clock_gettime(CLOCK_MONOTONIC, &start);
for (int i = 0; i < SAMPLESIZE; i++) {
=====================================
attic/random.c
=====================================
@@ -127,7 +127,11 @@ static int do_avg_priv(unsigned int bytes) {
clock_gettime(CLOCK_REALTIME, &start);
for (int i = 0; i < BATCHSIZE; i++) {
+#ifdef LIBRESSL_VERSION_NUMBER
+ err += RAND_bytes((unsigned char *)&rnd, bytes);
+#else
err += RAND_priv_bytes((unsigned char *)&rnd, bytes);
+#endif
}
clock_gettime(CLOCK_REALTIME, &stop);
@@ -209,7 +213,11 @@ static int do_fast_priv(unsigned bytes) {
for (int i = 0; i < BATCHSIZE; i++) {
clock_gettime(CLOCK_REALTIME, &start);
+#ifdef LIBRESSL_VERSION_NUMBER
+ err += RAND_bytes((unsigned char *)&rnd, bytes);
+#else
err += RAND_priv_bytes((unsigned char *)&rnd, bytes);
+#endif
clock_gettime(CLOCK_REALTIME, &stop);
sec = (stop.tv_sec-start.tv_sec);
nanos = sec*BILLION + (stop.tv_nsec-start.tv_nsec);
=====================================
libntp/ntp_random.c
=====================================
@@ -29,7 +29,7 @@ void ntp_RAND_bytes(unsigned char *buf, int num) {
void ntp_RAND_priv_bytes(unsigned char *buf, int num) {
int err;
-#if (OPENSSL_VERSION_NUMBER > 0x1010100fL)
+#if (OPENSSL_VERSION_NUMBER > 0x1010100fL) && !defined(LIBRESSL_VERSION_NUMBER)
err = RAND_priv_bytes(buf, num);
#else
err = RAND_bytes(buf, num);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/128b66ae122d7b41ce4b99f427383fd6a5923d71
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/128b66ae122d7b41ce4b99f427383fd6a5923d71
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20220814/6d6af95d/attachment-0001.htm>
More information about the vc
mailing list