/src/nettle/siv-ghash-update.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* siv-ghash-update.c |
2 | | |
3 | | POLYVAL implementation for AES-GCM-SIV, based on GHASH |
4 | | |
5 | | Copyright (C) 2011 Katholieke Universiteit Leuven |
6 | | Copyright (C) 2011, 2013, 2018, 2022 Niels Möller |
7 | | Copyright (C) 2018, 2022 Red Hat, Inc. |
8 | | |
9 | | This file is part of GNU Nettle. |
10 | | |
11 | | GNU Nettle is free software: you can redistribute it and/or |
12 | | modify it under the terms of either: |
13 | | |
14 | | * the GNU Lesser General Public License as published by the Free |
15 | | Software Foundation; either version 3 of the License, or (at your |
16 | | option) any later version. |
17 | | |
18 | | or |
19 | | |
20 | | * the GNU General Public License as published by the Free |
21 | | Software Foundation; either version 2 of the License, or (at your |
22 | | option) any later version. |
23 | | |
24 | | or both in parallel, as here. |
25 | | |
26 | | GNU Nettle is distributed in the hope that it will be useful, |
27 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
28 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
29 | | General Public License for more details. |
30 | | |
31 | | You should have received copies of the GNU General Public License and |
32 | | the GNU Lesser General Public License along with this program. If |
33 | | not, see http://www.gnu.org/licenses/. |
34 | | */ |
35 | | |
36 | | #if HAVE_CONFIG_H |
37 | | # include "config.h" |
38 | | #endif |
39 | | |
40 | | #include "ghash-internal.h" |
41 | | #include "block-internal.h" |
42 | | #include "macros.h" |
43 | | |
44 | | const uint8_t * |
45 | | _siv_ghash_update (const struct gcm_key *ctx, union nettle_block16 *state, |
46 | | size_t blocks, const uint8_t *data) |
47 | 0 | { |
48 | 0 | for (; blocks-- > 0; data += GCM_BLOCK_SIZE) |
49 | 0 | { |
50 | 0 | union nettle_block16 b; |
51 | |
|
52 | | #if WORDS_BIGENDIAN |
53 | | b.u64[1] = LE_READ_UINT64(data); |
54 | | b.u64[0] = LE_READ_UINT64(data + 8); |
55 | | #else |
56 | 0 | b.u64[1] = READ_UINT64(data); |
57 | 0 | b.u64[0] = READ_UINT64(data + 8); |
58 | 0 | #endif |
59 | |
|
60 | 0 | _ghash_update (ctx, state, 1, b.b); |
61 | 0 | } |
62 | |
|
63 | 0 | return data; |
64 | 0 | } |
65 | | |