mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
switching to alternate rsa implementation
This commit is contained in:
parent
7f85bfb66b
commit
be43f6829a
@ -328,6 +328,7 @@
|
|||||||
"${BUILT_PRODUCTS_DIR}/glog/glog.framework",
|
"${BUILT_PRODUCTS_DIR}/glog/glog.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
|
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/react-native-document-picker/react_native_document_picker.framework",
|
"${BUILT_PRODUCTS_DIR}/react-native-document-picker/react_native_document_picker.framework",
|
||||||
|
"${BUILT_PRODUCTS_DIR}/react-native-rsa-native/react_native_rsa_native.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/react-native-safe-area-context/react_native_safe_area_context.framework",
|
"${BUILT_PRODUCTS_DIR}/react-native-safe-area-context/react_native_safe_area_context.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/react-native-sqlite-storage/react_native_sqlite_storage.framework",
|
"${BUILT_PRODUCTS_DIR}/react-native-sqlite-storage/react_native_sqlite_storage.framework",
|
||||||
);
|
);
|
||||||
@ -376,6 +377,7 @@
|
|||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_document_picker.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_document_picker.framework",
|
||||||
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_rsa_native.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_safe_area_context.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_safe_area_context.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_sqlite_storage.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_sqlite_storage.framework",
|
||||||
);
|
);
|
||||||
|
@ -298,6 +298,8 @@ PODS:
|
|||||||
- glog
|
- glog
|
||||||
- react-native-document-picker (8.1.1):
|
- react-native-document-picker (8.1.1):
|
||||||
- React-Core
|
- React-Core
|
||||||
|
- react-native-rsa-native (2.0.5):
|
||||||
|
- React
|
||||||
- react-native-safe-area-context (4.3.3):
|
- react-native-safe-area-context (4.3.3):
|
||||||
- RCT-Folly
|
- RCT-Folly
|
||||||
- RCTRequired
|
- RCTRequired
|
||||||
@ -497,6 +499,7 @@ DEPENDENCIES:
|
|||||||
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
|
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
|
||||||
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
|
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
|
||||||
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
|
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
|
||||||
|
- react-native-rsa-native (from `../node_modules/react-native-rsa-native`)
|
||||||
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
|
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
|
||||||
- react-native-sqlite-storage (from `../node_modules/react-native-sqlite-storage`)
|
- react-native-sqlite-storage (from `../node_modules/react-native-sqlite-storage`)
|
||||||
- react-native-video (from `../node_modules/react-native-video`)
|
- react-native-video (from `../node_modules/react-native-video`)
|
||||||
@ -597,6 +600,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: "../node_modules/react-native/ReactCommon/logger"
|
:path: "../node_modules/react-native/ReactCommon/logger"
|
||||||
react-native-document-picker:
|
react-native-document-picker:
|
||||||
:path: "../node_modules/react-native-document-picker"
|
:path: "../node_modules/react-native-document-picker"
|
||||||
|
react-native-rsa-native:
|
||||||
|
:path: "../node_modules/react-native-rsa-native"
|
||||||
react-native-safe-area-context:
|
react-native-safe-area-context:
|
||||||
:path: "../node_modules/react-native-safe-area-context"
|
:path: "../node_modules/react-native-safe-area-context"
|
||||||
react-native-sqlite-storage:
|
react-native-sqlite-storage:
|
||||||
@ -689,6 +694,7 @@ SPEC CHECKSUMS:
|
|||||||
React-jsinspector: e385fb7a1440ae3f3b2cd1a139ca5aadaab43c10
|
React-jsinspector: e385fb7a1440ae3f3b2cd1a139ca5aadaab43c10
|
||||||
React-logger: 15c734997c06fe9c9b88e528fb7757601e7a56df
|
React-logger: 15c734997c06fe9c9b88e528fb7757601e7a56df
|
||||||
react-native-document-picker: f68191637788994baed5f57d12994aa32cf8bf88
|
react-native-document-picker: f68191637788994baed5f57d12994aa32cf8bf88
|
||||||
|
react-native-rsa-native: 12132eb627797529fdb1f0d22fd0f8f9678df64a
|
||||||
react-native-safe-area-context: b456e1c40ec86f5593d58b275bd0e9603169daca
|
react-native-safe-area-context: b456e1c40ec86f5593d58b275bd0e9603169daca
|
||||||
react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261
|
react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261
|
||||||
react-native-video: c26780b224543c62d5e1b2a7244a5cd1b50e8253
|
react-native-video: c26780b224543c62d5e1b2a7244a5cd1b50e8253
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"react-native-gesture-handler": "^2.7.0",
|
"react-native-gesture-handler": "^2.7.0",
|
||||||
"react-native-image-crop-picker": "^0.38.0",
|
"react-native-image-crop-picker": "^0.38.0",
|
||||||
"react-native-reanimated": "^2.10.0",
|
"react-native-reanimated": "^2.10.0",
|
||||||
|
"react-native-rsa-native": "^2.0.5",
|
||||||
"react-native-safe-area-context": "^4.3.3",
|
"react-native-safe-area-context": "^4.3.3",
|
||||||
"react-native-safe-area-view": "^1.1.1",
|
"react-native-safe-area-view": "^1.1.1",
|
||||||
"react-native-screens": "^3.18.2",
|
"react-native-screens": "^3.18.2",
|
||||||
|
@ -3,6 +3,7 @@ import { ConversationContext } from 'context/ConversationContext';
|
|||||||
import { AccountContext } from 'context/AccountContext';
|
import { AccountContext } from 'context/AccountContext';
|
||||||
import CryptoJS from 'crypto-js';
|
import CryptoJS from 'crypto-js';
|
||||||
import { JSEncrypt } from 'jsencrypt'
|
import { JSEncrypt } from 'jsencrypt'
|
||||||
|
import { RSA } from 'react-native-rsa-native';
|
||||||
|
|
||||||
export function useConversation() {
|
export function useConversation() {
|
||||||
|
|
||||||
@ -33,19 +34,28 @@ export function useConversation() {
|
|||||||
setState((s) => ({ ...s, ...value }));
|
setState((s) => ({ ...s, ...value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const converPem = (str) => {
|
||||||
|
var result = '';
|
||||||
|
while (str.length > 0) {
|
||||||
|
result += str.substring(0, 64) + '\n';
|
||||||
|
str = str.substring(64);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let sealKey;
|
let sealKey;
|
||||||
const { locked, seals } = conversation.state;
|
const { locked, seals } = conversation.state;
|
||||||
if (seals?.length) {
|
if (seals?.length) {
|
||||||
seals.forEach(seal => {
|
seals.forEach(seal => {
|
||||||
if (seal.publicKey === account.state.sealKey?.public) {
|
if (seal.publicKey === account.state.sealKey?.public) {
|
||||||
let crypto = new JSEncrypt();
|
const key = '-----BEGIN RSA PRIVATE KEY-----\n' + account.state.sealKey.private + '\n-----END RSA PRIVATE KEY-----'
|
||||||
crypto.setPrivateKey(account.state.sealKey.private);
|
RSA.decrypt(seal.sealedKey, key).then(sealKey => {
|
||||||
sealKey = crypto.decrypt(seal.sealedKey);
|
updateState({ locked, sealKey });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateState({ locked, sealKey });
|
|
||||||
}, [conversation.state.locked, conversation.state.seals, account.state.sealKey])
|
}, [conversation.state.locked, conversation.state.seals, account.state.sealKey])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -7,6 +7,7 @@ import { AppContext } from 'context/AppContext';
|
|||||||
import config from 'constants/Config';
|
import config from 'constants/Config';
|
||||||
import { JSEncrypt } from 'jsencrypt'
|
import { JSEncrypt } from 'jsencrypt'
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
|
import { RSA } from 'react-native-rsa-native';
|
||||||
|
|
||||||
export function useProfileBody() {
|
export function useProfileBody() {
|
||||||
|
|
||||||
@ -122,13 +123,12 @@ export function useProfileBody() {
|
|||||||
|
|
||||||
// generate rsa key for sealing channel, delay for activity indicator
|
// generate rsa key for sealing channel, delay for activity indicator
|
||||||
await new Promise(r => setTimeout(r, 1000));
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
const crypto = new JSEncrypt({ default_key_size: 2048 });
|
const keys = await RSA.generateKeys(2048);
|
||||||
const key = crypto.getKey();
|
|
||||||
|
|
||||||
// encrypt private key
|
// encrypt private key
|
||||||
const iv = CryptoJS.lib.WordArray.random(128 / 8);
|
const iv = CryptoJS.lib.WordArray.random(128 / 8);
|
||||||
const privateKey = convertPem(crypto.getPrivateKey());
|
const privateKey = convertPem(keys.private);
|
||||||
const publicKey = convertPem(crypto.getPublicKey());
|
const publicKey = convertPem(keys.public);
|
||||||
const enc = CryptoJS.AES.encrypt(privateKey, aes, { iv: iv });
|
const enc = CryptoJS.AES.encrypt(privateKey, aes, { iv: iv });
|
||||||
|
|
||||||
const seal = {
|
const seal = {
|
||||||
|
10247
app/mobile/yarn.lock
10247
app/mobile/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user