2016-12-21 23:37:48 +00:00
|
|
|
/*
|
|
|
|
* This is a stupid little mock that basically disabled encryption.
|
|
|
|
* The reason it is needed is because the Forge module loader doesn't
|
|
|
|
* play along with Jest.
|
|
|
|
*/
|
2017-02-26 21:12:51 +00:00
|
|
|
const forge = require('../../node_modules/node-forge/lib/index');
|
2016-12-21 23:37:48 +00:00
|
|
|
|
2017-02-26 21:12:51 +00:00
|
|
|
module.exports = {
|
|
|
|
jsbn: forge.jsbn,
|
|
|
|
util: forge.util,
|
|
|
|
pkcs5: {
|
2019-04-18 00:50:03 +00:00
|
|
|
pbkdf2: forge.pkcs5.pbkdf2,
|
2017-02-26 21:12:51 +00:00
|
|
|
},
|
|
|
|
md: {
|
2019-04-18 00:50:03 +00:00
|
|
|
sha256: forge.md.sha256,
|
2017-02-26 21:12:51 +00:00
|
|
|
},
|
|
|
|
rsa: {
|
2018-06-25 17:42:50 +00:00
|
|
|
setPublicKey() {
|
2017-01-09 21:59:52 +00:00
|
|
|
return {
|
2018-06-25 17:42:50 +00:00
|
|
|
encrypt(str) {
|
2017-03-03 20:09:08 +00:00
|
|
|
return str;
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2017-03-03 20:09:08 +00:00
|
|
|
};
|
2017-01-09 21:59:52 +00:00
|
|
|
},
|
2018-06-25 17:42:50 +00:00
|
|
|
setPrivateKey() {
|
2017-01-09 21:59:52 +00:00
|
|
|
return {
|
2018-06-25 17:42:50 +00:00
|
|
|
decrypt(str) {
|
2017-03-03 20:09:08 +00:00
|
|
|
return str;
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2017-03-03 20:09:08 +00:00
|
|
|
};
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2017-02-26 21:12:51 +00:00
|
|
|
},
|
|
|
|
random: {
|
2018-06-25 17:42:50 +00:00
|
|
|
getBytesSync(n) {
|
2016-12-21 23:37:48 +00:00
|
|
|
let s = '';
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
|
|
s += 'a';
|
|
|
|
}
|
|
|
|
return s;
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2017-02-26 21:12:51 +00:00
|
|
|
},
|
|
|
|
pki: {
|
2017-01-09 21:59:52 +00:00
|
|
|
rsa: {
|
2018-06-25 17:42:50 +00:00
|
|
|
generateKeyPair() {
|
2017-01-09 21:59:52 +00:00
|
|
|
return {
|
|
|
|
privateKey: {
|
|
|
|
d: 'a',
|
|
|
|
dP: 'a',
|
|
|
|
dQ: 'a',
|
|
|
|
e: 'a',
|
|
|
|
n: 'a',
|
|
|
|
p: 'a',
|
|
|
|
q: 'a',
|
2018-12-12 17:36:11 +00:00
|
|
|
qInv: 'a',
|
2017-01-09 21:59:52 +00:00
|
|
|
},
|
|
|
|
publicKey: {
|
|
|
|
e: 'a',
|
2018-12-12 17:36:11 +00:00
|
|
|
n: 'a',
|
|
|
|
},
|
2017-03-03 20:09:08 +00:00
|
|
|
};
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
|
|
|
},
|
2017-02-26 21:12:51 +00:00
|
|
|
},
|
|
|
|
cipher: {
|
2018-06-25 17:42:50 +00:00
|
|
|
createCipher(alg, key) {
|
2016-12-21 23:37:48 +00:00
|
|
|
return {
|
2018-06-25 17:42:50 +00:00
|
|
|
start(config) {
|
2016-12-21 23:37:48 +00:00
|
|
|
this._config = config;
|
|
|
|
},
|
2018-06-25 17:42:50 +00:00
|
|
|
update(buffer) {
|
2016-12-21 23:37:48 +00:00
|
|
|
this._data = buffer;
|
|
|
|
},
|
2018-06-25 17:42:50 +00:00
|
|
|
finish() {
|
|
|
|
this.mode = { tag: 'tag' };
|
2016-12-21 23:37:48 +00:00
|
|
|
this.output = this._data;
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2016-12-21 23:37:48 +00:00
|
|
|
};
|
|
|
|
},
|
2018-06-25 17:42:50 +00:00
|
|
|
createDecipher(alg, key) {
|
2016-12-21 23:37:48 +00:00
|
|
|
return {
|
2018-06-25 17:42:50 +00:00
|
|
|
start(config) {
|
2016-12-21 23:37:48 +00:00
|
|
|
this._config = config;
|
|
|
|
},
|
2018-06-25 17:42:50 +00:00
|
|
|
update(buffer) {
|
2016-12-21 23:37:48 +00:00
|
|
|
this.output = buffer;
|
|
|
|
},
|
2018-06-25 17:42:50 +00:00
|
|
|
finish() {
|
2016-12-21 23:37:48 +00:00
|
|
|
return true;
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2016-12-21 23:37:48 +00:00
|
|
|
};
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
|
|
|
},
|
2017-02-26 21:12:51 +00:00
|
|
|
};
|