1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 23:03:32 +00:00

tuneing up mdoels and services for site add

This commit is contained in:
Kyle Spearrin
2016-09-05 01:49:44 -04:00
parent cc67d12c57
commit abb6f37af2
8 changed files with 141 additions and 114 deletions

View File

@@ -7,6 +7,8 @@ function initCryptoService() {
_b64Key,
_aes;
sjcl.beware["CBC mode is dangerous because it doesn't protect message integrity."]();
CryptoService.prototype.setKey = function (key, callback) {
if (!callback || typeof callback !== 'function') {
throw 'callback function required';
@@ -101,6 +103,10 @@ function initCryptoService() {
throw 'callback function required';
}
if (plaintextValue === null || plaintextValue === undefined) {
callback(null);
}
this.getKey(false, function (key) {
if (!key) {
throw 'Encryption key unavailable.';
@@ -121,11 +127,15 @@ function initCryptoService() {
});
};
CryptoService.prototype.decrypt = function (cipherStrin, callback) {
CryptoService.prototype.decrypt = function (cipherString, callback) {
if (!callback || typeof callback !== 'function') {
throw 'callback function required';
}
if (cipherString === null || cipherString === undefined) {
throw 'cannot decrypt nothing';
}
this.getAes(function (aes) {
if (!aes) {
throw 'AES encryption unavailable.';