Permalink
Browse files

Introduce a default read size since JRuby OpenSSL doesn't support Ope…

…nSSL::Digest#block_length
  • Loading branch information...
1 parent f92c190 commit 53c533d47b260326d24b4afd8cd83f0bd66e355c @jtdowney committed Sep 23, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/hkdf.rb
View
@@ -2,6 +2,8 @@
require 'stringio'
class HKDF
+ DefaultReadSize = 512 * 1024
+
def initialize(source, options = {})
options = {:algorithm => 'SHA256', :info => '', :salt => nil, :read_size => nil}.merge(options)
source = StringIO.new(source) if source.is_a?(String)
@@ -11,7 +13,7 @@ def initialize(source, options = {})
salt = options[:salt]
salt = 0.chr * @digest.digest_length if salt.nil? or salt.empty?
- read_size = options[:read_size] || @digest.block_length
+ read_size = options[:read_size] || DefaultReadSize
@prk = _generate_prk(salt, source, read_size)
@position = 0

0 comments on commit 53c533d

Please sign in to comment.