Name anonymous functions for debugging purposes.
It also makes profiling more convenient.
This commit is contained in:
parent
0d5efbe9fe
commit
5ce5ca03d3
39
crypto.js
39
crypto.js
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ARCFourCipher = (function() {
|
var ARCFourCipher = (function aRCFourCipher() {
|
||||||
function constructor(key) {
|
function constructor(key) {
|
||||||
this.a = 0;
|
this.a = 0;
|
||||||
this.b = 0;
|
this.b = 0;
|
||||||
@ -21,7 +21,7 @@ var ARCFourCipher = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
encryptBlock: function(data) {
|
encryptBlock: function aRCFourCipherEncryptBlock(data) {
|
||||||
var i, n = data.length, tmp, tmp2;
|
var i, n = data.length, tmp, tmp2;
|
||||||
var a = this.a, b = this.b, s = this.s;
|
var a = this.a, b = this.b, s = this.s;
|
||||||
var output = new Uint8Array(n);
|
var output = new Uint8Array(n);
|
||||||
@ -45,7 +45,7 @@ var ARCFourCipher = (function() {
|
|||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var md5 = (function() {
|
var md5 = (function md5Md5() {
|
||||||
var r = new Uint8Array([
|
var r = new Uint8Array([
|
||||||
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
|
||||||
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
|
||||||
@ -129,12 +129,12 @@ var md5 = (function() {
|
|||||||
return hash;
|
return hash;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var NullCipher = (function() {
|
var NullCipher = (function nullCipher() {
|
||||||
function constructor() {
|
function constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
decryptBlock: function(data) {
|
decryptBlock: function nullCipherDecryptBlock(data) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -142,7 +142,7 @@ var NullCipher = (function() {
|
|||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var AES128Cipher = (function() {
|
var AES128Cipher = (function aES128Cipher() {
|
||||||
var rcon = new Uint8Array([
|
var rcon = new Uint8Array([
|
||||||
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
|
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
|
||||||
0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
|
0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
|
||||||
@ -372,7 +372,7 @@ var AES128Cipher = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
decryptBlock: function(data) {
|
decryptBlock: function aES128CipherDecryptBlock(data) {
|
||||||
var i, sourceLength = data.length;
|
var i, sourceLength = data.length;
|
||||||
var buffer = this.buffer, bufferLength = this.bufferPosition;
|
var buffer = this.buffer, bufferLength = this.bufferPosition;
|
||||||
// waiting for IV values -- they are at the start of the stream
|
// waiting for IV values -- they are at the start of the stream
|
||||||
@ -395,19 +395,21 @@ var AES128Cipher = (function() {
|
|||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var CipherTransform = (function() {
|
var CipherTransform = (function cipherTransform() {
|
||||||
function constructor(stringCipherConstructor, streamCipherConstructor) {
|
function constructor(stringCipherConstructor, streamCipherConstructor) {
|
||||||
this.stringCipherConstructor = stringCipherConstructor;
|
this.stringCipherConstructor = stringCipherConstructor;
|
||||||
this.streamCipherConstructor = streamCipherConstructor;
|
this.streamCipherConstructor = streamCipherConstructor;
|
||||||
}
|
}
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
createStream: function(stream) {
|
createStream: function cipherTransformCreateStream(stream) {
|
||||||
var cipher = new this.streamCipherConstructor();
|
var cipher = new this.streamCipherConstructor();
|
||||||
return new DecryptStream(stream, function(data) {
|
return new DecryptStream(stream,
|
||||||
|
function cipherTransformDecryptStream(data) {
|
||||||
return cipher.decryptBlock(data);
|
return cipher.decryptBlock(data);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
decryptString: function(s) {
|
decryptString: function cipherTransformDecryptString(s) {
|
||||||
var cipher = new this.stringCipherConstructor();
|
var cipher = new this.stringCipherConstructor();
|
||||||
var data = stringToBytes(s);
|
var data = stringToBytes(s);
|
||||||
data = cipher.decryptBlock(data);
|
data = cipher.decryptBlock(data);
|
||||||
@ -417,7 +419,7 @@ var CipherTransform = (function() {
|
|||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var CipherTransformFactory = (function() {
|
var CipherTransformFactory = (function cipherTransformFactory() {
|
||||||
function prepareKeyData(fileId, password, ownerPassword, userPassword,
|
function prepareKeyData(fileId, password, ownerPassword, userPassword,
|
||||||
flags, revision, keyLength, encryptMetadata) {
|
flags, revision, keyLength, encryptMetadata) {
|
||||||
var defaultPasswordBytes = new Uint8Array([
|
var defaultPasswordBytes = new Uint8Array([
|
||||||
@ -552,18 +554,18 @@ var CipherTransformFactory = (function() {
|
|||||||
if (cryptFilter != null)
|
if (cryptFilter != null)
|
||||||
cfm = cryptFilter.get('CFM');
|
cfm = cryptFilter.get('CFM');
|
||||||
if (!cfm || cfm.name == 'None') {
|
if (!cfm || cfm.name == 'None') {
|
||||||
return function() {
|
return function cipherTransformFactoryBuildCipherConstructorNone() {
|
||||||
return new NullCipher();
|
return new NullCipher();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if ('V2' == cfm.name) {
|
if ('V2' == cfm.name) {
|
||||||
return function() {
|
return function cipherTransformFactoryBuildCipherConstructorV2() {
|
||||||
return new ARCFourCipher(
|
return new ARCFourCipher(
|
||||||
buildObjectKey(num, gen, key, false));
|
buildObjectKey(num, gen, key, false));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if ('AESV2' == cfm.name) {
|
if ('AESV2' == cfm.name) {
|
||||||
return function() {
|
return function cipherTransformFactoryBuildCipherConstructorAESV2() {
|
||||||
return new AES128Cipher(
|
return new AES128Cipher(
|
||||||
buildObjectKey(num, gen, key, true));
|
buildObjectKey(num, gen, key, true));
|
||||||
};
|
};
|
||||||
@ -573,7 +575,8 @@ var CipherTransformFactory = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
createCipherTransform: function(num, gen) {
|
createCipherTransform: function buildCipherCreateCipherTransform(num,
|
||||||
|
gen) {
|
||||||
if (this.algorithm == 4) {
|
if (this.algorithm == 4) {
|
||||||
return new CipherTransform(
|
return new CipherTransform(
|
||||||
buildCipherConstructor(this.cf, this.stmf,
|
buildCipherConstructor(this.cf, this.stmf,
|
||||||
@ -583,7 +586,7 @@ var CipherTransformFactory = (function() {
|
|||||||
}
|
}
|
||||||
// algorithms 1 and 2
|
// algorithms 1 and 2
|
||||||
var key = buildObjectKey(num, gen, this.encryptionKey, false);
|
var key = buildObjectKey(num, gen, this.encryptionKey, false);
|
||||||
var cipherConstructor = function() {
|
var cipherConstructor = function buildCipherCipherConstructor() {
|
||||||
return new ARCFourCipher(key);
|
return new ARCFourCipher(key);
|
||||||
};
|
};
|
||||||
return new CipherTransform(cipherConstructor, cipherConstructor);
|
return new CipherTransform(cipherConstructor, cipherConstructor);
|
||||||
|
Loading…
Reference in New Issue
Block a user