/// <summary>
        ///     GetKeys provides an enumerator over all of the keys that are stored in the key storage
        ///     provider. This overload of GetKeys allows you to enumerate over only the user keys in the KSP
        ///     or only the machine keys. It also allows you to return only keys that are usable with a
        ///     specified algorithm.
        /// </summary>
        /// <param name="provider">CngProvider to enumerate the keys of</param>
        /// <param name="openOptions">options to use when opening the CNG keys</param>
        /// <param name="algorithm">algorithm that the returned keys should support</param>
        /// <exception cref="ArgumentNullException">if <paramref name="algorithm" /> is null</exception>
        public static IEnumerable <CngKey> GetKeys(this CngProvider provider,
                                                   CngKeyOpenOptions openOptions,
                                                   CngAlgorithm algorithm)
        {
            if (algorithm == null)
            {
                throw new ArgumentNullException("algorithm");
            }

            return(from key in provider.GetKeys(openOptions)
                   where key.Algorithm == algorithm
                   select key);
        }