Coverage Report

Created: 2024-11-25 06:29

/src/nettle/ed448-shake256-pubkey.c
Line
Count
Source
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
8.48k
{
46
8.48k
  const struct ecc_curve *ecc = &_nettle_curve448;
47
8.48k
  struct sha3_256_ctx ctx;
48
8.48k
  uint8_t digest[ED448_SIGNATURE_SIZE];
49
8.48k
  mp_size_t itch = ecc->q.size + _eddsa_public_key_itch (ecc);
50
8.48k
  mp_limb_t *scratch = gmp_alloc_limbs (itch);
51
52
16.9k
#define k scratch
53
8.48k
#define scratch_out (scratch + ecc->q.size)
54
8.48k
  sha3_256_init (&ctx);
55
8.48k
  _eddsa_expand_key (ecc, &_nettle_ed448_shake256, &ctx, priv, digest, k);
56
8.48k
  _eddsa_public_key (ecc, k, pub, scratch_out);
57
58
8.48k
  gmp_free_limbs (scratch, itch);
59
8.48k
#undef k
60
8.48k
#undef scratch_out
61
8.48k
}