diff --git a/frontend/src/mesh/meshIdentity.ts b/frontend/src/mesh/meshIdentity.ts index 3612eaf..a07c89c 100644 --- a/frontend/src/mesh/meshIdentity.ts +++ b/frontend/src/mesh/meshIdentity.ts @@ -1086,7 +1086,7 @@ async function deriveSharedSecretWithPrivateKey( theirDHPubBase64: string, privateKey: CryptoKey, ): Promise { - const theirPubRaw = base64ToBuf(theirDHPubBase64); + const theirPubRaw = toCryptoBytes(base64ToBuf(theirDHPubBase64)); if (privateKey.algorithm.name === 'X25519') { const theirPubKey = await crypto.subtle.importKey('raw', theirPubRaw, 'X25519', false, []); return crypto.subtle.deriveBits({ name: 'X25519', public: theirPubKey }, privateKey, 256); @@ -1110,7 +1110,7 @@ export async function deriveSharedKey(theirDHPubBase64: string): Promise { const secret = await deriveSharedSecret(theirDHPubBase64); const salt = await sha256Bytes(`SB-SEAL-SALT|${recipientId}|${msgId}|${PROTOCOL_VERSION}`); - const hkdfKey = await crypto.subtle.importKey('raw', secret, 'HKDF', false, ['deriveKey']); + const hkdfKey = await crypto.subtle.importKey('raw', toCryptoBytes(secret), 'HKDF', false, [ + 'deriveKey', + ]); return crypto.subtle.deriveKey( { name: 'HKDF', @@ -1201,7 +1203,9 @@ export async function deriveSenderSealKeyV3( const salt = await sha256Bytes( `SB-SEAL-SALT|${recipientId}|${msgId}|${PROTOCOL_VERSION}|${ephemeralPubBase64}`, ); - const hkdfKey = await crypto.subtle.importKey('raw', secret, 'HKDF', false, ['deriveKey']); + const hkdfKey = await crypto.subtle.importKey('raw', toCryptoBytes(secret), 'HKDF', false, [ + 'deriveKey', + ]); return crypto.subtle.deriveKey( { name: 'HKDF', @@ -1229,7 +1233,9 @@ async function decryptSenderSealPayloadWithRetainedKeys( const salt = await sha256Bytes( `SB-SEAL-SALT|${recipientId}|${msgId}|${PROTOCOL_VERSION}|${ephemeralPubBase64}`, ); - const hkdfKey = await crypto.subtle.importKey('raw', secret, 'HKDF', false, ['deriveKey']); + const hkdfKey = await crypto.subtle.importKey('raw', toCryptoBytes(secret), 'HKDF', false, [ + 'deriveKey', + ]); const sealKey = await crypto.subtle.deriveKey( { name: 'HKDF',