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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "../multiarch/test-aes-main.c.inc"
#undef BIG_ENDIAN
#define BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
static unsigned char bswap_le[16] __attribute__((aligned(16))) = {
8,9,10,11,12,13,14,15,
0,1,2,3,4,5,6,7
};
bool test_SB_SR(uint8_t *o, const uint8_t *i)
{
/* vcipherlast also adds round key, so supply zero. */
if (BIG_ENDIAN) {
asm("lxvd2x 32,0,%1\n\t"
"vspltisb 1,0\n\t"
"vcipherlast 0,0,1\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i) : "memory", "v0", "v1");
} else {
asm("lxvd2x 32,0,%1\n\t"
"lxvd2x 34,0,%2\n\t"
"vspltisb 1,0\n\t"
"vperm 0,0,0,2\n\t"
"vcipherlast 0,0,1\n\t"
"vperm 0,0,0,2\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2");
}
return true;
}
bool test_MC(uint8_t *o, const uint8_t *i)
{
return false;
}
bool test_SB_SR_MC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k)
{
if (BIG_ENDIAN) {
asm("lxvd2x 32,0,%1\n\t"
"lxvd2x 33,0,%2\n\t"
"vcipher 0,0,1\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1");
} else {
asm("lxvd2x 32,0,%1\n\t"
"lxvd2x 33,0,%2\n\t"
"lxvd2x 34,0,%3\n\t"
"vperm 0,0,0,2\n\t"
"vperm 1,1,1,2\n\t"
"vcipher 0,0,1\n\t"
"vperm 0,0,0,2\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i), "r"(k), "r"(bswap_le)
: "memory", "v0", "v1", "v2");
}
return true;
}
bool test_ISB_ISR(uint8_t *o, const uint8_t *i)
{
/* vcipherlast also adds round key, so supply zero. */
if (BIG_ENDIAN) {
asm("lxvd2x 32,0,%1\n\t"
"vspltisb 1,0\n\t"
"vncipherlast 0,0,1\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i) : "memory", "v0", "v1");
} else {
asm("lxvd2x 32,0,%1\n\t"
"lxvd2x 34,0,%2\n\t"
"vspltisb 1,0\n\t"
"vperm 0,0,0,2\n\t"
"vncipherlast 0,0,1\n\t"
"vperm 0,0,0,2\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i), "r"(bswap_le) : "memory", "v0", "v1", "v2");
}
return true;
}
bool test_IMC(uint8_t *o, const uint8_t *i)
{
return false;
}
bool test_ISB_ISR_AK_IMC(uint8_t *o, const uint8_t *i, const uint8_t *k)
{
if (BIG_ENDIAN) {
asm("lxvd2x 32,0,%1\n\t"
"lxvd2x 33,0,%2\n\t"
"vncipher 0,0,1\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i), "r"(k) : "memory", "v0", "v1");
} else {
asm("lxvd2x 32,0,%1\n\t"
"lxvd2x 33,0,%2\n\t"
"lxvd2x 34,0,%3\n\t"
"vperm 0,0,0,2\n\t"
"vperm 1,1,1,2\n\t"
"vncipher 0,0,1\n\t"
"vperm 0,0,0,2\n\t"
"stxvd2x 32,0,%0"
: : "r"(o), "r"(i), "r"(k), "r"(bswap_le)
: "memory", "v0", "v1", "v2");
}
return true;
}
bool test_ISB_ISR_IMC_AK(uint8_t *o, const uint8_t *i, const uint8_t *k)
{
return false;
}
|