From 6ec14b34bcc90f0dba33c5bf5197c67efd4edee4 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 4 Oct 2022 12:04:57 +0700 Subject: Support GOST agreement OIDs --- crypto/src/security/PrivateKeyFactory.cs | 10 ++++++---- crypto/src/security/PublicKeyFactory.cs | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'crypto') diff --git a/crypto/src/security/PrivateKeyFactory.cs b/crypto/src/security/PrivateKeyFactory.cs index 3c57297fe..d9d855c45 100644 --- a/crypto/src/security/PrivateKeyFactory.cs +++ b/crypto/src/security/PrivateKeyFactory.cs @@ -186,16 +186,18 @@ namespace Org.BouncyCastle.Security { return new Ed448PrivateKeyParameters(GetRawKey(keyInfo)); } - else if (algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512) - || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256)) + else if (algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256) + || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512) + || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_agreement_gost_3410_12_256) + || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_agreement_gost_3410_12_512)) { - Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(keyInfo.PrivateKeyAlgorithm.Parameters); + Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance( + keyInfo.PrivateKeyAlgorithm.Parameters); ECGost3410Parameters ecSpec; BigInteger d; Asn1Object p = keyInfo.PrivateKeyAlgorithm.Parameters.ToAsn1Object(); if (p is Asn1Sequence && (Asn1Sequence.GetInstance(p).Count == 2 || Asn1Sequence.GetInstance(p).Count == 3)) { - X9ECParameters ecP = ECGost3410NamedCurves.GetByOid(gostParams.PublicKeyParamSet); ecSpec = new ECGost3410Parameters( diff --git a/crypto/src/security/PublicKeyFactory.cs b/crypto/src/security/PublicKeyFactory.cs index 49ad49dd0..e0c7ce950 100644 --- a/crypto/src/security/PublicKeyFactory.cs +++ b/crypto/src/security/PublicKeyFactory.cs @@ -228,7 +228,9 @@ namespace Org.BouncyCastle.Security return new Ed448PublicKeyParameters(GetRawKey(keyInfo)); } else if (algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256) - || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512)) + || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512) + || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_agreement_gost_3410_12_256) + || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_agreement_gost_3410_12_512)) { Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(algID.Parameters); DerObjectIdentifier publicKeyParamSet = gostParams.PublicKeyParamSet; -- cgit 1.4.1