michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* Although this is not an exported header file, code which uses elliptic michael@0: * curve point operations will need to include it. */ michael@0: michael@0: #ifndef __ecl_h_ michael@0: #define __ecl_h_ michael@0: michael@0: #include "ecl-exp.h" michael@0: #include "mpi.h" michael@0: michael@0: struct ECGroupStr; michael@0: typedef struct ECGroupStr ECGroup; michael@0: michael@0: /* Construct ECGroup from hexadecimal representations of parameters. */ michael@0: ECGroup *ECGroup_fromHex(const ECCurveParams * params); michael@0: michael@0: /* Construct ECGroup from named parameters. */ michael@0: ECGroup *ECGroup_fromName(const ECCurveName name); michael@0: michael@0: /* Free an allocated ECGroup. */ michael@0: void ECGroup_free(ECGroup *group); michael@0: michael@0: /* Construct ECCurveParams from an ECCurveName */ michael@0: ECCurveParams *EC_GetNamedCurveParams(const ECCurveName name); michael@0: michael@0: /* Duplicates an ECCurveParams */ michael@0: ECCurveParams *ECCurveParams_dup(const ECCurveParams * params); michael@0: michael@0: /* Free an allocated ECCurveParams */ michael@0: void EC_FreeCurveParams(ECCurveParams * params); michael@0: michael@0: /* Elliptic curve scalar-point multiplication. Computes Q(x, y) = k * P(x, michael@0: * y). If x, y = NULL, then P is assumed to be the generator (base point) michael@0: * of the group of points on the elliptic curve. Input and output values michael@0: * are assumed to be NOT field-encoded. */ michael@0: mp_err ECPoint_mul(const ECGroup *group, const mp_int *k, const mp_int *px, michael@0: const mp_int *py, mp_int *qx, mp_int *qy); michael@0: michael@0: /* Elliptic curve scalar-point multiplication. Computes Q(x, y) = k1 * G + michael@0: * k2 * P(x, y), where G is the generator (base point) of the group of michael@0: * points on the elliptic curve. Input and output values are assumed to michael@0: * be NOT field-encoded. */ michael@0: mp_err ECPoints_mul(const ECGroup *group, const mp_int *k1, michael@0: const mp_int *k2, const mp_int *px, const mp_int *py, michael@0: mp_int *qx, mp_int *qy); michael@0: michael@0: /* Validates an EC public key as described in Section 5.2.2 of X9.62. michael@0: * Returns MP_YES if the public key is valid, MP_NO if the public key michael@0: * is invalid, or an error code if the validation could not be michael@0: * performed. */ michael@0: mp_err ECPoint_validate(const ECGroup *group, const mp_int *px, const michael@0: mp_int *py); michael@0: michael@0: #endif /* __ecl_h_ */