summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ayrton Munoz <ayrton@google.com> 2022-08-03 17:05:09 -0400
committer Ayrton Munoz <ayrton@google.com> 2022-08-11 01:37:19 -0400
commit04137372dcfe0d7eba8545efd65b7f43b682bb71 (patch)
tree767d22df9c0b93eec942adcfc2674efef39a8790
parente03fbcc4b97a46992b34e08ced303c7c340af7da (diff)
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
-rw-r--r--libs/binder/trusty/OS.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libs/binder/trusty/OS.cpp b/libs/binder/trusty/OS.cpp
index 187add4a7b..7c811b75e9 100644
--- a/libs/binder/trusty/OS.cpp
+++ b/libs/binder/trusty/OS.cpp
@@ -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