[PATCH] ecc: update GOST2012 curves

dbaryshkov at gmail.com dbaryshkov at gmail.com
Tue Nov 12 20:40:34 CET 2019


From: Paul Wolneykien <manowar at altlinux.org>

* cipher/ecc-curves.c (domain_parms): rename GOST 2012 curves to contain
  curve bit size
  (curve_aliases): rename curves, provide backwards-compatible
  aliases, add new OIDs and two new curves.
* cipher/ecc-curves.c (curve_aliases): add new OIDs and aliases for
* tests/basic.c (check_pubkey): use new name for GOST2012 512-bit test
  curve.
* tests/benchmark.c (ecc_bench): use new name for GOST2012 512-bit test
  curve.

--
Rename old GOST2012 curves to specifically mention that they are 512-bit
curves, add new OIDs for old curves and add two new curves.

Signed-off-by: Paul Wolneykien <manowar at altlinux.org>
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
---
 cipher/ecc-curves.c | 51 ++++++++++++++++++++++++++++++++++++++++-----
 tests/basic.c       |  4 ++--
 tests/benchmark.c   |  2 +-
 3 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c
index 581ba4d66e54..52872c5ec473 100644
--- a/cipher/ecc-curves.c
+++ b/cipher/ecc-curves.c
@@ -97,8 +97,21 @@ static const struct
     { "GOST2001-CryptoPro-A", "1.2.643.2.2.36.0" },
     { "GOST2001-CryptoPro-C", "1.2.643.2.2.36.1" },
 
-    { "GOST2012-tc26-A", "1.2.643.7.1.2.1.2.1" },
-    { "GOST2012-tc26-B", "1.2.643.7.1.2.1.2.2" },
+    { "GOST2012-256-tc26-A", "1.2.643.7.1.2.1.1.1" },
+    { "GOST2001-CryptoPro-A", "1.2.643.7.1.2.1.1.2" },
+    { "GOST2001-CryptoPro-A", "GOST2012-256-tc26-B" },
+    { "GOST2001-CryptoPro-B", "1.2.643.7.1.2.1.1.3" },
+    { "GOST2001-CryptoPro-B", "GOST2012-256-tc26-C" },
+    { "GOST2001-CryptoPro-C", "1.2.643.7.1.2.1.1.4" },
+    { "GOST2001-CryptoPro-C", "GOST2012-256-tc26-D" },
+
+    { "GOST2012-512-test", "GOST2012-test" },
+    { "GOST2012-512-test", "1.2.643.7.1.2.1.2.0" },
+    { "GOST2012-512-tc26-A", "GOST2012-tc26-A" },
+    { "GOST2012-512-tc26-B", "GOST2012-tc26-B" },
+    { "GOST2012-512-tc26-A", "1.2.643.7.1.2.1.2.1" },
+    { "GOST2012-512-tc26-B", "1.2.643.7.1.2.1.2.2" },
+    { "GOST2012-512-tc26-C", "1.2.643.7.1.2.1.2.3" },
 
     { "secp256k1", "1.3.132.0.10" },
 
@@ -408,7 +421,18 @@ static const ecc_domain_parms_t domain_parms[] =
       1
     },
     {
-      "GOST2012-test", 511, 0,
+      "GOST2012-256-A", 256, 0,
+      MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
+      "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd97",
+      "0xc2173f1513981673af4892c23035a27ce25e2013bf95aa33b22c656f277e7335",
+      "0x295f9bae7428ed9ccc20e7c359a9d41a22fccd9108e17bf7ba9337a6f8ae9513",
+      "0x400000000000000000000000000000000fd8cddfc87b6635c115af556c360c67",
+      "0x91e38443a5e82c0d880923425712b2bb658b9196932e02c78b2582fe742daa28",
+      "0x32879423ab1a0375895786c4bb46e9565fde0b5344766740af268adb32322e5c",
+      4
+    },
+    {
+      "GOST2012-512-test", 511, 0,
       MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
       "0x4531acd1fe0023c7550d267b6b2fee80922b14b2ffb90f04d4eb7c09b5d2d15d"
       "f1d852741af4704a0458047e80e4546d35b8336fac224dd81664bbf528be6373",
@@ -425,7 +449,7 @@ static const ecc_domain_parms_t domain_parms[] =
       1
     },
     {
-      "GOST2012-tc26-A", 512, 0,
+      "GOST2012-512-tc26-A", 512, 0,
       MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
       "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
         "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc7",
@@ -442,7 +466,7 @@ static const ecc_domain_parms_t domain_parms[] =
       1
     },
     {
-      "GOST2012-tc26-B", 512, 0,
+      "GOST2012-512-tc26-B", 512, 0,
       MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
       "0x8000000000000000000000000000000000000000000000000000000000000000"
         "000000000000000000000000000000000000000000000000000000000000006f",
@@ -458,6 +482,23 @@ static const ecc_domain_parms_t domain_parms[] =
         "dcb228fd1edf4a39152cbcaaf8c0398828041055f94ceeec7e21340780fe41bd",
       1
     },
