diff options
author | Yurii Shutkin <shutkin@google.com> | 2023-10-09 15:25:29 +0200 |
---|---|---|
committer | Yurii Shutkin <shutkin@google.com> | 2023-10-09 15:37:29 +0200 |
commit | f75464d65e935a7216cbd3db5753716a9cd6e546 (patch) | |
tree | f5e663bf70e3d5bf5ee27bfd9d20a81f2b9142a3 /trusty | |
parent | af5de39039e0cb61b7e66e2f031b2387bb6376f2 (diff) | |
download | core-f75464d65e935a7216cbd3db5753716a9cd6e546.tar.gz |
acvp: handle flush commond in modulewrapper as stated in BoringSSL.
Change-Id: Ife655f0764851cf2d9677abd507daec3f531031e
Bug: 287626912
Test: ACVP test
Diffstat (limited to 'trusty')
-rw-r--r-- | trusty/utils/acvp/trusty_modulewrapper.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/trusty/utils/acvp/trusty_modulewrapper.cpp b/trusty/utils/acvp/trusty_modulewrapper.cpp index 70ffb52ec..85b7159d3 100644 --- a/trusty/utils/acvp/trusty_modulewrapper.cpp +++ b/trusty/utils/acvp/trusty_modulewrapper.cpp @@ -21,15 +21,16 @@ #include <android-base/result.h> #include <android-base/unique_fd.h> #include <errno.h> +#include <iostream> #include <log/log.h> #include <modulewrapper.h> #include <openssl/span.h> #include <stdint.h> #include <stdlib.h> +#include <string.h> #include <sys/mman.h> #include <trusty/tipc.h> #include <unistd.h> -#include <iostream> #include "acvp_ipc.h" @@ -208,6 +209,11 @@ Result<void> ModuleWrapper::ForwardResponse() { return {}; } +static bool EqString(bssl::Span<const uint8_t> cmd, const char *str) { + return cmd.size() == strlen(str) && + memcmp(str, cmd.data(), cmd.size()) == 0; +} + int main() { for (;;) { auto buffer = bssl::acvp::RequestBuffer::New(); @@ -217,17 +223,24 @@ int main() { return EXIT_FAILURE; } - ModuleWrapper wrapper; - auto res = wrapper.SendMessage(args); - if (!res.ok()) { - std::cerr << res.error() << std::endl; - return EXIT_FAILURE; - } + if (EqString(args[0], "flush")) { + if (!bssl::acvp::FlushBuffer(STDOUT_FILENO)) { + ALOGE("Could not flush the buffer to stdout\n"); + return EXIT_FAILURE; + } + } else { + ModuleWrapper wrapper; + auto res = wrapper.SendMessage(args); + if (!res.ok()) { + std::cerr << res.error() << std::endl; + return EXIT_FAILURE; + } - res = wrapper.ForwardResponse(); - if (!res.ok()) { - std::cerr << res.error() << std::endl; - return EXIT_FAILURE; + res = wrapper.ForwardResponse(); + if (!res.ok()) { + std::cerr << res.error() << std::endl; + return EXIT_FAILURE; + } } } |