From ba286e5d624978f4f53ed5f9154790ef3595922e Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Sat, 26 Aug 2023 20:58:33 -0500 Subject: Store private key in a file with the public keyname, get rid of argon2 --- src/crypto/pubkey.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/crypto/pubkey.c (limited to 'src/crypto/pubkey.c') diff --git a/src/crypto/pubkey.c b/src/crypto/pubkey.c new file mode 100644 index 0000000..1224b07 --- /dev/null +++ b/src/crypto/pubkey.c @@ -0,0 +1,27 @@ +#include "curve25519.h" +#include "encoding.h" + +int wg_pubkey_base64(char const * privkey, char * base64) { + + uint8_t key[WG_KEY_LEN] __attribute((aligned(sizeof(uintptr_t)))); + + int i; + for(i = 0; privkey[i] && i < WG_KEY_LEN_BASE64 - 1; i++) + base64[i] = privkey[i]; + + base64[WG_KEY_LEN_BASE64 - 1] = '\0'; + + if(i != WG_KEY_LEN_BASE64 - 1 || privkey[i]) { + return 1; + } + + if(!key_from_base64(key, base64)) { + return 1; + } + + curve25519_generate_public(key, key); + + key_to_base64(base64, key); + + return 0; +} -- cgit v1.2.3