Utilize JavaScript in conjunction with encfs for enhanced encryption capabilities

I am attempting to access an encfs filesystem using JavaScript, but am struggling to understand the correct approach. I am utilizing the CryptoJS library for this task.

The .ecnfs6.xml file contains standard settings and uses the password "123456":

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="9">
<cfg class_id="0" tracking_level="0" version="20">
  <version>20100713</version>
  <creator>EncFS 1.7.4</creator>
  <cipherAlg class_id="1" tracking_level="0" version="0">
    <name>ssl/aes</name>
    <major>3</major>
    <minor>0</minor>
  </cipherAlg>
  <nameAlg>
    <name>nameio/block</name>
    <major>3</major>
    <minor>0</minor>
  </nameAlg>
  <keySize>192</keySize>
  <blockSize>1024</blockSize>
  <uniqueIV>1</uniqueIV>
  <chainedNameIV>1</chainedNameIV>
  <externalIVChaining>0</externalIVChaining>
  <blockMACBytes>0</blockMACBytes>
  <blockMACRandBytes>0</blockMACRandBytes>
  <allowHoles>1</allowHoles>
  <encodedKeySize>44</encodedKeySize>
  <encodedKeyData>
A2MxizkB27kOot67DqX/ftXoAiO0P8ORF4BqbKnbMeHuIusJl5y36Qy8o8w=
  </encodedKeyData>
  <saltLen>20</saltLen>
  <saltData>
z59o4aHs2QaKGdoEMEigtqSkXyw=
  </saltData>
  <kdfIterations>97742</kdfIterations>
  <desiredKDFDuration>500</desiredKDFDuration>
</cfg>
</boost_serialization>

I have created a file named "test" with content "test" and attempted to decrypt it without success:

var data = "Q75cZB2ok,JdXDqvWh8HbwHI";  // filename
var key = "123456";
var salt = "z59o4aHs2QaKGdoEMEigtqSkXyw=";

data = CryptoJS.enc.Base64.parse(data);
salt = CryptoJS.enc.Base64.parse(salt);

var cipher = CryptoJS.AES.decrypt(data, key, {keySize: 192/32});

Answer №1

EncFS functions by generating a volume key (192 bits based on your configuration) and then encrypting this key using another key derived from the user's password (the password key is derived using the PBKDF2 algorithm - Password-Based Key Derivation Function).

To work with the config file provided, you need to:

  • Enter the user's password into the PBKDF2 computation along with the salt and iteration count (both found in the config file) in order to obtain the password key.
  • Using the password key, decrypt the volume key (using AES stream decryption) from the encodedKeyData field of the config.

Once you have the volume key, you can use it to decrypt both filenames and contents of the files.

For a practical demonstration, you can refer to the Java library that I have created: https://github.com/mrpdaemon/encfs-java

Answer №2

At present, the performance of current JavaScript implementations is not optimal for producing a PBKDF2 with over 1000 - 2000 iterations (without noticeable delays) to 10000 iterations (with noticeable delays). A scenario like the one in your example with 97742 iterations would require several hours to complete...

Update: It seems that this issue only occurs when using CryptoJS: check out JSPerf and JSFiddle for PBKDF2.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to utilizing various Nodelists using the forEach function

I'm currently developing an online store project that includes a shopping cart feature. My goal is to send a POST request to the server with the items selected by the user in the cart. I have initialized an empty array and I have 3 Nodelists containin ...

Learn how to integrate ES6 features into your nodejs/expressjs application using either Gulp or Webpack

I am looking to incorporate ES6 features into my nodejs/expressjs application. Currently, I am using Gulp for JavaScript compilation and setting up live reload. What steps do I need to take in order to compile the es6 code to standard js within my exis ...

What is the best way to implement this design using CSS or JavaScript?

I would like to enhance the appearance of my school website during these challenging times of the pandemic by adding some CSS or JavaScript elements. However, I am unsure how to go about it. ...

Increase value by 1 with the push of a button within two specified ranges using JavaScript

