Coverage Report

Created: 2025-07-23 06:43

/src/nettle/curve448-mul.c
Line
Count
Source
1
/* curve448-mul.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 <assert.h>
38
#include <string.h>
39
40
#include "curve448.h"
41
42
#include "ecc.h"
43
#include "ecc-internal.h"
44
45
/* Intended to be compatible with NaCl's crypto_scalarmult. */
46
void
47
curve448_mul (uint8_t *q, const uint8_t *n, const uint8_t *p)
48
795
{
49
795
  const struct ecc_modulo *m = &_nettle_curve448.p;
50
795
  mp_size_t itch;
51
795
  mp_limb_t *x;
52
53
795
  itch = m->size + ECC_MUL_M_ITCH(m->size);
54
795
  x = gmp_alloc_limbs (itch);
55
56
795
  mpn_set_base256_le (x, m->size, p, CURVE448_SIZE);
57
795
  ecc_mul_m (m, 39081, 2, 446, x, n, x, x + m->size);
58
795
  mpn_get_base256_le (q, CURVE448_SIZE, x, m->size);
59
60
795
  gmp_free_limbs (x, itch);
61
795
}