Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"example": {
"name": "react-native-quick-crypto-example",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"dependencies": {
"@craftzdog/react-native-buffer": "6.1.0",
"@noble/ciphers": "^1.3.0",
Expand All @@ -41,7 +41,7 @@
"react-native-bouncy-checkbox": "4.1.2",
"react-native-nitro-modules": "0.25.2",
"react-native-quick-base64": "2.2.0",
"react-native-quick-crypto": "1.0.0-beta.17",
"react-native-quick-crypto": "workspace:*",
"react-native-safe-area-context": "5.1.0",
"react-native-screens": "3.35.0",
"react-native-vector-icons": "^10.1.0",
Expand Down Expand Up @@ -75,7 +75,7 @@
},
"packages/react-native-quick-crypto": {
"name": "react-native-quick-crypto",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"dependencies": {
"@craftzdog/react-native-buffer": "6.1.0",
"events": "3.3.0",
Expand Down
Binary file modified docs/test_suite_results_android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/test_suite_results_ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"react-native-bouncy-checkbox": "4.1.2",
"react-native-nitro-modules": "0.25.2",
"react-native-quick-base64": "2.2.0",
"react-native-quick-crypto": "1.0.0-beta.18",
"react-native-quick-crypto": "workspace:*",
"react-native-safe-area-context": "5.1.0",
"react-native-screens": "3.35.0",
"react-native-vector-icons": "^10.1.0",
Expand Down
14 changes: 14 additions & 0 deletions example/src/tests/cipher/cipher_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const SUITE = 'cipher';

// --- Constants and Test Data ---
const key16 = Buffer.from('a8a7d6a5d4a3d2a1a09f9e9d9c8b8a89', 'hex');
const key32 = Buffer.from(
'a8a7d6a5d4a3d2a1a09f9e9d9c8b8a89a8a7d6a5d4a3d2a1a09f9e9d9c8b8a89',
'hex',
);
const iv16 = randomFillSync(new Uint8Array(16));
const iv12 = randomFillSync(new Uint8Array(12)); // Common IV size for GCM/CCM/OCB
const iv = Buffer.from(iv16);
Expand Down Expand Up @@ -106,3 +110,13 @@ allCiphers.forEach(cipherName => {
}
});
});

test(SUITE, 'GCM getAuthTag', () => {
const cipher = createCipheriv('aes-256-gcm', key32, iv12);
cipher.setAAD(aad);
cipher.update(plaintextBuffer);
cipher.final();

const tag = cipher.getAuthTag();
expect(tag.length).to.equal(16);
});
2 changes: 1 addition & 1 deletion packages/react-native-quick-crypto/QuickCrypto.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/margelo/react-native-quick-crypto.git", :tag => "#{s.version}" }

sodium_enabled = ENV['SODIUM_ENABLED'] == '1'
Pod::UI.puts("[QuickCrypto] Has libsodium #{sodium_enabled ? "enabled" : "disabled"}!")
Pod::UI.puts("[QuickCrypto] 🧂 has libsodium #{sodium_enabled ? "enabled" : "disabled"}!")

if sodium_enabled
# cocoapod for Sodium has not been updated for a while, so we need to build it ourselves
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ std::shared_ptr<ArrayBuffer> HybridCipher::getAuthTag() {
throw std::runtime_error("Failed to get GCM/OCB auth tag: " + std::string(err_buf));
}

size_t actual_tag_len = static_cast<size_t>(ret);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I follow why this solves the bug @boorad

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right below here...

uint8_t* raw_ptr = tag_buf.get();
auto final_tag_buffer =
std::make_shared<margelo::nitro::NativeArrayBuffer>(tag_buf.release(), actual_tag_len, [raw_ptr]() { delete[] raw_ptr; });
std::make_shared<margelo::nitro::NativeArrayBuffer>(tag_buf.release(), auth_tag_len, [raw_ptr]() { delete[] raw_ptr; });
return final_tag_buffer;

} else if (mode == EVP_CIPH_CCM_MODE) {
Expand Down