From 38d78e5b82a30d1318e3cc2532b7ea22b8e163fa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 27 Nov 2016 18:25:35 +0100 Subject: Server: remove encryption when seending requests to other pods We don't need it anymore since HTTPS is mandatory now --- server/helpers/peertube-crypto.js | 48 --------------------------------------- server/helpers/requests.js | 17 ++------------ 2 files changed, 2 insertions(+), 63 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/peertube-crypto.js b/server/helpers/peertube-crypto.js index 1ff638b04..2e07df00e 100644 --- a/server/helpers/peertube-crypto.js +++ b/server/helpers/peertube-crypto.js @@ -16,8 +16,6 @@ const peertubeCrypto = { comparePassword, createCertsIfNotExist, cryptPassword, - decrypt, - encrypt, sign } @@ -57,34 +55,6 @@ function cryptPassword (password, callback) { }) } -function decrypt (key, data, callback) { - fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem', function (err, file) { - if (err) return callback(err) - - const myPrivateKey = ursa.createPrivateKey(file) - const decryptedKey = myPrivateKey.decrypt(key, 'hex', 'utf8') - const decryptedData = symetricDecrypt(data, decryptedKey) - - return callback(null, decryptedData) - }) -} - -function encrypt (publicKey, data, callback) { - const crt = ursa.createPublicKey(publicKey) - - symetricEncrypt(data, function (err, dataEncrypted) { - if (err) return callback(err) - - const key = crt.encrypt(dataEncrypted.password, 'utf8', 'hex') - const encrypted = { - data: dataEncrypted.crypted, - key: key - } - - callback(null, encrypted) - }) -} - function sign (data) { const myKey = ursa.createPrivateKey(fs.readFileSync(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem')) const signature = myKey.hashAndSign('sha256', data, 'utf8', 'hex') @@ -151,21 +121,3 @@ function generatePassword (callback) { callback(null, buf.toString('utf8')) }) } - -function symetricDecrypt (text, password) { - const decipher = crypto.createDecipher(algorithm, password) - let dec = decipher.update(text, 'hex', 'utf8') - dec += decipher.final('utf8') - return dec -} - -function symetricEncrypt (text, callback) { - generatePassword(function (err, password) { - if (err) return callback(err) - - const cipher = crypto.createCipher(algorithm, password) - let crypted = cipher.update(text, 'utf8', 'hex') - crypted += cipher.final('hex') - callback(null, { crypted: crypted, password: password }) - }) -} diff --git a/server/helpers/requests.js b/server/helpers/requests.js index 06109ce16..b0cda09fe 100644 --- a/server/helpers/requests.js +++ b/server/helpers/requests.js @@ -44,21 +44,8 @@ function makeSecureRequest (params, callback) { // If there are data informations if (params.data) { - // Encrypt data - if (params.encrypt === true) { - peertubeCrypto.encrypt(params.toPod.publicKey, JSON.stringify(params.data), function (err, encrypted) { - if (err) return callback(err) - - requestParams.json.data = encrypted.data - requestParams.json.key = encrypted.key - - request.post(requestParams, callback) - }) - } else { - // No encryption - requestParams.json.data = params.data - request.post(requestParams, callback) - } + requestParams.json.data = params.data + request.post(requestParams, callback) } else { // No data request.post(requestParams, callback) -- cgit v1.2.3