-
Notifications
You must be signed in to change notification settings - Fork 0
/
lock_stream.h
65 lines (55 loc) · 1.73 KB
/
lock_stream.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
#ifndef LOCK_STREAM_H
#define LOCK_STREAM_H
#include <stdint.h>
#include <stddef.h>
void ls_increment_nonce(uint8_t buf[24]);
struct ls_pdkf_params {
size_t nb_blocks;
size_t nb_iterations;
size_t salt_size;
};
//
// Encryption
//
// KX Mode
void ls_kx_challenge(uint8_t output[16 + 32],
const uint8_t sk[32],
const uint8_t pk[32],
const uint8_t enc_key[32]);
// PDKF Mode
void ls_pdkf_challenge(uint8_t *out /* 6 + salt_size */,
const struct ls_pdkf_params *params,
const uint8_t *salt);
// Lockstream
void ls_lock(uint8_t *output, // input_size + 34
uint8_t nonce [24],
const uint8_t key [32],
const uint8_t *input, size_t input_size);
//
// PDKF
//
int ls_pdkf_key(uint8_t key[32],
const struct ls_pdkf_params *params,
const uint8_t *salt,
const uint8_t *password, size_t password_size);
//
// Decryption
//
// KX Mode
int ls_kx_unwrap(uint8_t input[16 + 32],
uint8_t enc_key[32],
const uint8_t shared_key[32]);
// PDKF
void ls_pdkf_decode(uint8_t input[6],
struct ls_pdkf_params *params);
int ls_pdkf_verify(const struct ls_pdkf_params *params);
// Lockstream
int ls_unlock_length(size_t *to_read,
uint8_t nonce [24],
const uint8_t key [32],
const uint8_t input [18]);
int ls_unlock_payload(uint8_t *output,
uint8_t nonce [24],
const uint8_t key [32],
const uint8_t *input, size_t input_size);
#endif