diff options
author | Andrea Grandi <agrandi@google.com> | 2022-11-16 12:08:57 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-17 01:10:16 +0000 |
commit | ba50d8b3f7a6a9e24f24233cf61616c950606d0e (patch) | |
tree | 357011334df93670306bfd8f82c80b66ab7b5db9 | |
parent | f24003765b325932c9109527a7eb077197f277fc (diff) | |
download | chrome-ec-ba50d8b3f7a6a9e24f24233cf61616c950606d0e.tar.gz |
test: Convert AES test to C++
Convert the AES test file from C to C++ to be able to use the benchmark
library later on.
BUG=b:235476822
TEST=test/run_device_tests.py -b bloonchipper -t aes
TEST=make run-aes
BRANCH=none
Signed-off-by: Andrea Grandi <agrandi@google.com>
Change-Id: I5f0dd0a5f256e75b8688b28cc37c56b2f98039d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026545
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | test/aes.cc (renamed from test/aes.c) | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/aes.c b/test/aes.cc index 0fc220d997..659f9ec971 100644 --- a/test/aes.c +++ b/test/aes.cc @@ -14,15 +14,18 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "common.h" +#include "test_util.h" + +extern "C" { #include "aes.h" #include "aes-gcm.h" #include "builtin/assert.h" #include "console.h" -#include "common.h" -#include "test_util.h" #include "timer.h" #include "util.h" #include "watchdog.h" +} /* Temporary buffer, to avoid using too much stack space. */ static uint8_t tmp[512]; @@ -127,8 +130,9 @@ static int test_aes_gcm_raw_non_inplace(const uint8_t *key, int key_size, static int test_aes_gcm_raw(const uint8_t *key, int key_size, const uint8_t *plaintext, const uint8_t *ciphertext, - int plaintext_size, const uint8_t *nonce, - int nonce_size, const uint8_t *tag, int tag_size) + std::size_t plaintext_size, const uint8_t *nonce, + std::size_t nonce_size, const uint8_t *tag, + std::size_t tag_size) { TEST_ASSERT(plaintext_size <= sizeof(tmp)); @@ -427,7 +431,7 @@ static void test_aes_gcm_speed(void) }; const int key_size = sizeof(key); static const uint8_t plaintext[512] = { 0 }; - const int plaintext_size = sizeof(plaintext); + const auto plaintext_size = sizeof(plaintext); static const uint8_t nonce[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |