]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Explicitely setting cofactor
authorDmitry Belyavskiy <beldmit@gmail.com>
Thu, 12 Jul 2018 18:49:21 +0000 (21:49 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Tue, 21 Aug 2018 06:53:18 +0000 (09:53 +0300)
gost_ec_sign.c
gost_lcl.h
gost_params.c

index 03a2ba09da25079700ebdc69b3de3cf846282bd5..2deb09324b50d15a50caaba367362d5f83a496b4 100644 (file)
@@ -74,7 +74,7 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid)
     R3410_ec_params *params = gost_nid2params(nid);
     EC_GROUP *grp = NULL;
     EC_POINT *P = NULL;
-    BIGNUM *p = NULL, *q = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL;
+    BIGNUM *p = NULL, *q = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL, *cofactor = NULL;
     BN_CTX *ctx;
     int ok = 0;
 
@@ -95,14 +95,16 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid)
     x = BN_CTX_get(ctx);
     y = BN_CTX_get(ctx);
     q = BN_CTX_get(ctx);
-    if (!p || !a || !b || !x || !y || !q) {
+               cofactor = BN_CTX_get(ctx);
+    if (!p || !a || !b || !x || !y || !q || !cofactor) {
         GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_MALLOC_FAILURE);
         goto end;
     }
 
     if (!BN_hex2bn(&p, params->p)
         || !BN_hex2bn(&a, params->a)
-        || !BN_hex2bn(&b, params->b)) {
+        || !BN_hex2bn(&b, params->b)
+                               || !BN_hex2bn(&cofactor, params->cofactor) ) {
         GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_INTERNAL_ERROR);
         goto end;
     }
@@ -127,7 +129,7 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid)
         goto end;
     }
 
-    if (!EC_GROUP_set_generator(grp, P, q, NULL)) {
+    if (!EC_GROUP_set_generator(grp, P, q, cofactor)) {
         GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_INTERNAL_ERROR);
         goto end;
     }
index faa454bb380e0b41dbf21ef989f9cadc4df61015..c52838907d6c0857d6a5da4df6d82666601d9137 100644 (file)
@@ -33,6 +33,7 @@ typedef struct R3410_ec {
     char *q;
     char *x;
     char *y;
+               char *cofactor;
 } R3410_ec_params;
 
 extern R3410_ec_params R3410_2001_paramset[],
index 3e70990a2eedfb60f8e01c4dd7c038e8f688fe57..0a7557d239838bc19a15a868f203253a8314e146 100644 (file)
@@ -19,7 +19,8 @@ R3410_ec_params R3410_2001_paramset[] = {
      "8000000000000000000000000000000000000000000000000000000000000431",
      "8000000000000000000000000000000150FE8A1892976154C59CFC193ACCF5B3",
      "2",
-     "08E2A8A0E65147D4BD6316030E16D19C85C97F0A9CA267122B96ABBCEA7E8FC8"}
+     "08E2A8A0E65147D4BD6316030E16D19C85C97F0A9CA267122B96ABBCEA7E8FC8",
+     "1"}
     ,
     /*
      * 1.2.643.2.2.35.1
@@ -30,7 +31,8 @@ R3410_ec_params R3410_2001_paramset[] = {
      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893",
      "1",
-     "8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14"}
+     "8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14",
+     "1"}
     ,
     /*
      * 1.2.643.2.2.35.2
@@ -41,7 +43,8 @@ R3410_ec_params R3410_2001_paramset[] = {
      "8000000000000000000000000000000000000000000000000000000000000C99",
      "800000000000000000000000000000015F700CFFF1A624E5E497161BCC8A198F",
      "1",
-     "3FA8124359F96680B83D1C3EB2C070E5C545C9858D03ECFB744BF8D717717EFC"}
+     "3FA8124359F96680B83D1C3EB2C070E5C545C9858D03ECFB744BF8D717717EFC",
+     "1"}
     ,
     /*
      * 1.2.643.2.2.35.3
@@ -52,7 +55,8 @@ R3410_ec_params R3410_2001_paramset[] = {
      "9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B",
      "9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9",
      "0",
-     "41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67"}
+     "41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67",
+     "1"}
     ,
     /*
      * 1.2.643.2.2.36.0
@@ -63,7 +67,8 @@ R3410_ec_params R3410_2001_paramset[] = {
      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893",
      "1",
-     "8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14"}
+     "8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14",
+     "1"}
     ,
     /*
      * 1.2.643.2.2.36.1
@@ -74,9 +79,10 @@ R3410_ec_params R3410_2001_paramset[] = {
      "9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B",
      "9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9",
      "0",
-     "41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67"}
+     "41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67",
+     "1"}
     ,
-    {NID_undef, NULL, NULL, NULL, NULL, NULL, NULL}
+    {NID_undef, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 };
 
 /* Parameters of GOST 34.10-2012 */
@@ -101,7 +107,8 @@ R3410_ec_params R3410_2012_512_paramset[] = {
      "3",
      /* y */
      "7503CFE87A836AE3A61B8816E25450E6CE5E1C93ACF1ABC1778064FDCBEFA921DF16"
-     "26BE4FD036E93D75E6A50E3A41E98028FE5FC235F5B889A589CB5215F2A4"}
+     "26BE4FD036E93D75E6A50E3A41E98028FE5FC235F5B889A589CB5215F2A4",
+     "1"}
     ,
     {NID_id_tc26_gost_3410_2012_512_paramSetB,
      /* a */
@@ -120,7 +127,8 @@ R3410_ec_params R3410_2012_512_paramset[] = {
      "2",
      /* y */
      "1A8F7EDA389B094C2C071E3647A8940F3C123B697578C213BE6DD9E6C8EC7335"
-     "DCB228FD1EDF4A39152CBCAAF8C0398828041055F94CEEEC7E21340780FE41BD"}
+     "DCB228FD1EDF4A39152CBCAAF8C0398828041055F94CEEEC7E21340780FE41BD",
+     "1"}
     ,
-    {NID_undef, NULL, NULL, NULL, NULL, NULL, NULL}
+    {NID_undef, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 };