commit 9fcd9f91190ab89a777da608d52215631ba4da91
parent dda406622a65ea3905118661977763385ff03d3b
Author: sin <sin@2f30.org>
Date: Fri, 3 May 2019 12:35:01 +0100
Use xread/xwrite helpers in key.c
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/key.c b/key.c
@@ -5,6 +5,10 @@
#include "config.h"
+/* misc helpers */
+extern ssize_t xread(int, void *, size_t);
+extern ssize_t xwrite(int, void *, size_t);
+
int
keygen(unsigned char *key, size_t n)
{
@@ -23,7 +27,7 @@ savekey(int fd, unsigned char *key, size_t n)
assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES);
if (n != crypto_aead_xchacha20poly1305_ietf_KEYBYTES)
return -1;
- if (write(fd, key, n) != n)
+ if (xwrite(fd, key, n) != n)
return -1;
return 0;
}
@@ -34,7 +38,7 @@ loadkey(int fd, unsigned char *key, size_t n)
assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES);
if (n != crypto_aead_xchacha20poly1305_ietf_KEYBYTES)
return -1;
- if (read(fd, key, n) != n)
+ if (xread(fd, key, n) != n)
return -1;
return 0;
}