Refactor src/crypto/cipher/*.js to use import & export
This commit is contained in:
parent
60b23169ac
commit
19a97bf117
|
@ -511,4 +511,4 @@ export default {
|
||||||
128: makeClass(128),
|
128: makeClass(128),
|
||||||
192: makeClass(192),
|
192: makeClass(192),
|
||||||
256: makeClass(256)
|
256: makeClass(256)
|
||||||
}
|
};
|
|
@ -395,7 +395,7 @@ Blowfish.prototype.init = function(key) {
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
|
|
||||||
function BF(key) {
|
export default function BF(key) {
|
||||||
this.bf = new Blowfish();
|
this.bf = new Blowfish();
|
||||||
this.bf.init(key);
|
this.bf.init(key);
|
||||||
|
|
||||||
|
@ -403,8 +403,5 @@ function BF(key) {
|
||||||
return this.bf.encrypt_block(block);
|
return this.bf.encrypt_block(block);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
BF.keySize = BF.prototype.keySize = 16;
|
||||||
|
BF.blockSize = BF.prototype.blockSize = 16;
|
||||||
module.exports = BF;
|
|
||||||
module.exports.keySize = BF.prototype.keySize = 16;
|
|
||||||
module.exports.blockSize = BF.prototype.blockSize = 16;
|
|
|
@ -592,7 +592,7 @@ function OpenpgpSymencCast5() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Cast5(key) {
|
export default function Cast5(key) {
|
||||||
this.cast5 = new OpenpgpSymencCast5();
|
this.cast5 = new OpenpgpSymencCast5();
|
||||||
this.cast5.setKey(key);
|
this.cast5.setKey(key);
|
||||||
|
|
||||||
|
@ -601,6 +601,5 @@ function Cast5(key) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Cast5;
|
Cast5.blockSize = Cast5.prototype.blockSize = 8;
|
||||||
module.exports.blockSize = Cast5.prototype.blockSize = 8;
|
Cast5.keySize = Cast5.prototype.keySize = 16;
|
||||||
module.exports.keySize = Cast5.prototype.keySize = 16;
|
|
|
@ -422,9 +422,9 @@ function OriginalDes(key) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
/** @static */
|
/** @static */
|
||||||
des: Des,
|
des: Des,
|
||||||
/** @static */
|
/** @static */
|
||||||
originalDes: OriginalDes
|
originalDes: OriginalDes
|
||||||
};
|
};
|
|
@ -8,8 +8,11 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import desModule from './des.js';
|
|
||||||
import aes from'./aes.js';
|
import aes from'./aes.js';
|
||||||
|
import desModule from './des.js';
|
||||||
|
import cast5 from './cast5.js';
|
||||||
|
import twofish from './twofish.js';
|
||||||
|
import blowfish from './blowfish.js';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** @see module:crypto/cipher/aes */
|
/** @see module:crypto/cipher/aes */
|
||||||
|
@ -21,11 +24,11 @@ module.exports = {
|
||||||
/** @see module:crypto/cipher/des.des */
|
/** @see module:crypto/cipher/des.des */
|
||||||
tripledes: desModule.des,
|
tripledes: desModule.des,
|
||||||
/** @see module:crypto/cipher/cast5 */
|
/** @see module:crypto/cipher/cast5 */
|
||||||
cast5: require('./cast5.js'),
|
cast5: cast5,
|
||||||
/** @see module:crypto/cipher/twofish */
|
/** @see module:crypto/cipher/twofish */
|
||||||
twofish: require('./twofish.js'),
|
twofish: twofish,
|
||||||
/** @see module:crypto/cipher/blowfish */
|
/** @see module:crypto/cipher/blowfish */
|
||||||
blowfish: require('./blowfish.js'),
|
blowfish: blowfish,
|
||||||
/** Not implemented */
|
/** Not implemented */
|
||||||
idea: function() {
|
idea: function() {
|
||||||
throw new Error('IDEA symmetric-key algorithm not implemented');
|
throw new Error('IDEA symmetric-key algorithm not implemented');
|
||||||
|
|
|
@ -329,7 +329,7 @@ function createTwofish() {
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
|
|
||||||
function TF(key) {
|
export default function TF(key) {
|
||||||
this.tf = createTwofish();
|
this.tf = createTwofish();
|
||||||
this.tf.open(toArray(key), 0);
|
this.tf.open(toArray(key), 0);
|
||||||
|
|
||||||
|
@ -347,7 +347,5 @@ function toArray(typedArray) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TF.keySize = TF.prototype.keySize = 32;
|
||||||
module.exports = TF;
|
TF.blockSize = TF.prototype.blockSize = 16;
|
||||||
module.exports.keySize = TF.prototype.keySize = 32;
|
|
||||||
module.exports.blockSize = TF.prototype.blockSize = 16;
|
|
Loading…
Reference in New Issue
Block a user