private bool ValidateSignature(byte[] encodedBytes, byte[] signature, SecurityKey key, string algorithm)
        {
            // in the case that a SignatureProviderFactory can handle nulls, just don't check here.
            SignatureProvider signatureProvider = SignatureProviderFactory.CreateForVerifying(key, algorithm);
            if (signatureProvider == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ErrorMessages.IDX10636, key == null ? TextStrings.Null : key.ToString(), algorithm == null ? TextStrings.Null : algorithm));
            }

            return signatureProvider.Verify(encodedBytes, signature);
        }
 /// <summary>
 /// Produces a readable string for a key, used in error messages.
 /// </summary>
 /// <param name="securityKey"></param>
 /// <returns></returns>
 private static string CreateKeyString(SecurityKey securityKey)
 {
     if (securityKey == null)
     {
         return "null";
     }
     else
     {
         return securityKey.ToString();
     }
 }