summaryrefslogtreecommitdiffstats
path: root/test/aes-detect_guest.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-01-10 01:37:23 +0100
committerLouis Burda <quent.burda@gmail.com>2023-01-10 01:38:43 +0100
commit252b11a01e061fd17821e53a41c8451a1d2c27bd (patch)
treee887ead2faddc8691fc13da426655a0062351cdc /test/aes-detect_guest.c
parent864f5fa9d539734d823b3d0613dbf1a43beec334 (diff)
downloadcachepc-252b11a01e061fd17821e53a41c8451a1d2c27bd.tar.gz
cachepc-252b11a01e061fd17821e53a41c8451a1d2c27bd.zip
Begin ioctl and test-case overhaul
Diffstat (limited to 'test/aes-detect_guest.c')
-rw-r--r--test/aes-detect_guest.c78
1 files changed, 0 insertions, 78 deletions
diff --git a/test/aes-detect_guest.c b/test/aes-detect_guest.c
deleted file mode 100644
index 2b0f2ad..0000000
--- a/test/aes-detect_guest.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "cachepc/uapi.h"
-#include "kcapi.h"
-
-#include <sys/random.h>
-#include <err.h>
-#include <time.h>
-#include <assert.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-// #include "aes-detect.c"
-
-static uint8_t key[16];
-
-void
-printhex(uint8_t *buf, size_t size)
-{
- size_t i;
-
- for (i = 0; i < size; i++)
- printf("%02X", buf[i]);
- printf("\n");
-}
-
-int
-main(int argc, const char **argv)
-{
- struct kcapi_handle *kcapi;
- uint8_t block[128];
- uint8_t *buf;
- size_t n;
-
- buf = NULL;
- if (posix_memalign((void *)&buf, L1_LINESIZE * L1_SETS, L1_LINESIZE * L1_SETS))
- err(1, "memalign");
- memset(buf, 0, L1_LINESIZE * L1_SETS);
-
- while (1) {
- CPC_DO_VMMCALL(CPC_GUEST_START_TRACK, 0);
- buf[L1_LINESIZE * 5] += 1;
- CPC_DO_VMMCALL(CPC_GUEST_STOP_TRACK, 0);
- }
-
- return 0;
-
- kcapi = NULL;
- if (kcapi_cipher_init(&kcapi, "ecb(aes)", 0))
- err(1, "kcapi init");
-
- for (n = 0; n < 16; n++)
- key[n] = (uint8_t) n;
-
- if (kcapi_cipher_setkey(kcapi, key, sizeof(key)))
- err(1, "kcapi setkey");
-
- while (1) {
- printf("RUN %li\n", time(NULL));
-
- memset(block, 0, sizeof(block));
- strncpy((char *) block, "Hello world", sizeof(block));
-
- // DO_ACCESS_PATTERN();
-
- printhex(block, sizeof(block));
- n = kcapi_cipher_encrypt(kcapi, block, sizeof(block), NULL,
- block, sizeof(block), KCAPI_ACCESS_HEURISTIC);
- if (n != sizeof(block))
- err(1, "encrypt");
- printhex(block, sizeof(block));
-
- sleep(1);
- }
-
- kcapi_cipher_destroy(kcapi);
-}