aboutsummaryrefslogtreecommitdiff
path: root/include/axolotl/axolotl.hh
blob: e333dbc27523671e342d73e559cbb68a8bf09e26 (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef AXOLOTL_HH_
#define AXOLOTL_HH_

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

static const size_t AXOLOTL_MESSAGE_TYPE_PRE_KEY = 0;
static const size_t AXOLOTL_MESSAGE_TYPE_MESSAGE = 1;

struct AxolotlAccount;
struct AxolotlSession;

size_t axolotl_account_size();

size_t axolotl_session_size();

AxolotlAccount * axolotl_account(
    void * memory
);

AxolotlSession * axolotl_session(
    void * memory
);

size_t axolotl_error();

const char * axolotl_account_last_error(
    AxolotlSession * account
);

const char * axolotl_session_last_error(
    AxolotlSession * session
);

size_t axolotl_pickle_account_length(
    AxolotlAccount * account
);

size_t axolotl_pickle_session_length(
    AxolotlSession * session
);

size_t axolotl_pickle_account(
    AxolotlAccount * account,
    void const * key, size_t key_length,
    void * pickled, size_t pickled_length
);

size_t axolotl_pickle_session(
    AxolotlSession * session,
    void const * key, size_t key_length,
    void * pickled, size_t pickled_length
);

size_t axolotl_unpickle_account(
    AxolotlAccount * account,
    void const * key, size_t key_length,
    void * pickled, size_t pickled_length
);

size_t axolotl_unpickle_session(
    AxolotlSession * session,
    void const * key, size_t key_length,
    void * pickled, size_t pickled_length
);

size_t axolotl_create_account_random_length(
    AxolotlAccount * account
);

size_t axolotl_create_account(
    AxolotlAccount * account,
    void const * random, size_t random_length
);

size_t axolotl_account_identity_keys_length(
    AxolotlAccount * account
);

size_t axolotl_account_identity_keys(
    AxolotlAccount * account,
    void * identity_keys, size_t identity_key_length
);

size_t axolotl_account_one_time_keys_length(
    AxolotlAccount * account
);

size_t axolotl_account_one_time_keys(
    AxolotlAccount * account,
    void * identity_keys, size_t identity_key_length
);

/* TODO: Add methods for marking keys as used, generating new keys, and
 * tracking which keys have been uploaded to the central servers */

size_t axolotl_create_outbound_session_random_length(
    AxolotlSession * session
);

size_t axolotl_create_outbound_session(
    AxolotlSession * session,
    AxolotlAccount * account,
    void const * their_identity_key, size_t their_identity_key_length,
    unsigned their_one_time_key_id,
    void const * their_one_time_key, size_t their_one_time_key_length,
    void const * random, size_t random_length
);

size_t axolotl_create_inbound_session(
    AxolotlSession * session,
    AxolotlAccount * account,
    void * one_time_key_message, size_t message_length
);

size_t axolotl_matches_inbound_session(
    AxolotlSession * session,
    void * one_time_key_message, size_t message_length
);

size_t axolotl_remove_one_time_keys(
    AxolotlAccount * account,
    AxolotlSession * session
);

size_t axolotl_encrypt_message_type(
    AxolotlSession * session
);

size_t axolotl_encrypt_random_length(
    AxolotlSession * session
);

size_t axolotl_encrypt_message_length(
    AxolotlSession * session,
    size_t plaintext_length
);

size_t axolotl_encrypt(
    AxolotlSession * session,
    void const * plaintext, size_t plaintext_length,
    void const * random, size_t random_length,
    void * message, size_t message_length
);

size_t axolotl_decrypt_max_plaintext_length(
    AxolotlSession * session,
    size_t message_type,
    void * message, size_t message_length
);

size_t axolotl_decrypt(
    AxolotlSession * session,
    size_t message_type,
    void * message, size_t message_length,
    void * plaintext, size_t max_plaintext_length
);



#ifdef __cplusplus
}
#endif

#endif /* AXOLOTL_HH_ */