switch to libsodium implementation of aegis256

This commit is contained in:
2020-06-09 20:59:55 +02:00
parent 0183b35acf
commit e4988b9e9c
2 changed files with 7 additions and 7 deletions

13
mud.c
View File

@@ -22,7 +22,6 @@
#include <netinet/in.h>
#include <sodium.h>
#include "aegis256/aegis256.h"
#if !defined MSG_CONFIRM
#define MSG_CONFIRM 0
@@ -168,18 +167,19 @@ mud_encrypt_opt(const struct mud_crypto_key *k,
const struct mud_crypto_opt *c)
{
if (k->aes) {
unsigned char npub[AEGIS256_NPUBBYTES];
unsigned char npub[crypto_aead_aegis256_NPUBBYTES];
memcpy(npub, c->dst, MUD_TIME_SIZE);
memset(npub + MUD_TIME_SIZE, 0, sizeof(npub) - MUD_TIME_SIZE);
return aegis256_encrypt(
return crypto_aead_aegis256_encrypt(
c->dst + MUD_TIME_SIZE,
NULL,
c->src,
c->size,
c->dst,
MUD_TIME_SIZE,
NULL, // nsec
npub,
k->encrypt.key
);
@@ -208,14 +208,15 @@ mud_decrypt_opt(const struct mud_crypto_key *k,
const struct mud_crypto_opt *c)
{
if (k->aes) {
unsigned char npub[AEGIS256_NPUBBYTES];
unsigned char npub[crypto_aead_aegis256_NPUBBYTES];
memcpy(npub, c->src, MUD_TIME_SIZE);
memset(npub + MUD_TIME_SIZE, 0, sizeof(npub) - MUD_TIME_SIZE);
return aegis256_decrypt(
return crypto_aead_aegis256_decrypt(
c->dst,
NULL,
NULL, // nsec
c->src + MUD_TIME_SIZE,
c->size - MUD_TIME_SIZE,
c->src, MUD_TIME_SIZE,
@@ -832,7 +833,7 @@ mud_keyx_init(struct mud *mud, uint64_t now)
int
mud_set_aes(struct mud *mud)
{
if (!aegis256_is_available()) {
if (!crypto_aead_aegis256_is_available()) {
errno = ENOTSUP;
return -1;
}

1
test.c
View File

@@ -1,5 +1,4 @@
#include "mud.c"
#include "aegis256/aegis256.c"
#include <stdio.h>
#include <poll.h>