
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-secure-encryption-module
Advanced tools
Uses Secure Enclave for iOs and KeyStore System for Android to Encypt Data Securely and keeping Secrets Safe on Hardware Level
Uses Secure Enclave for iOS and KeyStore System for Android to encrypt data securely and keeping secrets safe on hardware level
npm install react-native-secure-encryption-module
Alias will be used throughout the process to access the key's and perform cryptographic actions with it.
import { generateKeyPair } from 'react-native-secure-encryption-module';
// ...
const key = await generateKeyPair('my-key');
The method returns a base64 encoded public key.
In case a key already exists it can be fetched with:
import { getKey } from 'react-native-secure-encryption-module';
// ...
const key = await getKey('my-key');
In case the Key does not exist, the promise will be rejected
We want to use our keys to either encrypt or sign a string. Both can be done easily like
import { encrypt } from 'react-native-secure-encryption-module';
// ...
const cipher = await encrypt('Encrypt this message', 'my-key');
Return value is a base64 encoded cipher string
import { sign } from 'react-native-secure-encryption-module';
// ...
const sign = await sign('Sign this message', 'my-key');
Return value is a base64 encoded signature
After encrypting or signing the original string is not readable for a human and can be transported over non-trusted channels. To decrypt the cipher or verify the signature we can call following methods
import { decrypt } from 'react-native-secure-encryption-module';
// ...
// hash is the result of an earlier encryption
const cipher = '0xasdfasdfa....';
const clearText = await decrypt(cipher, 'my-key');
Return value should be the original method before encryption as string
import { verify } from 'react-native-secure-encryption-module';
// ...
// signature is the result of the `sign` method
const signature = '0xasdfasdfa....';
const originalMessage = 'Sign this message';
const isOk = await verify(signature, originalMessage, 'my-key');
Return value is a boolean representing if the signature is really performed by our key
Of course the hardware level security can only be achieved if the Device itself supports it. To read more about that
android - Android keystore system ios: Secure Enclave
We can check if our device supports what we need by calling
import { isKeySecuredOnHardware } from 'react-native-secure-encryption-module';
// ...
const isSupported = await isKeySecuredOnHardware('my-key');
Return value is a boolean representing if hardware level security is available
The Library depends on native logic that can fail. The Promises, which are returned by all functions from the library, will be rejected with an Error message in that case.
The Public keys, which are returned by generateKeyPairand getKey are returned in PEM format. Additional Effort has been put in to be able to verify Signatures from Android and iOS
in the same way.
The goal was to be able to verify signatures with openssl and therefore being able to verify using Node.js
Here the node.js Example:
import crypto from "crypto";
const verify = (
message: string, // The original message which was signed by using this library
signature: string, // The result of the sign method
publicKey: string // The result from generateKeyPair or getKey
): boolean => {
const verifier = crypto.createVerify("SHA256").update(message, "utf-8");
const result = verifier.verify(
{
key: buildPubKey(publicKey),
format: "pem",
type: "pkcs1",
},
Buffer.from(signature, "base64")
);
return result;
};
const buildPubKey = (encoded: string): string => {
const l1 = "-----BEGIN PUBLIC KEY-----\n";
const l3 = "\n-----END PUBLIC KEY-----";
return l1 + encoded + l3;
};
Android: en- and decryption
MIT
FAQs
Uses Secure Enclave for iOs and KeyStore System for Android to Encypt Data Securely and keeping Secrets Safe on Hardware Level
The npm package react-native-secure-encryption-module receives a total of 0 weekly downloads. As such, react-native-secure-encryption-module popularity was classified as not popular.
We found that react-native-secure-encryption-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.