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

Function SASLContinue

cjs/src/connection.js:714–739  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

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