Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.26k stars 4.6k forks source link

Some KeyVault Crypto tests failing on .NET Framework #5997

Closed weshaggard closed 4 years ago

weshaggard commented 5 years ago

The following tests fail on .NET Framework:

Failed   Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.HardCodedKeysMustWork
Error Message:
 System.ArgumentException : Invalid key algorithm. Expected ES256, found ECDsa.
Stack Trace:
   at Microsoft.Azure.KeyVault.Cryptography.Algorithms.Ecdsa.CreateSignatureTransform(AsymmetricAlgorithm key, String algorithmName) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\Ecdsa.cs:line 32
   at Microsoft.Azure.KeyVault.Cryptography.Algorithms.Es256.CreateSignatureTransform(AsymmetricAlgorithm key) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\Es256.cs:line 24
   at Microsoft.Azure.KeyVault.EcKey.SignAsync(Byte[] digest, String algorithm, CancellationToken token) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\EcKey.cs:line 355
   at Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.DoSignVerifyTests(Int32 digestSize, EcKey privateKey, EcKey publicKey) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\tests\Tests\Cryptography\Algorithms\EcKeyTests.cs:line 89
   at Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.DoHardCodedKeyTests(String json, String curve, Int32 keySize, String defaultAlgo, Int32 digestSize) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\tests\Tests\Cryptography\Algorithms\EcKeyTests.cs:line 39
   at Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.HardCodedKeysMustWork() in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\tests\Tests\Cryptography\Algorithms\EcKeyTests.cs:line 28

Failed   Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.RandomKeysMustWork
Error Message:
 System.ArgumentException : Invalid key algorithm. Expected ES256, found ECDsa.
Stack Trace:
   at Microsoft.Azure.KeyVault.Cryptography.Algorithms.Ecdsa.CreateSignatureTransform(AsymmetricAlgorithm key, String algorithmName) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\Ecdsa.cs:line 32
   at Microsoft.Azure.KeyVault.Cryptography.Algorithms.Es256.CreateSignatureTransform(AsymmetricAlgorithm key) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\Es256.cs:line 24
   at Microsoft.Azure.KeyVault.EcKey.SignAsync(Byte[] digest, String algorithm, CancellationToken token) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\EcKey.cs:line 355
   at Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.DoSignVerifyTests(Int32 digestSize, EcKey privateKey, EcKey publicKey) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\tests\Tests\Cryptography\Algorithms\EcKeyTests.cs:line 89
   at Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.DoRamdomKeyTest(String curve, Int32 keySize, String defaultAlgo, Int32 digestSize) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\tests\Tests\Cryptography\Algorithms\EcKeyTests.cs:line 67
   at Microsoft.Azure.KeyVault.Cryptography.Tests.EcKeyTests.RandomKeysMustWork() in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\tests\Tests\Cryptography\Algorithms\EcKeyTests.cs:line 58

Failed   Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifyP521
Error Message:
 System.Security.Cryptography.CryptographicException : Unknown error "-1073741275".
Stack Trace:
   at System.Security.Cryptography.BCryptNative.OpenAlgorithm(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptAlgorithmHandleCache.GetCachedAlgorithmHandle(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptHashAlgorithm..ctor(CngAlgorithm algorithm, String implementation)
   at System.Security.Cryptography.ECDsaCng.HashData(Byte[] data, Int32 offset, Int32 count, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Int32 offset, Int32 count, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at Microsoft.Azure.KeyVault.Tests.Operations.TestSignVerify(KeyVaultClient client, KeyBundle keyBundle, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 391
   at Microsoft.Azure.KeyVault.Tests.Operations.TestEcKeyCreateSignVerify(String curve, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 369
   at Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifyP521() in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 339

Failed   Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifyP256
Error Message:
 System.Security.Cryptography.CryptographicException : Unknown error "-1073741275".
Stack Trace:
   at System.Security.Cryptography.BCryptNative.OpenAlgorithm(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptAlgorithmHandleCache.GetCachedAlgorithmHandle(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptHashAlgorithm..ctor(CngAlgorithm algorithm, String implementation)
   at System.Security.Cryptography.ECDsaCng.HashData(Byte[] data, Int32 offset, Int32 count, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Int32 offset, Int32 count, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at Microsoft.Azure.KeyVault.Tests.Operations.TestSignVerify(KeyVaultClient client, KeyBundle keyBundle, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 391
   at Microsoft.Azure.KeyVault.Tests.Operations.TestEcKeyCreateSignVerify(String curve, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 369
   at Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifyP256() in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 313

Failed   Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifyP384
Error Message:
 System.Security.Cryptography.CryptographicException : Unknown error "-1073741275".
Stack Trace:
   at System.Security.Cryptography.BCryptNative.OpenAlgorithm(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptAlgorithmHandleCache.GetCachedAlgorithmHandle(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptHashAlgorithm..ctor(CngAlgorithm algorithm, String implementation)
   at System.Security.Cryptography.ECDsaCng.HashData(Byte[] data, Int32 offset, Int32 count, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Int32 offset, Int32 count, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at Microsoft.Azure.KeyVault.Tests.Operations.TestSignVerify(KeyVaultClient client, KeyBundle keyBundle, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 391
   at Microsoft.Azure.KeyVault.Tests.Operations.TestEcKeyCreateSignVerify(String curve, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 369
   at Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifyP384() in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 326

Failed   Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifySECP256K1
Error Message:
 System.Security.Cryptography.CryptographicException : Unknown error "-1073741275".
Stack Trace:
   at System.Security.Cryptography.BCryptNative.OpenAlgorithm(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptAlgorithmHandleCache.GetCachedAlgorithmHandle(String algorithm, String implementation)
   at System.Security.Cryptography.BCryptHashAlgorithm..ctor(CngAlgorithm algorithm, String implementation)
   at System.Security.Cryptography.ECDsaCng.HashData(Byte[] data, Int32 offset, Int32 count, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Int32 offset, Int32 count, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at System.Security.Cryptography.ECDsa.VerifyData(Byte[] data, Byte[] signature, HashAlgorithmName hashAlgorithm)
   at Microsoft.Azure.KeyVault.Tests.Operations.TestSignVerify(KeyVaultClient client, KeyBundle keyBundle, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 391
   at Microsoft.Azure.KeyVault.Tests.Operations.TestEcKeyCreateSignVerify(String curve, Int32 digestSize, String algorithm) in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 369
   at Microsoft.Azure.KeyVault.Tests.Operations.EcKeyCreateSignVerifySECP256K1() in D:\a\1\s\sdk\keyvault\Microsoft.Azure.KeyVault\tests\KeyVaultOperationsTest.cs:line 352
AlexGhiondea commented 5 years ago

This is related to the support .NET Standard version of the KeyVault package.

heaths commented 4 years ago

This has been fixed in recent PRs. EC tests are skipped on net461. Instead, we introduced net47 when EC types were introduced (that ECDsa needs) so we added that to the multi-target test mix for Framework instead.