ffi-libsodium 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/crypto/box.rb +6 -2
- data/lib/crypto/secret_box.rb +6 -2
- data/lib/sodium.rb +1 -1
- data/lib/sodium/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf231bf8ed108114bdd026f20c6b297d2f18ecda
|
4
|
+
data.tar.gz: de5c7092f4c375780f3ccd8d0cfb277f1020a3aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2896b573f9f183f2f20d26a581f6d26541229c6e1865dbb86dbce8539ae0cdebc0c11f5d9e25edf99da6e21ce157646c1018d025ce757a24ead782e152fcfc
|
7
|
+
data.tar.gz: da3d3010caf1eb2d2aac3b432a26ad1a6438b95eae5838007f371d37568228057c2fda6a59ea3a92b3e28f6eb286cb0f16f4862bc4993136a6d108254f0dd689
|
data/lib/crypto/box.rb
CHANGED
@@ -114,7 +114,7 @@ module Crypto
|
|
114
114
|
secret_key.noaccess if secret_key.is_a?(Sodium::SecretBuffer)
|
115
115
|
end
|
116
116
|
|
117
|
-
def
|
117
|
+
def box!(data, nonce, public_key, secret_key)
|
118
118
|
message = String(data)
|
119
119
|
check_length(nonce, NONCEBYTES, :Nonce)
|
120
120
|
check_length(public_key, PUBLICKEYBYTES, :PublicKey)
|
@@ -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
|
133
|
+
def open!(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
|
@@ -165,4 +165,8 @@ module Crypto
|
|
165
165
|
def box(*args)
|
166
166
|
Box.box(*args)
|
167
167
|
end
|
168
|
+
|
169
|
+
def box!(*args)
|
170
|
+
Box.box!(*args)
|
171
|
+
end
|
168
172
|
end
|
data/lib/crypto/secret_box.rb
CHANGED
@@ -61,7 +61,7 @@ module Crypto
|
|
61
61
|
key.noaccess if key.is_a?(Sodium::SecretBuffer)
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def secretbox!(data, nonce, key)
|
65
65
|
message = String(data)
|
66
66
|
check_length(nonce, NONCEBYTES, :Nonce)
|
67
67
|
check_length(key, KEYBYTES, :SecretKey)
|
@@ -76,7 +76,7 @@ module Crypto
|
|
76
76
|
key.noaccess if key.is_a?(Sodium::SecretBuffer)
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def open!(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
|
@@ -110,4 +110,8 @@ module Crypto
|
|
110
110
|
def secretbox(*args)
|
111
111
|
SecretBox.secretbox(*args)
|
112
112
|
end
|
113
|
+
|
114
|
+
def secretbox!(*args)
|
115
|
+
SecretBox.secretbox!(*args)
|
116
|
+
end
|
113
117
|
end
|
data/lib/sodium.rb
CHANGED
@@ -72,7 +72,7 @@ module Sodium
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def hex2bin!(hex, bin_maxlen, ignore = nil)
|
76
76
|
bin_len = FFI::MemoryPointer.new(:size_t)
|
77
77
|
if sodium_hex2bin(hex, bin_maxlen, hex, hex.bytesize, ignore, bin_len, nil) == 0
|
78
78
|
size = bin_len.size == 8 ? bin_len.read_uint64 : bin_len.read_uint32
|
data/lib/sodium/version.rb
CHANGED