/* * ChaCha20 256-bit cipher algorithm, RFC7539 * * Copyright (C) 2015 Martin Willi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #include #include #include #include #include #include static inline u32 rotl32(u32 v, u8 n) { return (v << n) | (v >> (sizeof(v) * 8 - n)); } extern void chacha20_block(u32 *state, void *stream) { u32 x[16], *out = stream; int i; for (i = 0; i < ARRAY_SIZE(x); i++) x[i] = state[i]; for (i = 0; i < 20; i += 2) { x[0] += x[4]; x[12] = rotl32(x[12] ^ x[0], 16); x[1] += x[5]; x[13] = rotl32(x[13] ^ x[1], 16); x[2] += x[6]; x[14] = rotl32(x[14] ^ x[2], 16); x[3] += x[7]; x[15] = rotl32(x[15] ^ x[3], 16); x[8] += x[12]; x[4] = rotl32(x[4] ^ x[8], 12); x[9] += x[13]; x[5] = rotl32(x[5] ^ x[9], 12); x[10] += x[14]; x[6] = rotl32(x[6] ^ x[10], 12); x[11] += x[15]; x[7] = rotl32(x[7] ^ x[11], 12); x[0] += x[4]; x[12] = rotl32(x[12] ^ x[0], 8); x[1] += x[5]; x[13] = rotl32(x[13] ^ x[1], 8); x[2] += x[6]; x[14] = rotl32(x[14] ^ x[2], 8); x[3] += x[7]; x[15] = rotl32(x[15] ^ x[3], 8); x[8] += x[12]; x[4] = rotl32(x[4] ^ x[8], 7); x[9] += x[13]; x[5] = rotl32(x[5] ^ x[9], 7); x[10] += x[14]; x[6] = rotl32(x[6] ^ x[10], 7); x[11] += x[15]; x[7] = rotl32(x[7] ^ x[11], 7); x[0] += x[5]; x[15] = rotl32(x[15] ^ x[0], 16); x[1] += x[6]; x[12] = rotl32(x[12] ^ x[1], 16); x[2] += x[7]; x[13] = rotl32(x[13] ^ x[2], 16); x[3] += x[4]; x[14] = rotl32(x[14] ^ x[3], 16); x[10] += x[15]; x[5] = rotl32(x[5] ^ x[10], 12); x[11] += x[12]; x[6] = rotl32(x[6] ^ x[11], 12); x[8] += x[13]; x[7] = rotl32(x[7] ^ x[8], 12); x[9] += x[14]; x[4] = rotl32(x[4] ^ x[9], 12); x[0] += x[5]; x[15] = rotl32(x[15] ^ x[0], 8); x[1] += x[6]; x[12] = rotl32(x[12] ^ x[1], 8); x[2] += x[7]; x[13] = rotl32(x[13] ^ x[2], 8); x[3] += x[4]; x[14] = rotl32(x[14] ^ x[3], 8); x[10] += x[15]; x[5] = rotl32(x[5] ^ x[10], 7); x[11] += x[12]; x[6] = rotl32(x[6] ^ x[11], 7); x[8] += x[13]; x[7] = rotl32(x[7] ^ x[8], 7); x[9] += x[14]; x[4] = rotl32(x[4] ^ x[9], 7); } for (i = 0; i < ARRAY_SIZE(x); i++) out[i] = cpu_to_le32(x[i] + state[i]); state[12]++; } EXPORT_SYMBOL(chacha20_block); g/?id=253fd0f02040a19c6fe80e4171659fa3482a422d&showmsg=1'>root/net/sched
AgeCommit message (Collapse)AuthorFilesLines
2017-02-01net/sched: matchall: Fix configuration raceYotam Gigi1-82/+45
In the current version, the matchall internal state is split into two structs: cls_matchall_head and cls_matchall_filter. This makes little sense, as matchall instance supports only one filter, and there is no situation where one exists and the other does not. In addition, that led to some races when filter was deleted while packet was processed. Unify that two structs into one, thus simplifying the process of matchall creation and deletion. As a result, the new, delete and get callbacks have a dummy implementation where all the work is done in destroy and change callbacks, as was done in cls_cgroup. Fixes: bf3994d2ed31 ("net/sched: introduce Match-all classifier") Reported-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Yotam Gigi <yotamg@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>