Beispiel #1
0
        /// <summary>
        /// Returns <c>true</c> if the key string passed is a valid XML key
        /// and is NOT a key container name.
        /// </summary>
        /// <param name="algorithm">The asymmetric algorithm.</param>
        /// <param name="key">The key string to be tested.</param>
        /// <returns><c>true</c> if the key is a valid XML key.</returns>
        /// <remarks>
        /// The current implementation supports only the "RSA" provider.
        /// </remarks>
        public static bool IsXmlKey(string algorithm, string key)
        {
            AsymmetricAlgorithm asymmetric = null;

            try
            {
                if (ParseKeyContainer(key) != null)
                {
                    return(false);
                }

                asymmetric = EncryptionConfig.CreateAsymmetric(algorithm, 0);
                asymmetric.FromXmlString(key);

                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                if (asymmetric != null)
                {
                    asymmetric.Clear();
                }
            }
        }
 public void Dispose()
 {
     if (_disposeCryptoProvider && _signingKey != null)
     {
         _signingKey.Clear();
     }
 }
Beispiel #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose managed resources.
                    if (_algorithm != null)
                    {
                        _algorithm.Clear();
                    }
                }

                // Dispose unmanaged resources.
            }

            _isDisposed = true;
        }
Beispiel #4
0
 public virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             if (publicKeyData != null)
             {
                 for (int i = 0; i < publicKeyData.Length; i++)
                 {
                     publicKeyData[i] = 0;
                 }
                 publicKeyData = null;
             }
             if (privateKey != null)
             {
                 privateKey.Clear();
             }
             certificate = null;
         }
         disposed = true;
     }
 }