Botan
3.7.1
Crypto and TLS for C&
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerations
a
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
c
d
f
i
m
n
r
s
t
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
f
h
i
m
n
o
p
r
s
t
u
v
w
Enumerations
b
c
d
e
k
m
n
o
p
s
t
x
Enumerator
_
a
b
c
d
e
f
h
k
l
m
n
p
q
r
s
t
u
w
x
Related Symbols
b
c
d
e
f
k
o
p
s
t
x
Files
File List
File Members
All
_
a
b
c
d
e
f
i
k
m
n
o
p
q
s
t
u
w
x
y
z
Functions
b
c
Variables
Typedefs
b
c
e
p
t
Enumerations
Enumerator
b
c
d
e
k
n
Macros
_
a
b
c
f
m
n
q
s
t
w
src
lib
utils
simd
simd_avx2
simd_avx2_gfni.h
Go to the documentation of this file.
1
/*
2
* (C) 2024 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#ifndef BOTAN_SIMD_AVX2_GFNI_H_
8
#define BOTAN_SIMD_AVX2_GFNI_H_
9
10
#include <botan/internal/simd_avx2.h>
11
#include <stdexcept>
12
#include <string_view>
13
14
namespace
Botan
{
15
16
#define BOTAN_GFNI_ISA "gfni,avx2"
17
18
// Helper for defining GFNI constants
19
consteval
uint64_t
gfni_matrix
(std::string_view s) {
20
uint64_t matrix = 0;
21
size_t
bit_cnt = 0;
22
uint8_t row = 0;
23
24
for
(
char
c : s) {
25
if
(c ==
' '
|| c ==
'\n'
) {
26
continue
;
27
}
28
if
(c !=
'0'
&& c !=
'1'
) {
29
throw
std::runtime_error(
"gfni_matrix: invalid bit value"
);
30
}
31
32
if
(c ==
'1'
) {
33
row |= 0x80 >> (7 - bit_cnt % 8);
34
}
35
bit_cnt++;
36
37
if
(bit_cnt % 8 == 0) {
38
matrix <<= 8;
39
matrix |= row;
40
row = 0;
41
}
42
}
43
44
if
(bit_cnt != 64) {
45
throw
std::runtime_error(
"gfni_matrix: invalid bit count"
);
46
}
47
48
return
matrix;
49
}
19
consteval
uint64_t
gfni_matrix
(std::string_view s) {
…
}
50
51
template
<u
int
64_t A, u
int
8_t B>
52
BOTAN_FUNC_ISA_INLINE
(
BOTAN_GFNI_ISA
)
53
SIMD_8x32
gf2p8affine
(const
SIMD_8x32
& x) {
54
return
SIMD_8x32
(_mm256_gf2p8affine_epi64_epi8(x.raw(), _mm256_set1_epi64x(A), B));
55
}
53
SIMD_8x32
gf2p8affine
(const
SIMD_8x32
& x) {
…
}
56
57
template
<u
int
64_t A, u
int
8_t B>
58
BOTAN_FUNC_ISA_INLINE
(
BOTAN_GFNI_ISA
)
59
SIMD_8x32
gf2p8affineinv
(const
SIMD_8x32
& x) {
60
return
SIMD_8x32
(_mm256_gf2p8affineinv_epi64_epi8(x.raw(), _mm256_set1_epi64x(A), B));
61
}
59
SIMD_8x32
gf2p8affineinv
(const
SIMD_8x32
& x) {
…
}
62
63
BOTAN_FUNC_ISA_INLINE
(
BOTAN_GFNI_ISA
)
SIMD_8x32
gf2p8mul(
const
SIMD_8x32
& a,
const
SIMD_8x32
&
b
) {
64
return
SIMD_8x32
(_mm256_gf2p8mul_epi8(a.raw(),
b
.raw()));
65
}
66
67
}
// namespace Botan
68
69
#endif
Botan::SIMD_8x32
Definition
simd_avx2.h:18
BOTAN_FUNC_ISA_INLINE
#define BOTAN_FUNC_ISA_INLINE(isa)
Definition
compiler.h:48
Botan
Definition
alg_id.cpp:13
Botan::gf2p8affine
SIMD_8x32 gf2p8affine(const SIMD_8x32 &x)
Definition
simd_avx2_gfni.h:53
Botan::gfni_matrix
consteval uint64_t gfni_matrix(std::string_view s)
Definition
simd_avx2_gfni.h:19
Botan::b
const SIMD_8x32 & b
Definition
simd_avx2_gfni.h:63
Botan::gf2p8affineinv
SIMD_8x32 gf2p8affineinv(const SIMD_8x32 &x)
Definition
simd_avx2_gfni.h:59
BOTAN_GFNI_ISA
#define BOTAN_GFNI_ISA
Definition
simd_avx2_gfni.h:16
Generated by
1.12.0