diff --git a/.gitignore b/.gitignore index 53f0017f..691e5945 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ tsconfig.tsbuildinfo package-lock.json .vscode/settings.json +.vscode/mcp.json diff --git a/bun.lockb b/bun.lockb index 66d792c7..5e61b23b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c51f2bc1..68712e7c 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "version": "0.7.14", + "version": "0.7.17", "scripts": { "clean": "bun --filter='*' clean", "deepclean": "bun --filter='*' deepclean && del-cli node_modules", - "specs": "bun --filter='react-native-quick-crypto' specs", + "specs": "bun --filter='@coolwallet-app/react-native-quick-crypto' specs", "bundle-install": "bun --filter='react-native-quick-crypto-example' bundle-install", "pods": "bun --filter='react-native-quick-crypto-example' pods", "start": "cd packages/example && bun start", @@ -13,7 +13,7 @@ "lint:fix": "bun --filter='*' lint:fix", "format": "bun --filter='*' format", "format:fix": "bun --filter='*' format:fix", - "prepare": "bun --filter=\"react-native-quick-crypto\" prepare", + "prepare": "bun --filter=\"@coolwallet-app/react-native-quick-crypto\" prepare", "release": "./scripts/release.sh" }, "devDependencies": { diff --git a/packages/example/ios/Podfile.lock b/packages/example/ios/Podfile.lock index 56c9889a..67c4a12d 100644 --- a/packages/example/ios/Podfile.lock +++ b/packages/example/ios/Podfile.lock @@ -323,7 +323,7 @@ PODS: - react-native-quick-base64 (2.1.2): - RCT-Folly (= 2021.07.22.00) - React-Core - - react-native-quick-crypto (0.7.15): + - react-native-quick-crypto (0.7.17): - OpenSSL-Universal - RCT-Folly (= 2021.07.22.00) - React @@ -628,7 +628,7 @@ SPEC CHECKSUMS: React-logger: 8edc785c47c8686c7962199a307015e2ce9a0e4f react-native-fast-encoder: 6f59e9b08e2bc5a8bf1f36e1630cdcfd66dd18af react-native-quick-base64: 61228d753294ae643294a75fece8e0e80b7558a6 - react-native-quick-crypto: 0e6636e4a9ae327d710d3eee75f1c105584636bd + react-native-quick-crypto: c63f09c36b5e03ee0cb6b03cc2de296fb6ff3f0f react-native-safe-area-context: 141eca0fd4e4191288dfc8b96a7c7e1c2983447a React-NativeModulesApple: b6868ee904013a7923128892ee4a032498a1024a React-perflogger: 31ea61077185eb1428baf60c0db6e2886f141a5a diff --git a/packages/example/package.json b/packages/example/package.json index 3f1a7f2e..2013f7a1 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -1,7 +1,7 @@ { "name": "react-native-quick-crypto-example", "description": "Example app for react-native-quick-crypto", - "version": "0.7.15", + "version": "0.7.17", "private": true, "packageManager": "bun@1.1.26", "scripts": { @@ -33,7 +33,7 @@ "react-native": "0.72.7", "react-native-fast-encoder": "^0.1.12", "react-native-quick-base64": "^2.1.2", - "react-native-quick-crypto": "0.7.15", + "react-native-quick-crypto": "0.7.17", "react-native-safe-area-context": "^4.5.0", "react-native-screens": "3.35.0", "readable-stream": "^4.5.2", diff --git a/packages/example/src/testing/tests/webcryptoTests/import_export.ts b/packages/example/src/testing/tests/webcryptoTests/import_export.ts index 3e8f9d55..e0f1f64e 100644 --- a/packages/example/src/testing/tests/webcryptoTests/import_export.ts +++ b/packages/example/src/testing/tests/webcryptoTests/import_export.ts @@ -1,17 +1,11 @@ -import { assert, expect } from 'chai'; import { Buffer } from '@craftzdog/react-native-buffer'; +import { assert, expect } from 'chai'; import { fromByteArray, toByteArray, trimBase64Padding, } from 'react-native-quick-base64'; import crypto from 'react-native-quick-crypto'; -import { describe, it } from '../../MochaRNAdapter'; -import { - ab2str, - binaryLikeToArrayBuffer, -} from '../../../../../react-native-quick-crypto/src/Utils'; -import { assertThrowsAsync } from '../util'; import type { CryptoKey, CryptoKeyPair, @@ -23,8 +17,14 @@ import type { SubtleAlgorithm, } from '../../../../../react-native-quick-crypto/src/keys'; import type { RandomTypedArrays } from '../../../../../react-native-quick-crypto/src/random'; -import pubTestKeyEc256 from '../../fixtures/keys/ec_p256_public'; +import { + ab2str, + binaryLikeToArrayBuffer, +} from '../../../../../react-native-quick-crypto/src/Utils'; import privTestKeyEc256 from '../../fixtures/keys/ec_p256_private'; +import pubTestKeyEc256 from '../../fixtures/keys/ec_p256_public'; +import { describe, it } from '../../MochaRNAdapter'; +import { assertThrowsAsync } from '../util'; const { subtle, createPublicKey, createPrivateKey } = crypto; @@ -132,6 +132,20 @@ describe('subtle - importKey / exportKey', () => { ); }); + it(' importKey - raw - pbkdf2 - empty byte source #735', async () => { + const key = await crypto.subtle.importKey( + 'raw', + new Uint8Array(), + { + name: 'PBKDF2', + hash: 'SHA-256', + }, + false, + ['deriveBits', 'deriveKey'], + ); + expect(key).to.not.equal(null); + }); + // Import/Export AES Secret Key { it('AES import raw / export raw', async () => { diff --git a/packages/react-native-quick-crypto/android/build.gradle b/packages/react-native-quick-crypto/android/build.gradle index 45e323e8..fb29ca5c 100644 --- a/packages/react-native-quick-crypto/android/build.gradle +++ b/packages/react-native-quick-crypto/android/build.gradle @@ -112,7 +112,8 @@ android { externalNativeBuild { cmake { cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -DANDROID" - arguments "-DANDROID_STL=c++_shared" + arguments "-DANDROID_STL=c++_shared", + "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON" abiFilters (*reactNativeArchitectures()) } } @@ -175,7 +176,7 @@ dependencies { implementation "com.facebook.react:react-android:+" // Add a dependency on OpenSSL - implementation 'io.github.ronickg:openssl:3.3.2' + implementation 'io.github.ronickg:openssl:3.3.2-1' } // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct". diff --git a/packages/react-native-quick-crypto/cpp/MGLKeys.cpp b/packages/react-native-quick-crypto/cpp/MGLKeys.cpp index bd7e7de4..0cead675 100644 --- a/packages/react-native-quick-crypto/cpp/MGLKeys.cpp +++ b/packages/react-native-quick-crypto/cpp/MGLKeys.cpp @@ -806,7 +806,6 @@ KeyObjectData::KeyObjectData(KeyType type, std::shared_ptr KeyObjectData::CreateSecret(ByteSource key) { - CHECK(key); return std::shared_ptr(new KeyObjectData(std::move(key))); } diff --git a/packages/react-native-quick-crypto/cpp/fastpbkdf2/fastpbkdf2.c b/packages/react-native-quick-crypto/cpp/fastpbkdf2/fastpbkdf2.c index 47debc56..ee2d2f0a 100644 --- a/packages/react-native-quick-crypto/cpp/fastpbkdf2/fastpbkdf2.c +++ b/packages/react-native-quick-crypto/cpp/fastpbkdf2/fastpbkdf2.c @@ -17,7 +17,11 @@ #include #include #if defined(__GNUC__) -#include + #if TARGET_OS_MACCATALYST + #include // Mac Catalyst + #else + #include // iOS + #endif #endif #include diff --git a/packages/react-native-quick-crypto/package.json b/packages/react-native-quick-crypto/package.json index 7934a658..46af6a8a 100644 --- a/packages/react-native-quick-crypto/package.json +++ b/packages/react-native-quick-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@coolwallet-app/react-native-quick-crypto", - "version": "0.7.15", + "version": "0.7.17", "description": "A fast implementation of Node's `crypto` module written in C/C++ JSI", "packageManager": "bun@1.1.26", "main": "lib/commonjs/index", diff --git a/packages/react-native-quick-crypto/src/pbkdf2.ts b/packages/react-native-quick-crypto/src/pbkdf2.ts index 15c47337..e1c423af 100644 --- a/packages/react-native-quick-crypto/src/pbkdf2.ts +++ b/packages/react-native-quick-crypto/src/pbkdf2.ts @@ -70,7 +70,7 @@ export function pbkdf2Sync( iterations: number, keylen: number, digest?: string, -): ArrayBuffer { +): Buffer { const sanitizedPassword = sanitizeInput(password, WRONG_PASS); const sanitizedSalt = sanitizeInput(salt, WRONG_SALT); const algo = digest ? normalizeHashName(digest, HashContext.Node) : 'sha1'; @@ -83,7 +83,7 @@ export function pbkdf2Sync( algo, ); - return result; + return Buffer.from(result); } // We need this because the typescript overload signatures in pbkdf2() above do