Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building an Encrypted Virtual Filesystem in the...

Avatar for Cam Pedersen Cam Pedersen
December 13, 2013

Building an Encrypted Virtual Filesystem in the Browser

Avatar for Cam Pedersen

Cam Pedersen

December 13, 2013

Other Decks in Programming

Transcript

  1. WHY? window.requestFileSystem is young Only supported in WebKit File APIs

    are local to the machine Want to store the files remotely
  2. CONTAINER DATA inodes dentries files just data {“id":2, “dentries":[{"id":1,"name":".."}], “links":1,

    “atime":0, “mtime":1386954461254, “ctime":1386954455150, “size":71498, “isDirectory":false, “fileId":3, "custom":{"type":"image/png"}} {“value":"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAB7sAAAUn CAYAAAAsNwN2AAAABHNCS…="}
  3. CONTAINER DATA inodes dentries files just data {“iv":"6dBwnCXN8dV8B4iruDH4lw","v":1, “iter":1000,"ks":128,"ts":64, “mode":"gcm","adata":"","cipher":"aes",

    “ct”:”fsUndHDCsROgLHglmzPN48oPF1+s…"} {“iv”:"GRcbuBDEIuCVJno/4xIrnA","v":1, “iter":1000,"ks":128,"ts":64,"mode":"gcm", “adata":"","cipher":"aes", “ct”:”a0b9/ggRWslifA..."}
  4. crate in userspace var fs = new Crate({ driver: 'localStorage',

    }, function (err) { fs.open(‘/foo’, function (err, file) { file.write(‘bar’, function (err) { console.log(‘i made a file in js!’); }); }); }); !
  5. crate with encryption var fs = new Crate({ driver: ‘crypton',

    options: { session: cryptonSession } }, function (err) { fs.open(‘/foo’, function (err, file) { file.write(‘bar’, function (err) { console.log(‘i encrypted a file!’); }); }); }); !
  6. opening files fs.open(path, function (err, file) { file.read(function (err, data)

    { var blob = dataURItoBlob(data); var url = URL.createObjectURL(blob); var name = file.name; var reference = window.open(url, name, null); URL.revokeObjectURL(url); }); });
  7. saving files fs.open(path, function (err, file) { file.read(function (err, data)

    { var link = document.createElement('a'); link.href = data; link.download = file.name; document.body.appendChild(link); link.click(); document.body.removeChild(link); }); });