2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2011 - 2013 Daniel Borkmann.
4 * Subject to the GPL, version 2.
20 static struct taia tolerance_taia
= {
26 struct curve25519_proto
{
27 unsigned char enonce
[crypto_box_noncebytes
] __aligned_16
;
28 unsigned char dnonce
[crypto_box_noncebytes
] __aligned_16
;
29 unsigned char key
[crypto_box_noncebytes
] __aligned_16
;
32 struct curve25519_struct
{
33 unsigned char *enc_buf
;
34 unsigned char *dec_buf
;
37 struct spinlock enc_lock
;
38 struct spinlock dec_lock
;
41 extern void curve25519_selftest(void);
42 extern void curve25519_alloc_or_maybe_die(struct curve25519_struct
*curve
);
43 extern void curve25519_free(void *curve
);
44 extern int curve25519_pubkey_hexparse_32(unsigned char *bin
, size_t blen
, const char *ascii
, size_t alen
);
45 extern int curve25519_proto_init(struct curve25519_proto
*proto
, unsigned char *pubkey_remote
, size_t len
,
46 char *home
, int server
);
47 extern ssize_t
curve25519_encode(struct curve25519_struct
*curve
, struct curve25519_proto
*proto
,
48 unsigned char *plaintext
, size_t size
, unsigned char **chipertext
);
49 extern ssize_t
curve25519_decode(struct curve25519_struct
*curve
, struct curve25519_proto
*proto
,
50 unsigned char *chipertext
, size_t size
, unsigned char **plaintext
,
51 struct taia
*arrival_taia
);
53 static inline int is_good_taia(struct taia
*arrival_taia
, struct taia
*packet_taia
)
58 if (taia_less(arrival_taia
, packet_taia
)) {
59 taia_sub(&sub_res
, packet_taia
, arrival_taia
);
60 if (taia_less(&sub_res
, &tolerance_taia
))
65 taia_sub(&sub_res
, arrival_taia
, packet_taia
);
66 if (taia_less(&sub_res
, &tolerance_taia
))