-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcrypto.h
More file actions
55 lines (48 loc) · 1.45 KB
/
Copy pathcrypto.h
File metadata and controls
55 lines (48 loc) · 1.45 KB
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
#ifndef CRYPTO_H
#define CRYPTO_H
#ifdef __cplusplus
extern "C" {
#endif
#include <mbedtls/ssl.h>
#include <mbedtls/error.h>
#include <mbedtls/certs.h>
#include <mbedtls/x509.h>
#include <mbedtls/timing.h>
#include <mbedtls/ecp.h>
#include <mbedtls/ecdh.h>
#include "inttypes.h"
#include "ecchat.h"
#include "identity.h"
struct tls_ctx {
mbedtls_ssl_context ssl;
mbedtls_ssl_config conf;
};
void crypto_init();
void crypto_deinit();
int crypto_tls_ctx_new(struct tls_ctx *c, struct identity *id);
void crypto_tls_ctx_free(struct tls_ctx *c);
void crypto_perror(const char *msg, int err);
const char * crypto_strerror(int err);
void crypto_key_regenerate(mbedtls_ecp_keypair *key);
int crypto_generate_session_key(mbedtls_ecp_keypair *key,
unsigned char *session_key,
unsigned char *ecp_x,
unsigned char *ecp_y);
void crypto_enc(char *out, const char *in, const uint len, const uchar *key);
void crypto_dec(char *out, const char *in, const uint len, const uchar *key);
void crypto_hmac(char *out, const char *in, const uint len, const uchar *key);
int crypto_sign(mbedtls_pk_context pk,
const unsigned char *data,
const unsigned len,
unsigned char sig[ECCHAT_ECKEY_LEN]);
int crypto_verify_signature(mbedtls_pk_context pk,
const unsigned char *data,
const unsigned len,
unsigned char sig[ECCHAT_ECKEY_LEN]);
int crypto_verify_contact(ecchat_id_t *id,
mbedtls_x509_crt *contact_crt,
mbedtls_x509_crt *ca_crt);
#ifdef __cplusplus
}
#endif
#endif