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

Commit c30afb5d authored by Yurii Shutkin's avatar Yurii Shutkin Committed by Automerger Merge Worker
Browse files

Merge "acvp: handle flush commond in modulewrapper as stated in BoringSSL."...

Merge "acvp: handle flush commond in modulewrapper as stated in BoringSSL." into main am: a7dd7767 am: 94052318 am: 88a6a562 am: eea2f493

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2778528



Change-Id: Ie1cf27f2da091072334c4b5280f9d0da4ae2f5a9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8f854508 eea2f493
Loading
Loading
Loading
Loading
+24 −11
Original line number Diff line number Diff line
@@ -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,6 +223,12 @@ int main() {
            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()) {
@@ -230,6 +242,7 @@ int main() {
                return EXIT_FAILURE;
            }
        }
    }

    return EXIT_SUCCESS;
};