Skip to content

[boring] Bind BN_ULONG as UintPtr - #2892

Merged
mosuem merged 1 commit into
mainfrom
boring-bn-ulong-uintptr
Nov 18, 2026
Merged

mosuem merged 1 commit into
mainfrom
boring-bn-ulong-uintptr

Conversation

@mosuem

@mosuem mosuem commented Nov 17, 2026

Copy link
Copy Markdown
Member

Note

This PR was generated by an AI coding agent (Jetski) on behalf of @mosuem.

First of a stack of three package:boring fixes for regressions found while moving package:webcrypto to package:boring (google/webcrypto.dart#417):

  1. This PR: bind BN_ULONG as UintPtr
  2. Compile with OPENSSL_SMALL and the sanitizer of the Dart runtime
  3. Run the prebuilt Linux libraries on glibc 2.28, and detect other C libraries

BoringSSL's BN_ULONG is uint64_t on 64-bit targets and uint32_t on 32-bit targets (openssl/base.h). tool/ffigen.dart runs on a 64-bit host, so the bindings used Uint64. That passes and returns the wrong values for the BN_*_word functions on 32-bit targets, such as Android arm, which has prebuilt libraries. package:webcrypto hit this with BN_set_word(bn, 65537), which set the wrong RSA public exponent (fixed there in google/webcrypto.dart#432, before the move).

  • tool/ffigen.dart maps BN_ULONG to the pointer-sized UintPtr with importType, and the bindings are regenerated. The only changes in them are BN_ULONG → ffi.UintPtr.
  • ffigen no longer generates the BN_ULONG and DartBN_ULONG typedefs, so bindings.dart declares them (BN_ULONG = ffi.UintPtr), and this isn't a breaking change.
  • test/boring_test.dart checks that BN_ULONG is UintPtr, which fails on 64-bit hosts too, and round-trips BN_set_word / BN_get_word.

This conflicts with #2886, which renames lib/bindings.dart to lib/boring.dart. The typedefs would just move with it.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@github-actions

Copy link
Copy Markdown

PR Health

Publish ✔️
Package Version Status Publish tag (post-merge)
package:boring ⭐ 0.4.3-wip WIP (no publish necessary)
  • 15 already published.
  • 27 WIP (no publish necessary).

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

This check can be disabled by tagging the PR with skip-publish-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
boring Breaking 0.4.2 0.4.3-wip 0.4.3-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

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.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Unused Dependencies ✔️
Package Status
boring ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/html/test/differential_test.dart
pkgs/html/test/dom_parsing_test.dart
pkgs/html/test/mxss_test.dart
pkgs/html/test/noah_ark_clause_limit_test.dart

This check can be disabled by tagging the PR with skip-license-check.

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.

@brianquinlan

Copy link
Copy Markdown
Contributor

Mapping a plain integer to a pointer-sized type doesn't seem perfect. Maybe ask @liamappelbe or @dcharkes if there is a better mapping.

@dcharkes

Copy link
Copy Markdown
Contributor

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.

@mosuem
mosuem merged commit 43475f4 into main Nov 18, 2026
33 of 34 checks passed
@mosuem
mosuem deleted the boring-bn-ulong-uintptr branch November 18, 2026 08:38
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Nov 18, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants