-
Notifications
You must be signed in to change notification settings - Fork 6
/
dsi.h
104 lines (78 loc) · 2.28 KB
/
dsi.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef _DSI_H_
#define _DSI_H_
#include "polarssl/aes.h"
typedef struct
{
unsigned char ctr[16];
unsigned char mac[16];
unsigned char S0[16];
unsigned int maclen;
aes_context aes;
}
dsi_context;
typedef struct
{
unsigned char key[16];
unsigned char nonce[12];
int randomnonce;
} dsi_es_context;
#ifdef __cplusplus
extern "C" {
#endif
void dsi_set_key( dsi_context* ctx,
unsigned char key[16] );
void dsi_add_ctr( dsi_context* ctx,
unsigned int carry );
void dsi_set_ctr( dsi_context* ctx,
unsigned char ctr[16] );
void dsi_init_ctr( dsi_context* ctx,
unsigned char key[16],
unsigned char ctr[12] );
void dsi_crypt_ctr( dsi_context* ctx,
void* in,
void* out,
unsigned int len);
void dsi_crypt_ctr_block( dsi_context* ctx,
unsigned char input[16],
unsigned char output[16] );
void dsi_init_ccm( dsi_context* ctx,
unsigned char key[16],
unsigned int maclength,
unsigned int payloadlength,
unsigned int assoclength,
unsigned char nonce[12] );
void dsi_encrypt_ccm_block( dsi_context* ctx,
unsigned char input[16],
unsigned char output[16],
unsigned char* mac );
void dsi_decrypt_ccm_block( dsi_context* ctx,
unsigned char input[16],
unsigned char output[16],
unsigned char* mac );
void dsi_decrypt_ccm( dsi_context* ctx,
unsigned char* input,
unsigned char* output,
unsigned int size,
unsigned char* mac );
void dsi_encrypt_ccm( dsi_context* ctx,
unsigned char* input,
unsigned char* output,
unsigned int size,
unsigned char* mac );
void dsi_es_init( dsi_es_context* ctx,
unsigned char key[16] );
void dsi_es_set_nonce( dsi_es_context* ctx,
unsigned char nonce[12] );
void dsi_es_set_random_nonce( dsi_es_context* ctx );
int dsi_es_decrypt( dsi_es_context* ctx,
unsigned char* buffer,
unsigned char metablock[32],
unsigned int size );
void dsi_es_encrypt( dsi_es_context* ctx,
unsigned char* buffer,
unsigned char metablock[32],
unsigned int size );
#ifdef __cplusplus
}
#endif
#endif // _DSI_H_