aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertube-crypto.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-27 18:25:35 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-27 18:25:35 +0100
commit38d78e5b82a30d1318e3cc2532b7ea22b8e163fa (patch)
tree3c4cdab683caf1e30c6e76ba78efeb0431fec932 /server/helpers/peertube-crypto.js
parentbf57d5eebf8b0fa2361b7973ce9772abd1bb4828 (diff)
downloadPeerTube-38d78e5b82a30d1318e3cc2532b7ea22b8e163fa.tar.gz
PeerTube-38d78e5b82a30d1318e3cc2532b7ea22b8e163fa.tar.zst
PeerTube-38d78e5b82a30d1318e3cc2532b7ea22b8e163fa.zip
Server: remove encryption when seending requests to other pods
We don't need it anymore since HTTPS is mandatory now
Diffstat (limited to 'server/helpers/peertube-crypto.js')
-rw-r--r--server/helpers/peertube-crypto.js48
1 files changed, 0 insertions, 48 deletions
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 = {
16 comparePassword, 16 comparePassword,
17 createCertsIfNotExist, 17 createCertsIfNotExist,
18 cryptPassword, 18 cryptPassword,
19 decrypt,
20 encrypt,
21 sign 19 sign
22} 20}
23 21
@@ -57,34 +55,6 @@ function cryptPassword (password, callback) {
57 }) 55 })
58} 56}
59 57
60function decrypt (key, data, callback) {
61 fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem', function (err, file) {
62 if (err) return callback(err)
63
64 const myPrivateKey = ursa.createPrivateKey(file)
65 const decryptedKey = myPrivateKey.decrypt(key, 'hex', 'utf8')
66 const decryptedData = symetricDecrypt(data, decryptedKey)
67
68 return callback(null, decryptedData)
69 })
70}
71
72function encrypt (publicKey, data, callback) {
73 const crt = ursa.createPublicKey(publicKey)
74
75 symetricEncrypt(data, function (err, dataEncrypted) {
76 if (err) return callback(err)
77
78 const key = crt.encrypt(dataEncrypted.password, 'utf8', 'hex')
79 const encrypted = {
80 data: dataEncrypted.crypted,
81 key: key
82 }
83
84 callback(null, encrypted)
85 })
86}
87
88function sign (data) { 58function sign (data) {
89 const myKey = ursa.createPrivateKey(fs.readFileSync(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem')) 59 const myKey = ursa.createPrivateKey(fs.readFileSync(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.key.pem'))
90 const signature = myKey.hashAndSign('sha256', data, 'utf8', 'hex') 60 const signature = myKey.hashAndSign('sha256', data, 'utf8', 'hex')
@@ -151,21 +121,3 @@ function generatePassword (callback) {
151 callback(null, buf.toString('utf8')) 121 callback(null, buf.toString('utf8'))
152 }) 122 })
153} 123}
154
155function symetricDecrypt (text, password) {
156 const decipher = crypto.createDecipher(algorithm, password)
157 let dec = decipher.update(text, 'hex', 'utf8')
158 dec += decipher.final('utf8')
159 return dec
160}
161
162function symetricEncrypt (text, callback) {
163 generatePassword(function (err, password) {
164 if (err) return callback(err)
165
166 const cipher = crypto.createCipher(algorithm, password)
167 let crypted = cipher.update(text, 'utf8', 'hex')
168 crypted += cipher.final('hex')
169 callback(null, { crypted: crypted, password: password })
170 })
171}