-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto.h
45 lines (32 loc) · 1.57 KB
/
crypto.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
#pragma once
#include "proto.h"
#include <stdint.h>
#include <stdbool.h>
struct authkeypair;
struct authpubkey;
struct enckey;
const struct authkeypair *crypto_import_key(const char *hexkey);
const char *crypto_export_key(const struct authkeypair *k);
const struct authpubkey *crypto_import_pk(const char *hexpubkey);
const char *crypto_export_pk(const struct enckey *k);
int pk_cmp(const struct enckey *k, const struct authpubkey *p);
const struct authpubkey *authkeypair_apk(const struct authkeypair *ak);
const struct authpubkey *new_apk(const uint8_t *pk);
const uint8_t *__pk(const struct authpubkey *p);
struct enckey *kx_begin(struct kx_msg_2 *m, const struct authkeypair *a,
const struct authpubkey *remote);
struct enckey *kx_reply(struct kx_msg_2 *m2, struct kx_msg_3 *m3,
const struct authkeypair *a, uint32_t cookie);
int kx_complete(struct enckey *key, const struct authkeypair *a,
struct kx_msg_3 *m);
bool kx_start_reply(struct kx_msg_2 *m2, const struct authkeypair *a);
struct enckey *kx_finish_reply(const struct kx_msg_2 *m2, struct kx_msg_3 *m3,
const struct authkeypair *a, uint32_t cookie);
uint64_t crypto_nonce_seq_tx(const struct enckey *k);
uint64_t crypto_nonce_seq_rx(const struct enckey *k);
void encrypt_one(void *out, const void *in, int len, struct enckey *k);
void encrypt_one_nonce(void *out, const void *in, int len,
struct enckey *k, uint64_t nonce);
int decrypt_one(void *out, const void *in, int declen, struct enckey *k);
int decrypt_one_nonce(void *out, const void *in, int declen,
struct enckey *k, uint64_t nonce);