Skip to content

Compute the Blowfish tables from pi, so the package is MIT only - #1

Merged
XeonFX merged 1 commit into
mainfrom
refactor/computed-blowfish-tables
Oct 19, 2026
Merged

XeonFX merged 1 commit into
mainfrom
refactor/computed-blowfish-tables

Conversation

@XeonFX

@XeonFX XeonFX commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

BlowfishConstants.cs was copied from Go's golang.org/x/crypto and carried its BSD-3-Clause licence, so 1.0.0 is licensed "MIT AND BSD-3-Clause". This replaces the copied file with numbers computed at compile time, so every line in the package is our own and it is licensed MIT only.

What changed

  • BlowfishTablesGenerator (in the existing generator project) computes pi's fractional hex digits with Machin's formula, pi = 16 atan(1/5) − 4 atan(1/239), in exact BigInteger fixed point with 64 guard bits, and writes BlowfishConstants.g.cs: the 18-word P-array and the 1,024-word S-boxes. It runs in about 80 ms per build.
  • Deleted BlowfishConstants.cs and THIRD-PARTY-NOTICES.md; PackageLicenseExpression is MIT; LICENSE and the README's licence section updated.
  • Version 1.0.1 in the project file; the release tag sets it anyway.

Nothing changes at run time: the DLL holds the same constant tables, so speed, results and allocations are the same.

How it was tested

  • Before deleting the copied file, the generator's output was compared with it word by word: all 1,042 words identical.
  • New test BlowfishTablesAreTheDigitsOfPi pins the table sizes and Schneier's first and last values.
  • All 183 tests pass on .NET 8, 9, 10 and 11 (macOS arm64). Shifting the computed digits by one bit on purpose fails 80 of them, through the published test vectors.
  • Packed 1.0.1: license is MIT, no notices file, net8.0/net9.0/net10.0 assemblies.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…age as MIT only

BlowfishConstants.cs was copied from Go's golang.org/x/crypto (BSD-3-Clause),
which made the package "MIT AND BSD-3-Clause". A source generator now computes
the same 1,042 words from pi (Machin's formula in exact fixed point) while the
library compiles, so no copied code remains: the copied file and
THIRD-PARTY-NOTICES.md are gone and the package is MIT. The generated tables
are identical to the copied ones, and the shipped code is unchanged.
@XeonFX
XeonFX merged commit d5bf3cf into main Oct 19, 2026
3 checks passed
@XeonFX
XeonFX deleted the refactor/computed-blowfish-tables branch October 19, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant