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 poly64_mul (uint32_t kh, uint32_t kl, uint64_t y)
35 uint64_t yl, yh, pl, ph, ml, mh;
40 ml = yh * kl + yl * kh; /* No overflow, thanks to special form */
46 /* Reduce, using 2^64 = UMAC_P64_OFFSET (mod p) */
47 assert (ph < ((uint64_t) 1 << 57));
48 ph *= UMAC_P64_OFFSET;
51 pl += UMAC_P64_OFFSET;
57 _umac_poly64 (uint32_t kh, uint32_t kl, uint64_t y, uint64_t m)
59 if ( (m >> 32) == 0xffffffff)
61 y = poly64_mul (kh, kl, y);
68 y = poly64_mul (kh, kl, y);