From ca592cb6e6a9aeee619d3fd7311030ab34844c2f Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Sun, 27 Aug 2023 20:11:39 -0500 Subject: Add wg2nd-web source --- src/models/crypto/encoding.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/models/crypto/encoding.h (limited to 'src/models/crypto/encoding.h') diff --git a/src/models/crypto/encoding.h b/src/models/crypto/encoding.h new file mode 100644 index 0000000..bc54049 --- /dev/null +++ b/src/models/crypto/encoding.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * Copyright (C) 2015-2020 Jason A. Donenfeld . All Rights Reserved. + */ + +#ifndef ENCODING_H +#define ENCODING_H + +#include +#include + +#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 -- cgit v1.2.3