+int gost_ec_point_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,
+ const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (group == NULL || r == NULL || ctx == NULL)
+ return 0;
+
+ if (m != NULL && n != NULL) {
+ /* verification */
+ if (q == NULL)
+ return 0;
+ switch(EC_GROUP_get_curve_name(group)) {
+ case NID_id_GostR3410_2001_CryptoPro_A_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetB:
+ return point_mul_two_id_GostR3410_2001_CryptoPro_A_ParamSet(group, r, n, q, m, ctx);
+ case NID_id_GostR3410_2001_CryptoPro_B_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetC:
+ return point_mul_two_id_GostR3410_2001_CryptoPro_B_ParamSet(group, r, n, q, m, ctx);
+ case NID_id_GostR3410_2001_CryptoPro_C_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetD:
+ return point_mul_two_id_GostR3410_2001_CryptoPro_C_ParamSet(group, r, n, q, m, ctx);
+ case NID_id_GostR3410_2001_TestParamSet:
+ return point_mul_two_id_GostR3410_2001_TestParamSet(group, r, n, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_256_paramSetA:
+ return point_mul_two_id_tc26_gost_3410_2012_256_paramSetA(group, r, n, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetA:
+ return point_mul_two_id_tc26_gost_3410_2012_512_paramSetA(group, r, n, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetB:
+ return point_mul_two_id_tc26_gost_3410_2012_512_paramSetB(group, r, n, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetC:
+ return point_mul_two_id_tc26_gost_3410_2012_512_paramSetC(group, r, n, q, m, ctx);
+ default:
+ return EC_POINT_mul(group, r, n, q, m, ctx);
+ }
+ } else if (n != NULL) {
+ /* mul g */
+ switch(EC_GROUP_get_curve_name(group)) {
+ case NID_id_GostR3410_2001_CryptoPro_A_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetB:
+ return point_mul_g_id_GostR3410_2001_CryptoPro_A_ParamSet(group, r, n, ctx);
+ case NID_id_GostR3410_2001_CryptoPro_B_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetC:
+ return point_mul_g_id_GostR3410_2001_CryptoPro_B_ParamSet(group, r, n, ctx);
+ case NID_id_GostR3410_2001_CryptoPro_C_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetD:
+ return point_mul_g_id_GostR3410_2001_CryptoPro_C_ParamSet(group, r, n, ctx);
+ case NID_id_GostR3410_2001_TestParamSet:
+ return point_mul_g_id_GostR3410_2001_TestParamSet(group, r, n, ctx);
+ case NID_id_tc26_gost_3410_2012_256_paramSetA:
+ return point_mul_g_id_tc26_gost_3410_2012_256_paramSetA(group, r, n, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetA:
+ return point_mul_g_id_tc26_gost_3410_2012_512_paramSetA(group, r, n, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetB:
+ return point_mul_g_id_tc26_gost_3410_2012_512_paramSetB(group, r, n, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetC:
+ return point_mul_g_id_tc26_gost_3410_2012_512_paramSetC(group, r, n, ctx);
+ default:
+ return EC_POINT_mul(group, r, n, q, m, ctx);
+ }
+ } else if (m != NULL) {
+ if (q == NULL)
+ return 0;
+ /* mul */
+ switch(EC_GROUP_get_curve_name(group)) {
+ case NID_id_GostR3410_2001_CryptoPro_A_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetB:
+ return point_mul_id_GostR3410_2001_CryptoPro_A_ParamSet(group, r, q, m, ctx);
+ case NID_id_GostR3410_2001_CryptoPro_B_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetC:
+ return point_mul_id_GostR3410_2001_CryptoPro_B_ParamSet(group, r, q, m, ctx);
+ case NID_id_GostR3410_2001_CryptoPro_C_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetD:
+ return point_mul_id_GostR3410_2001_CryptoPro_C_ParamSet(group, r, q, m, ctx);
+ case NID_id_GostR3410_2001_TestParamSet:
+ return point_mul_id_GostR3410_2001_TestParamSet(group, r, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_256_paramSetA:
+ return point_mul_id_tc26_gost_3410_2012_256_paramSetA(group, r, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetA:
+ return point_mul_id_tc26_gost_3410_2012_512_paramSetA(group, r, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetB:
+ return point_mul_id_tc26_gost_3410_2012_512_paramSetB(group, r, q, m, ctx);
+ case NID_id_tc26_gost_3410_2012_512_paramSetC:
+ return point_mul_id_tc26_gost_3410_2012_512_paramSetC(group, r, q, m, ctx);
+ default:
+ return EC_POINT_mul(group, r, n, q, m, ctx);
+ }
+ }
+ return 0;
+}
+