Repository navigation
fix(ffi): use native word width for BN_set_word - #432
Conversation
|
Implemented in b5dce7d. The permanent Android integration test now contains only the corrected ARM32 device validationCorrected binding, run through Firebase Test Lab on Galaxy A10, API 29 (
Separate old-binding comparisonI ran the previous
This comparison is evidence from that run only. The mismatched native call has no guaranteed behavior, which is why the permanent test asserts only the corrected binding. Local Android validation also passed: |
There was a problem hiding this comment.
this is great! thank you @harrshita123 we should take a patch release with this.
cc: @jonasfj
Conflict resolution: - Keep the deletion of hook/build.dart, src/CMakeLists.txt, third_party/boringssl/, the generated bindings, tool/ffigen.dart and tool/bump-boringssl-revision.sh. Their master-side fixes are now package:boring's concern: it already includes the fiat ADX assembly on Apple x86_64 (google#448), and tracks its own build inputs (google#429). - Keep _checkUnsignedLong and _checkInt32 from master in impl_ffi.utils.dart. - Drop ffigen from dev_dependencies, keep master's new dev_dependencies. - Remove test/build_dependencies_test.dart, which tested the removed hook/build.dart. BN_set_word (google#432): package:boring binds BN_ULONG as Uint64, which is wrong on 32-bit targets, so this would regress RSA key generation on Android ARM32. Use BN_set_u64, whose argument is 64 bits wide everywhere. Remove test/ffi/bn_word_abi_test.dart and integration_test/bn_word_abi_32_test.dart, which tested webcrypto's own binding. integration_test/rsa_key_generation_test.dart still covers the exponent end to end.
Summary
BoringSSL defines
BN_ULONGas a 32-bit type on 32-bit targets and a 64-bit type on 64-bit targets. The checked-in bindings were generated on a 64-bit host and usedffi.Uint64forBN_set_wordon every target. Map this typedef toffi.UintPtrin the binding generator and regenerate the binding so the FFI argument follows the target's native word width.Add a focused native test that sets a BIGNUM to the RSA public exponent 65537 and reads the bytes back.
Validation
The reported failure in #136 has not been reproduced on a 32-bit Android target here. This PR is a draft pending that validation. It addresses the ABI mismatch identified in the issue discussion; it does not establish that every reported
TOO_MANY_ITERATIONSfailure has the same cause.Related: #136. The pending #417 replaces these bindings, so this correction may need to move to that dependency if #417 lands first.