sysrandom 1.0.2-java → 1.0.3-java

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: de6a4f367fd32e3e7c2c64a57b22d0809869d15d
4
- data.tar.gz: 5d09e581a15ed0af0d9ed6d10466e5b469eedf3b
3
+ metadata.gz: d812ca3fb0df778688c2d76874a023a337f5f1c4
4
+ data.tar.gz: 9344ca8db08119375316e6088a54da2470d14368
5
5
  SHA512:
6
- metadata.gz: fd2a08738476a0782872c8f354f8c6727efdef3926437fc75578c6a9a4ac129490b367a5e31b0a5182a920e755663146f3cbf5243d0ca568747e48a980de01b3
7
- data.tar.gz: 4bdc9edb6cb44b4829747b22e3fd6f6315ccd5d1df10379ee3ed4c482a5ad0ffa50ff98c30684f7e7fb52b674a0fdd1cc0290cfefafca9d6c80c26c5135e493b
6
+ metadata.gz: f22fb8633a3454f7fef9f2cbd1ea1b3b7128a823a518f3a0bfe44a8025e0ff4fb5a13a8064beb2792e8587c1eae7ad0f8faa60cb91d0fdf1c2931981179f9c6e
7
+ data.tar.gz: bfe736acebef9fe868cf41baa05fb9b6ba14df7da1dd8e46d13a2131432155b6d6ddf8b2d8bf61c35b3c81bf7deab8536e2ca90c5de15ae82adee15a830b47b3
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;
data/lib/sysrandom.rb CHANGED
@@ -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: java
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-13 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(), etc
14
14
  email: