Repository navigation
[boring] Bind BN_ULONG as UintPtr - #2892
Conversation
BoringSSL's BN_ULONG is uint64_t on 64-bit targets and uint32_t on 32-bit targets (openssl/base.h). ffigen runs on a 64-bit host, so the bindings used Uint64, which passes and returns the wrong values for the BN_*_word functions on 32-bit targets such as Android arm. For example, BN_set_word(bn, 65537) set the wrong RSA public exponent in package:webcrypto (fixed there in google/webcrypto.dart#432 before it moved to package:boring). Map BN_ULONG to the pointer-sized UintPtr in tool/ffigen.dart, and keep the BN_ULONG and DartBN_ULONG typedefs in bindings.dart, because ffigen no longer generates them.
There was a problem hiding this comment.
Code Review
This pull request fixes the bindings of BN_*_word functions on 32-bit targets, such as Android ARM, by mapping BoringSSL's BN_ULONG to the pointer-sized ffi.UintPtr instead of Uint64. This is done by updating the ffigen configuration to map BN_ULONG to UintPtr, defining the BN_ULONG and DartBN_ULONG typedefs in bindings.dart, and adding a test in boring_test.dart to verify that BN_ULONG is pointer-sized. There are no review comments, and we have no feedback to provide.
PR HealthPublish ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Unused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with
Coverage
|
| File | Coverage |
|---|---|
| pkgs/boring/lib/bindings.dart | 💚 71 % |
| pkgs/boring/tool/ffigen.dart | 💔 Not covered |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
|
Mapping a plain integer to a pointer-sized type doesn't seem perfect. Maybe ask @liamappelbe or @dcharkes if there is a better mapping. |
If you want to be more correct, you can define your own https://api.dart.dev/dart-ffi/AbiSpecificInteger-class.html. As far as I can see Dart doesn't run in 128 bit mode anywhere, so for all current supported platforms uintptr_t as mapping seems fine. |
Revisions updated by `dart tools/rev_sdk_deps.dart`. core (https://github.com/dart-lang/core/compare/eef4a30..00d420f): 00d420fd Tue Nov 17 08:27:36 2026 -0800 Kevin Moore Validate and fix README examples with package:example (dart-lang/core#1067) dartdoc (https://github.com/dart-lang/dartdoc/compare/1c40672..1224e35): 1224e35c Wed Nov 18 14:59:46 2026 +0200 Sergey G. Grekhov Add tests for setter parameters (dart-lang/dartdoc#4319) 39cd39c6 Tue Nov 17 14:40:59 2026 +0100 Sarah Zakarias Validate and escape linkTo.url URLs (dart-lang/dartdoc#4326) ad966640 Tue Nov 17 11:43:24 2026 +0100 Sarah Zakarias Validate and escape linkToSource.uriTemplate URLs (dart-lang/dartdoc#4324) http (https://github.com/dart-lang/http/compare/e319115..e940128): e940128b Wed Nov 18 12:19:41 2026 +0100 Moritz fix(http2): limit how fast a peer may reset the streams it opens (dart-lang/http#2101) fa8318b2 Wed Nov 18 00:37:13 2026 -0800 Brian Quinlan chore(cupertino_http): modernize ios_test for Flutter 3.47+ and iOS 15 (dart-lang/http#2117) a57d1dd8 Wed Nov 18 00:36:56 2026 -0800 Brian Quinlan chore(cupertino_http): test on `macos-26` (dart-lang/http#2119) fd289700 Wed Nov 18 00:35:35 2026 -0800 Brian Quinlan chore(cupertino_http): update package metadata and docs (dart-lang/http#2120) 684fc891 Wed Nov 18 00:35:16 2026 -0800 Brian Quinlan chore(cupertino_http): analyze cupertino_http as a standalone Dart package (dart-lang/http#2118) cbc763e7 Wed Nov 18 05:01:19 2026 +0400 Brahim Guaali [cupertino_http] Add onMetrics to URLSession to expose the negotiated protocol (dart-lang/http#2036) c637ddbe Tue Nov 17 19:20:04 2026 +0100 Moritz chore(flutter_http_example): migrate from deprecated package:flutter/material.dart to material_ui (dart-lang/http#2076) 28ce1680 Tue Nov 17 11:57:54 2026 +0100 Moritz fix(http2): bound the replies queued for a peer that does not read them (dart-lang/http#2100) 0cc006e6 Tue Nov 17 11:45:28 2026 +0100 Moritz fix(http2): Http2Client evicts dead connections from its pool and keeps healthy ones on a stream reset (dart-lang/http#2010) cbd94d7c Tue Nov 17 11:44:55 2026 +0100 Moritz fix(http2): finish() and terminate() must not hang after a failed socket write (dart-lang/http#2014) native (https://github.com/dart-lang/native/compare/5fcc6f4..5bc02a7): 5bc02a797 Wed Nov 18 05:34:54 2026 +0100 Jakob Kordež [ffigen] Add non-throwing `fromValueOrNull` to generated Dart enums (dart-lang/native#3729) bcc4f4547 Wed Nov 18 09:47:48 2026 +0530 Sivapriya [jni] Remove hack in findClass (dart-lang/native#3709) 83c17c3ba Wed Nov 18 05:58:44 2026 +0530 Rachit Vikram Singh [ffigen] Generate Function companion typedef for bare NativeFunction (dart-lang/native#3740) a524056de Wed Nov 18 05:57:57 2026 +0530 Aman Maurya [ffigen] [jnigen] Util to dump entire parsed API (dart-lang/native#3621) 0ff3ff3df Wed Nov 18 10:35:04 2026 +1100 Liam Appelbe [infra] Fix CI for Flutter 3.50 (dart-lang/native#3796) test (https://github.com/dart-lang/test/compare/269bdfd..b0f8b06): b0f8b061 Mon Nov 16 22:20:21 2026 -0800 Nate Bosch [checks] Remove temporary `has2` extension method (dart-lang/test#2822) a0328d7a Mon Nov 16 17:06:31 2026 -0800 Nate Bosch Default to failures-only reporter for AI coding agents (dart-lang/test#2820) tools (https://github.com/dart-lang/tools/compare/e97f625..a0b6e88): a0b6e88b4 Wed Nov 18 10:32:05 2026 +0100 Moritz [boring] Make package:boring/boring.dart the only library (0.5.0) (dart-lang/tools#2886) c30c9ad1e Wed Nov 18 09:40:25 2026 +0100 Moritz chore(coverage): prepare for v1.16.1 release (dart-lang/tools#2885) 43475f437 Wed Nov 18 09:38:00 2026 +0100 Moritz [boring] Bind BN_ULONG as UintPtr (dart-lang/tools#2892) 15a564f65 Tue Nov 17 09:17:58 2026 -0800 Kevin Moore [api_summary] Canonicalize sort order across ApiSummary models (dart-lang/tools#2870) 1444f69db Tue Nov 17 17:10:49 2026 +0100 Jonas Finnemann Jensen [markdown] Reuse RegExp when splitting fenced code info strings (dart-lang/tools#2882) 64b388338 Tue Nov 17 15:42:46 2026 +0100 dart-ecosystem-bot[bot] [boring] Pin the prebuilt binaries of boring-binaries-20261117-a385c332fa79 (dart-lang/tools#2888) c34caadb8 Tue Nov 17 15:42:27 2026 +0100 Moritz [boring] Close superseded bot pull requests (dart-lang/tools#2887) a385c332f Tue Nov 17 14:55:51 2026 +0100 dart-ecosystem-bot[bot] [boring] Update BoringSSL to 8f2554dc (dart-lang/tools#2879) a6a20dfe4 Mon Nov 16 19:01:25 2026 -0800 Kevin Moore [coverage] Fix BazelResolver file URI matching and path handling (dart-lang/tools#2876) 9517049e9 Mon Nov 16 17:50:27 2026 -0800 Nate Bosch [unified_analytics] Cross-reference test_core AI agent detection (dart-lang/tools#2881) Change-Id: I73d9b3c58686e19bc169b659900546b03f4491bc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/579420 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Quinlan <bquinlan@google.com> Commit-Queue: Nate Bosch <nbosch@google.com>
Note
This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.
First of a stack of three
package:boringfixes for regressions found while movingpackage:webcryptotopackage:boring(google/webcrypto.dart#417):BN_ULONGasUintPtrOPENSSL_SMALLand the sanitizer of the Dart runtimeBoringSSL's
BN_ULONGisuint64_ton 64-bit targets anduint32_ton 32-bit targets (openssl/base.h).tool/ffigen.dartruns on a 64-bit host, so the bindings usedUint64. That passes and returns the wrong values for theBN_*_wordfunctions on 32-bit targets, such as Android arm, which has prebuilt libraries.package:webcryptohit this withBN_set_word(bn, 65537), which set the wrong RSA public exponent (fixed there in google/webcrypto.dart#432, before the move).tool/ffigen.dartmapsBN_ULONGto the pointer-sizedUintPtrwithimportType, and the bindings are regenerated. The only changes in them areBN_ULONG→ffi.UintPtr.BN_ULONGandDartBN_ULONGtypedefs, sobindings.dartdeclares them (BN_ULONG = ffi.UintPtr), and this isn't a breaking change.test/boring_test.dartchecks thatBN_ULONGisUintPtr, which fails on 64-bit hosts too, and round-tripsBN_set_word/BN_get_word.This conflicts with #2886, which renames
lib/bindings.darttolib/boring.dart. The typedefs would just move with it.