4
/* nettle, low-level cryptographics library
6
* Copyright (C) 2013 Niels Möller
8
* The nettle library is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation; either version 2.1 of the License, or (at your
11
* option) any later version.
13
* The nettle library is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16
* License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with the nettle library; see the file COPYING.LIB. If not, write to
20
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
33
#define P 0x0000000FFFFFFFFBULL
36
#define BE_SWAP64(x) x
38
#define BE_SWAP64(x) \
40
| ((x & 0xff00) << 40) \
41
| ((x & 0xff0000) << 24) \
42
| ((x & 0xff000000) << 8) \
43
| ((x >> 8) & 0xff000000) \
44
| ((x >> 24) & 0xff0000) \
45
| ((x >> 40) & 0xff00) \
50
_umac_l3_init (unsigned size, uint64_t *k)
53
for (i = 0; i < size; i++)
62
umac_l3_word (const uint64_t *k, uint64_t w)
67
/* Since it's easiest to process the input word from the low end,
68
* loop over keys in reverse order. */
70
for (i = y = 0; i < 4; i++, w >>= 16)
71
y += (w & 0xffff) * k[3-i];
77
_umac_l3 (const uint64_t *key, const uint64_t *m)
79
uint32_t y = (umac_l3_word (key, m[0])
80
+ umac_l3_word (key + 4, m[1])) % P;
83
y = ((ROTL32(8, y) & 0x00FF00FFUL)
84
| (ROTL32(24, y) & 0xFF00FF00UL));