ffi-libsodium 0.2.0 → 0.2.1
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/crypto/box.rb +1 -1
- data/lib/crypto/secret_box.rb +1 -1
- data/lib/libsodium.rb +2 -1
- data/lib/sodium.rb +0 -2
- data/lib/sodium/core_ext.rb +5 -0
- data/lib/sodium/mprotect.rb +0 -1
- data/lib/sodium/utils.rb +8 -25
- data/lib/sodium/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b54d280d3fdd22d6572b1eed77f44a3c7566091
|
4
|
+
data.tar.gz: abdbaaa5de78cc99f1cb9a26044e5ba4514e0127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ead290d9a7cfdc44bf9184d5ac2245e9af185d53d7ce34588afa63b7438204a53521b43a136ed394bfe6193d68949932d7656fa1a1fdc8cf0a71bd3f88435fd
|
7
|
+
data.tar.gz: 6e9dedb63914e6287f3ba27f5a3d6a970a04f0c297f60ee6938831cbe58b979fa75c7660bc9c3d37b0f47d13729a8a1abc2a29580cd07aaa5a909a72f086f696
|
data/lib/crypto/box.rb
CHANGED
@@ -130,7 +130,7 @@ module Crypto
|
|
130
130
|
secret_key.noaccess if secret_key.is_a?(Sodium::SecretBuffer)
|
131
131
|
end
|
132
132
|
|
133
|
-
def open_easy_in_place(data, nonce, public_key, secret_key, encoding =
|
133
|
+
def open_easy_in_place(data, nonce, public_key, secret_key, encoding = nil)
|
134
134
|
ciphertext = String(data)
|
135
135
|
ciphertext_len = ciphertext.bytesize
|
136
136
|
if (message_len = ciphertext_len - MACBYTES) > 0
|
data/lib/crypto/secret_box.rb
CHANGED
@@ -76,7 +76,7 @@ module Crypto
|
|
76
76
|
key.noaccess if key.is_a?(Sodium::SecretBuffer)
|
77
77
|
end
|
78
78
|
|
79
|
-
def open_easy_in_place(data, nonce, key, encoding =
|
79
|
+
def open_easy_in_place(data, nonce, key, encoding = nil)
|
80
80
|
ciphertext = String(data)
|
81
81
|
ciphertext_len = ciphertext.bytesize
|
82
82
|
if (message_len = ciphertext_len - MACBYTES) > 0
|
data/lib/libsodium.rb
CHANGED
data/lib/sodium.rb
CHANGED
data/lib/sodium/mprotect.rb
CHANGED
data/lib/sodium/utils.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require_relative 'secret_buffer'
|
1
|
+
require_relative 'core_ext'
|
3
2
|
require_relative 'errors'
|
4
3
|
|
5
4
|
module Sodium
|
@@ -8,34 +7,18 @@ module Sodium
|
|
8
7
|
module_function
|
9
8
|
|
10
9
|
def get_size(data)
|
11
|
-
|
12
|
-
when FFI::Pointer, SecretBuffer
|
13
|
-
data.size
|
14
|
-
when String
|
10
|
+
if data.respond_to?(:bytesize)
|
15
11
|
data.bytesize
|
16
|
-
when NilClass
|
17
|
-
0
|
18
12
|
else
|
19
|
-
|
13
|
+
data.size
|
20
14
|
end
|
21
15
|
end
|
22
16
|
|
23
17
|
def check_length(data, length, description)
|
24
|
-
|
25
|
-
|
26
|
-
if data.size == length
|
27
|
-
true
|
28
|
-
else
|
29
|
-
fail LengthError, "Expected a length=#{length} bytes #{description}, got size=#{data.size} bytes", caller
|
30
|
-
end
|
31
|
-
when String
|
32
|
-
if data.bytesize == length
|
33
|
-
true
|
34
|
-
else
|
35
|
-
fail LengthError, "Expected a length=#{length} bytes #{description}, got size=#{data.bytesize} bytes", caller
|
36
|
-
end
|
18
|
+
if data.respond_to?(:bytesize)
|
19
|
+
data.bytesize == length || fail(LengthError, "Expected a length=#{length} bytes #{description}, got size=#{data.bytesize} bytes", caller)
|
37
20
|
else
|
38
|
-
fail
|
21
|
+
data.size == length || fail(LengthError, "Expected a length=#{length} bytes #{description}, got size=#{data.size} bytes", caller)
|
39
22
|
end
|
40
23
|
end
|
41
24
|
|
@@ -48,11 +31,11 @@ module Sodium
|
|
48
31
|
HEXY = 'H*'.freeze
|
49
32
|
|
50
33
|
def bin2hex(bytes)
|
51
|
-
bytes.
|
34
|
+
String(bytes).unpack(HEXY).first
|
52
35
|
end
|
53
36
|
|
54
37
|
def hex2bin(hex)
|
55
|
-
[hex].pack(HEXY)
|
38
|
+
[String(hex)].pack(HEXY)
|
56
39
|
end
|
57
40
|
end
|
58
41
|
|
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.1
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/random_bytes.rb
|
62
62
|
- lib/sodium.rb
|
63
63
|
- lib/sodium/buffer.rb
|
64
|
+
- lib/sodium/core_ext.rb
|
64
65
|
- lib/sodium/errors.rb
|
65
66
|
- lib/sodium/mprotect.rb
|
66
67
|
- lib/sodium/secret_buffer.rb
|