ffi-libsodium 0.2.4 → 0.2.5
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 +4 -4
- data/lib/sodium.rb +25 -12
- data/lib/sodium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 098cc9a2b79fd39389f77241c75bc2e03efb0461
|
4
|
+
data.tar.gz: e1ae4db97427751f2eb56d9081c30a3a7791604b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be3aa678237413491b999b89dc66d93a4567fed6a01be67e197844f92e4aa9dc4e3a58dc506eac54731ab117ca5501e04caa665332902477531e3fb6a097195a
|
7
|
+
data.tar.gz: 15f1532694c26a4b2ec4bd04c64c25805e1f9c9a9d688aee75b1ac92142876a7ab4cd8bbd483a869375b36eda66429e82f3e680e5f663df752a60625283a7a75
|
data/lib/sodium.rb
CHANGED
@@ -24,19 +24,35 @@ module Sodium
|
|
24
24
|
module_function
|
25
25
|
|
26
26
|
def mlock(addr, len)
|
27
|
-
sodium_mlock(addr, len) == 0
|
27
|
+
if sodium_mlock(addr, len) == 0
|
28
|
+
true
|
29
|
+
else
|
30
|
+
raise MemoryError, "Could not lock length=#{len} bytes memory at address=#{addr.address}", caller
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
def munlock(addr, len)
|
31
|
-
sodium_munlock(addr, len) == 0
|
35
|
+
if sodium_munlock(addr, len) == 0
|
36
|
+
true
|
37
|
+
else
|
38
|
+
raise MemoryError, "Could not unlock length=#{len} bytes memory at address=#{addr.address}", caller
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
def malloc(size)
|
35
|
-
|
43
|
+
unless (mem = sodium_malloc(size)).null?
|
44
|
+
mem
|
45
|
+
else
|
46
|
+
raise NoMemoryError, "Failed to allocate memory size=#{size} bytes", caller
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
50
|
def allocarray(count, size)
|
39
|
-
|
51
|
+
unless (mem = sodium_allocarray(count, size)).null?
|
52
|
+
mem
|
53
|
+
else
|
54
|
+
raise NoMemoryError, "Failed to allocate memory size=#{count * size} bytes", caller
|
55
|
+
end
|
40
56
|
end
|
41
57
|
|
42
58
|
def bin2hex(bin)
|
@@ -45,15 +61,12 @@ module Sodium
|
|
45
61
|
sodium_bin2hex(hex, hex.size, bin, bin_len)
|
46
62
|
end
|
47
63
|
|
48
|
-
def hex2bin(hex, ignore = nil)
|
49
|
-
|
50
|
-
|
64
|
+
def hex2bin(hex, bin_maxlen, ignore = nil)
|
65
|
+
bin = Sodium::Buffer.new(:uchar, bin_maxlen)
|
66
|
+
if sodium_hex2bin(bin, bin_maxlen, hex, hex.bytesize, ignore, nil, nil) == 0
|
67
|
+
bin
|
51
68
|
else
|
52
|
-
bin_maxlen
|
69
|
+
raise LengthError, "bin_maxlen=#{bin_maxlen} is too short", caller
|
53
70
|
end
|
54
|
-
|
55
|
-
bin = Sodium::Buffer.new(:uchar, bin_maxlen)
|
56
|
-
sodium_hex2bin(bin, bin_maxlen, hex, hex.bytesize, ignore, nil, nil)
|
57
|
-
bin
|
58
71
|
end
|
59
72
|
end
|
data/lib/sodium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-libsodium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hendrik Beskow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|