From c8063785853e516280cd68e9d8e9ae79b2081989 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 27 Jan 2024 20:08:18 +0100 Subject: cache room hashes, bump version --- client-web/source/protocol/crypto.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'client-web/source/protocol/crypto.ts') diff --git a/client-web/source/protocol/crypto.ts b/client-web/source/protocol/crypto.ts index 784bd49..ebb552a 100644 --- a/client-web/source/protocol/crypto.ts +++ b/client-web/source/protocol/crypto.ts @@ -12,7 +12,7 @@ const IV_LENGTH = 12 const CRYPTO_SALT = base64_to_buf("keksmeet/cryptosaltAAA==") const HASH_SALT = base64_to_buf("keksmeet/roomhashsaltA==") -export async function crypto_seeded_key(seed: string): Promise { +export async function derive_seeded_key(seed: string): Promise { log("crypto", "deriving crytographic key...") const seed_key = await window.crypto.subtle.importKey( "raw", @@ -32,7 +32,7 @@ export async function crypto_seeded_key(seed: string): Promise { return key } -export async function crypto_hash(input: string): Promise { +export async function room_hash(input: string): Promise { log("crypto", "deriving room hash...") const seed_key = await window.crypto.subtle.importKey( "raw", @@ -50,7 +50,7 @@ export async function crypto_hash(input: string): Promise { return hex } -export async function crypto_encrypt(key: CryptoKey, data: string): Promise { +export async function encrypt(key: CryptoKey, data: string): Promise { const iv = window.crypto.getRandomValues(new Uint8Array(IV_LENGTH)); const ciphertext = new Uint8Array(await window.crypto.subtle.encrypt( { name: "AES-GCM", iv }, @@ -64,7 +64,7 @@ export async function crypto_encrypt(key: CryptoKey, data: string): Promise { +export async function decrypt(key: CryptoKey, data: string): Promise { try { const buf = base64_to_buf(data); const iv = buf.slice(0, IV_LENGTH); -- cgit v1.2.3-70-g09d2