aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Chikunov <vt@altlinux.org>2019-01-24 04:32:28 +0300
committerVitaly Chikunov <vt@altlinux.org>2019-01-26 01:52:06 +0300
commitb2e0f8c6e708e70fcfea9384095aa48f2774af47 (patch)
treed40f7124ffd5913be759da36ad5a6d784dbde8d0
parent0a514524c7d003329a47d339f623312db390b344 (diff)
downloadgost-engine-b2e0f8c6e708e70fcfea9384095aa48f2774af47.zip
gost-engine-b2e0f8c6e708e70fcfea9384095aa48f2774af47.tar.gz
gost-engine-b2e0f8c6e708e70fcfea9384095aa48f2774af47.tar.bz2
Allow key creation using TC26 (2012) parameters
R 1323565.1.023-2018 forbids encoding hash oid into TC26 (2012) parameters in AlgorithmIdentifier, so this is removed. New "paramset" names for 256-bit TC26 parameters: TCA, TCB, TCC, TCD, for 512-bit parameter: C. Using these new OIDs for gost2012_256: NID_id_tc26_gost_3410_2012_256_paramSetA = TCA NID_id_tc26_gost_3410_2012_256_paramSetB = TCB NID_id_tc26_gost_3410_2012_256_paramSetC = TCC NID_id_tc26_gost_3410_2012_256_paramSetD = TCD for gost2012_512: NID_id_tc26_gost_3410_2012_512_paramSetC = C Resolves #84.
-rw-r--r--README.gost4
-rw-r--r--gost_ameth.c11
-rw-r--r--gost_ec_sign.c2
-rw-r--r--gost_pmeth.c28
4 files changed, 40 insertions, 5 deletions
diff --git a/README.gost b/README.gost
index db6b4b9..3579665 100644
--- a/README.gost
+++ b/README.gost
@@ -70,8 +70,8 @@ USAGE WITH COMMAND LINE openssl UTILITY
Use -pkeyopt option to pass paramset to algorithm. The following paramsets
are supported by
gost2001: 0,A,B,C,XA,XB
- gost2012_256: 0,A,B,C,XA,XB
- gost2012_512: A,B
+ gost2012_256: 0,A,B,C,XA,XB,TCA,TCB,TCC,TCD
+ gost2012_512: A,B,C
You can also use numeric representation of OID as to destinate
paramset.
diff --git a/gost_ameth.c b/gost_ameth.c
index df59520..6ae2786 100644
--- a/gost_ameth.c
+++ b/gost_ameth.c
@@ -67,11 +67,18 @@ static ASN1_STRING *encode_gost_algor_params(const EVP_PKEY *key)
switch (EVP_PKEY_base_id(key)) {
case NID_id_GostR3410_2012_256:
pkey_param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(key_ptr));
- gkp->hash_params = OBJ_nid2obj(NID_id_GostR3411_2012_256);
+ switch (pkey_param_nid) {
+ case NID_id_GostR3410_2001_TestParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_A_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_B_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_C_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet:
+ case NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet:
+ gkp->hash_params = OBJ_nid2obj(NID_id_GostR3411_2012_256);
+ }
break;
case NID_id_GostR3410_2012_512:
pkey_param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(key_ptr));
- gkp->hash_params = OBJ_nid2obj(NID_id_GostR3411_2012_512);
break;
case NID_id_GostR3410_2001:
pkey_param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(key_ptr));
diff --git a/gost_ec_sign.c b/gost_ec_sign.c
index ba12783..3db118a 100644
--- a/gost_ec_sign.c
+++ b/gost_ec_sign.c
@@ -146,7 +146,7 @@ int fill_GOST_EC_params(EC_KEY *eckey, int nid)
GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_INTERNAL_ERROR);
goto end;
}
- EC_GROUP_set_curve_name(grp, params->nid);
+ EC_GROUP_set_curve_name(grp, nid);
if (!EC_KEY_set_group(eckey, grp)) {
GOSTerr(GOST_F_FILL_GOST_EC_PARAMS, ERR_R_INTERNAL_ERROR);
goto end;
diff --git a/gost_pmeth.c b/gost_pmeth.c
index b2e0a49..41bda94 100644
--- a/gost_pmeth.c
+++ b/gost_pmeth.c
@@ -208,6 +208,25 @@ static int pkey_gost_ec_ctrl_str_256(EVP_PKEY_CTX *ctx,
default:
return 0;
}
+ } else if ((strlen(value) == 3)
+ && (toupper((unsigned char)value[0]) == 'T')
+ && (toupper((unsigned char)value[1]) == 'C')) {
+ switch (toupper((unsigned char)value[2])) {
+ case 'A':
+ param_nid = NID_id_tc26_gost_3410_2012_256_paramSetA;
+ break;
+ case 'B':
+ param_nid = NID_id_tc26_gost_3410_2012_256_paramSetB;
+ break;
+ case 'C':
+ param_nid = NID_id_tc26_gost_3410_2012_256_paramSetC;
+ break;
+ case 'D':
+ param_nid = NID_id_tc26_gost_3410_2012_256_paramSetD;
+ break;
+ default:
+ return 0;
+ }
} else {
R3410_ec_params *p = R3410_2001_paramset;
param_nid = OBJ_txt2nid(value);
@@ -252,6 +271,10 @@ static int pkey_gost_ec_ctrl_str_512(EVP_PKEY_CTX *ctx,
param_nid = NID_id_tc26_gost_3410_2012_512_paramSetB;
break;
+ case 'C':
+ param_nid = NID_id_tc26_gost_3410_2012_512_paramSetC;
+ break;
+
default:
return 0;
}
@@ -320,6 +343,7 @@ static int pkey_gost2012_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
switch (data->sign_param_nid) {
case NID_id_tc26_gost_3410_2012_512_paramSetA:
case NID_id_tc26_gost_3410_2012_512_paramSetB:
+ case NID_id_tc26_gost_3410_2012_512_paramSetC:
result =
(EVP_PKEY_assign(pkey, NID_id_GostR3410_2012_512, ec)) ? 1 : 0;
break;
@@ -330,6 +354,10 @@ static int pkey_gost2012_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
case NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet:
case NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet:
case NID_id_GostR3410_2001_TestParamSet:
+ case NID_id_tc26_gost_3410_2012_256_paramSetA:
+ case NID_id_tc26_gost_3410_2012_256_paramSetB:
+ case NID_id_tc26_gost_3410_2012_256_paramSetC:
+ case NID_id_tc26_gost_3410_2012_256_paramSetD:
result =
(EVP_PKEY_assign(pkey, NID_id_GostR3410_2012_256, ec)) ? 1 : 0;
break;