From 83902f1f1dbc8263a0c3f61be59cd2eb95293c97 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin-Solenikov Date: Tue, 15 Oct 2013 23:56:44 +0400 Subject: ecc: Add support for GOST R 34.10-2001/-2012 signatures * src/cipher.h: define PUBKEY_FLAG_GOST * cipher/ecc-curves.c: Add GOST2001-test and GOST2012-test curves defined in standards. Typical applications would use either those curves, or curves defined in RFC 4357 (will be added later). * cipher/ecc.c (sign_gost, verify_gost): New. (ecc_sign, ecc_verify): use sign_gost/verify_gost if PUBKEY_FLAG_GOST is set. (ecc_names): add "gost" for gost signatures. * cipher/pubkey-util.c (_gcry_pk_util_parse_flaglist, _gcry_pk_util_preparse_sigval): set PUBKEY_FLAG_GOST if gost flag is present in s-exp. * tests/benchmark.c (ecc_bench): also benchmark GOST signatures. * tests/basic.c (check_pubkey): add two public keys from GOST R 34.10-2012 standard. (check_pubkey_sign_ecdsa): add two data sets to check gost signatures. * tests/curves.c: correct N_CURVES as we now have 2 more curves. Signed-off-by: Dmitry Eremin-Solenikov Removed some comments from the new curve definitions in ecc-curves.c to avoid line wrapping. Eventually we will develop a precompiler to avoid parsing those hex strings. -wk --- cipher/pubkey-util.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cipher/pubkey-util.c') diff --git a/cipher/pubkey-util.c b/cipher/pubkey-util.c index 0b90054f..0db5840b 100644 --- a/cipher/pubkey-util.c +++ b/cipher/pubkey-util.c @@ -79,6 +79,11 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list, { flags |= PUBKEY_FLAG_ECDSA; } + else if (n == 4 && !memcmp (s, "gost", 4)) + { + encoding = PUBKEY_ENC_RAW; + flags |= PUBKEY_FLAG_GOST; + } else if (n == 3 && !memcmp (s, "raw", 3) && encoding == PUBKEY_ENC_UNKNOWN) { @@ -347,6 +352,8 @@ _gcry_pk_util_preparse_sigval (gcry_sexp_t s_sig, const char **algo_names, { if (!strcmp (name, "eddsa")) *r_eccflags = PUBKEY_FLAG_EDDSA; + if (!strcmp (name, "gost")) + *r_eccflags = PUBKEY_FLAG_GOST; } *r_parms = l2; -- cgit v1.2.1