2017-11-30 10:23:50 -05:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
2018-01-03 15:58:00 -05:00
|
|
|
* Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
2017-11-30 10:23:50 -05:00
|
|
|
*/
|
2015-06-05 09:58:00 -04:00
|
|
|
|
2017-05-15 17:24:48 -04:00
|
|
|
#ifndef ENCODING_H
|
|
|
|
#define ENCODING_H
|
2015-06-05 09:58:00 -04:00
|
|
|
|
2017-04-15 19:20:43 -04:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2017-09-24 22:22:09 -04:00
|
|
|
#include "containers.h"
|
2015-06-05 09:58:00 -04:00
|
|
|
|
2017-04-15 19:20:43 -04:00
|
|
|
#define WG_KEY_LEN_BASE64 ((((WG_KEY_LEN) + 2) / 3) * 4 + 1)
|
2017-05-15 17:24:48 -04:00
|
|
|
#define WG_KEY_LEN_HEX (WG_KEY_LEN * 2 + 1)
|
2015-06-05 09:58:00 -04:00
|
|
|
|
2017-04-15 19:20:43 -04:00
|
|
|
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);
|
2015-06-05 09:58:00 -04:00
|
|
|
|
2017-05-15 17:24:48 -04:00
|
|
|
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);
|
|
|
|
|
2017-09-21 22:04:00 -04:00
|
|
|
bool key_is_zero(const uint8_t key[static WG_KEY_LEN]);
|
|
|
|
|
2015-06-05 09:58:00 -04:00
|
|
|
#endif
|