示例#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();
            }
        }
示例#2
0
        public void Clear() {
            EnsureNotDisposed();
            EnsureNotReadOnly();

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

                _decryptedLength = 0;
                _encryptedBuffer.ClearBuffer();
            }
        }
示例#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();
            }
        }