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
I noticed that using a very large cost with
BCrypt::Password.createwould not increase the runtime on MRI. When I tested this under JRuby, the Java Extensions would raise a "bad number of rounds"ArgumentErrorif the cost was over 31. The C extensions should have the same behavior as the Java Extensions.Steps to Reproduce
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