Merge pull request #177 from mozilla/gcmCompliance

Gcm compliance
This commit is contained in:
Danny Coates 2017-07-10 21:45:31 -07:00 committed by GitHub
commit 109fd671e0
3 changed files with 50 additions and 2 deletions

View File

@ -1,10 +1,15 @@
const FileSender = require('./fileSender');
const { notify } = require('./utils');
const { notify, gcmCompliant } = require('./utils');
const $ = require('jquery');
const Raven = window.Raven;
$(document).ready(function() {
gcmCompliant().catch(err => {
$('#page-one').hide();
$('#compliance-error').show();
})
// reset copy button
const $copyBtn = $('#copy-btn');
$copyBtn.attr('disabled', false);
@ -15,6 +20,7 @@ $(document).ready(function() {
$('#upload-progress').hide();
$('#share-link').hide();
$('#upload-error').hide();
$('#compliance-error').hide();
if (localStorage.length === 0) {
toggleHeader();

View File

@ -32,8 +32,43 @@ 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)),
tagLength: 128
},
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
};

View File

@ -100,6 +100,13 @@
</div>
</div>
<div id="compliance-error">
<div class="title">
Encryption error<br>
Your browser does not support gcm encryption.
</div>
</div>
</div>
</body>