test: minor refactoring of onticketkeycallback

The motivation for this commit is to make the the onticketkeycallback
function more readable.

PR-URL: https://github.com/nodejs/node/pull/24718
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Daniel Bevenius 2018-11-29 09:21:06 +01:00 committed by Rich Trott
parent f0b6b39324
commit 82ceb5e4b1

View File

@ -22,16 +22,13 @@ const hmac = Buffer.alloc(16, 'H');
server._sharedCreds.context.enableTicketKeyCallback();
server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) {
let newName, newIV;
if (enc) {
newName = Buffer.alloc(16, 'A');
newIV = crypto.randomBytes(16);
} else {
// Renew
return [ 2, hmac, aes ];
const newName = Buffer.alloc(16, 'A');
const newIV = crypto.randomBytes(16);
return [ 1, hmac, aes, newName, newIV ];
}
return [ 1, hmac, aes, newName, newIV ];
// Renew
return [ 2, hmac, aes ];
};
server.listen(0, function() {