5
5
6
6
#include < bench/bench.h>
7
7
#include < crypto/chacha20.h>
8
+ #include < crypto/chacha20poly1305.h>
8
9
9
10
/* Number of bytes to process per iteration */
10
11
static const uint64_t BUFFER_SIZE_TINY = 64 ;
@@ -23,6 +24,18 @@ static void CHACHA20(benchmark::Bench& bench, size_t buffersize)
23
24
});
24
25
}
25
26
27
+ static void FSCHACHA20POLY1305 (benchmark::Bench& bench, size_t buffersize)
28
+ {
29
+ std::vector<std::byte> key (32 );
30
+ FSChaCha20Poly1305 ctx (key, 224 );
31
+ std::vector<std::byte> in (buffersize);
32
+ std::vector<std::byte> aad;
33
+ std::vector<std::byte> out (buffersize + FSChaCha20Poly1305::EXPANSION);
34
+ bench.batch (in.size ()).unit (" byte" ).run ([&] {
35
+ ctx.Encrypt (in, aad, out);
36
+ });
37
+ }
38
+
26
39
static void CHACHA20_64BYTES (benchmark::Bench& bench)
27
40
{
28
41
CHACHA20 (bench, BUFFER_SIZE_TINY);
@@ -38,6 +51,24 @@ static void CHACHA20_1MB(benchmark::Bench& bench)
38
51
CHACHA20 (bench, BUFFER_SIZE_LARGE);
39
52
}
40
53
54
+ static void FSCHACHA20POLY1305_64BYTES (benchmark::Bench& bench)
55
+ {
56
+ FSCHACHA20POLY1305 (bench, BUFFER_SIZE_TINY);
57
+ }
58
+
59
+ static void FSCHACHA20POLY1305_256BYTES (benchmark::Bench& bench)
60
+ {
61
+ FSCHACHA20POLY1305 (bench, BUFFER_SIZE_SMALL);
62
+ }
63
+
64
+ static void FSCHACHA20POLY1305_1MB (benchmark::Bench& bench)
65
+ {
66
+ FSCHACHA20POLY1305 (bench, BUFFER_SIZE_LARGE);
67
+ }
68
+
41
69
BENCHMARK (CHACHA20_64BYTES, benchmark::PriorityLevel::HIGH);
42
70
BENCHMARK (CHACHA20_256BYTES, benchmark::PriorityLevel::HIGH);
43
71
BENCHMARK (CHACHA20_1MB, benchmark::PriorityLevel::HIGH);
72
+ BENCHMARK (FSCHACHA20POLY1305_64BYTES, benchmark::PriorityLevel::HIGH);
73
+ BENCHMARK (FSCHACHA20POLY1305_256BYTES, benchmark::PriorityLevel::HIGH);
74
+ BENCHMARK (FSCHACHA20POLY1305_1MB, benchmark::PriorityLevel::HIGH);
0 commit comments