Skip to content

Sync bcrypt_pbkdf.c (v1.13→v1.17) and blowfish.c (v1.19→v1.20) from OpenBSD#36

Merged
mfazekas merged 1 commit into
mainfrom
sync-openbsd-sources
Jun 13, 2026
Merged

Sync bcrypt_pbkdf.c (v1.13→v1.17) and blowfish.c (v1.19→v1.20) from OpenBSD#36
mfazekas merged 1 commit into
mainfrom
sync-openbsd-sources

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Updates the two copied OpenBSD C sources to their current versions in openssh-portable.

bcrypt_pbkdf.c v1.13 (2015) → v1.17 (2022):

  • Replace SHA512Init/Update/Final with crypto_hash_sha512() — already available in this gem via crypto_api.h
  • Heap-allocate countsalt via calloc(1, saltlen + 4) instead of a fixed 4-byte stack array — correctly handles salts of any length
  • Add saltlen > 1<<20 guard against DoS with huge salts
  • Fix blf_enc argument: sizeof(cdata)/sizeof(uint64_t)BCRYPT_WORDS/2 — same value (4) but eliminates the compiler warning
  • Zero tmpout in the cleanup section (was missing in v1.13)

blowfish.c v1.19 (2015) → v1.20 (2021):

  • Remove the superseded BSD advertising clause from the license header

The bcrypt_pbkdf_ext.c Ruby wrapper gets a matching fix for the bcrypt_hash signature change (parameters are now non-const to match upstream).

@mfazekas mfazekas changed the base branch from master to main June 13, 2026 09:10
…penBSD

Key changes in bcrypt_pbkdf.c:
- switch SHA512 to crypto_hash_sha512() (simpler one-call API)
- heap-allocate countsalt to safely handle any salt length
- add saltlen > 1<<20 DoS guard
- fix blf_enc call: sizeof(cdata)/sizeof(uint64_t) -> BCRYPT_WORDS/2
- zero tmpout in cleanup (was missing)

blowfish.c: drop superseded advertising clause from license
@mfazekas mfazekas force-pushed the sync-openbsd-sources branch from e28b35c to ea84e39 Compare June 13, 2026 09:21
@mfazekas mfazekas merged commit e1247ab into main Jun 13, 2026
12 checks passed
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