Open
Description
What's happening?
The tag returned is always length 1. Here is a fix, the issue is that the return value of EVP_CIPHER_CTX_ctrl
is 1 for success, not the length of the tag.
diff --git a/node_modules/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp b/node_modules/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp
index d684fe6..965d3f7 100644
--- a/node_modules/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp
+++ b/node_modules/react-native-quick-crypto/cpp/cipher/HybridCipher.cpp
@@ -230,7 +230,7 @@ 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);
+ size_t actual_tag_len = auth_tag_len;
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; });
Reproducible Code
const cipher = crypto.createCipheriv('aes-256-gcm', key, nonce);
cipher.setAAD(...);
cipher.update(...);
cipher.final();
const tag = cipher.getAuthTag();
Relevant log output
There is no relevant log.
Device
iPhone 16 Pro
QuickCrypto Version
1.0.0 beta 15
Can you reproduce this issue in the QuickCrypto Example app?
I didn't try (
Additional information
- I am using Expo
- I have read the Troubleshooting Guide
- I agree to follow this project's Code of Conduct
- I searched for similar issues in this repository and found none.
Metadata
Metadata
Assignees
Labels
No labels