Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/security/ec/impl/ec2.h
38918 views
/*1* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.2* Use is subject to license terms.3*4* This library is free software; you can redistribute it and/or5* modify it under the terms of the GNU Lesser General Public6* License as published by the Free Software Foundation; either7* version 2.1 of the License, or (at your option) any later version.8*9* This library is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* Lesser General Public License for more details.13*14* You should have received a copy of the GNU Lesser General Public License15* along with this library; if not, write to the Free Software Foundation,16* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* *********************************************************************24*25* The Original Code is the elliptic curve math library for binary polynomial field curves.26*27* The Initial Developer of the Original Code is28* Sun Microsystems, Inc.29* Portions created by the Initial Developer are Copyright (C) 200330* the Initial Developer. All Rights Reserved.31*32* Contributor(s):33* Douglas Stebila <[email protected]>, Sun Microsystems Laboratories34*35* Last Modified Date from the Original Code: May 201736*********************************************************************** */3738#ifndef _EC2_H39#define _EC2_H4041#include "ecl-priv.h"4243/* Checks if point P(px, py) is at infinity. Uses affine coordinates. */44mp_err ec_GF2m_pt_is_inf_aff(const mp_int *px, const mp_int *py);4546/* Sets P(px, py) to be the point at infinity. Uses affine coordinates. */47mp_err ec_GF2m_pt_set_inf_aff(mp_int *px, mp_int *py);4849/* Computes R = P + Q where R is (rx, ry), P is (px, py) and Q is (qx,50* qy). Uses affine coordinates. */51mp_err ec_GF2m_pt_add_aff(const mp_int *px, const mp_int *py,52const mp_int *qx, const mp_int *qy, mp_int *rx,53mp_int *ry, const ECGroup *group);5455/* Computes R = P - Q. Uses affine coordinates. */56mp_err ec_GF2m_pt_sub_aff(const mp_int *px, const mp_int *py,57const mp_int *qx, const mp_int *qy, mp_int *rx,58mp_int *ry, const ECGroup *group);5960/* Computes R = 2P. Uses affine coordinates. */61mp_err ec_GF2m_pt_dbl_aff(const mp_int *px, const mp_int *py, mp_int *rx,62mp_int *ry, const ECGroup *group);6364/* Validates a point on a GF2m curve. */65mp_err ec_GF2m_validate_point(const mp_int *px, const mp_int *py, const ECGroup *group);6667/* by default, this routine is unused and thus doesn't need to be compiled */68#ifdef ECL_ENABLE_GF2M_PT_MUL_AFF69/* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters70* a, b and p are the elliptic curve coefficients and the irreducible that71* determines the field GF2m. Uses affine coordinates. */72mp_err ec_GF2m_pt_mul_aff(const mp_int *n, const mp_int *px,73const mp_int *py, mp_int *rx, mp_int *ry,74const ECGroup *group);75#endif7677/* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters78* a, b and p are the elliptic curve coefficients and the irreducible that79* determines the field GF2m. Uses Montgomery projective coordinates. */80mp_err ec_GF2m_pt_mul_mont(const mp_int *n, const mp_int *px,81const mp_int *py, mp_int *rx, mp_int *ry,82const ECGroup *group, int timing);8384#ifdef ECL_ENABLE_GF2M_PROJ85/* Converts a point P(px, py) from affine coordinates to projective86* coordinates R(rx, ry, rz). */87mp_err ec_GF2m_pt_aff2proj(const mp_int *px, const mp_int *py, mp_int *rx,88mp_int *ry, mp_int *rz, const ECGroup *group);8990/* Converts a point P(px, py, pz) from projective coordinates to affine91* coordinates R(rx, ry). */92mp_err ec_GF2m_pt_proj2aff(const mp_int *px, const mp_int *py,93const mp_int *pz, mp_int *rx, mp_int *ry,94const ECGroup *group);9596/* Checks if point P(px, py, pz) is at infinity. Uses projective97* coordinates. */98mp_err ec_GF2m_pt_is_inf_proj(const mp_int *px, const mp_int *py,99const mp_int *pz);100101/* Sets P(px, py, pz) to be the point at infinity. Uses projective102* coordinates. */103mp_err ec_GF2m_pt_set_inf_proj(mp_int *px, mp_int *py, mp_int *pz);104105/* Computes R = P + Q where R is (rx, ry, rz), P is (px, py, pz) and Q is106* (qx, qy, qz). Uses projective coordinates. */107mp_err ec_GF2m_pt_add_proj(const mp_int *px, const mp_int *py,108const mp_int *pz, const mp_int *qx,109const mp_int *qy, mp_int *rx, mp_int *ry,110mp_int *rz, const ECGroup *group);111112/* Computes R = 2P. Uses projective coordinates. */113mp_err ec_GF2m_pt_dbl_proj(const mp_int *px, const mp_int *py,114const mp_int *pz, mp_int *rx, mp_int *ry,115mp_int *rz, const ECGroup *group);116117/* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters118* a, b and p are the elliptic curve coefficients and the prime that119* determines the field GF2m. Uses projective coordinates. */120mp_err ec_GF2m_pt_mul_proj(const mp_int *n, const mp_int *px,121const mp_int *py, mp_int *rx, mp_int *ry,122const ECGroup *group);123#endif124125#endif /* _EC2_H */126127128