unet-cli: strip initial newline in usage message
[project/unetd.git] / auth-data.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2022 Felix Fietkau <nbd@nbd.name>
4 */
5 #ifndef __AUTH_DATA_H
6 #define __AUTH_DATA_H
7
8 #include <stdint.h>
9
10 #include <libubox/utils.h>
11
12 #include "edsign.h"
13 #include "curve25519.h"
14
15 #define UNET_AUTH_MAGIC 0x754e6574
16
17 struct unet_auth_hdr {
18 uint32_t magic;
19
20 uint8_t version;
21 uint8_t _pad[3];
22
23 uint8_t signature[EDSIGN_SIGNATURE_SIZE];
24 } __packed;
25
26 struct unet_auth_data {
27 uint64_t timestamp;
28 uint8_t pubkey[CURVE25519_KEY_SIZE];
29 uint32_t flags;
30 } __packed;
31
32 int unet_auth_data_validate(const uint8_t *key, const void *buf, size_t len,
33 uint64_t *timestamp, const char **json_data);
34
35 static inline const struct unet_auth_data *
36 net_data_auth_data_hdr(const void *net_data)
37 {
38 return net_data + sizeof(struct unet_auth_hdr);
39 }
40
41 #endif