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