curve: curve25519_tfm_alloc/curve25519_tfm_free helpers
[netsniff-ng.git] / curve.h
blob1b3a9195dddb867f1170c781f469dfbb8377e73f
1 #ifndef CURVE_H
2 #define CURVE_H
4 #include "locking.h"
5 #include "built_in.h"
6 #include "ioops.h"
7 #include "rnd.h"
8 #include "taia.h"
9 #include "crypto.h"
11 struct curve25519_proto {
12 unsigned char enonce[crypto_box_noncebytes] __aligned_16;
13 unsigned char dnonce[crypto_box_noncebytes] __aligned_16;
14 unsigned char key[crypto_box_beforenmbytes] __aligned_16;
17 struct curve25519_struct {
18 unsigned char *enc, *dec;
19 size_t enc_size, dec_size;
20 struct spinlock enc_lock, dec_lock;
23 extern void curve25519_selftest(void);
25 extern struct curve25519_struct *curve25519_tfm_alloc(void);
26 extern void curve25519_tfm_free(struct curve25519_struct *tfm);
27 extern void curve25519_tfm_free_void(void *tfm);
29 extern void curve25519_proto_init(struct curve25519_proto *proto,
30 unsigned char *pubkey_remote, size_t len);
31 extern int curve25519_pubkey_hexparse_32(unsigned char *bin, size_t blen,
32 const char *ascii, size_t alen);
34 extern ssize_t curve25519_encode(struct curve25519_struct *curve,
35 struct curve25519_proto *proto,
36 unsigned char *plaintext, size_t size,
37 unsigned char **ciphertext);
38 extern ssize_t curve25519_decode(struct curve25519_struct *curve,
39 struct curve25519_proto *proto,
40 unsigned char *ciphertext, size_t size,
41 unsigned char **plaintext,
42 struct taia *arrival_taia);
44 #endif /* CURVE_H */