rsa 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/rsa/pkcs1.rb +12 -6
  3. data/lib/rsa/version.rb +1 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -23,13 +23,19 @@ module RSA
23
23
  # @return [String] octet string of length `len`
24
24
  # @see http://tools.ietf.org/html/rfc3447#section-4.1
25
25
  # @raise [ArgumentError] if `n` is greater than 256^len
26
- def self.i2osp(x, len = Math.log256(x).ceil)
27
- raise ArgumentError, "integer too large" if x >= 256**len
26
+ def self.i2osp(x, len = nil)
27
+ raise ArgumentError, "integer too large" if len && x >= 256**len
28
28
 
29
- len.downto(1).inject(String.new) do |s, i|
30
- b = (x & 0xFF).chr
31
- x >>= 8
32
- s = b + s
29
+ StringIO.open do |buffer|
30
+ while x > 0
31
+ b = (x & 0xFF).chr
32
+ x >>= 8
33
+ buffer << b
34
+ end
35
+ s = buffer.string
36
+ s.force_encoding(Encoding::BINARY) if s.respond_to?(:force_encoding)
37
+ s.reverse!
38
+ s = len ? s.rjust(len, "\0") : s
33
39
  end
34
40
  end
35
41
 
@@ -2,7 +2,7 @@ module RSA
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 3
5
+ TINY = 4
6
6
  EXTRA = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arto Bendiken
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-10 00:00:00 +02:00
17
+ date: 2010-10-17 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency