sysrandom 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adce2384cb0f6661da7eab70ac7461a5e34ae4cf
4
- data.tar.gz: 0fb461a5d537f8b64cd46a75eb1520d3c6b79bd7
3
+ metadata.gz: 7b09e764d20a1a07bf2e7f87a93f295592c575ca
4
+ data.tar.gz: 23189ac23947a740ec6c8ccaabd248cbb482428b
5
5
  SHA512:
6
- metadata.gz: bb2d48b31aa5897ba856315a5c81b83d2c9738d3dc10e108051d8a8b2ae7808dcf22066310152f712ab0767ee97a078ff5ee8478042364f69ee292448f64d2ae
7
- data.tar.gz: 8139ae7e2a5dcfd9470a86c875d8e22d531a10512245916466d4892f21a4ff2d879649fb0d080b334e674c55a83705062f76f29eb89903d4c433e2dd7f979e22
6
+ metadata.gz: 3ca2fcfbd1ff6bbe5e414c085f190f7a66bd406f51ea0eb7b66dd84a206df1d8dbf01400b8e4c89be9398beca9377cc111baeea65e73137583441a4657c6c6c3
7
+ data.tar.gz: 9881ce341e7e03d6b58f0063f34e9a631b8006b2152249b9c69c7e91508d3e9d587534cad79f3734c496aaa93f7d4d9aaad62fecf973865100468153cbcc4618
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.0.3 (2016-09-27)
2
+
3
+ * [#14](https://github.com/cryptosphere/sysrandom/pull/14)
4
+ Return empty string on random_bytes(0) as SecureRandom does.
5
+ ([@grempe])
6
+
1
7
  ## 1.0.2 (2016-06-06)
2
8
 
3
9
  * [#12](https://github.com/cryptosphere/sysrandom/pull/12)
@@ -27,3 +33,4 @@
27
33
  [@tarcieri]: https://github.com/tarcieri
28
34
  [@coda]: https://github.com/coda
29
35
  [@azet]: https://github.com/azet
36
+ [@grempe]: https://github.com/grempe
@@ -45,7 +45,8 @@ Sysrandom_random_uint32(VALUE self)
45
45
  *
46
46
  * The argument n specifies how long the resulting string should be.
47
47
  *
48
- * For compatibility with SecureRandom, if n is not specified, 16 is assumed.
48
+ * For compatibility with SecureRandom, if n is not specified, 16 is assumed,
49
+ * and if n is 0, an empty string is returned.
49
50
  *
50
51
  * The resulting string may contain any byte (i.e. "x00" - "xff")
51
52
  *
@@ -70,7 +71,8 @@ Sysrandom_random_bytes(int argc, VALUE * argv, VALUE self)
70
71
  str = rb_str_new(0, n);
71
72
  __randombytes_sysrandom_buf(RSTRING_PTR(str), n);
72
73
  } else {
73
- rb_raise(rb_eArgError, "string size is zero");
74
+ // n == 0, return empty string
75
+ str = rb_str_new(0, 0);
74
76
  }
75
77
 
76
78
  return str;
@@ -28,7 +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
+ return "" if n == 0
32
32
 
33
33
  bytes = Java::byte[n].new
34
34
  @_java_secure_random.nextBytes(bytes)
@@ -1,3 +1,3 @@
1
1
  module Sysrandom
2
- VERSION = "1.0.2".freeze
2
+ VERSION = "1.0.3".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.2
4
+ version: 1.0.3
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-06-06 00:00:00.000000000 Z
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Sysrandom generates secure random numbers using /dev/urandom, getrandom(),
14
14
  etc