public void EcdsaPlatformTest() { using (var store = new Pkcs11X509Store(SoftHsm2Manager.LibraryPath, SoftHsm2Manager.PinProvider)) { Pkcs11X509Certificate cert = Helpers.GetCertificate(store, SoftHsm2Manager.Token1Label, SoftHsm2Manager.Token1TestUserEcdsaLabel); ECDsa p11PrivKey = cert.GetECDsaPrivateKey(); Assert.IsNotNull(p11PrivKey); ECDsa p11PubKey = cert.GetECDsaPublicKey(); Assert.IsNotNull(p11PubKey); ECDsa cngKey = CryptoObjects.GetTestUserPlatformEcdsaProvider(); Assert.IsNotNull(cngKey); foreach (HashAlgorithmName hashAlgName in _hashNames) { byte[] hash1 = Helpers.ComputeHash(_data1, hashAlgName); byte[] hash2 = Helpers.ComputeHash(_data2, hashAlgName); byte[] p11Signature = p11PrivKey.SignHash(hash1); Assert.IsNotNull(p11Signature); bool result1 = cngKey.VerifyHash(hash1, p11Signature); Assert.IsTrue(result1); bool result2 = cngKey.VerifyHash(hash2, p11Signature); Assert.IsFalse(result2); byte[] cngSignature = cngKey.SignHash(hash1); Assert.IsNotNull(cngSignature); bool result3 = p11PubKey.VerifyHash(hash1, cngSignature); Assert.IsTrue(result3); bool result4 = p11PubKey.VerifyHash(hash2, cngSignature); Assert.IsFalse(result4); } } }