Skip to content

Add pure Ruby fallback for bcrypt_pbkdf (enables JRuby)#39

Open
mfazekas wants to merge 1 commit into
mainfrom
pure-ruby-fallback
Open

Add pure Ruby fallback for bcrypt_pbkdf (enables JRuby)#39
mfazekas wants to merge 1 commit into
mainfrom
pure-ruby-fallback

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

When the C extension is unavailable (JRuby, or any environment without a native compiler), load a pure Ruby implementation instead of failing with a LoadError.

The pure Ruby path is ~68x slower than the C extension at rounds=4 (~930ms vs ~14ms), but bcrypt_pbkdf is only used in net-ssh for decrypting encrypted Ed25519 private keys — a one-time cost at connection time — so this is acceptable.

JRuby users currently hit a hardcoded raise "BCryptPbkdf is not implemented for jruby" in net-ssh; with this change that can be removed.

All existing test vectors pass under the pure Ruby implementation.

When the C extension is unavailable (JRuby or environments without a
native compiler), load a pure Ruby implementation of Blowfish/bcrypt_pbkdf
instead of raising. Approximately 68x slower than the C extension but
acceptable for the one-time key-decryption use case in net-ssh.
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