+    {
+      "GOST2012-512-tc26-C", 512, 0,
+      MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
+      "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+        "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc7",
+      "0xdc9203e514a721875485a529d2c722fb187bc8980eb866644de41c68e1430645"
+        "46e861c0e2c9edd92ade71f46fcf50ff2ad97f951fda9f2a2eb6546f39689bd3",
+      "0xb4c4ee28cebc6c2c8ac12952cf37f16ac7efb6a9f69f4b57ffda2e4f0de5ade0"
+        "38cbc2fff719d2c18de0284b8bfef3b52b8cc7a5f5bf0a3c8d2319a5312557e1",
+      "0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
+        "c98cdba46506ab004c33a9ff5147502cc8eda9e7a769a12694623cef47f023ed",
+      "0xe2e31edfc23de7bdebe241ce593ef5de2295b7a9cbaef021d385f7074cea043a"
+        "a27272a7ae602bf2a7b9033db9ed3610c6fb85487eae97aac5bc7928c1950148",
+      "0xf5ce40d95b5eb899abbccff5911cb8577939804d6527378b8c108c3d2090ff9be"
+        "18e2d33e3021ed2ef32d85822423b6304f726aa854bae07d0396e9a9addc40f",
+      4
+    },
 
     {
       "secp256k1", 256, 0,
diff --git a/tests/basic.c b/tests/basic.c
index b798eaafa21c..8337bcfb7ba0 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -13227,7 +13227,7 @@ check_pubkey (void)
     {
       "(private-key\n"
       " (ecc\n"
-      "  (curve GOST2012-test)\n"
+      "  (curve GOST2012-512-test)\n"
       "  (q #04115DC5BC96760C7B48598D8AB9E740D4C4A85A65BE33C1"
       "        815B5C320C854621DD5A515856D13314AF69BC5B924C8B"
       "        4DDFF75C45415C1D9DD9DD33612CD530EFE137C7C90CD4"
@@ -13240,7 +13240,7 @@ check_pubkey (void)
 
       "(public-key\n"
       " (ecc\n"
-      "  (curve GOST2012-test)\n"
+      "  (curve GOST2012-512-test)\n"
       "  (q #04115DC5BC96760C7B48598D8AB9E740D4C4A85A65BE33C1"
       "        815B5C320C854621DD5A515856D13314AF69BC5B924C8B"
       "        4DDFF75C45415C1D9DD9DD33612CD530EFE137C7C90CD4"
diff --git a/tests/benchmark.c b/tests/benchmark.c
index 0f15c0d89fe7..a245152c0228 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -1528,7 +1528,7 @@ ecc_bench (int iterations, int print_header)
       else if (is_gost)
         err = gcry_sexp_build (&key_spec, NULL,
                                "(genkey (ecdsa (curve %s)))",
-                               p_size == 256 ? "GOST2001-test" : "GOST2012-test");
+                               p_size == 256 ? "GOST2001-test" : "GOST2012-512-test");
       else
         err = gcry_sexp_build (&key_spec, NULL,
                                "(genkey (ECDSA (nbits %d)))", p_size);
-- 
2.24.0




More information about the Gcrypt-devel mailing list