@capgo/capacitor-native-biometric 8.3.1 → 8.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -363,12 +363,15 @@ public class NativeBiometric extends Plugin {
363
363
  Cipher cipher;
364
364
  cipher = Cipher.getInstance(TRANSFORMATION);
365
365
 
366
- // Generate a random IV for each encryption operation
367
- byte[] iv = new byte[GCM_IV_LENGTH];
368
- SecureRandom secureRandom = new SecureRandom();
369
- secureRandom.nextBytes(iv);
370
-
371
- cipher.init(Cipher.ENCRYPT_MODE, getKey(KEY_ALIAS), new GCMParameterSpec(128, iv));
366
+ // Let the system generate the IV to comply with hardware-backed keystore requirements
367
+ // Modern Android devices with StrongBox/TEE enforce RandomizedEncryption and reject caller-provided IVs
368
+ cipher.init(Cipher.ENCRYPT_MODE, getKey(KEY_ALIAS));
369
+ byte[] iv = cipher.getIV(); // Retrieve the system-generated IV
370
+ if (iv == null || iv.length != GCM_IV_LENGTH) {
371
+ throw new GeneralSecurityException(
372
+ "Failed to generate valid IV: expected " + GCM_IV_LENGTH + " bytes, got " + (iv == null ? "null" : iv.length + " bytes")
373
+ );
374
+ }
372
375
  byte[] encryptedBytes = cipher.doFinal(stringToEncrypt.getBytes(StandardCharsets.UTF_8));
373
376
 
374
377
  // Prepend IV to the encrypted data
@@ -11,7 +11,7 @@ import LocalAuthentication
11
11
 
12
12
  @objc(NativeBiometricPlugin)
13
13
  public class NativeBiometricPlugin: CAPPlugin, CAPBridgedPlugin {
14
- private let pluginVersion: String = "8.3.1"
14
+ private let pluginVersion: String = "8.3.3"
15
15
  public let identifier = "NativeBiometricPlugin"
16
16
  public let jsName = "NativeBiometric"
17
17
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-biometric",
3
- "version": "8.3.1",
3
+ "version": "8.3.3",
4
4
  "description": "This plugin gives access to the native biometric apis for android and iOS",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",