Exemplo n.º 1
0
        public async Task AsymmetricCryptography_SignStringUsingPrivateKey_VerifySignatureUsingPublicKey_ReturnsTrue_Succeeds(int keySize)
        {
            (string, string)keys = await FreshKeys(keySize);

            string sig      = crypto.Sign(text, keys.Item2);
            bool   verified = crypto.Verify(text, sig, keys.Item1);

            Assert.True(verified);
            Assert.NotNull(sig);
            Assert.NotEmpty(sig);
        }
 /// <summary>
 /// Verifies the <see cref="Signature"/> using the provided <paramref name="crypto"/> instance.
 /// </summary>
 /// <param name="crypto">The <see cref="IAsymmetricCryptographyRSA"/> instance to use for signature verification.</param>
 /// <param name="publicRsaKeyPem">The public RSA key (PEM-formatted) to use for verifying the signature.</param>
 /// <returns>Whether the <see cref="Signature"/> could be verified or not.</returns>
 /// <seealso cref="IAsymmetricCryptographyRSA.Verify(string,string,string)"/>
 public bool VerifySignature(IAsymmetricCryptographyRSA crypto, string publicRsaKeyPem)
 {
     return(crypto.Verify(this, Signature, publicRsaKeyPem));
 }