Add SM9 encapsulate key functions

This commit is contained in:
Zhi Guan
2018-10-05 11:53:13 +08:00
parent eaf4002536
commit a7b96e8024
12 changed files with 5754 additions and 5362 deletions

View File

@@ -2514,10 +2514,29 @@ int rate_pairing(fp12_t r, const point_t *Q, const EC_POINT *P, BN_CTX *ctx)
xP = BN_CTX_get(ctx);
yP = BN_CTX_get(ctx);
EC_POINT_get_affine_coordinates_GFp(group, P, xP, yP, ctx);
if (!P) {
EC_POINT_get_affine_coordinates_GFp(group,
EC_GROUP_get0_generator(group), xP, yP, ctx);
} else {
EC_POINT_get_affine_coordinates_GFp(group, P, xP, yP, ctx);
}
if (!Q) {
point_t P2;
point_init(&P2, ctx);
point_set_affine_coordinates_bignums(&P2,
SM9_get0_generator2_x0(),
SM9_get0_generator2_x1(),
SM9_get0_generator2_y0(),
SM9_get0_generator2_y1());
rate(r, &P2, xP, yP, a, k, p, ctx);
point_cleanup(&P2);
} else {
rate(r, Q, xP, yP, a, k, p, ctx);
}
rate(r, Q, xP, yP, a, k, p, ctx);
BN_free(xP);
BN_free(yP);
return ret;