diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-08 03:21:52 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-08 03:23:15 +0100 |
commit | 0539929d0ca56466e8b63e54b86dd2c754ddee81 (patch) | |
tree | ae5020a0b6870109cb03ea03a60b2254bf82e664 /WireGuard/Shared/Model/key.h | |
parent | Key: Constant time encoding (diff) | |
download | wireguard-apple-0539929d0ca56466e8b63e54b86dd2c754ddee81.tar.xz wireguard-apple-0539929d0ca56466e8b63e54b86dd2c754ddee81.zip |
Key: Use C implementation instead
Swift compiles so slowly and it's unclear all of the insane type punning
was even correct.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/Shared/Model/key.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/WireGuard/Shared/Model/key.h b/WireGuard/Shared/Model/key.h new file mode 100644 index 0000000..bd22a94 --- /dev/null +++ b/WireGuard/Shared/Model/key.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + */ + +#ifndef KEY_H +#define KEY_H + +#include <stdbool.h> +#include <stdint.h> + +#define WG_KEY_LEN (32) +#define WG_KEY_LEN_BASE64 (45) +#define WG_KEY_LEN_HEX (65) + +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); + +#endif |