sysrandom 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45c1dd03f5f7845b10731b29830035e09e8ccb8f
4
- data.tar.gz: 758b5a0669875cad1a90cc6b8f3c685ab1c9002f
3
+ metadata.gz: adce2384cb0f6661da7eab70ac7461a5e34ae4cf
4
+ data.tar.gz: 0fb461a5d537f8b64cd46a75eb1520d3c6b79bd7
5
5
  SHA512:
6
- metadata.gz: 2546ede22a85b518248a0e81ad21bedb5a3267c2cd358500498be82b0582ded90cf28908dc8cdfab64f8b33e8567e03e525179acf3a4d184aefcc7d54790527c
7
- data.tar.gz: 52489195938140051a78dc8e005de1c9e09eb4614a396e9206cb60acad5f7b7f39fca3ff8e8da7e87123a43cad6b77ac6237858e55934e443d8c9ea375ac9542
6
+ metadata.gz: bb2d48b31aa5897ba856315a5c81b83d2c9738d3dc10e108051d8a8b2ae7808dcf22066310152f712ab0767ee97a078ff5ee8478042364f69ee292448f64d2ae
7
+ data.tar.gz: 8139ae7e2a5dcfd9470a86c875d8e22d531a10512245916466d4892f21a4ff2d879649fb0d080b334e674c55a83705062f76f29eb89903d4c433e2dd7f979e22
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.0.2 (2016-06-06)
2
+
3
+ * [#12](https://github.com/cryptosphere/sysrandom/pull/12)
4
+ Remove unnecessary SecureRandom reference in 'hex' method.
5
+ ([@tarcieri])
6
+
7
+ * [#6](https://github.com/cryptosphere/sysrandom/pull/6)
8
+ Raise ArgumentError if 0 random bytes are requested (new minimum is 1).
9
+ ([@azet])
10
+
1
11
  ## 1.0.1 (2016-05-29)
2
12
 
3
13
  * [#11](https://github.com/cryptosphere/sysrandom/pull/11)
@@ -16,3 +26,4 @@
16
26
 
17
27
  [@tarcieri]: https://github.com/tarcieri
18
28
  [@coda]: https://github.com/coda
29
+ [@azet]: https://github.com/azet
@@ -70,7 +70,7 @@ Sysrandom_random_bytes(int argc, VALUE * argv, VALUE self)
70
70
  str = rb_str_new(0, n);
71
71
  __randombytes_sysrandom_buf(RSTRING_PTR(str), n);
72
72
  } else {
73
- str = rb_str_new2("");
73
+ rb_raise(rb_eArgError, "string size is zero");
74
74
  }
75
75
 
76
76
  return str;
data/lib/sysrandom.rb CHANGED
@@ -28,6 +28,7 @@ module Sysrandom
28
28
 
29
29
  def random_bytes(n = DEFAULT_LENGTH)
30
30
  raise ArgumentError, "negative string size" if n < 0
31
+ raise ArgumentError, "string size is zero" if n == 0
31
32
 
32
33
  bytes = Java::byte[n].new
33
34
  @_java_secure_random.nextBytes(bytes)
@@ -61,7 +62,7 @@ module Sysrandom
61
62
  end
62
63
 
63
64
  def uuid
64
- values = SecureRandom.hex(16).match(/\A(.{8})(.{4})(.)(.{3})(.)(.{3})(.{12})\z/)
65
+ values = hex(16).match(/\A(.{8})(.{4})(.)(.{3})(.)(.{3})(.{12})\z/)
65
66
  "#{values[1]}-#{values[2]}-4#{values[4]}-#{'89ab'[values[5].ord % 4]}#{values[6]}-#{values[7]}"
66
67
  end
67
68
  end
@@ -1,3 +1,3 @@
1
1
  module Sysrandom
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sysrandom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-30 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Sysrandom generates secure random numbers using /dev/urandom, getrandom(),
14
14
  etc