diff options
author | David Hook <dgh@cryptoworkshop.com> | 2019-01-20 11:19:49 +1100 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2019-01-20 11:19:49 +1100 |
commit | 9480083a2bdc5dea14e69c6ebb263d227d981d3f (patch) | |
tree | 97ff82de5c2d0a3b1fa74bd1c588ebaae4df6f2d /crypto/src | |
parent | fixed file name (diff) | |
parent | minor tweaking (diff) | |
download | BouncyCastle.NET-ed25519-9480083a2bdc5dea14e69c6ebb263d227d981d3f.tar.xz |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/cms/KeyTransRecipientInformation.cs | 14 | ||||
-rw-r--r-- | crypto/src/crypto/digests/GOST3411_2012Digest.cs | 6 | ||||
-rw-r--r-- | crypto/src/crypto/digests/GOST3411_2012_256Digest.cs | 8 | ||||
-rw-r--r-- | crypto/src/crypto/digests/GOST3411_2012_512Digest.cs | 8 | ||||
-rw-r--r-- | crypto/src/crypto/operators/Asn1KeyWrapper.cs | 15 | ||||
-rw-r--r-- | crypto/src/crypto/parameters/ECGOST3410Parameters.cs | 6 | ||||
-rw-r--r-- | crypto/src/crypto/signers/EcGost3410_2012Signer.cs | 4 | ||||
-rw-r--r-- | crypto/src/pkcs/PrivateKeyInfoFactory.cs | 4 | ||||
-rw-r--r-- | crypto/src/security/DigestUtilities.cs | 4 | ||||
-rw-r--r-- | crypto/src/security/PrivateKeyFactory.cs | 12 | ||||
-rw-r--r-- | crypto/src/security/PublicKeyFactory.cs | 4 | ||||
-rw-r--r-- | crypto/src/x509/SubjectPublicKeyInfoFactory.cs | 4 |
12 files changed, 48 insertions, 41 deletions
diff --git a/crypto/src/cms/KeyTransRecipientInformation.cs b/crypto/src/cms/KeyTransRecipientInformation.cs index 3b1ea7b5e..7d2f072b5 100644 --- a/crypto/src/cms/KeyTransRecipientInformation.cs +++ b/crypto/src/cms/KeyTransRecipientInformation.cs @@ -55,12 +55,18 @@ namespace Org.BouncyCastle.Cms } private string GetExchangeEncryptionAlgorithmName( - DerObjectIdentifier oid) + AlgorithmIdentifier algo) { - if (Asn1Pkcs.PkcsObjectIdentifiers.RsaEncryption.Equals(oid)) + DerObjectIdentifier oid = algo.Algorithm; + + if (Asn1Pkcs.PkcsObjectIdentifiers.RsaEncryption.Equals(oid)) { return "RSA//PKCS1Padding"; - } + } else if (Asn1Pkcs.PkcsObjectIdentifiers.IdRsaesOaep.Equals(oid)) + { + Asn1Pkcs.RsaesOaepParameters rsaParams = Asn1Pkcs.RsaesOaepParameters.GetInstance(algo.Parameters); + return "RSA//OAEPWITH"+DigestUtilities.GetAlgorithmName(rsaParams.HashAlgorithm.Algorithm)+"ANDMGF1Padding"; + } return oid.Id; } @@ -68,7 +74,7 @@ namespace Org.BouncyCastle.Cms internal KeyParameter UnwrapKey(ICipherParameters key) { byte[] encryptedKey = info.EncryptedKey.GetOctets(); - string keyExchangeAlgorithm = GetExchangeEncryptionAlgorithmName(keyEncAlg.Algorithm); + string keyExchangeAlgorithm = GetExchangeEncryptionAlgorithmName(keyEncAlg); try { diff --git a/crypto/src/crypto/digests/GOST3411_2012Digest.cs b/crypto/src/crypto/digests/GOST3411_2012Digest.cs index 439512924..68cb6c035 100644 --- a/crypto/src/crypto/digests/GOST3411_2012Digest.cs +++ b/crypto/src/crypto/digests/GOST3411_2012Digest.cs @@ -4,7 +4,7 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Crypto.Digests { - public abstract class GOST3411_2012Digest:IDigest,IMemoable + public abstract class Gost3411_2012Digest:IDigest,IMemoable { private readonly byte[] IV = new byte[64]; private readonly byte[] N = new byte[64]; @@ -19,7 +19,7 @@ namespace Org.BouncyCastle.Crypto.Digests private int bOff = 64; - protected GOST3411_2012Digest(byte[] IV) + protected Gost3411_2012Digest(byte[] IV) { System.Array.Copy(IV,this.IV,64); System.Array.Copy(IV, h, 64); @@ -79,7 +79,7 @@ namespace Org.BouncyCastle.Crypto.Digests public void Reset(IMemoable other) { - GOST3411_2012Digest o = (GOST3411_2012Digest)other; + Gost3411_2012Digest o = (Gost3411_2012Digest)other; System.Array.Copy(o.IV, 0, this.IV, 0, 64); System.Array.Copy(o.N, 0, this.N, 0, 64); diff --git a/crypto/src/crypto/digests/GOST3411_2012_256Digest.cs b/crypto/src/crypto/digests/GOST3411_2012_256Digest.cs index 8686851e2..77cf6c50f 100644 --- a/crypto/src/crypto/digests/GOST3411_2012_256Digest.cs +++ b/crypto/src/crypto/digests/GOST3411_2012_256Digest.cs @@ -3,7 +3,7 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Crypto.Digests { - public class GOST3411_2012_256Digest : GOST3411_2012Digest + public class Gost3411_2012_256Digest : Gost3411_2012Digest { private readonly static byte[] IV = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -21,12 +21,12 @@ namespace Org.BouncyCastle.Crypto.Digests get { return "GOST3411-2012-256"; } } - public GOST3411_2012_256Digest() : base(IV) + public Gost3411_2012_256Digest() : base(IV) { } - public GOST3411_2012_256Digest(GOST3411_2012_256Digest other) : base(IV) + public Gost3411_2012_256Digest(Gost3411_2012_256Digest other) : base(IV) { Reset(other); } @@ -48,7 +48,7 @@ namespace Org.BouncyCastle.Crypto.Digests public override IMemoable Copy() { - return new GOST3411_2012_256Digest(this); + return new Gost3411_2012_256Digest(this); } } } diff --git a/crypto/src/crypto/digests/GOST3411_2012_512Digest.cs b/crypto/src/crypto/digests/GOST3411_2012_512Digest.cs index eb40aba1d..2b77e36a9 100644 --- a/crypto/src/crypto/digests/GOST3411_2012_512Digest.cs +++ b/crypto/src/crypto/digests/GOST3411_2012_512Digest.cs @@ -3,7 +3,7 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Crypto.Digests { - public class GOST3411_2012_512Digest:GOST3411_2012Digest + public class Gost3411_2012_512Digest:Gost3411_2012Digest { private readonly static byte[] IV = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -21,11 +21,11 @@ namespace Org.BouncyCastle.Crypto.Digests get { return "GOST3411-2012-512"; } } - public GOST3411_2012_512Digest():base(IV) + public Gost3411_2012_512Digest():base(IV) { } - public GOST3411_2012_512Digest(GOST3411_2012_512Digest other) : base(IV) + public Gost3411_2012_512Digest(Gost3411_2012_512Digest other) : base(IV) { Reset(other); } @@ -37,7 +37,7 @@ namespace Org.BouncyCastle.Crypto.Digests public override IMemoable Copy() { - return new GOST3411_2012_512Digest(this); + return new Gost3411_2012_512Digest(this); } } } diff --git a/crypto/src/crypto/operators/Asn1KeyWrapper.cs b/crypto/src/crypto/operators/Asn1KeyWrapper.cs index 527e3df31..ffce7f63a 100644 --- a/crypto/src/crypto/operators/Asn1KeyWrapper.cs +++ b/crypto/src/crypto/operators/Asn1KeyWrapper.cs @@ -12,6 +12,7 @@ using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Asn1.Oiw; using Org.BouncyCastle.Asn1.Nist; +using Org.BouncyCastle.Security; namespace Org.BouncyCastle.Crypto.Operators { @@ -106,33 +107,33 @@ namespace Org.BouncyCastle.Crypto.Operators { internal static object Rsa_Sha1_Oaep(bool forWrapping, ICipherParameters parameters) { - return new RsaOaepWrapper(forWrapping, parameters, OiwObjectIdentifiers.IdSha1, new Sha1Digest()); + return new RsaOaepWrapper(forWrapping, parameters, OiwObjectIdentifiers.IdSha1); } internal static object Rsa_Sha224_Oaep(bool forWrapping, ICipherParameters parameters) { - return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha224, new Sha224Digest()); + return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha224); } internal static object Rsa_Sha256_Oaep(bool forWrapping, ICipherParameters parameters) { - return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha256, new Sha256Digest()); + return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha256); } internal static object Rsa_Sha384_Oaep(bool forWrapping, ICipherParameters parameters) { - return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha384, new Sha384Digest()); + return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha384); } internal static object Rsa_Sha512_Oaep(bool forWrapping, ICipherParameters parameters) { - return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha512, new Sha512Digest()); + return new RsaOaepWrapper(forWrapping, parameters, NistObjectIdentifiers.IdSha512); } private readonly AlgorithmIdentifier algId; private readonly IAsymmetricBlockCipher engine; - public RsaOaepWrapper(bool forWrapping, ICipherParameters parameters, DerObjectIdentifier digestOid, IDigest digest) + public RsaOaepWrapper(bool forWrapping, ICipherParameters parameters, DerObjectIdentifier digestOid) { AlgorithmIdentifier digestAlgId = new AlgorithmIdentifier(digestOid, DerNull.Instance); @@ -142,7 +143,7 @@ namespace Org.BouncyCastle.Crypto.Operators digestAlgId, new AlgorithmIdentifier(PkcsObjectIdentifiers.IdMgf1, digestAlgId), RsaesOaepParameters.DefaultPSourceAlgorithm)); - this.engine = new OaepEncoding(new RsaBlindedEngine()); + this.engine = new OaepEncoding(new RsaBlindedEngine(), DigestUtilities.GetDigest(digestOid) ); this.engine.Init(forWrapping, parameters); } diff --git a/crypto/src/crypto/parameters/ECGOST3410Parameters.cs b/crypto/src/crypto/parameters/ECGOST3410Parameters.cs index ede7433d6..a3aa1953c 100644 --- a/crypto/src/crypto/parameters/ECGOST3410Parameters.cs +++ b/crypto/src/crypto/parameters/ECGOST3410Parameters.cs @@ -4,7 +4,7 @@ using Org.BouncyCastle.Math.EC; namespace Org.BouncyCastle.Crypto.Parameters { - public class ECGOST3410Parameters : ECNamedDomainParameters + public class ECGost3410Parameters : ECNamedDomainParameters { private readonly DerObjectIdentifier _publicKeyParamSet; @@ -26,7 +26,7 @@ namespace Org.BouncyCastle.Crypto.Parameters get { return _encryptionParamSet; } } - public ECGOST3410Parameters( + public ECGost3410Parameters( ECNamedDomainParameters dp, DerObjectIdentifier publicKeyParamSet, DerObjectIdentifier digestParamSet, @@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Crypto.Parameters } - public ECGOST3410Parameters(ECDomainParameters dp, DerObjectIdentifier publicKeyParamSet, + public ECGost3410Parameters(ECDomainParameters dp, DerObjectIdentifier publicKeyParamSet, DerObjectIdentifier digestParamSet, DerObjectIdentifier encryptionParamSet) : base(publicKeyParamSet, dp.Curve, dp.G, dp.N, dp.H, dp.GetSeed()) { diff --git a/crypto/src/crypto/signers/EcGost3410_2012Signer.cs b/crypto/src/crypto/signers/EcGost3410_2012Signer.cs index e7174ace6..c94f2c7d1 100644 --- a/crypto/src/crypto/signers/EcGost3410_2012Signer.cs +++ b/crypto/src/crypto/signers/EcGost3410_2012Signer.cs @@ -10,7 +10,7 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Crypto.Signers { - public class ECGOST3410_2012Signer : IDsaExt + public class ECGost3410_2012Signer : IDsaExt { private ECKeyParameters key; private SecureRandom secureRandom; @@ -150,4 +150,4 @@ namespace Org.BouncyCastle.Crypto.Signers return new FixedPointCombMultiplier(); } } -} \ No newline at end of file +} diff --git a/crypto/src/pkcs/PrivateKeyInfoFactory.cs b/crypto/src/pkcs/PrivateKeyInfoFactory.cs index 75a56983a..0d5026909 100644 --- a/crypto/src/pkcs/PrivateKeyInfoFactory.cs +++ b/crypto/src/pkcs/PrivateKeyInfoFactory.cs @@ -124,9 +124,9 @@ namespace Org.BouncyCastle.Pkcs ECDomainParameters dp = priv.Parameters; // ECGOST3410 - if (dp is ECGOST3410Parameters) + if (dp is ECGost3410Parameters) { - ECGOST3410Parameters domainParameters = (ECGOST3410Parameters) dp; + ECGost3410Parameters domainParameters = (ECGost3410Parameters) dp; Gost3410PublicKeyAlgParameters gostParams = new Gost3410PublicKeyAlgParameters( (domainParameters).PublicKeyParamSet, diff --git a/crypto/src/security/DigestUtilities.cs b/crypto/src/security/DigestUtilities.cs index 24a68f63d..7685e3384 100644 --- a/crypto/src/security/DigestUtilities.cs +++ b/crypto/src/security/DigestUtilities.cs @@ -213,8 +213,8 @@ namespace Org.BouncyCastle.Security case DigestAlgorithm.DSTU7564_384: return new Dstu7564Digest(384); case DigestAlgorithm.DSTU7564_512: return new Dstu7564Digest(512); case DigestAlgorithm.GOST3411: return new Gost3411Digest(); - case DigestAlgorithm.GOST3411_2012_256: return new GOST3411_2012_256Digest(); - case DigestAlgorithm.GOST3411_2012_512: return new GOST3411_2012_512Digest(); + case DigestAlgorithm.GOST3411_2012_256: return new Gost3411_2012_256Digest(); + case DigestAlgorithm.GOST3411_2012_512: return new Gost3411_2012_512Digest(); case DigestAlgorithm.KECCAK_224: return new KeccakDigest(224); case DigestAlgorithm.KECCAK_256: return new KeccakDigest(256); case DigestAlgorithm.KECCAK_288: return new KeccakDigest(288); diff --git a/crypto/src/security/PrivateKeyFactory.cs b/crypto/src/security/PrivateKeyFactory.cs index 9f2d2e9c1..f7709160d 100644 --- a/crypto/src/security/PrivateKeyFactory.cs +++ b/crypto/src/security/PrivateKeyFactory.cs @@ -192,7 +192,7 @@ namespace Org.BouncyCastle.Security || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256)) { Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(keyInfo.PrivateKeyAlgorithm.Parameters); - ECGOST3410Parameters ecSpec = null; + ECGost3410Parameters ecSpec = null; BigInteger d = null; Asn1Object p = keyInfo.PrivateKeyAlgorithm.Parameters.ToAsn1Object(); if (p is Asn1Sequence && (Asn1Sequence.GetInstance(p).Count == 2 || Asn1Sequence.GetInstance(p).Count == 3)) @@ -200,7 +200,7 @@ namespace Org.BouncyCastle.Security ECDomainParameters ecP = ECGost3410NamedCurves.GetByOid(gostParams.PublicKeyParamSet); - ecSpec = new ECGOST3410Parameters( + ecSpec = new ECGost3410Parameters( new ECNamedDomainParameters( gostParams.PublicKeyParamSet, ecP), gostParams.PublicKeyParamSet, @@ -237,7 +237,7 @@ namespace Org.BouncyCastle.Security if (ecP == null) { ECDomainParameters gParam = ECGost3410NamedCurves.GetByOid(oid); - ecSpec = new ECGOST3410Parameters(new ECNamedDomainParameters( + ecSpec = new ECGost3410Parameters(new ECNamedDomainParameters( oid, gParam.Curve, gParam.G, @@ -248,7 +248,7 @@ namespace Org.BouncyCastle.Security } else { - ecSpec = new ECGOST3410Parameters(new ECNamedDomainParameters( + ecSpec = new ECGost3410Parameters(new ECNamedDomainParameters( oid, ecP.Curve, ecP.G, @@ -265,7 +265,7 @@ namespace Org.BouncyCastle.Security else { X9ECParameters ecP = X9ECParameters.GetInstance(parameters.Parameters); - ecSpec = new ECGOST3410Parameters(new ECNamedDomainParameters( + ecSpec = new ECGost3410Parameters(new ECNamedDomainParameters( algOid, ecP.Curve, ecP.G, @@ -292,7 +292,7 @@ namespace Org.BouncyCastle.Security return new ECPrivateKeyParameters( d, - new ECGOST3410Parameters( + new ECGost3410Parameters( ecSpec, gostParams.PublicKeyParamSet, gostParams.DigestParamSet, diff --git a/crypto/src/security/PublicKeyFactory.cs b/crypto/src/security/PublicKeyFactory.cs index 3623c3ee2..7a34d71df 100644 --- a/crypto/src/security/PublicKeyFactory.cs +++ b/crypto/src/security/PublicKeyFactory.cs @@ -261,8 +261,8 @@ namespace Org.BouncyCastle.Security Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(keyInfo.AlgorithmID.Parameters); - ECGOST3410Parameters ecDomainParameters = - new ECGOST3410Parameters( + ECGost3410Parameters ecDomainParameters = + new ECGost3410Parameters( new ECNamedDomainParameters(gostParams.PublicKeyParamSet, ECGost3410NamedCurves.GetByOid(gostParams.PublicKeyParamSet)), gostParams.PublicKeyParamSet, gostParams.DigestParamSet, diff --git a/crypto/src/x509/SubjectPublicKeyInfoFactory.cs b/crypto/src/x509/SubjectPublicKeyInfoFactory.cs index 234bcff34..395c31263 100644 --- a/crypto/src/x509/SubjectPublicKeyInfoFactory.cs +++ b/crypto/src/x509/SubjectPublicKeyInfoFactory.cs @@ -98,9 +98,9 @@ namespace Org.BouncyCastle.X509 ECPublicKeyParameters _key = (ECPublicKeyParameters) publicKey; - if (_key.Parameters is ECGOST3410Parameters) + if (_key.Parameters is ECGost3410Parameters) { - ECGOST3410Parameters gostParams = (ECGOST3410Parameters)_key.Parameters; + ECGost3410Parameters gostParams = (ECGost3410Parameters)_key.Parameters; BigInteger bX = _key.Q.AffineXCoord.ToBigInteger(); BigInteger bY = _key.Q.AffineYCoord.ToBigInteger(); |