Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/security/ec/impl/ecl.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.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 _ECL_H39#define _ECL_H4041/* Although this is not an exported header file, code which uses elliptic42* curve point operations will need to include it. */4344#include "ecl-exp.h"45#include "mpi.h"4647struct ECGroupStr;48typedef struct ECGroupStr ECGroup;4950/* Construct ECGroup from hexadecimal representations of parameters. */51ECGroup *ECGroup_fromHex(const ECCurveParams * params, int kmflag);5253/* Construct ECGroup from named parameters. */54ECGroup *ECGroup_fromName(const ECCurveName name, int kmflag);5556/* Free an allocated ECGroup. */57void ECGroup_free(ECGroup *group);5859/* Construct ECCurveParams from an ECCurveName */60ECCurveParams *EC_GetNamedCurveParams(const ECCurveName name, int kmflag);6162/* Duplicates an ECCurveParams */63ECCurveParams *ECCurveParams_dup(const ECCurveParams * params, int kmflag);6465/* Free an allocated ECCurveParams */66void EC_FreeCurveParams(ECCurveParams * params);6768/* Elliptic curve scalar-point multiplication. Computes Q(x, y) = k * P(x,69* y). If x, y = NULL, then P is assumed to be the generator (base point)70* of the group of points on the elliptic curve. Input and output values71* are assumed to be NOT field-encoded. */72mp_err ECPoint_mul(const ECGroup *group, const mp_int *k, const mp_int *px,73const mp_int *py, mp_int *qx, mp_int *qy,74int timing);7576/* Elliptic curve scalar-point multiplication. Computes Q(x, y) = k1 * G +77* k2 * P(x, y), where G is the generator (base point) of the group of78* points on the elliptic curve. Input and output values are assumed to79* be NOT field-encoded. */80mp_err ECPoints_mul(const ECGroup *group, const mp_int *k1,81const mp_int *k2, const mp_int *px, const mp_int *py,82mp_int *qx, mp_int *qy, int timing);8384/* Validates an EC public key as described in Section 5.2.2 of X9.62.85* Returns MP_YES if the public key is valid, MP_NO if the public key86* is invalid, or an error code if the validation could not be87* performed. */88mp_err ECPoint_validate(const ECGroup *group, const mp_int *px, const89mp_int *py);9091#endif /* _ECL_H */929394