|
Packit Service |
4684c1 |
/* eddsa-pubkey.c
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
Copyright (C) 2015 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 |
#if HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
# include "config.h"
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <assert.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "eddsa.h"
|
|
Packit Service |
4684c1 |
#include "eddsa-internal.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "ecc-internal.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
mp_size_t
|
|
Packit Service |
4684c1 |
_eddsa_public_key_itch (const struct ecc_curve *ecc)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
assert (_eddsa_compress_itch (ecc) <= ecc->mul_g_itch);
|
|
Packit Service |
4684c1 |
return 3*ecc->p.size + ecc->mul_g_itch;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
_eddsa_public_key (const struct ecc_curve *ecc,
|
|
Packit Service |
4684c1 |
const mp_limb_t *k, uint8_t *pub, mp_limb_t *scratch)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
#define P scratch
|
|
Packit Service |
4684c1 |
#define scratch_out (scratch + 3*ecc->p.size)
|
|
Packit Service |
4684c1 |
ecc->mul_g (ecc, P, k, scratch_out);
|
|
Packit Service |
4684c1 |
_eddsa_compress (ecc, pub, P, scratch_out);
|
|
Packit Service |
4684c1 |
#undef P
|
|
Packit Service |
4684c1 |
#undef scratch_out
|
|
Packit Service |
4684c1 |
}
|