diff --git a/src/node/security/SecretRotator.js b/src/node/security/SecretRotator.js index 3cc08a01c..4077c6f64 100644 --- a/src/node/security/SecretRotator.js +++ b/src/node/security/SecretRotator.js @@ -1,7 +1,8 @@ 'use strict'; const {Buffer} = require('buffer'); -const crypto = require('./crypto'); +const crypto = require('node:crypto') +const cryptoHelper = require('./crypto') const db = require('../db/DB'); const log4js = require('log4js'); @@ -30,8 +31,7 @@ class Hkdf extends Kdf { } async derive(p, info) { - return Buffer.from( - await crypto.hkdf(p.digest, p.secret, p.salt, info, p.keyLen)).toString('hex'); + return Buffer.from(await cryptoHelper.hkdf(p.digest, p.secret, p.salt, info, p.keyLen)).toString('hex'); } } diff --git a/src/node/security/crypto.js b/src/node/security/crypto.js index 95b3986fe..428804cc3 100644 --- a/src/node/security/crypto.js +++ b/src/node/security/crypto.js @@ -2,7 +2,13 @@ const crypto = require('crypto'); -const newMethod = async (...args) => new Promise((resolve) => crypto.hkdf(...args, resolve)); +const newMethod = async (...args) => new Promise((resolve, reject) => crypto.hkdf(...args, (err, result)=>{ + if(err){ + return reject(err) + } else { + return resolve(result) + } +})); /** * Promisified version of Node.js's crypto.hkdf.