/src/nettle/ed448-shake256-verify.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* ed448-shake256-verify.c |
2 | | |
3 | | Copyright (C) 2017 Daiki Ueno |
4 | | Copyright (C) 2017 Red Hat, Inc. |
5 | | |
6 | | This file is part of GNU Nettle. |
7 | | |
8 | | GNU Nettle is free software: you can redistribute it and/or |
9 | | modify it under the terms of either: |
10 | | |
11 | | * the GNU Lesser General Public License as published by the Free |
12 | | Software Foundation; either version 3 of the License, or (at your |
13 | | option) any later version. |
14 | | |
15 | | or |
16 | | |
17 | | * the GNU General Public License as published by the Free |
18 | | Software Foundation; either version 2 of the License, or (at your |
19 | | option) any later version. |
20 | | |
21 | | or both in parallel, as here. |
22 | | |
23 | | GNU Nettle is distributed in the hope that it will be useful, |
24 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
26 | | General Public License for more details. |
27 | | |
28 | | You should have received copies of the GNU General Public License and |
29 | | the GNU Lesser General Public License along with this program. If |
30 | | not, see http://www.gnu.org/licenses/. |
31 | | */ |
32 | | |
33 | | #if HAVE_CONFIG_H |
34 | | # include "config.h" |
35 | | #endif |
36 | | |
37 | | #include <string.h> |
38 | | |
39 | | #include "eddsa.h" |
40 | | |
41 | | #include "ecc-internal.h" |
42 | | #include "eddsa-internal.h" |
43 | | #include "sha3.h" |
44 | | |
45 | | int |
46 | | ed448_shake256_verify (const uint8_t *pub, |
47 | | size_t length, const uint8_t *msg, |
48 | | const uint8_t *signature) |
49 | 0 | { |
50 | 0 | const struct ecc_curve *ecc = &_nettle_curve448; |
51 | 0 | mp_size_t itch = 3*ecc->p.size + _eddsa_verify_itch (ecc); |
52 | 0 | mp_limb_t *scratch = gmp_alloc_limbs (itch); |
53 | 0 | struct sha3_256_ctx ctx; |
54 | 0 | int res; |
55 | 0 | #define A scratch |
56 | 0 | #define scratch_out (scratch + 3*ecc->p.size) |
57 | 0 | sha3_256_init (&ctx); |
58 | |
|
59 | 0 | res = (_eddsa_decompress (ecc, |
60 | 0 | A, pub, scratch_out) |
61 | 0 | && _eddsa_verify (ecc, &_nettle_ed448_shake256, pub, A, |
62 | 0 | &ctx, |
63 | 0 | length, msg, signature, |
64 | 0 | scratch_out)); |
65 | 0 | gmp_free_limbs (scratch, itch); |
66 | 0 | return res; |
67 | 0 | #undef A |
68 | 0 | #undef scratch_out |
69 | 0 | } |