Zephyr API 3.6.99
Loading...
Searching...
No Matches
jwt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Linaro Ltd
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DATA_JWT_H_
8#define ZEPHYR_INCLUDE_DATA_JWT_H_
9
10#include <zephyr/types.h>
11#include <stdbool.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
34 char *base;
35
38 char *buf;
39
41 size_t len;
42
48
49 /* Pending bytes yet to be converted to base64. */
50 unsigned char wip[3];
51
52 /* Number of pending bytes. */
54};
55
70int jwt_init_builder(struct jwt_builder *builder,
71 char *buffer,
72 size_t buffer_size);
73
92int jwt_add_payload(struct jwt_builder *builder,
93 int32_t exp,
94 int32_t iat,
95 const char *aud);
96
109int jwt_sign(struct jwt_builder *builder,
110 const char *der_key,
111 size_t der_key_len);
112
113
114static inline size_t jwt_payload_len(struct jwt_builder *builder)
115{
116 return (builder->buf - builder->base);
117}
118
119#ifdef __cplusplus
120}
121#endif
122
127#endif /* ZEPHYR_INCLUDE_DATA_JWT_H_ */
int jwt_add_payload(struct jwt_builder *builder, int32_t exp, int32_t iat, const char *aud)
Add JWT payload.
int jwt_sign(struct jwt_builder *builder, const char *der_key, size_t der_key_len)
Sign the JWT.
static size_t jwt_payload_len(struct jwt_builder *builder)
Definition jwt.h:114
int jwt_init_builder(struct jwt_builder *builder, char *buffer, size_t buffer_size)
Initialize the JWT builder.
__INT32_TYPE__ int32_t
Definition stdint.h:74
JWT data tracking.
Definition jwt.h:32
char * base
The base of the buffer we are writing to.
Definition jwt.h:34
unsigned char wip[3]
Definition jwt.h:50
char * buf
The place in this buffer where we are currently writing.
Definition jwt.h:38
int pending
Definition jwt.h:53
size_t len
The remaining free space in buf.
Definition jwt.h:41
bool overflowed
Flag that is set if we try to write past the end of the buffer.
Definition jwt.h:47