Ejemplo n.º 1
1
        /// <summary>
        /// Determines whether the <see cref="ILicense.Signature"/> property verifies for the specified key.
        /// </summary>
        /// <param name="publicKey">The public key in xml string format to verify the <see cref="ILicense.Signature"/>.</param>
        /// <returns>true if the <see cref="ILicense.Signature"/> verifies; otherwise false.</returns>
        public bool VerifySignature(string publicKey)
        {
            var signTag = Element("Signature");
            
            if (signTag == null)
                return false;

            try
            {
                signTag.Remove();

                using (var e = new Security.Cryptography.ElGamal.ElGamalManaged())
                {
                    e.FromXmlString(publicKey);
                    return e.VerifySignature(Encoding.UTF8.GetBytes(ToString(SaveOptions.DisableFormatting)),
                                             Convert.FromBase64String(signTag.Value));
                }
            }
            finally
            {
                Add(signTag);
            }
        }