aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/pubkey.hpp
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-26 20:58:33 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2023-08-26 22:39:35 -0500
commitba286e5d624978f4f53ed5f9154790ef3595922e (patch)
tree05a88849f4c9133fc60311ac355a079186073d51 /src/crypto/pubkey.hpp
parentc1554d0a1cd337fb1edf23ab0fa4e0e178ced1fc (diff)
downloadwg2nd-ba286e5d624978f4f53ed5f9154790ef3595922e.tar.xz
wg2nd-ba286e5d624978f4f53ed5f9154790ef3595922e.zip
Store private key in a file with the public keyname, get rid of argon2
Diffstat (limited to 'src/crypto/pubkey.hpp')
-rw-r--r--src/crypto/pubkey.hpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/crypto/pubkey.hpp b/src/crypto/pubkey.hpp
new file mode 100644
index 0000000..8596431
--- /dev/null
+++ b/src/crypto/pubkey.hpp
@@ -0,0 +1,22 @@
+extern "C" {
+
+#ifndef WG_KEY_LEN
+#define WG_KEY_LEN 32
+#endif
+
+#define WG_KEY_LEN_BASE64 ((((WG_KEY_LEN) + 2) / 3) * 4 + 1)
+
+/*
+ * wg_pubkey_base64 is a C++-compatible wrapper for the curve25519 public-key
+ * derivation routines used natively in `wg(8)`
+ *
+ * PRIVKEY: a c-style string containing the base64-encoded private key
+ * BASE64: a c-style string of capacity WG_KEY_LEN_BASE64 containing the
+ * encoded public key
+ *
+ * returns: 0 on success
+ * > 0 when an error occurs (due to improper key formatting)
+ */
+int wg_pubkey_base64(char const * privkey, char * base64);
+
+}