|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 /* Although this is not an exported header file, code which uses elliptic |
|
6 * curve point operations will need to include it. */ |
|
7 |
|
8 #ifndef __ecl_h_ |
|
9 #define __ecl_h_ |
|
10 |
|
11 #include "ecl-exp.h" |
|
12 #include "mpi.h" |
|
13 |
|
14 struct ECGroupStr; |
|
15 typedef struct ECGroupStr ECGroup; |
|
16 |
|
17 /* Construct ECGroup from hexadecimal representations of parameters. */ |
|
18 ECGroup *ECGroup_fromHex(const ECCurveParams * params); |
|
19 |
|
20 /* Construct ECGroup from named parameters. */ |
|
21 ECGroup *ECGroup_fromName(const ECCurveName name); |
|
22 |
|
23 /* Free an allocated ECGroup. */ |
|
24 void ECGroup_free(ECGroup *group); |
|
25 |
|
26 /* Construct ECCurveParams from an ECCurveName */ |
|
27 ECCurveParams *EC_GetNamedCurveParams(const ECCurveName name); |
|
28 |
|
29 /* Duplicates an ECCurveParams */ |
|
30 ECCurveParams *ECCurveParams_dup(const ECCurveParams * params); |
|
31 |
|
32 /* Free an allocated ECCurveParams */ |
|
33 void EC_FreeCurveParams(ECCurveParams * params); |
|
34 |
|
35 /* Elliptic curve scalar-point multiplication. Computes Q(x, y) = k * P(x, |
|
36 * y). If x, y = NULL, then P is assumed to be the generator (base point) |
|
37 * of the group of points on the elliptic curve. Input and output values |
|
38 * are assumed to be NOT field-encoded. */ |
|
39 mp_err ECPoint_mul(const ECGroup *group, const mp_int *k, const mp_int *px, |
|
40 const mp_int *py, mp_int *qx, mp_int *qy); |
|
41 |
|
42 /* Elliptic curve scalar-point multiplication. Computes Q(x, y) = k1 * G + |
|
43 * k2 * P(x, y), where G is the generator (base point) of the group of |
|
44 * points on the elliptic curve. Input and output values are assumed to |
|
45 * be NOT field-encoded. */ |
|
46 mp_err ECPoints_mul(const ECGroup *group, const mp_int *k1, |
|
47 const mp_int *k2, const mp_int *px, const mp_int *py, |
|
48 mp_int *qx, mp_int *qy); |
|
49 |
|
50 /* Validates an EC public key as described in Section 5.2.2 of X9.62. |
|
51 * Returns MP_YES if the public key is valid, MP_NO if the public key |
|
52 * is invalid, or an error code if the validation could not be |
|
53 * performed. */ |
|
54 mp_err ECPoint_validate(const ECGroup *group, const mp_int *px, const |
|
55 mp_int *py); |
|
56 |
|
57 #endif /* __ecl_h_ */ |