libkcapi/libkcapi-1.1.1-test_Fix_AEAD_fuzz_test_for_big-endian_archs.patch
2018-07-27 11:53:06 +02:00

43 lines
1.6 KiB
Diff

From def2282fd28390f4a8afd0f43be6c3b3b1586f41 Mon Sep 17 00:00:00 2001
From: Ondrej Mosnacek <omosnace@redhat.com>
Date: Fri, 27 Jul 2018 10:53:00 +0200
Subject: [PATCH] test: Fix AEAD fuzz test for big-endian archs
The stupid authenc() key format contains fields that need to be in the
machine's endianity. Right now, they are hard-coded in the LE format.
This patch makes them always be in the right format.
---
test/kcapi-main.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/test/kcapi-main.c b/test/kcapi-main.c
index e24956c..d62c91a 100644
--- a/test/kcapi-main.c
+++ b/test/kcapi-main.c
@@ -451,14 +451,17 @@ static int fuzz_aead(struct kcapi_cavs *cavs_test, unsigned long flags,
if (kcapi_aead_setkey(handle, key, 16)) {
if (!strncmp(cavs_test->cipher, "authenc", 7)) {
- uint8_t *k = (uint8_t *)
- "\x08\x00\x01\x00\x00\x00\x00\x10"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x06\xa9\x21\x40"
- "\x36\xb8\xa1\x5b\x51\x2e\x03\xd5"
- "\x34\x12\x00\x06";
- if (kcapi_aead_setkey(handle, k, 44)) {
+ uint8_t k[44];
+ memcpy(k, "\x00\x00\x00\x00\x00\x00\x00\x10"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x06\xa9\x21\x40"
+ "\x36\xb8\xa1\x5b\x51\x2e\x03\xd5"
+ "\x34\x12\x00\x06", sizeof(k));
+ /* These need to be in machine's endianity: */
+ *(uint16_t *)(k + 0) = 8;
+ *(uint16_t *)(k + 2) = 1;
+ if (kcapi_aead_setkey(handle, k, sizeof(k))) {
printf("AEAD setkey failed\n");
goto out;
}