aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/encoding.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-05-15 23:24:48 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-05-17 18:13:14 +0200
commit2823e0192e9465f0260d5b43915fb925c5e6bdc8 (patch)
tree3b34341206c3027274b11f55a78bcfd46c5c0b60 /src/tools/encoding.h
parenttools: check for proto error on set too (diff)
downloadwireguard-monolithic-historical-2823e0192e9465f0260d5b43915fb925c5e6bdc8.tar.xz
wireguard-monolithic-historical-2823e0192e9465f0260d5b43915fb925c5e6bdc8.zip
tools: support text-based ipc
Diffstat (limited to 'src/tools/encoding.h')
-rw-r--r--src/tools/encoding.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/encoding.h b/src/tools/encoding.h
new file mode 100644
index 0000000..f4fe51e
--- /dev/null
+++ b/src/tools/encoding.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */
+
+#ifndef ENCODING_H
+#define ENCODING_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "../uapi.h"
+
+#define WG_KEY_LEN_BASE64 ((((WG_KEY_LEN) + 2) / 3) * 4 + 1)
+#define WG_KEY_LEN_HEX (WG_KEY_LEN * 2 + 1)
+
+void key_to_base64(char base64[static WG_KEY_LEN_BASE64], const uint8_t key[static WG_KEY_LEN]);
+bool key_from_base64(uint8_t key[static WG_KEY_LEN], const char *base64);
+
+void key_to_hex(char hex[static WG_KEY_LEN_HEX], const uint8_t key[static WG_KEY_LEN]);
+bool key_from_hex(uint8_t key[static WG_KEY_LEN], const char *hex);
+
+#endif