summaryrefslogtreecommitdiffstats
path: root/src/methods/xsalsa20_poly1305
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-08 20:30:44 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-08 20:30:44 +0200
commit80b1412c65a7a7e209c66684cf78e2ab13cfd5e6 (patch)
treea148c84c7eb41d25a9a1e709b47a84b43f26805c /src/methods/xsalsa20_poly1305
parent58b8518100c8b306d5b6a3d87b4a83a1ae383a09 (diff)
downloadfastd-80b1412c65a7a7e209c66684cf78e2ab13cfd5e6.tar
fastd-80b1412c65a7a7e209c66684cf78e2ab13cfd5e6.zip
Make stats of reordered packets
Diffstat (limited to 'src/methods/xsalsa20_poly1305')
-rw-r--r--src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
index ee44200..670d09f 100644
--- a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
+++ b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
@@ -167,7 +167,7 @@ static bool method_encrypt(UNUSED fastd_peer_t *peer, fastd_method_session_state
}
/** Performs validation and decryption of a packet */
-static bool method_decrypt(fastd_peer_t *peer, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in) {
+static bool method_decrypt(fastd_peer_t *peer, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in, bool *reordered) {
if (in.len < COMMON_HEADBYTES)
return false;
@@ -201,7 +201,11 @@ static bool method_decrypt(fastd_peer_t *peer, fastd_method_session_state_t *ses
fastd_buffer_free(in);
- if (!fastd_method_reorder_check(peer, &session->common, in_nonce, age)) {
+ fastd_tristate_t reorder_check = fastd_method_reorder_check(peer, &session->common, in_nonce, age);
+ if (reorder_check.set) {
+ *reordered = reorder_check.state;
+ }
+ else {
fastd_buffer_free(*out);
*out = fastd_buffer_alloc(crypto_secretbox_xsalsa20poly1305_ZEROBYTES, 0, 0);
}