2 * Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 * Author: Ilya Tumaykin
6 * This file is part of GNUTLS.
8 * The GNUTLS library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
27 @param P The point to negate
28 @param R [out] The destination of the negate
29 @param modulus The modulus of the field the ECC curve is in
30 @return GNUTLS_E_SUCCESS on success
33 ecc_projective_negate_point (ecc_point
* P
, ecc_point
* R
, mpz_t modulus
)
36 if (P
== NULL
|| R
== NULL
)
37 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER
;
39 if (ecc_projective_isneutral (P
, modulus
))
41 /* we set R.y to (modulus - P.y) to avoid negative coordinates */
43 mpz_sub (R
->y
, modulus
, P
->y
);
44 mpz_mod (R
->y
, R
->y
, modulus
);
49 /* -neutral = neutral */
55 return GNUTLS_E_SUCCESS
;