switch to libsodium implementation of aegis256
This commit is contained in:
13
mud.c
13
mud.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user