|
Packit Service |
4684c1 |
/* curve448-mul.c
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
Copyright (C) 2017 Daiki Ueno
|
|
Packit Service |
4684c1 |
Copyright (C) 2017 Red Hat, Inc.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
This file is part of GNU Nettle.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
GNU Nettle is free software: you can redistribute it and/or
|
|
Packit Service |
4684c1 |
modify it under the terms of either:
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 3 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 2 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or both in parallel, as here.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
GNU Nettle is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
General Public License for more details.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
You should have received copies of the GNU General Public License and
|
|
Packit Service |
4684c1 |
the GNU Lesser General Public License along with this program. If
|
|
Packit Service |
4684c1 |
not, see http://www.gnu.org/licenses/.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
# include "config.h"
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "curve448.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <nettle/ecc.h>
|
|
Packit Service |
4684c1 |
#include "ecc-internal.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Intended to be compatible with NaCl's crypto_scalarmult. */
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
curve448_mul (uint8_t *q, const uint8_t *n, const uint8_t *p)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
const struct ecc_modulo *m = &_nettle_curve448.p;
|
|
Packit Service |
4684c1 |
mp_size_t itch;
|
|
Packit Service |
4684c1 |
mp_limb_t *x;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
itch = m->size + ECC_MUL_M_ITCH(m->size);
|
|
Packit Service |
4684c1 |
x = gmp_alloc_limbs (itch);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
mpn_set_base256_le (x, m->size, p, CURVE448_SIZE);
|
|
Packit Service |
4684c1 |
ecc_mul_m (m, 39081, 2, 446, x, n, x, x + m->size);
|
|
Packit Service |
4684c1 |
mpn_get_base256_le (q, CURVE448_SIZE, x, m->size);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gmp_free_limbs (x, itch);
|
|
Packit Service |
4684c1 |
}
|