KeePassLib.Keys.CompositeKey.CreateRawCompositeKey32 C# (CSharp) Method

CreateRawCompositeKey32() private method

Creates the composite key from the supplied user key sources (password, key file, user account, computer ID, etc.).
private CreateRawCompositeKey32 ( ) : byte[]
return byte[]
        private byte[] CreateRawCompositeKey32()
        {
            ValidateUserKeys();

            // Concatenate user key data
            List<byte[]> lData = new List<byte[]>();
            int cbData = 0;
            foreach(IUserKey pKey in m_vUserKeys)
            {
                ProtectedBinary b = pKey.KeyData;
                if(b != null)
                {
                    byte[] pbKeyData = b.ReadData();
                    lData.Add(pbKeyData);
                    cbData += pbKeyData.Length;
                }
            }

            byte[] pbAllData = new byte[cbData];
            int p = 0;
            foreach(byte[] pbData in lData)
            {
                Array.Copy(pbData, 0, pbAllData, p, pbData.Length);
                p += pbData.Length;
                MemUtil.ZeroByteArray(pbData);
            }
            Debug.Assert(p == cbData);

            SHA256Managed sha256 = new SHA256Managed();
            byte[] pbHash = sha256.ComputeHash(pbAllData);
            MemUtil.ZeroByteArray(pbAllData);
            return pbHash;
        }

Usage Example

Example #1
0
        public bool EqualsValue(CompositeKey ckOther)
        {
            if (ckOther == null)
            {
                throw new ArgumentNullException("ckOther");
            }

            byte[] pbThis  = CreateRawCompositeKey32();
            byte[] pbOther = ckOther.CreateRawCompositeKey32();
            bool   bResult = MemUtil.ArraysEqual(pbThis, pbOther);

            MemUtil.ZeroByteArray(pbOther);
            MemUtil.ZeroByteArray(pbThis);

            return(bResult);
        }
All Usage Examples Of KeePassLib.Keys.CompositeKey::CreateRawCompositeKey32