Ejemplo n.º 1
0
        [System.Security.SecurityCritical]  // auto-generated
        private void ProtectMemory(SafeBSTRHandle decryptedBuffer)
        {
            Debug.Assert(!decryptedBuffer.IsInvalid, "Invalid buffer!");

            if (_decryptedLength == 0)
            {
                return;
            }

            try
            {
                SafeBSTRHandle newEncryptedBuffer = null;
                if (Interop.Crypt32.CryptProtectData(decryptedBuffer, out newEncryptedBuffer))
                {
                    _encryptedBuffer.Dispose();
                    _encryptedBuffer = newEncryptedBuffer;
                }
                else
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }
            }
            finally
            {
                decryptedBuffer.ClearBuffer();
            }
        }
Ejemplo n.º 2
0
        public void Clear() {
            EnsureNotDisposed();
            EnsureNotReadOnly();

            m_length = 0;
            m_buffer.ClearBuffer();
            m_encrypted = false;
        }
Ejemplo n.º 3
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public void Clear()
        {
            lock (_methodLock)
            {
                EnsureNotDisposed();
                EnsureNotReadOnly();

                _decryptedLength = 0;
                _encryptedBuffer.ClearBuffer();
            }
        }
Ejemplo n.º 4
0
        [System.Security.SecurityCritical]  // auto-generated
        private void ProtectMemory(SafeBSTRHandle decryptedBuffer)
        {
            Debug.Assert(!decryptedBuffer.IsInvalid, "Invalid buffer!");

            if (_decryptedLength == 0)
            {
                return;
            }

            try
            {
                SafeBSTRHandle newEncryptedBuffer = null;
                if (Interop.Crypt32.CryptProtectData(decryptedBuffer, out newEncryptedBuffer))
                {
                    _encryptedBuffer.Dispose();
                    _encryptedBuffer = newEncryptedBuffer;
                }
                else
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }
            }
            finally
            {
                decryptedBuffer.ClearBuffer();
                decryptedBuffer.Dispose();
            }
        }