Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cost limiting not enforced in C extensions. #27

Closed
postmodern opened this issue Aug 26, 2011 · 0 comments
Closed

Cost limiting not enforced in C extensions. #27

postmodern opened this issue Aug 26, 2011 · 0 comments

Comments

@postmodern
Copy link

I noticed that using a very large cost with BCrypt::Password.create would not increase the runtime on MRI. When I tested this under JRuby, the Java Extensions would raise a "bad number of rounds" ArgumentError if the cost was over 31. The C extensions should have the same behavior as the Java Extensions.

Steps to Reproduce

require 'bcrypt'
require 'benchmark'

# base
puts Benchmark.measure { BCrypt::Password.create("hello", :cost => 10) }

# midpoint
puts Benchmark.measure { BCrypt::Password.create("hello", :cost => 32) }

# extreme
puts Benchmark.measure { BCrypt::Password.create("hello", :cost => (2 ** 30)) }

Actual Results

MRI

Base:
0.090000 0.000000 0.090000 ( 0.094195)

Midpoint:
+5 minutes

Extreme:
0.000000 0.000000 0.000000 ( 0.001570)

JRuby

Base:
0.295000 0.000000 0.295000 ( 0.296000)

Midpoint:
NativeException: java.lang.IllegalArgumentException: Bad number of rounds

Extreme:
NativeException: java.lang.IllegalArgumentException: Missing salt rounds

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

No branches or pull requests

2 participants