I am looking to create buttons that will increase the value of both the first and second range by 1 when pressed, as well as decrease the value of both ranges by 1 when pressed. Here is my code: function run(){ var one = document.getElementById("rang ...

Troubleshooting problems with resolving deeply nested promises

My approach to utilizing promises has been effective until now. The issue arises when the console.log(this.recipe) returns undefined and console.log(JSON.stringify(recipes)) displays an empty array. This suggests that the nested promises may not be resolvi ...

"Unlocking the door: a step-by-step guide to logging in with ajax and json for your hybrid

As a beginner coder, I am currently working on a project to create a mobile web login form using json and ajax. To test my code, I followed the tutorial provided here. This is the code I have developed: <!DOCTYPE html> <html> <head> ...

Issues with basic emit and listener in socket.io

I recently inherited an App that already has socket IO functioning for various events. The App is a game where pieces are moved on a board and moves are recorded using notation. My task is to work on the notation feature. However, I am facing issues while ...

JSX Script issue: the input prompt is missing

Greetings! I am currently working on a script to export JSON files from Adobe Illustrator. // Custom function for exporting prefixed objects function exportPrefixedObjects(doc) { // User input for prefixes and reference points var prefixInput = prompt( ...

Sending various types of data to an MVC C# controller using AJAX

Currently, I am utilizing AJAX to retrieve information from a Razor View and forward it to the controller. Although everything is functioning as expected, I now face the challenge of passing an array along with a string as the data: // View - JavaScript v ...

Enhancing JavaScript Objects with New Key/Value Pairs

I'm trying to wrap my head around the code structure of a solution I stumbled upon. The issue at hand: Create a function that takes in a string with only lowercase letters as a parameter, and returns an object with each letter and the number of times ...

What factors influence the speed of an Ajax request?

It is common knowledge that the amount of data transmitted to the server, as well as the volume of information returned in a call can greatly affect its speed. However, what I am curious about is whether the following factors might also impact the transmi ...

New in the world of JavaScript: A method that replicates the functionality of jQuery's

Take a look at this JSFiddle example: https://jsfiddle.net/1a6j4es1/1/ $('table').on('click', 'td', function() { $(this).css('background', 'green'); }); How can you rewrite this code using plain JavaS ...

Unexpected appearance of a blue line in Material UI when the overflow attribute is included

For my React application, I've integrated Material-UI along with styled components. The strange thing is that when I use a Chrome browser to view the app, I encounter an issue that doesn't seem to happen in Firefox. The problem arises when I add ...

What is the best way to identify a specific list item from a dropdown menu and determine its position on

Check out my jsfiddle for reference. My goal is to calculate scores based on different options selected, specifically relating to radiation types. I'm struggling with assigning a score to each type of radiation and integrating the drop-down menu selec ...

Looking to adjust the API response to fit the necessary JSON format for an Angular project?

A modification is needed in the API response to align with the required JSON format provided below. The current responses and the desired format are detailed for reference. Assistance is appreciated. The current representation of individual's data ne ...

Ways to show alternative data from a database in Laravel 8

I am working on a project where I need to display additional data based on the option selected from a dropdown menu populated from a database. Can anyone guide me on how to achieve this using javascript or jquery? https://i.stack.imgur.com/k3WLl.png Belo ...

What steps can be taken to ensure a function operates even when the mouse is stationary?

$(document).ready(function() { var score = 0; $("body").mousemove(function() { score++; $("#result").val(score); console.log(score); }); }); As I move my mouse, the score keeps increasing. But, I'm wonde ...

What is the best way to organize code into separate files while utilizing a module that needs to be included in every file?

In this particular scenario, I am utilizing a headless browser with Puppeteer Chrome and MongoDB. Take a look at the following code snippet: var browser = await puppeteer.launch() var page = await browser.newPage() var db = await MongoClient.connect(" ...

Express.js applications may encounter issues with static files and scripts not being found when utilizing dynamic endpoints

I've run into a snag with my Express.js application regarding the inability to locate static files and scripts when accessing certain endpoints. Here's what's happening: My Express.js app has multiple routes serving HTML pages along with st ...

Error: In Nodejs Promises, you cannot invoke the "then" method on an undefined value

Could you clarify what's incorrect about the following code snippet? var promise = fs.readFile(file); var promise2 = promise.then(function(data){ var base64 = new Buffer(data, 'binary').toString('base64'); res.e ...