Use aegis256

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2019-09-17 16:48:42 +00:00
parent 43e1dfe86f
commit 4b4c080cc4
6 changed files with 19 additions and 17 deletions

View File

@@ -14,7 +14,7 @@ FLAGS += -DPACKAGE_NAME=\"$(NAME)\" -DPACKAGE_VERSION=\"$(VERSION)\"
FLAGS += -I.static/$(CROSS)/libsodium-stable/src/libsodium/include FLAGS += -I.static/$(CROSS)/libsodium-stable/src/libsodium/include
FLAGS += -L.static/$(CROSS)/libsodium-stable/src/libsodium/.libs FLAGS += -L.static/$(CROSS)/libsodium-stable/src/libsodium/.libs
SRC := argz/argz.c mud/mud.c $(wildcard src/*.c) SRC := argz/argz.c mud/mud.c mud/aegis256/aegis256.c $(wildcard src/*.c)
.PHONY: $(NAME) .PHONY: $(NAME)
$(NAME): $(NAME):

View File

@@ -9,6 +9,8 @@ glorytun_SOURCES = \
argz/argz.h \ argz/argz.h \
mud/mud.c \ mud/mud.c \
mud/mud.h \ mud/mud.h \
mud/aegis256/aegis256.c \
mud/aegis256/aegis256.h \
src/bench.c \ src/bench.c \
src/bind.c \ src/bind.c \
src/common.c \ src/common.c \

View File

@@ -20,8 +20,8 @@ The key features of Glorytun come directly from mud:
The use of UDP and [libsodium](https://github.com/jedisct1/libsodium) allows you to secure The use of UDP and [libsodium](https://github.com/jedisct1/libsodium) allows you to secure
your communications without impacting performance. your communications without impacting performance.
Glorytun uses AES only if AES-NI is available otherwise ChaCha20 is used. Glorytun uses AEGIS-256 only if AES-NI is available otherwise ChaCha20Poly1305 is used.
If you are not cpu bounded, you can force the use of ChaCha20 for higher security. If you are not cpu bounded, you can force the use of ChaCha20Poly1305 for higher security.
All messages are encrypted, authenticated and marked with a timestamp. All messages are encrypted, authenticated and marked with a timestamp.
Perfect forward secrecy is also implemented with ECDH over Curve25519. Perfect forward secrecy is also implemented with ECDH over Curve25519.

View File

@@ -23,6 +23,7 @@ executable('glorytun', install: true,
sources: [ sources: [
'argz/argz.c', 'argz/argz.c',
'mud/mud.c', 'mud/mud.c',
'mud/aegis256/aegis256.c',
'src/bench.c', 'src/bench.c',
'src/bind.c', 'src/bind.c',
'src/common.c', 'src/common.c',

2
mud

Submodule mud updated: 2c9d971437...181e22011d

View File

@@ -13,9 +13,14 @@
#endif #endif
#include "../argz/argz.h" #include "../argz/argz.h"
#include "../mud/aegis256/aegis256.h"
#define STR_S(X) (((X) > 1) ? "s" : "") #define STR_S(X) (((X) > 1) ? "s" : "")
#define NPUBBYTES 32
#define KEYBYTES 32
#define ABYTES 16
static unsigned long long static unsigned long long
gt_now(void) gt_now(void)
{ {
@@ -68,7 +73,7 @@ gt_bench(int argc, char **argv)
int aes = argz_is_set(bench_argz, "aes"); int aes = argz_is_set(bench_argz, "aes");
int chacha = argz_is_set(bench_argz, "chacha"); int chacha = argz_is_set(bench_argz, "chacha");
if (!crypto_aead_aes256gcm_is_available()) { if (!aegis256_is_available()) {
if (aes) { if (aes) {
gt_log("aes is not available on your platform\n"); gt_log("aes is not available on your platform\n");
return 1; return 1;
@@ -76,22 +81,22 @@ gt_bench(int argc, char **argv)
chacha = 1; chacha = 1;
} }
unsigned char *buf = calloc(1, bufsize + crypto_aead_aes256gcm_ABYTES); unsigned char *buf = calloc(1, bufsize + ABYTES);
if (!buf) { if (!buf) {
perror("calloc"); perror("calloc");
return 1; return 1;
} }
unsigned char npub[crypto_aead_aes256gcm_NPUBBYTES]; unsigned char npub[NPUBBYTES];
unsigned char key[crypto_aead_aes256gcm_KEYBYTES]; unsigned char key[KEYBYTES];
randombytes_buf(npub, sizeof(npub)); randombytes_buf(npub, sizeof(npub));
randombytes_buf(key, sizeof(key)); randombytes_buf(key, sizeof(key));
if (term) { if (term) {
printf("\n"); printf("\n");
printf(" %-10s %s\n", "bench", chacha ? "chacha20poly1305" : "aes256gcm"); printf(" %-10s %s\n", "bench", chacha ? "chacha20poly1305" : "aegis256");
printf(" %-10s %s\n", "libsodium", sodium_version_string()); printf(" %-10s %s\n", "libsodium", sodium_version_string());
printf("\n"); printf("\n");
printf(" %-10s 2^(-%lu)\n", "precision", precision); printf(" %-10s 2^(-%lu)\n", "precision", precision);
@@ -112,11 +117,6 @@ gt_bench(int argc, char **argv)
double mbps_dlt = INFINITY; double mbps_dlt = INFINITY;
while (!gt_quit && mbps_dlt > ldexp(mbps, -(int)precision)) { while (!gt_quit && mbps_dlt > ldexp(mbps, -(int)precision)) {
crypto_aead_aes256gcm_state ctx;
if (!chacha)
crypto_aead_aes256gcm_beforenm(&ctx, key);
unsigned long long now = gt_now(); unsigned long long now = gt_now();
double mbps_old = mbps; double mbps_old = mbps;
size_t bytes = 0; size_t bytes = 0;
@@ -129,9 +129,8 @@ gt_bench(int argc, char **argv)
crypto_aead_chacha20poly1305_encrypt( crypto_aead_chacha20poly1305_encrypt(
buf, NULL, buf, 1ULL << i, NULL, 0, NULL, npub, key); buf, NULL, buf, 1ULL << i, NULL, 0, NULL, npub, key);
} else { } else {
crypto_aead_aes256gcm_encrypt_afternm( aegis256_encrypt(
buf, NULL, buf, 1ULL << i, NULL, 0, NULL, npub, buf, NULL, buf, 1ULL << i, NULL, 0, npub, key);
(const crypto_aead_aes256gcm_state *)&ctx);
} }
bytes += 1ULL << i; bytes += 1ULL << i;
} }