diff options
author | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-08-26 20:58:33 -0500 |
---|---|---|
committer | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-08-26 22:39:35 -0500 |
commit | ba286e5d624978f4f53ed5f9154790ef3595922e (patch) | |
tree | 05a88849f4c9133fc60311ac355a079186073d51 /src/crypto/encoding.h | |
parent | c1554d0a1cd337fb1edf23ab0fa4e0e178ced1fc (diff) | |
download | wg2nd-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/encoding.h')
-rw-r--r-- | src/crypto/encoding.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/crypto/encoding.h b/src/crypto/encoding.h new file mode 100644 index 0000000..bc54049 --- /dev/null +++ b/src/crypto/encoding.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + */ + +#ifndef ENCODING_H +#define ENCODING_H + +#include <stdbool.h> +#include <stdint.h> + +#ifndef WG_KEY_LEN +#define WG_KEY_LEN 32 +#endif + +#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); + +bool key_is_zero(const uint8_t key[static WG_KEY_LEN]); + +#endif |