Example #1
0
 [System.Security.SecurityCritical]  // auto-generated
 internal SecureString(SecureString str)
 {
     AllocateBuffer(str.BufferLength);
     SafeBSTRHandle.Copy(str.m_buffer, this.m_buffer);
     m_length    = str.m_length;
     m_encrypted = str.m_encrypted;
 }
Example #2
0
        internal SecureString(SecureString str)
        {
            Debug.Assert(str != null, "Expected non-null SecureString");
            Debug.Assert(str._buffer != null, "Expected other SecureString's buffer to be non-null");
            Debug.Assert(str._encrypted, "Expected to be used only on encrypted SecureStrings");

            AllocateBuffer(str._buffer.Length);
            SafeBSTRHandle.Copy(str._buffer, _buffer, str._buffer.Length * sizeof(char));

            _decryptedLength = str._decryptedLength;
            _encrypted       = str._encrypted;
        }
Example #3
0
        [System.Security.SecurityCritical]  // auto-generated
        private void EnsureCapacity(ref SafeBSTRHandle decryptedBuffer, int capacity)
        {
            if (capacity > MaxLength)
            {
                throw new ArgumentOutOfRangeException("capacity", SR.ArgumentOutOfRange_Capacity);
            }

            if (capacity <= _decryptedLength)
            {
                return;
            }

            SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(null, (uint)capacity);

            SafeBSTRHandle.Copy(decryptedBuffer, newBuffer, (uint)_decryptedLength * sizeof(char));
            decryptedBuffer.Dispose();
            decryptedBuffer = newBuffer;
        }
 private void EnsureCapacity(int capacity)
 {
     if (capacity > 0x10000)
     {
         throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_Capacity"));
     }
     if (capacity > this.m_buffer.Length)
     {
         SafeBSTRHandle target = SafeBSTRHandle.Allocate(null, GetAlignedSize(capacity));
         if (target.IsInvalid)
         {
             throw new OutOfMemoryException();
         }
         SafeBSTRHandle.Copy(this.m_buffer, target);
         this.m_buffer.Close();
         this.m_buffer = target;
     }
 }
Example #5
0
        private void EnsureCapacity(int capacity)
        {
            if (capacity > MaxLength)
            {
                throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_Capacity);
            }

            if (((uint)capacity * sizeof(char)) <= _buffer.ByteLength)
            {
                return;
            }

            var            oldBuffer = _buffer;
            SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(GetAlignedSize((uint)capacity));

            SafeBSTRHandle.Copy(oldBuffer, newBuffer, (uint)_decryptedLength * sizeof(char));
            _buffer = newBuffer;
            oldBuffer.Dispose();
        }
Example #6
0
        [System.Security.SecurityCritical]  // auto-generated
        private void EnsureCapacity(int capacity) {            
            if( capacity > MaxLength) {
                throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_Capacity"));
            }
            Contract.EndContractBlock();

            if( capacity <= m_buffer.Length) {
                return;
            }

            SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(null, GetAlignedSize(capacity));

            if (newBuffer.IsInvalid) {
                throw new OutOfMemoryException();
            }                

            SafeBSTRHandle.Copy(m_buffer, newBuffer);
            m_buffer.Close();
            m_buffer = newBuffer;                
        }
Example #7
0
 [System.Security.SecurityCritical]  // auto-generated
 internal SecureString(SecureString str)
 {
     AllocateBuffer(str.EncryptedBufferLength);
     SafeBSTRHandle.Copy(str._encryptedBuffer, _encryptedBuffer);
     _decryptedLength = str._decryptedLength;
 }