public void WhenHashAlgorithmIsNotSupported_ThrowsNotSupportedException()
            {
                var    sut = new ECDsaSignatureAlgorithm(new HashAlgorithmName("unsupporteed"), _ecdsa);
                Action act = () => sut.ComputeHash("payload");

                act.Should().Throw <NotSupportedException>();
            }
            public void CreatesHash()
            {
                var sut     = new ECDsaSignatureAlgorithm(HashAlgorithmName.SHA384, _ecdsa);
                var payload = "_abc_123_";
                var actual  = sut.ComputeHash(payload);

                actual.Should().NotBeNull().And.NotBeEmpty();
            }
 public ECDsaSignatureAlgorithmTests()
 {
     _ecdsa            = ECDsa.Create();
     _publicKeyParams  = _ecdsa.ExportParameters(false);
     _privateKeyParams = _ecdsa.ExportParameters(true);
     _signer           = ECDsaSignatureAlgorithm.CreateForSigning(HashAlgorithmName.SHA1, _privateKeyParams);
     _verifier         = ECDsaSignatureAlgorithm.CreateForVerification(HashAlgorithmName.SHA1, _publicKeyParams);
 }
            public void CanVerifyWithAlgorithmThatKnowsAboutThePrivateKey()
            {
                var payload   = "_abc_123_";
                var signature = _signer.ComputeHash(payload);
                var verifier  = new ECDsaSignatureAlgorithm(HashAlgorithmName.SHA1, _ecdsa);
                var actual    = verifier.VerifySignature(payload, signature);

                actual.Should().BeTrue();
            }
            public void CanVerifyWithAlgorithmThatOnlyKnowsAboutThePublicKey()
            {
                var payload   = "_abc_123_";
                var signature = _signer.ComputeHash(payload);
                var verifier  = ECDsaSignatureAlgorithm.CreateForVerification(HashAlgorithmName.SHA1, _publicKeyParams);
                var actual    = verifier.VerifySignature(payload, signature);

                actual.Should().BeTrue();
            }
 public static ISignatureAlgorithm CreateForSigning(ECParameters privateParameters, HashAlgorithmName hashAlgorithm)
 {
     return(ECDsaSignatureAlgorithm.CreateForSigning(hashAlgorithm, privateParameters));
 }
 public static ISignatureAlgorithm CreateForVerification(ECParameters publicParameters, HashAlgorithmName hashAlgorithm)
 {
     return(ECDsaSignatureAlgorithm.CreateForVerification(hashAlgorithm, publicParameters));
 }