diff options
Diffstat (limited to 'crypto/test')
5 files changed, 54 insertions, 47 deletions
diff --git a/crypto/test/UnitTests.csproj b/crypto/test/UnitTests.csproj index 2dd3547fa..d36877026 100644 --- a/crypto/test/UnitTests.csproj +++ b/crypto/test/UnitTests.csproj @@ -137,6 +137,7 @@ <Compile Include="src\cms\test\Rfc4134Test.cs" /> <Compile Include="src\cms\test\SignedDataStreamTest.cs" /> <Compile Include="src\cms\test\SignedDataTest.cs" /> + <Compile Include="src\crmf\test\CrmfTest.cs" /> <Compile Include="src\crypto\examples\DESExample.cs" /> <Compile Include="src\crypto\io\test\AllTests.cs" /> <Compile Include="src\crypto\io\test\CipherStreamTest.cs" /> @@ -185,11 +186,13 @@ <Compile Include="src\crypto\test\EAXTest.cs" /> <Compile Include="src\crypto\test\ECDHKEKGeneratorTest.cs" /> <Compile Include="src\crypto\test\ECGOST3410Test.cs" /> + <Compile Include="src\crypto\test\ECGOST3410_2012Test.cs" /> <Compile Include="src\crypto\test\ECIESTest.cs" /> <Compile Include="src\crypto\test\ECNRTest.cs" /> <Compile Include="src\crypto\test\ECTest.cs" /> <Compile Include="src\crypto\test\Ed25519Test.cs" /> <Compile Include="src\crypto\test\Ed448Test.cs" /> + <Compile Include="src\crypto\test\EGOST3410_2012SignatureTest.cs" /> <Compile Include="src\crypto\test\ElGamalTest.cs" /> <Compile Include="src\crypto\test\EqualsHashCodeTest.cs" /> <Compile Include="src\crypto\test\GCMTest.cs" /> @@ -386,6 +389,7 @@ <Compile Include="src\pkcs\test\EncryptedPrivateKeyInfoTest.cs" /> <Compile Include="src\pkcs\test\PKCS10Test.cs" /> <Compile Include="src\pkcs\test\PKCS12StoreTest.cs" /> + <Compile Include="src\ProtectedMessageTest.cs" /> <Compile Include="src\security\test\SecureRandomTest.cs" /> <Compile Include="src\security\test\TestDigestUtil.cs" /> <Compile Include="src\security\test\TestDotNetUtil.cs" /> @@ -1317,4 +1321,7 @@ <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> + <ItemGroup> + <Folder Include="src\NewFolder1\" /> + </ItemGroup> </Project> \ No newline at end of file diff --git a/crypto/test/src/crypto/test/ECGOST3410_2012Test.cs b/crypto/test/src/crypto/test/ECGOST3410_2012Test.cs index 94726bc92..8c5997835 100644 --- a/crypto/test/src/crypto/test/ECGOST3410_2012Test.cs +++ b/crypto/test/src/crypto/test/ECGOST3410_2012Test.cs @@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Crypto.Tests DerObjectIdentifier oid = ECGost3410NamedCurves.GetOid("Tc26-Gost-3410-12-512-paramSetA"); ECNamedDomainParameters ecp = new ECNamedDomainParameters(oid, ECGost3410NamedCurves.GetByOid(oid)); - ECGOST3410Parameters gostParams = new ECGOST3410Parameters(ecp, oid, RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512,null); + ECGost3410Parameters gostParams = new ECGost3410Parameters(ecp, oid, RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512,null); ECKeyGenerationParameters paramameters = new ECKeyGenerationParameters(gostParams, new SecureRandom()); ECKeyPairGenerator engine = new ECKeyPairGenerator(); engine.Init(paramameters); @@ -49,8 +49,8 @@ namespace Org.BouncyCastle.Crypto.Tests keyParameters = (ECPublicKeyParameters)PublicKeyFactory.CreateKey(info); { // Specifically cast and test gost parameters. - ECGOST3410Parameters gParam = (ECGOST3410Parameters)generatedKeyParameters.Parameters; - ECGOST3410Parameters rParam = (ECGOST3410Parameters)keyParameters.Parameters; + ECGost3410Parameters gParam = (ECGost3410Parameters)generatedKeyParameters.Parameters; + ECGost3410Parameters rParam = (ECGost3410Parameters)keyParameters.Parameters; bool ok = SafeEquals(gParam.DigestParamSet, rParam.DigestParamSet) && @@ -64,8 +64,8 @@ namespace Org.BouncyCastle.Crypto.Tests } - if (!((ECGOST3410Parameters)keyParameters.Parameters).Name.Equals( - ((ECGOST3410Parameters)generatedKeyParameters.Parameters).Name)) + if (!((ECGost3410Parameters)keyParameters.Parameters).Name.Equals( + ((ECGost3410Parameters)generatedKeyParameters.Parameters).Name)) { return new SimpleTestResult(false, "Name does not match"); } @@ -124,7 +124,7 @@ namespace Org.BouncyCastle.Crypto.Tests DerObjectIdentifier oid = ECGost3410NamedCurves.GetOid("Tc26-Gost-3410-12-512-paramSetA"); ECNamedDomainParameters ecp = new ECNamedDomainParameters(oid, ECGost3410NamedCurves.GetByOid(oid)); - ECGOST3410Parameters gostParams = new ECGOST3410Parameters(ecp, oid, RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512,null); + ECGost3410Parameters gostParams = new ECGost3410Parameters(ecp, oid, RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512,null); ECKeyGenerationParameters parameters = new ECKeyGenerationParameters(gostParams, new SecureRandom()); ECKeyPairGenerator engine = new ECKeyPairGenerator(); engine.Init(parameters); @@ -145,8 +145,8 @@ namespace Org.BouncyCastle.Crypto.Tests keyParameters = (ECPrivateKeyParameters)PrivateKeyFactory.CreateKey(info); { // Specifically cast and test gost parameters. - ECGOST3410Parameters gParam = (ECGOST3410Parameters)generatedKeyParameters.Parameters; - ECGOST3410Parameters rParam = (ECGOST3410Parameters)keyParameters.Parameters; + ECGost3410Parameters gParam = (ECGost3410Parameters)generatedKeyParameters.Parameters; + ECGost3410Parameters rParam = (ECGost3410Parameters)keyParameters.Parameters; bool ok = SafeEquals(gParam.DigestParamSet, rParam.DigestParamSet) && SafeEquals(gParam.EncryptionParamSet, rParam.EncryptionParamSet) && @@ -169,8 +169,8 @@ namespace Org.BouncyCastle.Crypto.Tests return new SimpleTestResult(false, "D does not match"); } - if (!((ECGOST3410Parameters)keyParameters.Parameters).Name.Equals( - ((ECGOST3410Parameters)generatedKeyParameters.Parameters).Name)) + if (!((ECGost3410Parameters)keyParameters.Parameters).Name.Equals( + ((ECGost3410Parameters)generatedKeyParameters.Parameters).Name)) { return new SimpleTestResult(false, "Name does not match"); } @@ -232,17 +232,17 @@ namespace Org.BouncyCastle.Crypto.Tests return new SimpleTestResult(false, "Q does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.1.1")) + if (!((ECGost3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.1.1")) { return new SimpleTestResult(false, "PublicKeyParamSet does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.2")) + if (!((ECGost3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.2")) { return new SimpleTestResult(false, "DigestParamSet does not match"); } - if (((ECGOST3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) + if (((ECGost3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) { return new SimpleTestResult(false, "EncryptionParamSet is not null"); } @@ -266,17 +266,17 @@ namespace Org.BouncyCastle.Crypto.Tests } - if (!((ECGOST3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.2.1")) + if (!((ECGost3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.2.1")) { return new SimpleTestResult(false, "PublicKeyParamSet does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.3")) + if (!((ECGost3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.3")) { return new SimpleTestResult(false, "DigestParamSet does not match"); } - if (((ECGOST3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) + if (((ECGost3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) { return new SimpleTestResult(false, "EncryptionParamSet is not null"); } @@ -304,17 +304,17 @@ namespace Org.BouncyCastle.Crypto.Tests return new SimpleTestResult(false, "D does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.1.1")) + if (!((ECGost3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.1.1")) { return new SimpleTestResult(false, "PublicKeyParamSet does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.2")) + if (!((ECGost3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.2")) { return new SimpleTestResult(false, "DigestParamSet does not match"); } - if (((ECGOST3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) + if (((ECGost3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) { return new SimpleTestResult(false, "EncryptionParamSet is not null"); } @@ -337,17 +337,17 @@ namespace Org.BouncyCastle.Crypto.Tests return new SimpleTestResult(false, "D does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.2.1")) + if (!((ECGost3410Parameters)pkInfo.Parameters).PublicKeyParamSet.ToString().Equals("1.2.643.7.1.2.1.2.1")) { return new SimpleTestResult(false, "PublicKeyParamSet does not match"); } - if (!((ECGOST3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.3")) + if (!((ECGost3410Parameters)pkInfo.Parameters).DigestParamSet.ToString().Equals("1.2.643.7.1.1.2.3")) { return new SimpleTestResult(false, "DigestParamSet does not match"); } - if (((ECGOST3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) + if (((ECGost3410Parameters)pkInfo.Parameters).EncryptionParamSet != null) { return new SimpleTestResult(false, "EncryptionParamSet is not null"); } @@ -363,7 +363,7 @@ namespace Org.BouncyCastle.Crypto.Tests { DerObjectIdentifier oid = ECGost3410NamedCurves.GetOid(oidStr); ECNamedDomainParameters ecp = new ECNamedDomainParameters(oid, ECGost3410NamedCurves.GetByOid(oid)); - ECGOST3410Parameters gostParams = new ECGOST3410Parameters(ecp, oid, digest, null); + ECGost3410Parameters gostParams = new ECGost3410Parameters(ecp, oid, digest, null); ECKeyGenerationParameters parameters = new ECKeyGenerationParameters(gostParams, new SecureRandom()); ECKeyPairGenerator engine = new ECKeyPairGenerator(); engine.Init(parameters); @@ -378,8 +378,8 @@ namespace Org.BouncyCastle.Crypto.Tests { // Specifically cast and test gost parameters. - ECGOST3410Parameters gParam = (ECGOST3410Parameters)generatedKeyParameters.Parameters; - ECGOST3410Parameters rParam = (ECGOST3410Parameters)recoveredKeyParameters.Parameters; + ECGost3410Parameters gParam = (ECGost3410Parameters)generatedKeyParameters.Parameters; + ECGost3410Parameters rParam = (ECGost3410Parameters)recoveredKeyParameters.Parameters; bool ok = SafeEquals(gParam.DigestParamSet, rParam.DigestParamSet) && SafeEquals(gParam.EncryptionParamSet, rParam.EncryptionParamSet) && @@ -398,8 +398,8 @@ namespace Org.BouncyCastle.Crypto.Tests return new SimpleTestResult(false, "isPrivate does not match"); } - if (!((ECGOST3410Parameters)recoveredKeyParameters.Parameters).Name.Equals( - ((ECGOST3410Parameters)generatedKeyParameters.Parameters).Name)) + if (!((ECGost3410Parameters)recoveredKeyParameters.Parameters).Name.Equals( + ((ECGost3410Parameters)generatedKeyParameters.Parameters).Name)) { return new SimpleTestResult(false, "Name does not match"); } @@ -449,7 +449,7 @@ namespace Org.BouncyCastle.Crypto.Tests { DerObjectIdentifier oid = ECGost3410NamedCurves.GetOid(oidStr); ECNamedDomainParameters ecp = new ECNamedDomainParameters(oid, ECGost3410NamedCurves.GetByOid(oid)); - ECGOST3410Parameters gostParams = new ECGOST3410Parameters(ecp,oid,digest,null); + ECGost3410Parameters gostParams = new ECGost3410Parameters(ecp,oid,digest,null); ECKeyGenerationParameters parameters = new ECKeyGenerationParameters(gostParams, new SecureRandom()); ECKeyPairGenerator engine = new ECKeyPairGenerator(); engine.Init(parameters); @@ -461,8 +461,8 @@ namespace Org.BouncyCastle.Crypto.Tests ECPublicKeyParameters recoveredKeyParameters = (ECPublicKeyParameters)PublicKeyFactory.CreateKey(info); { // Specifically cast and test gost parameters. - ECGOST3410Parameters gParam = (ECGOST3410Parameters)generatedKeyParameters.Parameters; - ECGOST3410Parameters rParam = (ECGOST3410Parameters)recoveredKeyParameters.Parameters; + ECGost3410Parameters gParam = (ECGost3410Parameters)generatedKeyParameters.Parameters; + ECGost3410Parameters rParam = (ECGost3410Parameters)recoveredKeyParameters.Parameters; bool ok = SafeEquals(gParam.DigestParamSet, rParam.DigestParamSet) && @@ -476,8 +476,8 @@ namespace Org.BouncyCastle.Crypto.Tests } - if (!((ECGOST3410Parameters)recoveredKeyParameters.Parameters).Name.Equals( - ((ECGOST3410Parameters)generatedKeyParameters.Parameters).Name)) + if (!((ECGost3410Parameters)recoveredKeyParameters.Parameters).Name.Equals( + ((ECGost3410Parameters)generatedKeyParameters.Parameters).Name)) { return new SimpleTestResult(false, "Name does not match"); } diff --git a/crypto/test/src/crypto/test/EGOST3410_2012SignatureTest.cs b/crypto/test/src/crypto/test/EGOST3410_2012SignatureTest.cs index 0065174ed..7c9801430 100644 --- a/crypto/test/src/crypto/test/EGOST3410_2012SignatureTest.cs +++ b/crypto/test/src/crypto/test/EGOST3410_2012SignatureTest.cs @@ -65,7 +65,7 @@ namespace Org.BouncyCastle.Crypto.Tests new BigInteger("17614944419213781543809391949654080031942662045363639260709847859438286763994")), // y spec); - ECGOST3410_2012Signer signer = new ECGOST3410_2012Signer(); + ECGost3410_2012Signer signer = new ECGost3410_2012Signer(); signer.Init(true, new ParametersWithRandom(privateKey, k)); byte[] rev = e.ToByteArray(); @@ -104,7 +104,7 @@ namespace Org.BouncyCastle.Crypto.Tests { DerObjectIdentifier oid = RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256_paramSetA; ECNamedDomainParameters ecp = new ECNamedDomainParameters(oid, ECGost3410NamedCurves.GetByOid(oid)); - ECGOST3410Parameters gostParams = new ECGOST3410Parameters(ecp, oid, + ECGost3410Parameters gostParams = new ECGost3410Parameters(ecp, oid, RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256, null); ECKeyGenerationParameters parameters = new ECKeyGenerationParameters(gostParams, new SecureRandom()); ECKeyPairGenerator engine = new ECKeyPairGenerator(); @@ -119,7 +119,7 @@ namespace Org.BouncyCastle.Crypto.Tests { DerObjectIdentifier oid = RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512_paramSetA; ECNamedDomainParameters ecp = new ECNamedDomainParameters(oid, ECGost3410NamedCurves.GetByOid(oid)); - ECGOST3410Parameters gostParams = new ECGOST3410Parameters(ecp, oid, + ECGost3410Parameters gostParams = new ECGost3410Parameters(ecp, oid, RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512, null); ECKeyGenerationParameters parameters = new ECKeyGenerationParameters(gostParams, new SecureRandom()); ECKeyPairGenerator engine = new ECKeyPairGenerator(); @@ -141,13 +141,13 @@ namespace Org.BouncyCastle.Crypto.Tests ECPrivateKeyParameters sKey = (ECPrivateKeyParameters)p.Private; ECPublicKeyParameters vKey = (ECPublicKeyParameters)p.Public; - ECGOST3410_2012Signer s = new ECGOST3410_2012Signer(); + ECGost3410_2012Signer s = new ECGost3410_2012Signer(); s.Init(true, sKey); BigInteger[] sig = s.GenerateSignature(data); - s = new ECGOST3410_2012Signer(); + s = new ECGost3410_2012Signer(); s.Init(false, vKey); if (!s.VerifySignature(data, sig[0], sig[1])) @@ -159,8 +159,8 @@ namespace Org.BouncyCastle.Crypto.Tests // Test with Digest signer. // Gost3410DigestSigner digestSigner = new Gost3410DigestSigner( - new ECGOST3410_2012Signer(), - DigestUtilities.GetDigest(((ECGOST3410Parameters)vKey.Parameters).DigestParamSet)); + new ECGost3410_2012Signer(), + DigestUtilities.GetDigest(((ECGost3410Parameters)vKey.Parameters).DigestParamSet)); digestSigner.Init(true, sKey); digestSigner.BlockUpdate(data, 0, data.Length); byte[] sigBytes = digestSigner.GenerateSignature(); @@ -171,8 +171,8 @@ namespace Org.BouncyCastle.Crypto.Tests } digestSigner = new Gost3410DigestSigner( - new ECGOST3410_2012Signer(), - DigestUtilities.GetDigest(((ECGOST3410Parameters)vKey.Parameters).DigestParamSet)); + new ECGost3410_2012Signer(), + DigestUtilities.GetDigest(((ECGost3410Parameters)vKey.Parameters).DigestParamSet)); digestSigner.Init(false, vKey); digestSigner.BlockUpdate(data, 0, data.Length); diff --git a/crypto/test/src/crypto/test/GOST3411_2012_256DigestTest.cs b/crypto/test/src/crypto/test/GOST3411_2012_256DigestTest.cs index 5b20f46be..1f2ef1823 100644 --- a/crypto/test/src/crypto/test/GOST3411_2012_256DigestTest.cs +++ b/crypto/test/src/crypto/test/GOST3411_2012_256DigestTest.cs @@ -61,7 +61,7 @@ namespace Org.BouncyCastle.Crypto.Tests }; public GOST3411_2012_256DigestTest() - : base(new GOST3411_2012_256Digest(), messages, digests) + : base(new Gost3411_2012_256Digest(), messages, digests) { } @@ -69,7 +69,7 @@ namespace Org.BouncyCastle.Crypto.Tests { base.PerformTest(); - HMac gMac = new HMac(new GOST3411_2012_256Digest()); + HMac gMac = new HMac(new Gost3411_2012_256Digest()); gMac.Init(new KeyParameter(Hex.Decode("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"))); @@ -88,7 +88,7 @@ namespace Org.BouncyCastle.Crypto.Tests protected override IDigest CloneDigest(IDigest digest) { - return new GOST3411_2012_256Digest((GOST3411_2012_256Digest)digest); + return new Gost3411_2012_256Digest((Gost3411_2012_256Digest)digest); } [Test] diff --git a/crypto/test/src/crypto/test/GOST3411_2012_512DigestTest.cs b/crypto/test/src/crypto/test/GOST3411_2012_512DigestTest.cs index 05b33e7f9..f4398952b 100644 --- a/crypto/test/src/crypto/test/GOST3411_2012_512DigestTest.cs +++ b/crypto/test/src/crypto/test/GOST3411_2012_512DigestTest.cs @@ -61,7 +61,7 @@ namespace Org.BouncyCastle.Crypto.Tests { base.PerformTest(); - HMac gMac = new HMac(new GOST3411_2012_512Digest()); + HMac gMac = new HMac(new Gost3411_2012_512Digest()); gMac.Init(new KeyParameter(Hex.Decode("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"))); @@ -79,13 +79,13 @@ namespace Org.BouncyCastle.Crypto.Tests } public GOST3411_2012_512DigestTest() - : base(new GOST3411_2012_512Digest(), messages, digests) + : base(new Gost3411_2012_512Digest(), messages, digests) { } protected override IDigest CloneDigest(IDigest digest) { - return new GOST3411_2012_512Digest((GOST3411_2012_512Digest)digest); + return new Gost3411_2012_512Digest((Gost3411_2012_512Digest)digest); } [Test] |