1 import type { SessionKey } from '@proton/crypto'
2 import { HKDF_SALT_SIZE } from './Constants'
3 import { deriveKey } from '@proton/crypto/lib/subtle/aesGcm'
5 export async function deriveGcmKey(sessionKey: SessionKey, salt: Uint8Array, info: Uint8Array) {
6 if (sessionKey.algorithm !== 'aes256') {
7 throw new Error('Unexpected session key algorithm')
10 if (salt.length !== HKDF_SALT_SIZE) {
11 throw new Error('Unexpected salt size')
14 return deriveKey(sessionKey.data, salt, info)