From 64998de42374dc24d3a1cfaf685ee07270aae87f Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 10 Jul 2017 13:27:01 -0700 Subject: [PATCH 1/3] added check to see if browser is gcm compliant --- frontend/src/upload.js | 11 ++++++++++- frontend/src/utils.js | 36 +++++++++++++++++++++++++++++++++++- views/index.handlebars | 10 ++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index 60ebe96c..e9f0811a 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -1,10 +1,18 @@ const FileSender = require('./fileSender'); -const { notify } = require('./utils'); +const { notify, gcmCompliant } = require('./utils'); const $ = require('jquery'); const Raven = window.Raven; $(document).ready(function() { + + // added as a print statement for now, eventually move init stuff + // into here and display an error page if it's not compliant + gcmCompliant().catch(err => { + $('#page-one').hide(); + $('#compliance-error').show(); + }) + // reset copy button const $copyBtn = $('#copy-btn'); $copyBtn.attr('disabled', false); @@ -15,6 +23,7 @@ $(document).ready(function() { $('#upload-progress').hide(); $('#share-link').hide(); $('#upload-error').hide(); + $('#compliance-error').hide(); if (localStorage.length === 0) { toggleHeader(); diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 2e6400ce..419f7b88 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -32,8 +32,42 @@ function notify(str) { } } +function gcmCompliant() { + try { + return window.crypto.subtle.generateKey( + { + name: 'AES-GCM', + length: 128 + }, + true, + ['encrypt', 'decrypt'] + ).then(key => { + return window.crypto.subtle.encrypt( + { + name: 'AES-GCM', + iv: window.crypto.getRandomValues(new Uint8Array(12)), + additionalData: window.crypto.getRandomValues(new Uint8Array(6)) + }, + key, + new ArrayBuffer(8) + ) + .then(() => { + return Promise.resolve() + }) + .catch(err => { + return Promise.reject() + }) + }).catch(err => { + return Promise.reject(); + }) + } catch(err) { + return Promise.reject(); + } +} + module.exports = { arrayToHex, hexToArray, - notify + notify, + gcmCompliant }; diff --git a/views/index.handlebars b/views/index.handlebars index dd2942d7..6d6b89db 100644 --- a/views/index.handlebars +++ b/views/index.handlebars @@ -100,6 +100,16 @@ +
+
+ Encryption error
+ Your browser does not support gcm encryption. +
+
+ Send another file +
+
+ From fce615842d37b491eb75b28998ff21570a11400c Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 10 Jul 2017 13:35:32 -0700 Subject: [PATCH 2/3] no longer renders 'send another file' --- frontend/src/upload.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index e9f0811a..ac17b2a1 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -5,12 +5,10 @@ const $ = require('jquery'); const Raven = window.Raven; $(document).ready(function() { - - // added as a print statement for now, eventually move init stuff - // into here and display an error page if it's not compliant gcmCompliant().catch(err => { $('#page-one').hide(); $('#compliance-error').show(); + $('#compliance-error .send-new').hide() }) // reset copy button From 2682f95a2b09b6c00f311fed7d28185fef70458a Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 10 Jul 2017 13:48:00 -0700 Subject: [PATCH 3/3] fixed for id/edge and removed some html --- frontend/src/upload.js | 1 - frontend/src/utils.js | 3 ++- views/index.handlebars | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/src/upload.js b/frontend/src/upload.js index ac17b2a1..ec0bfb8a 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -8,7 +8,6 @@ $(document).ready(function() { gcmCompliant().catch(err => { $('#page-one').hide(); $('#compliance-error').show(); - $('#compliance-error .send-new').hide() }) // reset copy button diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 419f7b88..af0c9c99 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -46,7 +46,8 @@ function gcmCompliant() { { name: 'AES-GCM', iv: window.crypto.getRandomValues(new Uint8Array(12)), - additionalData: window.crypto.getRandomValues(new Uint8Array(6)) + additionalData: window.crypto.getRandomValues(new Uint8Array(6)), + tagLength: 128 }, key, new ArrayBuffer(8) diff --git a/views/index.handlebars b/views/index.handlebars index 6d6b89db..70742855 100644 --- a/views/index.handlebars +++ b/views/index.handlebars @@ -105,9 +105,6 @@ Encryption error
Your browser does not support gcm encryption. -
- Send another file -