Finished requestPairingCode

This commit is contained in:
Alessandro Autiero
2023-07-16 20:14:17 +02:00
parent f498e1e56c
commit c506182035
8 changed files with 68 additions and 74 deletions

View File

@@ -411,31 +411,4 @@ export function bytesToCrockford(buffer: Buffer): string {
}
return crockford.join('')
}
export async function derivePairingKey(pairingCode: string, salt: Buffer) {
const encoded = new TextEncoder().encode(pairingCode)
const cryptoKey = await crypto.subtle.importKey(
'raw',
encoded,
{
name: 'PBKDF2'
},
!1,
[
'deriveKey'
]
)
return await crypto.subtle.deriveKey({
name: 'PBKDF2',
hash: 'SHA-256',
salt: salt,
iterations: 2 << 16
}, cryptoKey, {
name: 'AES-CTR',
length: 256
}, false, [
'encrypt',
'decrypt'
])
}