diff --git a/lib/register-authenticator.js b/lib/register-authenticator.js index de82b5e..0357128 100644 --- a/lib/register-authenticator.js +++ b/lib/register-authenticator.js @@ -3,7 +3,6 @@ const debug = require('debug')('jambonz:sbc-registrar'); const bent = require('bent'); const qs = require('qs'); const crypto = require('crypto'); -const { decrypt } = require('./utils'); const toBase64 = (str) => Buffer.from(str || '', 'utf8').toString('base64'); function basicAuth(username, password) { @@ -172,8 +171,7 @@ async function clientAuthentication(logger, data, req) { if (clients.length) { // Only take the first result. const client = clients[0]; - const password = decrypt(client.password); - if (calculateResponse(data, password) === response) { + if (calculateResponse(data, client.password) === response) { return { status: 'ok', statusCode: 200 diff --git a/lib/utils.js b/lib/utils.js index dd79625..b120283 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,10 +1,3 @@ -const crypto = require('crypto'); -const algorithm = process.env.LEGACY_CRYPTO ? 'aes-256-ctr' : 'aes-256-cbc'; -const secretKey = crypto.createHash('sha256') - .update(process.env.ENCRYPTION_SECRET || process.env.JWT_SECRET) - .digest('base64') - .substring(0, 32); - function isUacBehindNat(req) { // no need for nat handling if wss or tcp being used @@ -21,16 +14,8 @@ function getSipProtocol(req) { if (req.getParsedHeader('Via')[0].protocol.toLowerCase().startsWith('udp')) return 'udp'; } -const decrypt = (data) => { - const hash = JSON.parse(data); - const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.from(hash.iv, 'hex')); - const decrpyted = Buffer.concat([decipher.update(Buffer.from(hash.content, 'hex')), decipher.final()]); - return decrpyted.toString(); -}; - module.exports = { isUacBehindNat, getSipProtocol, - decrypt, NAT_EXPIRES: 30 };