Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04137372 authored by Ayrton Munoz's avatar Ayrton Munoz
Browse files

libbinder: Remove dependency on openssl for Trusty kernel

This modifies the trusty-specific OS.cpp to use the RNG
available in the trusty kernel instead of openssl when
TRUSTY_KERNEL_FD is defined.

Bug: 230134581
Test: build Trusty
Change-Id: Ic27406707a515882ca6340d6e8db81f3e2f9509d
parent e03fbcc4
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -14,7 +14,11 @@
 * limitations under the License.
 */

#if defined(TRUSTY_USERSPACE)
#include <openssl/rand.h>
#else
#include <lib/rand/rand.h>
#endif

#include "../OS.h"

@@ -28,8 +32,13 @@ Result<void> setNonBlocking(android::base::borrowed_fd fd) {
}

status_t getRandomBytes(uint8_t* data, size_t size) {
#if defined(TRUSTY_USERSPACE)
    int res = RAND_bytes(data, size);
    return res == 1 ? OK : UNKNOWN_ERROR;
#else
    int res = rand_get_bytes(data, size);
    return res == 0 ? OK : UNKNOWN_ERROR;
#endif // TRUSTY_USERSPACE
}

} // namespace android