@@ -240,18 +240,39 @@ public void doTestECDsa(
240
240
// }
241
241
}
242
242
243
- public void doTestECGost (
244
- string name )
243
+ public void doTestECGost ( string name )
245
244
{
246
- // ECGenParameterSpec ecSpec = new ECGenParameterSpec(name);
247
- ECDomainParameters ecSpec = GetCurveParameters ( name ) ;
245
+ ISigner sgr ;
246
+ string keyAlgorithm ;
247
+
248
+ if ( name . IndexOf ( "Tc26-Gost-3410" ) == 0 )
249
+ {
250
+ // TODO Implement ECGOST3410-2012 in SignerUtilies/GeneratorUtilities etc.
251
+ // Current test cases don't work for GOST34.10 2012
252
+ return ;
253
+
254
+ keyAlgorithm = "ECGOST3410-2012" ;
255
+ if ( name . IndexOf ( "256" ) > 0 )
256
+ {
257
+ sgr = SignerUtilities . GetSigner ( "ECGOST3410-2012-256" ) ;
258
+ }
259
+ else
260
+ {
261
+ sgr = SignerUtilities . GetSigner ( "ECGOST3410-2012-512" ) ;
262
+ }
263
+ }
264
+ else
265
+ {
266
+ keyAlgorithm = "ECGOST3410" ;
248
267
249
- IAsymmetricCipherKeyPairGenerator g = GeneratorUtilities . GetKeyPairGenerator ( "ECGOST3410" ) ;
268
+ sgr = SignerUtilities . GetSigner ( "ECGOST3410" ) ;
269
+ }
250
270
251
- // g.initialize(ecSpec, new SecureRandom());
271
+ ECDomainParameters ecSpec = GetCurveParameters ( name ) ;
272
+
273
+ IAsymmetricCipherKeyPairGenerator g = GeneratorUtilities . GetKeyPairGenerator ( keyAlgorithm ) ;
252
274
g . Init ( new ECKeyGenerationParameters ( ecSpec , new SecureRandom ( ) ) ) ;
253
275
254
- ISigner sgr = SignerUtilities . GetSigner ( "ECGOST3410" ) ;
255
276
AsymmetricCipherKeyPair pair = g . GenerateKeyPair ( ) ;
256
277
AsymmetricKeyParameter sKey = pair . Private ;
257
278
AsymmetricKeyParameter vKey = pair . Public ;
@@ -280,7 +301,7 @@ public void doTestECGost(
280
301
//// byte[] pubEnc = vKey.getEncoded();
281
302
// byte[] pubEnc = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(vKey).GetDerEncoded();
282
303
//
283
- //// KeyFactory keyFac = KeyFactory.getInstance("ECGOST3410" );
304
+ //// KeyFactory keyFac = KeyFactory.getInstance(keyAlgorithm );
284
305
//// X509EncodedKeySpec pubX509 = new X509EncodedKeySpec(pubEnc);
285
306
//// ECPublicKey pubKey = (ECPublicKey)keyFac.generatePublic(pubX509);
286
307
// ECPublicKeyParameters pubKey = (ECPublicKeyParameters) PublicKeyFactory.CreateKey(pubEnc);
@@ -369,10 +390,6 @@ public override void PerformTest()
369
390
370
391
foreach ( string name in ECGost3410NamedCurves . Names )
371
392
{
372
- // Current test cases don't work for GOST34.10 2012
373
- if ( name . IndexOf ( "3410-12" ) >= 0 )
374
- continue ;
375
-
376
393
doTestECGost ( name ) ;
377
394
}
378
395
}
0 commit comments