MCPcopy Create free account
hub / github.com/porsager/postgres / SASLContinue

Function SASLContinue

cf/src/connection.js:716–741  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

714 }
715
716 async function SASLContinue(x) {
717 const res = x.toString('utf8', 9).split(',').reduce((acc, x) => (acc[x[0]] = x.slice(2), acc), {})
718
719 const saltedPassword = await crypto.pbkdf2Sync(
720 await Pass(),
721 Buffer.from(res.s, 'base64'),
722 parseInt(res.i), 32,
723 'sha256'
724 )
725
726 const clientKey = await hmac(saltedPassword, 'Client Key')
727
728 const auth = 'n=*,r=' + nonce + ','
729 + 'r=' + res.r + ',s=' + res.s + ',i=' + res.i
730 + ',c=biws,r=' + res.r
731
732 serverSignature = (await hmac(await hmac(saltedPassword, 'Server Key'), auth)).toString('base64')
733
734 const payload = 'c=biws,r=' + res.r + ',p=' + xor(
735 clientKey, Buffer.from(await hmac(await sha256(clientKey), auth))
736 ).toString('base64')
737
738 write(
739 b().p().str(payload).end()
740 )
741 }
742
743 function SASLFinal(x) {
744 if (x.toString('utf8', 9).split(b.N, 1)[0].slice(2) === serverSignature)

Callers

nothing calls this directly

Calls 6

PassFunction · 0.70
hmacFunction · 0.70
xorFunction · 0.70
sha256Function · 0.70
writeFunction · 0.70
endMethod · 0.65

Tested by

no test coverage detected