aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/aarch64/test-aes.c
blob: 2cd324f09baec19abfe6143ec8055b6d2801c686 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include "../multiarch/test-aes-main.c.inc"

bool test_SB_SR(uint8_t *o, const uint8_t *i)
{
    /* aese also adds round key, so supply zero. */
    asm("ld1 { v0.16b }, [%1]\n\t"
        "movi v1.16b, #0\n\t"
        "aese v0.16b, v1.16b\n\t"
        "st1 { v0.16b }, [%0]"
        : : "r"(o), "r"(i) : "v0", "v1", "memory");
    return true;
}

bool test_MC(uint8_t *o, const uint8_t *i)
{
    asm("ld1 { v0.16b }, [%1]\n\t"
        "aesmc v0.16b, v0.16b\n\t"
        "st1 { v0.16b }, [%0]"
        : : "r"(o), "r"(i) : "v0", "memory");
    return true;
}

bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k)
{
    return false;
}

bool test_ISB_ISR(uint8_t *o, const uint8_t *i)
{
    /* aesd also adds round key, so supply zero. */
    asm("ld1 { v0.16b }, [%1]\n\t"
        "movi v1.16b, #0\n\t"
        "aesd v0.16b, v1.16b\n\t"
        "st1 { v0.16b }, [%0]"
        : : "r"(o), "r"(i) : "v0", "v1", "memory");
    return true;
}

bool test_IMC(uint8_t *o, const uint8_t *i)
{
    asm("ld1 { v0.16b }, [%1]\n\t"
        "aesimc v0.16b, v0.16b\n\t"
        "st1 { v0.16b }, [%0]"
        : : "r"(o), "r"(i) : "v0", "memory");
    return true;
}

bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k)
{
    return false;
}

bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k)
{
    return false;
}