aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertubeCrypto.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-11 21:19:34 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-13 14:23:11 +0200
commitbc503c2a62dcf9aed6b8d90b68f0f27a7755ac01 (patch)
treea1fe1ad88afd29ee4d7cb05c480649d5a9c6f9a0 /server/helpers/peertubeCrypto.js
parent881a5e68b64e4acd43408852bbdc914643d8fac6 (diff)
downloadPeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.gz
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.zst
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.zip
Update to standard 7. Goodbye snake_case, I used to love you
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)