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

Function SASLContinue

deno/src/connection.js:717–742  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

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