aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertubeCrypto.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/peertubeCrypto.js')
-rw-r--r--server/helpers/peertubeCrypto.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/helpers/peertubeCrypto.js b/server/helpers/peertubeCrypto.js
index 3826ebaf6..46dff8d03 100644
--- a/server/helpers/peertubeCrypto.js
+++ b/server/helpers/peertubeCrypto.js
@@ -21,10 +21,10 @@ const peertubeCrypto = {
21 sign: sign 21 sign: sign
22} 22}
23 23
24function checkSignature (public_key, raw_data, hex_signature) { 24function checkSignature (publicKey, rawData, hexSignature) {
25 const crt = ursa.createPublicKey(public_key) 25 const crt = ursa.createPublicKey(publicKey)
26 const is_valid = crt.hashAndVerify('sha256', new Buffer(raw_data).toString('hex'), hex_signature, 'hex') 26 const isValid = crt.hashAndVerify('sha256', new Buffer(rawData).toString('hex'), hexSignature, 'hex')
27 return is_valid 27 return isValid
28} 28}
29 29
30function createCertsIfNotExist (callback) { 30function createCertsIfNotExist (callback) {
@@ -43,16 +43,16 @@ function decrypt (key, data, callback) {
43 fs.readFile(getCertDir() + 'peertube.key.pem', function (err, file) { 43 fs.readFile(getCertDir() + 'peertube.key.pem', function (err, file) {
44 if (err) return callback(err) 44 if (err) return callback(err)
45 45
46 const my_private_key = ursa.createPrivateKey(file) 46 const myPrivateKey = ursa.createPrivateKey(file)
47 const decrypted_key = my_private_key.decrypt(key, 'hex', 'utf8') 47 const decryptedKey = myPrivateKey.decrypt(key, 'hex', 'utf8')
48 const decrypted_data = symetricDecrypt(data, decrypted_key) 48 const decryptedData = symetricDecrypt(data, decryptedKey)
49 49
50 return callback(null, decrypted_data) 50 return callback(null, decryptedData)
51 }) 51 })
52} 52}
53 53
54function encrypt (public_key, data, callback) { 54function encrypt (publicKey, data, callback) {
55 const crt = ursa.createPublicKey(public_key) 55 const crt = ursa.createPublicKey(publicKey)
56 56
57 symetricEncrypt(data, function (err, dataEncrypted) { 57 symetricEncrypt(data, function (err, dataEncrypted) {
58 if (err) return callback(err) 58 if (err) return callback(err)