1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-18 02:41:15 +02:00

added error logs for decrypt methods

This commit is contained in:
Kyle Spearrin 2017-07-31 23:19:02 -04:00
parent 747b5608e8
commit 2beb22e8cf

View File

@ -477,6 +477,7 @@ angular
};
_service.decrypt = function (encValue, key, outputEncoding) {
try {
key = key || _service.getEncKey() || _service.getKey();
var headerPieces = encValue.split('.'),
@ -489,6 +490,7 @@ angular
encPieces = headerPieces[1].split('|');
}
catch (e) {
console.error('Cannot parse headerPieces.');
return null;
}
}
@ -513,15 +515,18 @@ angular
case constants.encType.AesCbc128_HmacSha256_B64:
case constants.encType.AesCbc256_HmacSha256_B64:
if (encPieces.length !== 3) {
console.error('Enc type (' + encType + ') not valid.');
return null;
}
break;
case constants.encType.AesCbc256_B64:
if (encPieces.length !== 2) {
console.error('Enc type (' + encType + ') not valid.');
return null;
}
break;
default:
console.error('Enc type (' + encType + ') not supported.');
return null;
}
@ -550,9 +555,15 @@ angular
else {
return decipher.output.getBytes();
}
}
catch (e) {
console.error('Caught unhandled error in decrypt: ' + e);
throw e;
}
};
_service.decryptFromBytes = function (encBuf, key) {
try {
if (!encBuf) {
throw 'no encBuf.';
}
@ -567,6 +578,7 @@ angular
case constants.encType.AesCbc128_HmacSha256_B64:
case constants.encType.AesCbc256_HmacSha256_B64:
if (encBytes.length <= 49) { // 1 + 16 + 32 + ctLength
console.error('Enc type (' + encType + ') not valid.');
return null;
}
@ -576,6 +588,7 @@ angular
break;
case constants.encType.AesCbc256_B64:
if (encBytes.length <= 17) { // 1 + 16 + ctLength
console.error('Enc type (' + encType + ') not valid.');
return null;
}
@ -583,6 +596,7 @@ angular
ctBytes = slice(encBytes, 17);
break;
default:
console.error('Enc type (' + encType + ') not supported.');
return null;
}
@ -592,6 +606,11 @@ angular
ivBytes.buffer,
macBytes ? macBytes.buffer : null,
key);
}
catch (e) {
console.error('Caught unhandled error in decryptFromBytes: ' + e);
throw e;
}
};
function aesDecryptWC(encType, ctBuf, ivBuf, macBuf, key) {