Web Crypto API using Microsoft Edge (38.14393.0.0) - Microsoft Community
- Get link
- X
- Other Apps
i using web crypto api (https://www.w3.org/tr/webcryptoapi/) on chrome (since first web crypto support), firefox (since first web crypto support) , on safari tp (10.2) support of webcrypto liner pollyfill webcrypto api (https://github.com/peculiarventures/webcrypto-liner).
want test our code using microsoft edge. encrypting , decrypting sample arraybuffer fails. here code:
var crypto = window.crypto;
if (crypto.subtle) {
var aesgcmkey = null;
// create new, random iv in production systems!!!
var tempiv = new uint8array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
// needed edge, if additional data missing decrypting failing
var tempadditionaldata = new uint8array(0);
var datatoencrypt = new uint8array([1, 2, 3, 4, 5]);
// 1.) generate key
var generatekeypromise = crypto.subtle.generatekey(
{name: "aes-gcm", length: 256}, true, ["encrypt", "decrypt"]
);
generatekeypromise.then(function (tempkey) {
aesgcmkey = tempkey;
// 2.) start encryption key
var encrypteddatapromise = crypto.subtle.encrypt(
{name: "aes-gcm", iv: tempiv, additionaldata: tempadditionaldata, taglength: 128},
aesgcmkey,
datatoencrypt
);
encrypteddatapromise.then(function (encrypteddata) {
// 3.) decrypt using same key
var decrypteddatapromise = crypto.subtle.decrypt(
{name: "aes-gcm", iv: tempiv, additionaldata: tempadditionaldata, taglength: 128},
aesgcmkey,
encrypteddata
);
decrypteddatapromise.then(function (decrypteddata) {
// 4.) compare decrypted array buffer , inital data
console.log('data decrypted!');
console.log(decrypteddata);
});
decrypteddatapromise.catch(function (error) {
console.log('decrypting sample data failed');
console.log(error);
});
});
// if 2.) failing
encrypteddatapromise.catch(function (error) {
console.log('encrypting sample data failed');
console.log(error);
});
});
// if 1.) failing
generatekeypromise.catch(function (error) {
console.log('creating aec gcm key failed');
console.log(error);
});
}
this code failing in decrypting phase (step 3. in code) on edge, while working fine on chrome, firefox , safari. wired part decrypteddatapromise resolved exception returned data doesnt exception @ all:
[object object] {additionaldata: uint8array {...}, iv: uint8array {...}, name: "aes-gcm", taglength: 128}
have clue why fails on microsoft edge?
***post moved moderator appropriate forum category.***
you find consumer-specific support edge browser beginning own, new thread in forum => http://answers.microsoft.com/en-us/windows/forum/apps_windows_10-msedge
otherwise, should posting in win10 pro-specific forums: https://social.technet.microsoft.com/forums/en-us/home?category=windows10itpro
Microsoft Edge / All other issues / Windows 10
- Get link
- X
- Other Apps
Comments
Post a Comment