Skip to content

Platform storage ​

The same JavaScript API uses different native storage systems on Apple platforms and Android.

Apple Keychain ​

Generic credentials use kSecClassGenericPassword; internet credentials use kSecClassInternetPassword. The accessible option controls when an item can be accessed, and accessControl adds an authentication policy.

OptionWhat it controls
accessibleWhen the item is available, such as after the first unlock.
accessControlWhether authentication is required to access the item.
accessGroupThe entitled Keychain group that owns the item.
cloudSyncWhether to select synchronizable items.

Keep the service or server, access group, and synchronization setting consistent across operations. See Data persistence for synchronization and reinstall behavior.

Android Keystore ​

Encrypted credentials are stored in Jetpack DataStore. The encryption keys are managed by Android Keystore.

When storage is omitted, the library selects a cipher using the Android version, requested access control, and available authentication methods. Without storage or accessControl, it selects storage that does not require user authentication. The returned storage field identifies the cipher used.

Storage types ​

StorageAuthenticationUse
AES_GCMRequiredAES-GCM with user authentication.
RSARequiredRSA with user authentication.
AES_GCM_NO_AUTHNot requiredAES-GCM without an authentication prompt.
AES_CBCNot requiredLegacy entries; deprecated for new writes.

Authentication requirements and hardware protection are separate choices. An unauthenticated cipher still encrypts credentials; it simply does not require the user to approve access.

ts
import * as Keychain from 'react-native-keychain';

await Keychain.setGenericPassword('session', 'example-token', {
  service: 'com.example.session',
  storage: Keychain.STORAGE_TYPE.AES_GCM_NO_AUTH,
});

Reads use the cipher recorded with the entry. Changing the default for new writes does not automatically re-encrypt existing credentials. See Common questions before upgrading older Android installations.

Security levels ​

SECURITY_LEVEL expresses the required protection of Android key material:

  • ANY accepts the available level.
  • SECURE_SOFTWARE requires at least software protection.
  • SECURE_HARDWARE requires hardware-backed protection.

Hardware-backed keys can use a Trusted Execution Environment (TEE) or StrongBox. A TEE is not the same as software-only key storage, and SECURE_HARDWARE does not specifically promise StrongBox. See Android Keystore for the platform's security model.

A device may not satisfy the requested level. Handle a rejected operation without silently lowering the requirement. Emulator results do not establish hardware-backed security on a real device.