/src/nettle/ed448-shake256-pubkey.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* ed448-shake256-pubkey.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 "eddsa.h" |
38 | | |
39 | | #include "ecc-internal.h" |
40 | | #include "eddsa-internal.h" |
41 | | #include "sha3.h" |
42 | | |
43 | | void |
44 | | ed448_shake256_public_key (uint8_t *pub, const uint8_t *priv) |
45 | 0 | { |
46 | 0 | const struct ecc_curve *ecc = &_nettle_curve448; |
47 | 0 | struct sha3_256_ctx ctx; |
48 | 0 | uint8_t digest[ED448_SIGNATURE_SIZE]; |
49 | 0 | mp_size_t itch = ecc->q.size + _eddsa_public_key_itch (ecc); |
50 | 0 | mp_limb_t *scratch = gmp_alloc_limbs (itch); |
51 | |
|
52 | 0 | #define k scratch |
53 | 0 | #define scratch_out (scratch + ecc->q.size) |
54 | 0 | sha3_256_init (&ctx); |
55 | 0 | _eddsa_expand_key (ecc, &_nettle_ed448_shake256, &ctx, priv, digest, k); |
56 | 0 | _eddsa_public_key (ecc, k, pub, scratch_out); |
57 | |
|
58 | 0 | gmp_free_limbs (scratch, itch); |
59 | 0 | #undef k |
60 | 0 | #undef scratch_out |
61 | 0 | } |