From 0a86cbff452f3c1807738968a88332416279e3dc Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 26 Feb 2021 18:15:20 -0500 Subject: [PATCH] RAND_set_rand_method returns int. This improves compatibility with cryptography.io. cryptography.io doesn't actually care what we return, since the code won't run, but feigning success seems better than failure. If some application does try to run this function and checks, returning an error will probably crash it. Change-Id: I7a8164753a2f1a7b31dbeb10c7030c5e5fea2bc9 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46004 Commit-Queue: David Benjamin Commit-Queue: Adam Langley Reviewed-by: Adam Langley --- crypto/rand_extra/rand_extra.c | 2 +- include/openssl/rand.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/rand_extra/rand_extra.c b/crypto/rand_extra/rand_extra.c index 596605acc..e73b99e30 100644 --- a/crypto/rand_extra/rand_extra.c +++ b/crypto/rand_extra/rand_extra.c @@ -69,6 +69,6 @@ RAND_METHOD *RAND_OpenSSL(void) { const RAND_METHOD *RAND_get_rand_method(void) { return RAND_SSLeay(); } -void RAND_set_rand_method(const RAND_METHOD *method) {} +int RAND_set_rand_method(const RAND_METHOD *method) { return 1; } void RAND_cleanup(void) {} diff --git a/include/openssl/rand.h b/include/openssl/rand.h index b07015b32..bd41f9e32 100644 --- a/include/openssl/rand.h +++ b/include/openssl/rand.h @@ -103,8 +103,8 @@ OPENSSL_EXPORT RAND_METHOD *RAND_OpenSSL(void); // RAND_get_rand_method returns |RAND_SSLeay()|. OPENSSL_EXPORT const RAND_METHOD *RAND_get_rand_method(void); -// RAND_set_rand_method does nothing. -OPENSSL_EXPORT void RAND_set_rand_method(const RAND_METHOD *); +// RAND_set_rand_method returns one. +OPENSSL_EXPORT int RAND_set_rand_method(const RAND_METHOD *); #if defined(__cplusplus)