summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-nixio/src/nixio-tls.h
blob: 0fac5a980d6dc2f2bcc92d2b204c4430d4d2a27b (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
#ifndef NIXIO_TLS_H_
#define NIXIO_TLS_H_

#include "nixio.h"
#include <sys/types.h>

#ifndef WITHOUT_OPENSSL
#include <openssl/ssl.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
#endif

#define NIXIO_TLS_CTX_META "nixio.tls.ctx"
#define NIXIO_TLS_SOCK_META "nixio.tls.sock"

typedef struct nixio_tls_socket {
	SSL		*socket;
#ifdef WITH_AXTLS
	char	connected;
	size_t	pbufsiz;
	char	*pbufpos;
	char	*pbuffer;
#endif
} nixio_tls_sock;

#define NIXIO_CRYPTO_HASH_META "nixio.crypto.hash"
#define NIXIO_DIGEST_SIZE 64
#define NIXIO_CRYPTO_BLOCK_SIZE 64

#define NIXIO_HASH_NONE	0
#define NIXIO_HASH_MD5	0x01
#define NIXIO_HASH_SHA1	0x02

#define NIXIO_HMAC_BIT	0x40

typedef int(*nixio_hash_initcb)(void *);
typedef int(*nixio_hash_updatecb)(void *, const void *, unsigned long);
typedef int(*nixio_hash_finalcb)(unsigned char *, void *);

typedef struct nixio_hash_obj {
	uint				type;
	unsigned char		digest[NIXIO_DIGEST_SIZE];
	size_t				digest_size;
	unsigned char		key[NIXIO_CRYPTO_BLOCK_SIZE];
	size_t				key_size;
	size_t				block_size;
	void				*ctx;
	nixio_hash_initcb	init;
	nixio_hash_updatecb	update;
	nixio_hash_finalcb	final;
} nixio_hash;

#endif /* NIXIO_TLS_H_ */