/// <summary>
 /// Gets user's decrypted Key used for symmetric encryption/decryption of the file.
 /// </summary>
 /// <param name="userId">Unique user identifier from the database.</param>
 /// <param name="userPrivatKey">Users private RSA key used for decryption of encrypted FEK data.</param>
 /// <returns>Decrypted Key used for symmetric encryption/decryption of the file.</returns>
 public byte[] GetKey(int userId, RSAParameters userPrivateKey)
 {
     if (Users.ContainsKey(userId))
     {
         var usersFek = new FileEncryptionKey();
         usersFek.ParseFek(Users[userId], userPrivateKey);
         return(usersFek.Key);
     }
     else
     {
         throw new Exception("You don't have access to this file.");
     }
 }
        /// <summary>
        /// Share a file with other specific user on EnigmaEfs. File can be shared max. with 3 other users.
        /// Key used for file encryption is encrypted for the shared user using their public RSA key.
        /// </summary>
        /// <param name="loggedInUserId">Unique identifier of the logged-in user.</param>
        /// <param name="userId">Unique user identifier from the database.</param>
        /// <param name="loggedInUserPrivateKey">Private RSA key of the logged-in user.</param>
        /// <param name="userPublicKey">Users public RSA key.</param>
        public void ShareFile(int loggedInUserId, int userId, RSAParameters loggedInUserPrivateKey, RSAParameters userPublicKey)
        {
            if (OwnerId == loggedInUserId)
            {
                if (Users.Count > 4)
                {
                    throw new Exception("File can't be shared with more than 4 users.");
                }
                if (!Users.ContainsKey(userId))
                {
                    var usersFek = new FileEncryptionKey();
                    usersFek.ParseFek(Users[loggedInUserId], loggedInUserPrivateKey);

                    Users.Add(userId, usersFek.UnparseFek(userPublicKey));
                }
            }
            else
            {
                throw new Exception("Only file owner can share this file.");
            }
        }