l8w8jwt
Loading...
Searching...
No Matches
decode.h
Go to the documentation of this file.
1/*
2 Copyright 2020 Raphael Beck
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
23#ifndef L8W8JWT_DECODE_H
24#define L8W8JWT_DECODE_H
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include "algs.h"
31#include "claim.h"
32#include "version.h"
33#include "retcodes.h"
34#include "timehelper.h"
35#include <stddef.h>
36#include <stdint.h>
37
38#ifndef L8W8JWT_MAX_KEY_SIZE
39#define L8W8JWT_MAX_KEY_SIZE 8192
40#endif
41
49 L8W8JWT_VALID = (unsigned)0,
50
54 L8W8JWT_ISS_FAILURE = (unsigned)1 << (unsigned)0,
55
59 L8W8JWT_SUB_FAILURE = (unsigned)1 << (unsigned)1,
60
64 L8W8JWT_AUD_FAILURE = (unsigned)1 << (unsigned)2,
65
69 L8W8JWT_JTI_FAILURE = (unsigned)1 << (unsigned)3,
70
74 L8W8JWT_EXP_FAILURE = (unsigned)1 << (unsigned)4,
75
79 L8W8JWT_NBF_FAILURE = (unsigned)1 << (unsigned)5,
80
84 L8W8JWT_IAT_FAILURE = (unsigned)1 << (unsigned)6,
85
89 L8W8JWT_SIGNATURE_VERIFICATION_FAILURE = (unsigned)1 << (unsigned)7,
90
94 L8W8JWT_TYP_FAILURE = (unsigned)1 << (unsigned)8
95};
96
101{
105 char* jwt;
106
111
117 int alg;
118
126
131
139
144
152
157
165
170
176
182
188
195
201
207
212 unsigned char* verification_key;
213
218
224
229};
230
236
243
271L8W8JWT_API int l8w8jwt_decode(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validation_result* out_validation_result, struct l8w8jwt_claim** out_claims, size_t* out_claims_length);
272
307L8W8JWT_API int l8w8jwt_decode_raw(struct l8w8jwt_decoding_params* params, enum l8w8jwt_validation_result* out_validation_result, char** out_header, size_t* out_header_length, char** out_payload, size_t* out_payload_length, uint8_t** out_signature, size_t* out_signature_length);
308
328L8W8JWT_API int l8w8jwt_decode_raw_no_validation(struct l8w8jwt_decoding_params* params, char** out_header, size_t* out_header_length, char** out_payload, size_t* out_payload_length, uint8_t** out_signature, size_t* out_signature_length);
329
330#ifdef __cplusplus
331} // extern "C"
332#endif
333
334#endif // L8W8JWT_DECODE_H
JWT algorithms as defined in https://tools.ietf.org/html/rfc7518#section-3.1.
JWT claims as described in https://auth0.com/docs/tokens/concepts/jwt-claims.
L8W8JWT_API void l8w8jwt_decoding_params_init(struct l8w8jwt_decoding_params *params)
L8W8JWT_API int l8w8jwt_decode(struct l8w8jwt_decoding_params *params, enum l8w8jwt_validation_result *out_validation_result, struct l8w8jwt_claim **out_claims, size_t *out_claims_length)
L8W8JWT_API int l8w8jwt_decode_raw_no_validation(struct l8w8jwt_decoding_params *params, char **out_header, size_t *out_header_length, char **out_payload, size_t *out_payload_length, uint8_t **out_signature, size_t *out_signature_length)
l8w8jwt_validation_result
Definition decode.h:45
@ L8W8JWT_NBF_FAILURE
Definition decode.h:79
@ L8W8JWT_AUD_FAILURE
Definition decode.h:64
@ L8W8JWT_SIGNATURE_VERIFICATION_FAILURE
Definition decode.h:89
@ L8W8JWT_SUB_FAILURE
Definition decode.h:59
@ L8W8JWT_TYP_FAILURE
Definition decode.h:94
@ L8W8JWT_VALID
Definition decode.h:49
@ L8W8JWT_JTI_FAILURE
Definition decode.h:69
@ L8W8JWT_IAT_FAILURE
Definition decode.h:84
@ L8W8JWT_ISS_FAILURE
Definition decode.h:54
@ L8W8JWT_EXP_FAILURE
Definition decode.h:74
L8W8JWT_API int l8w8jwt_decode_raw(struct l8w8jwt_decoding_params *params, enum l8w8jwt_validation_result *out_validation_result, char **out_header, size_t *out_header_length, char **out_payload, size_t *out_payload_length, uint8_t **out_signature, size_t *out_signature_length)
L8W8JWT_API int l8w8jwt_validate_decoding_params(struct l8w8jwt_decoding_params *params)
Macros for possible integer codes returned by the various l8w8jwt functions.
Definition claim.h:83
Definition decode.h:101
size_t validate_sub_length
Definition decode.h:143
int validate_nbf
Definition decode.h:181
size_t validate_typ_length
Definition decode.h:228
char * validate_jti
Definition decode.h:164
char * jwt
Definition decode.h:105
size_t validate_iss_length
Definition decode.h:130
size_t jwt_length
Definition decode.h:110
int validate_exp
Definition decode.h:175
int alg
Definition decode.h:117
uint8_t nbf_tolerance_seconds
Definition decode.h:200
uint8_t exp_tolerance_seconds
Definition decode.h:194
size_t validate_jti_length
Definition decode.h:169
int validate_iat
Definition decode.h:187
size_t validate_aud_length
Definition decode.h:156
uint8_t iat_tolerance_seconds
Definition decode.h:206
char * validate_iss
Definition decode.h:125
size_t verification_key_length
Definition decode.h:217
unsigned char * verification_key
Definition decode.h:212
char * validate_aud
Definition decode.h:151
char * validate_sub
Definition decode.h:138
char * validate_typ
Definition decode.h:223
l8w8jwt version checking.