Skip to content

Commit 588df9c

Browse files
committed
fix(mobile): resolve node-forge type compatibility in key derivation
1 parent 7b47f37 commit 588df9c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
22
* Base Cryptographic Utilities
33
* Conversion and encoding helpers
4+
*
5+
* Note: All encoding/decoding is handled by node-forge utilities
6+
* to maintain compatibility with the web app implementation.
47
*/
5-
6-
export function stringToUint8Array(str: string): Uint8Array {
7-
const encoder = new TextEncoder();
8-
return encoder.encode(str);
9-
}

apps/mobile/v1/src/lib/encryption/core/keyDerivation.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import forge from 'node-forge';
77
import { ENCRYPTION_CONFIG } from '../config';
8-
import { stringToUint8Array } from './crypto';
8+
99

1010
/**
1111
* PBKDF2 implementation using node-forge to match web app
@@ -20,9 +20,8 @@ export async function pbkdf2(
2020
// Convert inputs to proper format to match web app
2121
const passwordBytes = forge.util.encodeUtf8(password);
2222

23-
// Convert salt string to bytes using TextEncoder equivalent
24-
const saltUint8Array = stringToUint8Array(salt);
25-
const saltBytes = forge.util.createBuffer(saltUint8Array).data;
23+
// Salt is already a string, use it directly
24+
const saltBytes = forge.util.encodeUtf8(salt);
2625

2726
// Perform PBKDF2 computation (will block for ~2 minutes with 250k iterations)
2827
const derivedKey = forge.pkcs5.pbkdf2(

0 commit comments

Comments
 (0)