diff --git a/bun.lock b/bun.lock index 0f76f54c..70bada23 100644 --- a/bun.lock +++ b/bun.lock @@ -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", @@ -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", @@ -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", diff --git a/docs/test_suite_results_android.png b/docs/test_suite_results_android.png index 909a69af..16d90714 100644 Binary files a/docs/test_suite_results_android.png and b/docs/test_suite_results_android.png differ diff --git a/docs/test_suite_results_ios.png b/docs/test_suite_results_ios.png index 59289fb6..3c7e9553 100644 Binary files a/docs/test_suite_results_ios.png and b/docs/test_suite_results_ios.png differ diff --git a/example/package.json b/example/package.json index dfd5dde3..638a05b9 100644 --- a/example/package.json +++ b/example/package.json @@ -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", diff --git a/example/src/tests/cipher/cipher_tests.ts b/example/src/tests/cipher/cipher_tests.ts index 49022bac..54c7c7f3 100644 --- a/example/src/tests/cipher/cipher_tests.ts +++ b/example/src/tests/cipher/cipher_tests.ts @@ -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); @@ -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); +}); diff --git a/packages/react-native-quick-crypto/QuickCrypto.podspec b/packages/react-native-quick-crypto/QuickCrypto.podspec index b4d56bf9..bd7d6153 100644 --- a/packages/react-native-quick-crypto/QuickCrypto.podspec +++ b/packages/react-native-quick-crypto/QuickCrypto.podspec @@ -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 diff --git a/packages/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp b/packages/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp index 969c20ce..588b279a 100644 --- a/packages/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp +++ b/packages/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp @@ -229,10 +229,9 @@ std::shared_ptr HybridCipher::getAuthTag() { throw std::runtime_error("Failed to get GCM/OCB auth tag: " + std::string(err_buf)); } - size_t actual_tag_len = static_cast(ret); uint8_t* raw_ptr = tag_buf.get(); auto final_tag_buffer = - std::make_shared(tag_buf.release(), actual_tag_len, [raw_ptr]() { delete[] raw_ptr; }); + std::make_shared(tag_buf.release(), auth_tag_len, [raw_ptr]() { delete[] raw_ptr; }); return final_tag_buffer; } else if (mode == EVP_CIPH_CCM_MODE) {