From d359dd9981f4137e8873a7a571e5c54c5b2449c4 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 2 Feb 2022 08:14:56 +0100 Subject: linux and freebsd compatibility --- ecp/util/util.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ecp/util/util.c') diff --git a/ecp/util/util.c b/ecp/util/util.c index 4f4adc2..7ce8da5 100644 --- a/ecp/util/util.c +++ b/ecp/util/util.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "core.h" #include "cr.h" @@ -9,7 +10,7 @@ int ecp_util_key_save(ECPContext *ctx, ECPDHKey *key, char *filename) { int fd; ssize_t rv; - + if ((fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) return ECP_ERR; rv = write(fd, ecp_cr_dh_pub_get_buf(&key->public), ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { @@ -29,7 +30,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) { int fd; ssize_t rv; unsigned char buf[ECP_ECDH_SIZE_KEY]; - + if ((fd = open(filename, O_RDONLY)) < 0) return ECP_ERR; rv = read(fd, buf, ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { @@ -44,7 +45,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) { close(fd); ecp_cr_dh_pub_from_buf(&key->public, buf); - + key->valid = 1; return ECP_OK; } @@ -52,7 +53,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) { int ecp_util_node_save(ECPContext *ctx, ECPNode *node, char *filename) { int fd; ssize_t rv; - + if ((fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) return ECP_ERR; rv = write(fd, ecp_cr_dh_pub_get_buf(&node->public), ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { @@ -72,7 +73,7 @@ int ecp_util_node_load(ECPContext *ctx, ECPNode *node, char *filename) { int fd; ssize_t rv; unsigned char buf[ECP_ECDH_SIZE_KEY]; - + if ((fd = open(filename, O_RDONLY)) < 0) return ECP_ERR; rv = read(fd, buf, ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { -- cgit v1.2.3