Check crypto_scalarmult() return value

This commit is contained in:
Frank Denis 2015-11-17 01:28:16 +01:00
parent bb747e6e36
commit 91f50be917

8
auth.c
View File

@ -332,7 +332,9 @@ struct vtun_host *auth_server(int fd)
sodium_bin2hex(flhash_hex, sizeof flhash_hex, flhash, sizeof flhash); sodium_bin2hex(flhash_hex, sizeof flhash_hex, flhash, sizeof flhash);
print_p(fd, "FLAGS: %s %s\n", flags, flhash_hex); print_p(fd, "FLAGS: %s %s\n", flags, flhash_hex);
crypto_scalarmult(dhkey, server_sk, client_pk); if (crypto_scalarmult(dhkey, server_sk, client_pk) != 0) {
break;
}
sodium_memzero(server_sk, sizeof server_sk); sodium_memzero(server_sk, sizeof server_sk);
if ((host->key = sodium_malloc(HOST_KEYBYTES)) == NULL) { if ((host->key = sodium_malloc(HOST_KEYBYTES)) == NULL) {
abort(); abort();
@ -457,7 +459,9 @@ int auth_client(int fd, struct vtun_host *host)
if (sodium_memcmp(hash, flhash, sizeof hash) != 0) { if (sodium_memcmp(hash, flhash, sizeof hash) != 0) {
break; break;
} }
crypto_scalarmult(dhkey, client_sk, server_pk); if (crypto_scalarmult(dhkey, client_sk, server_pk) != 0) {
break;
}
sodium_memzero(client_sk, sizeof client_sk); sodium_memzero(client_sk, sizeof client_sk);
if ((host->key = sodium_malloc(HOST_KEYBYTES)) == NULL) { if ((host->key = sodium_malloc(HOST_KEYBYTES)) == NULL) {
abort(); abort();