|
Packit Service |
4684c1 |
/* ecc-a-to-j.c
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
Copyright (C) 2013 Niels Möller
|
|
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 |
/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
|
|
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 <nettle/ecc.h>
|
|
Packit Service |
4684c1 |
#include "ecc-internal.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
ecc_a_to_j (const struct ecc_curve *ecc,
|
|
Packit Service |
4684c1 |
mp_limb_t *r, const mp_limb_t *p)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (ecc->use_redc)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
mpn_copyd (r + ecc->p.size, p, 2*ecc->p.size);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
mpn_zero (r, ecc->p.size);
|
|
Packit Service |
4684c1 |
ecc->p.mod (&ecc->p, r);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
mpn_zero (r + ecc->p.size, ecc->p.size);
|
|
Packit Service |
4684c1 |
ecc->p.mod (&ecc->p, r + ecc->p.size);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
else if (r != p)
|
|
Packit Service |
4684c1 |
mpn_copyi (r, p, 2*ecc->p.size);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
mpn_copyi (r + 2*ecc->p.size, ecc->unit, ecc->p.size);
|
|
Packit Service |
4684c1 |
}
|