-
Notifications
You must be signed in to change notification settings - Fork 0
/
cwt.h
55 lines (46 loc) · 1.17 KB
/
cwt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Created by Urs Gerber on 08.03.18.
//
#ifndef RS_HTTP_CWT_H
#define RS_HTTP_CWT_H
#include "tinycbor.h"
#include "rs_types.h"
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/ecc.h>
typedef struct rs_key {
char* x;
char* y;
char* d;
ecc_curve_id curve_id;
} rs_key;
typedef struct cose_key {
bytes kid;
uint8_t kty;
uint8_t crv;
bytes x;
bytes y;
} cose_key;
typedef struct rs_cwt {
CborValue h_protected;
CborValue h_unprotected;
CborValue payload;
CborValue signature;
} rs_cwt;
typedef struct rs_payload {
char* iss;
int iat;
int exp;
int cti;
char* scope;
char* aud;
bytes cnf;
} rs_payload;
void cwt_parse(rs_cwt* cwt, uint8_t* encoded, size_t len);
int cwt_verify(rs_cwt* cwt, bytes eaad, rs_key* key);
void cwt_parse_payload(rs_cwt* cwt, rs_payload*);
void cwt_parse_cose_key(bytes* encoded, cose_key* out);
void cwt_encode_cose_key(cose_key* key, uint8_t* buffer, size_t buf_size, size_t* len);
void cwt_encode_ecc_key(ecc_key* key, uint8_t* buffer, size_t buf_size, size_t* len);
void cwt_import_key(ecc_key* key, cose_key* cose);
#endif //RS_HTTP_CWT_H