/// <summary>Adds a database-key mapping.</summary>
        /// <param name="databasePath">Full path of the database file.</param>
        /// <param name="pin">The pin to unlock the database.</param>
        /// <param name="keys">The keys used to encrypt the database.</param>
        public void AddCachedKey(string databasePath, ProtectedString pin, CompositeKey keys)
        {
            Contract.Requires(!string.IsNullOrEmpty(databasePath));
            Contract.Requires(pin != null);
            Contract.Requires(keys != null);

            var validPeriod = KeePassQuickUnlockExt.Host.CustomConfig.GetULong(CfgValidPeriod, VALID_DEFAULT);

            lock (unlockCache)
            {
                unlockCache[databasePath] = new QuickUnlockData
                {
                    ValidUntil  = validPeriod == VALID_UNLIMITED ? DateTime.MaxValue : DateTime.Now.AddSeconds(validPeriod),
                    UnlockKey   = pin.WithProtection(true),
                    ComposedKey = keys.CombineKeys()
                };
            }
        }
        /// <summary>Adds a database-key mapping.</summary>
        /// <param name="databasePath">Full path of the database file.</param>
        /// <param name="pin">The pin to unlock the database.</param>
        /// <param name="keys">The keys used to encrypt the database.</param>
        public void AddCachedKey(string databasePath, ProtectedString pin, CompositeKey keys)
        {
            Contract.Requires(!string.IsNullOrEmpty(databasePath));
            Contract.Requires(pin != null);
            Contract.Requires(keys != null);

            var validPeriod = KeePassQuickUnlockExt.Host.CustomConfig.GetULong(CfgValidPeriod, VALID_DEFAULT);

            lock (unlockCache)
            {
                var cn = CreateCipher(pin);

                unlockCache[databasePath] = new QuickUnlockData
                {
                    ValidUntil  = validPeriod == VALID_UNLIMITED ? DateTime.MaxValue : DateTime.Now.AddSeconds(validPeriod),
                    Nonce       = cn.Item2,
                    ComposedKey = keys.CombineKeys().Encrypt(cn.Item1)
                };

                cn.Item1.Dispose();
            }
        }