ffi-libsodium 0.0.3 → 0.0.4

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: 3cb05fe120d8eed38b8e0c341e1d3fba27425a34
4
- data.tar.gz: 76dfa4ba9d75a50bf547f210e77288a835b26814
3
+ metadata.gz: 01cf5df0b9bcbcc100cc7acedb2a11b7f5a91b2c
4
+ data.tar.gz: 7fda27dfaaed7e2f538e82d234ddfc254c5b25d5
5
5
  SHA512:
6
- metadata.gz: 6502883f4678d0d9c2c671be5e2db48bcbc5f53a8a37696b9014bedf8b0557251d3d4007a957836c5308e7cc4495a955d6937f2aff547a087ac2bc4aa5b4aabe
7
- data.tar.gz: fc6a22a13e8a9e37c69406df100918e445e0ca218e51ead932770842e11b9cae7061e7b7e1e562e1714052b25b1aabda398a7505f29eb1cd63de5424d69c4532
6
+ metadata.gz: d2fe21f487536468f00fde101b3a595c7f671a3f9a2854890db9eb046e40dca5f5bea4db7f7beaecfcdaad8299e31a021c151442dbca0ec86d4d0f32230db15c
7
+ data.tar.gz: 0ba70b4e2983a644878bc186d16c0084c5195a40887de0efe1a66956f4a9b6471d0e336e5536d87e1731fea619e724a13cd71e1de035aec61c488af5f1bdee66
@@ -15,7 +15,6 @@ module Crypto
15
15
  attach_function :seedbytes, :crypto_box_seedbytes, [], :size_t
16
16
  attach_function :publickeybytes, :crypto_box_publickeybytes, [], :size_t
17
17
  attach_function :secretkeybytes, :crypto_box_secretkeybytes, [], :size_t
18
- attach_function :beforenmbytes, :crypto_box_beforenmbytes, [], :size_t
19
18
  attach_function :noncebytes, :crypto_box_noncebytes, [], :size_t
20
19
  attach_function :macbytes, :crypto_box_macbytes, [], :size_t
21
20
 
@@ -23,7 +22,6 @@ module Crypto
23
22
  SEEDBYTES = seedbytes.freeze
24
23
  PUBLICKEYBYTES = publickeybytes.freeze
25
24
  SECRETKEYBYTES = secretkeybytes.freeze
26
- BEFORENMBYTES = beforenmbytes.freeze
27
25
  NONCEBYTES = noncebytes.freeze
28
26
  MACBYTES = macbytes.freeze
29
27
 
@@ -96,7 +94,9 @@ module Crypto
96
94
  ciphertext
97
95
  end
98
96
 
99
- alias_method :box, :easy
97
+ def box(*args)
98
+ easy(*args)
99
+ end
100
100
 
101
101
  def open_easy(ciphertext, nonce, public_key, secret_key)
102
102
  ciphertext_len = get_size(ciphertext)
@@ -115,7 +115,9 @@ module Crypto
115
115
  decrypted
116
116
  end
117
117
 
118
- alias_method :open, :open_easy
118
+ def open(*args)
119
+ open_easy(*args)
120
+ end
119
121
 
120
122
  def easy_in_place(data, nonce, public_key, secret_key)
121
123
  message = get_string(data)
@@ -157,43 +159,9 @@ module Crypto
157
159
 
158
160
  ciphertext
159
161
  end
160
-
161
- def beforenm(public_key, secret_key)
162
- check_length(public_key, PUBLICKEYBYTES, :PublicKey)
163
- check_length(secret_key, SECRETKEYBYTES, :SecretKey)
164
-
165
- shared_secret = Sodium::SecretBuffer.new(BEFORENMBYTES)
166
- crypto_box_beforenm(shared_secret, public_key, secret_key)
167
-
168
- shared_secret
169
- end
170
-
171
- def afternm(message, nonce, shared_secret)
172
- message_len = get_size(message)
173
- check_length(nonce, NONCEBYTES, :Nonce)
174
- check_length(shared_secret, BEFORENMBYTES, :SharedSecret)
175
-
176
- ciphertext = Sodium::Buffer.new(:uchar, MACBYTES + message_len)
177
- crypto_box_afternm(ciphertext, message, message_len, nonce, shared_secret)
178
-
179
- ciphertext
180
- end
181
-
182
- def open_afternm(ciphertext, nonce, shared_secret)
183
- ciphertext_len = get_size(ciphertext)
184
- check_length(nonce, NONCEBYTES, :Nonce)
185
- check_length(shared_secret, BEFORENMBYTES, :SharedSecret)
186
-
187
- decrypted = Sodium::Buffer.new(:uchar, ciphertext_len - MACBYTES)
188
- if crypto_box_open_afternm(decrypted, ciphertext, ciphertext_len, nonce, shared_secret) == -1
189
- raise Sodium::CryptoError, "Message forged", caller
190
- end
191
-
192
- decrypted
193
- end
194
162
  end
195
163
 
196
164
  def self.box(*args)
197
- Box.box(*args)
165
+ Box.easy(*args)
198
166
  end
199
167
  end
@@ -1,3 +1,3 @@
1
1
  module Sodium
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-libsodium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Beskow