Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function buildEncryptionMaterialCacheKey (
partition: string,
{ suite, encryptionContext }: EncryptionRequest<s>
) {
const algorithmInfo = suite
? [new Uint8Array([1]), uInt16BE(suite.id)]
: [new Uint8Array([0])]
const key = await sha512(
await sha512(fromUtf8(partition)),
...algorithmInfo,
await encryptionContextHash(encryptionContext)
)
return toUtf8(key)
}
</s>
async function buildDecryptionMaterialCacheKey (
partition: string,
{ suite, encryptedDataKeys, encryptionContext }: DecryptionRequest<s>
) {
const { id } = suite
const key = await sha512(
await sha512(fromUtf8(partition)),
uInt16BE(id),
...(await encryptedDataKeysHash(encryptedDataKeys)),
BIT_PAD_512,
await encryptionContextHash(encryptionContext)
)
return toUtf8(key)
}
</s>