-
Notifications
You must be signed in to change notification settings - Fork 0
/
cose.h
50 lines (39 loc) · 1.62 KB
/
cose.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
//
// Created by Urs Gerber on 16.03.18.
//
#ifndef RS_HTTP_COSE_H
#define RS_HTTP_COSE_H
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include "rs_types.h"
typedef struct cose_sign1 {
bytes payload;
bytes external_aad;
bytes protected_header;
bytes unprotected_header;
} cose_sign1;
typedef struct cose_encrypt0 {
bytes plaintext;
bytes external_aad;
} cose_encrypt0;
void cose_encode_signed(cose_sign1* sign1,
ecc_key* signing_key,
uint8_t* out,
size_t out_size,
size_t* out_len);
void cose_sign1_structure(const char* context,
bytes* body_protected,
bytes* external_aad,
bytes* payload,
uint8_t* out,
size_t out_size,
size_t* out_len);
void cose_encode_encrypted(cose_encrypt0 *enc0, byte *key, byte *iv, uint8_t *out, size_t out_size, size_t *out_len);
void cose_enc0_structure(bytes* body_protected, bytes* external_aad,
uint8_t* out, size_t out_size, size_t* out_len);
void cose_kdf_context(const char* algorithm_id, int key_length, bytes other, uint8_t* out, size_t out_size, size_t *out_len);
void derive_key(bytes input_key, bytes info, uint8_t* out, size_t out_size);
void cose_decrypt_enc0(bytes* enc0, uint8_t *key, uint8_t *iv, bytes* external_aad,
uint8_t* out, size_t out_size, size_t *out_len);
int cose_verify_sign1(bytes* sign1, ecc_key* key, bytes* external_aad);
#endif //RS_HTTP_COSE_H