rubythemis 0.9.2 → 0.9.3
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/rubythemis.rb +41 -41
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 010a5172a65b943185448f107916d3bab8433f79
|
4
|
+
data.tar.gz: 9d24683b1218f954d2733348d02806981711d070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 431df4be161fe1fd0b002ed3b4fc29ef4406a206977c7cb532faeffb2b963dda0413590ff77d4ba60e4ba47f6bf621d575f077ac993d096ad109c6fa23a85278
|
7
|
+
data.tar.gz: 2bb25ba4d01363b9f139af7693fb16eb4bbc98d3dacbb1ba3eb7dddc15cd80e4a51c0b10354a6c7c1dc5157a3fb6faf4b91f1833a1585a6faa4887a0f4bd215a
|
data/lib/rubythemis.rb
CHANGED
@@ -112,11 +112,11 @@ module Themis
|
|
112
112
|
private_key_length=FFI::MemoryPointer.new(:uint)
|
113
113
|
public_key_length= FFI::MemoryPointer.new(:uint)
|
114
114
|
res=themis_gen_ec_key_pair(nil, private_key_length, nil, public_key_length)
|
115
|
-
raise ThemisError, "
|
115
|
+
raise ThemisError, "Themis failed generating EC KeyPair: #{res}" unless res == BUFFER_TOO_SMALL
|
116
116
|
private_key = FFI::MemoryPointer.new(:char, private_key_length.read_uint)
|
117
117
|
public_key = FFI::MemoryPointer.new(:char, public_key_length.read_uint)
|
118
118
|
res=themis_gen_ec_key_pair(private_key, private_key_length, public_key, public_key_length)
|
119
|
-
raise ThemisError, "
|
119
|
+
raise ThemisError, "Themis failed generating EC KeyPair: #{res}" unless res == SUCCESS
|
120
120
|
return private_key.get_bytes(0, private_key_length.read_uint), public_key.get_bytes(0, public_key_length.read_uint)
|
121
121
|
end
|
122
122
|
|
@@ -124,11 +124,11 @@ module Themis
|
|
124
124
|
private_key_length=FFI::MemoryPointer.new(:uint)
|
125
125
|
public_key_length= FFI::MemoryPointer.new(:uint)
|
126
126
|
res=themis_gen_rsa_key_pair(nil, private_key_length, nil, public_key_length)
|
127
|
-
raise ThemisError, "
|
127
|
+
raise ThemisError, "Themis failed generating RSA KeyPair: #{res}" unless res == BUFFER_TOO_SMALL
|
128
128
|
private_key = FFI::MemoryPointer.new(:char, private_key_length.read_uint)
|
129
129
|
public_key = FFI::MemoryPointer.new(:char, public_key_length.read_uint)
|
130
130
|
res=themis_gen_rsa_key_pair(private_key, private_key_length, public_key, public_key_length)
|
131
|
-
raise ThemisError, "
|
131
|
+
raise ThemisError, "Themis failed generating RSA KeyPair: #{res}" unless res == SUCCESS
|
132
132
|
return private_key.get_bytes(0, private_key_length.read_uint), public_key.get_bytes(0, public_key_length.read_uint)
|
133
133
|
end
|
134
134
|
end
|
@@ -157,7 +157,7 @@ module Themis
|
|
157
157
|
@callbacks[:user_data] = FFI::MemoryPointer.new(:uint64)
|
158
158
|
@callbacks[:user_data].write_uint64(@transport_obj_id)
|
159
159
|
@session=secure_session_create(id_buf, id_length, private_key_buf, private_key_length, @callbacks);
|
160
|
-
raise ThemisError, "
|
160
|
+
raise ThemisError, "Secure Session failed creating" unless @session
|
161
161
|
end
|
162
162
|
|
163
163
|
def is_established()
|
@@ -167,10 +167,10 @@ module Themis
|
|
167
167
|
def connect_request()
|
168
168
|
connect_request_length = FFI::MemoryPointer.new(:uint)
|
169
169
|
res=secure_session_generate_connect_request(@session, nil, connect_request_length)
|
170
|
-
raise ThemisError, "
|
170
|
+
raise ThemisError, "Secure Session failed making connection request: #{res}" unless res == BUFFER_TOO_SMALL
|
171
171
|
connect_request = FFI::MemoryPointer.new(:char, connect_request_length.read_uint)
|
172
172
|
res=secure_session_generate_connect_request(@session, connect_request, connect_request_length)
|
173
|
-
raise ThemisError, "
|
173
|
+
raise ThemisError, "Secure Session failed making connection request: #{res}" unless res == SUCCESS
|
174
174
|
return connect_request.get_bytes(0, connect_request_length.read_uint);
|
175
175
|
end
|
176
176
|
|
@@ -178,13 +178,13 @@ module Themis
|
|
178
178
|
message_, message_length_=string_to_pointer_size(message)
|
179
179
|
unwrapped_message_length = FFI::MemoryPointer.new(:uint)
|
180
180
|
res=secure_session_unwrap(@session, message_, message_length_, nil, unwrapped_message_length)
|
181
|
-
raise ThemisError, "
|
181
|
+
raise ThemisError, "Secure Session failed decrypting: #{res}" unless res == BUFFER_TOO_SMALL || res == SUCCESS
|
182
182
|
if res == SUCCESS
|
183
183
|
return SUCCESS, ""
|
184
184
|
end
|
185
185
|
unwrapped_message = FFI::MemoryPointer.new(:char, unwrapped_message_length.read_uint)
|
186
186
|
res=secure_session_unwrap(@session, message_, message_length_, unwrapped_message, unwrapped_message_length)
|
187
|
-
raise ThemisError, "
|
187
|
+
raise ThemisError, "Secure Session failed decrypting: #{res}" unless res == SUCCESS || res == SEND_AS_IS
|
188
188
|
return res, unwrapped_message.get_bytes(0, unwrapped_message_length.read_uint);
|
189
189
|
end
|
190
190
|
|
@@ -192,16 +192,16 @@ module Themis
|
|
192
192
|
message_, message_length_=string_to_pointer_size(message)
|
193
193
|
wrapped_message_length = FFI::MemoryPointer.new(:uint)
|
194
194
|
res=secure_session_wrap(@session, message_, message_length_, nil, wrapped_message_length)
|
195
|
-
raise ThemisError, "
|
195
|
+
raise ThemisError, "Secure Session failed encrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
196
196
|
wrapped_message = FFI::MemoryPointer.new(:char, wrapped_message_length.read_uint)
|
197
197
|
res=secure_session_wrap(@session, message_, message_length_, wrapped_message, wrapped_message_length)
|
198
|
-
raise ThemisError, "
|
198
|
+
raise ThemisError, "Secure Session failed encrypting: #{res}" unless res == SUCCESS || res == SEND_AS_IS
|
199
199
|
return wrapped_message.get_bytes(0, wrapped_message_length.read_uint);
|
200
200
|
end
|
201
201
|
|
202
202
|
def finalize
|
203
203
|
res=secure_session_destroy(@session)
|
204
|
-
raise ThemisError, "
|
204
|
+
raise ThemisError, "Secure Session failed destroying" unless res == SUCCESS
|
205
205
|
|
206
206
|
end
|
207
207
|
end
|
@@ -218,10 +218,10 @@ module Themis
|
|
218
218
|
message_, message_length_=string_to_pointer_size(message)
|
219
219
|
wrapped_message_length = FFI::MemoryPointer.new(:uint)
|
220
220
|
res=themis_secure_message_wrap(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, message_, message_length_, nil, wrapped_message_length)
|
221
|
-
raise ThemisError, "
|
221
|
+
raise ThemisError, "Secure Message failed encrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
222
222
|
wrapped_message = FFI::MemoryPointer.new(:char, wrapped_message_length.read_uint)
|
223
223
|
res=themis_secure_message_wrap(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, message_, message_length_, wrapped_message, wrapped_message_length)
|
224
|
-
raise ThemisError, "
|
224
|
+
raise ThemisError, "Secure Message failed encrypting: #{res}" unless res == SUCCESS
|
225
225
|
return wrapped_message.get_bytes(0, wrapped_message_length.read_uint);
|
226
226
|
end
|
227
227
|
|
@@ -229,10 +229,10 @@ module Themis
|
|
229
229
|
message_, message_length_=string_to_pointer_size(message)
|
230
230
|
unwrapped_message_length = FFI::MemoryPointer.new(:uint)
|
231
231
|
res=themis_secure_message_unwrap(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, message_, message_length_, nil, unwrapped_message_length)
|
232
|
-
raise ThemisError, "
|
232
|
+
raise ThemisError, "Secure Message failed decrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
233
233
|
unwrapped_message = FFI::MemoryPointer.new(:char, unwrapped_message_length.read_uint)
|
234
234
|
res=themis_secure_message_unwrap(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, message_, message_length_, unwrapped_message, unwrapped_message_length)
|
235
|
-
raise ThemisError, "
|
235
|
+
raise ThemisError, "Secure Message failed decrypting: #{res}" unless res == SUCCESS
|
236
236
|
return unwrapped_message.get_bytes(0, unwrapped_message_length.read_uint);
|
237
237
|
end
|
238
238
|
end
|
@@ -242,10 +242,10 @@ module Themis
|
|
242
242
|
message_, message_length_=string_to_pointer_size(message)
|
243
243
|
wrapped_message_length = FFI::MemoryPointer.new(:uint)
|
244
244
|
res=themis_secure_message_wrap(private_key_, private_key_length_, nil, 0, message_, message_length_, nil, wrapped_message_length)
|
245
|
-
raise ThemisError, "
|
245
|
+
raise ThemisError, "Secure Message failed singing: #{res}" unless res == BUFFER_TOO_SMALL
|
246
246
|
wrapped_message = FFI::MemoryPointer.new(:char, wrapped_message_length.read_uint)
|
247
247
|
res=themis_secure_message_wrap(private_key_, private_key_length_, nil, 0, message_, message_length_, wrapped_message, wrapped_message_length)
|
248
|
-
raise ThemisError, "
|
248
|
+
raise ThemisError, "Secure Message failed singing: #{res}" unless res == SUCCESS
|
249
249
|
return wrapped_message.get_bytes(0, wrapped_message_length.read_uint);
|
250
250
|
end
|
251
251
|
|
@@ -256,10 +256,10 @@ module Themis
|
|
256
256
|
message_, message_length_=string_to_pointer_size(message)
|
257
257
|
unwrapped_message_length = FFI::MemoryPointer.new(:uint)
|
258
258
|
res=themis_secure_message_unwrap(nil, 0, public_key_, public_key_length_, message_, message_length_, nil, unwrapped_message_length)
|
259
|
-
raise ThemisError, "
|
259
|
+
raise ThemisError, "Secure Message failed verifying: #{res}" unless res == BUFFER_TOO_SMALL
|
260
260
|
unwrapped_message = FFI::MemoryPointer.new(:char, unwrapped_message_length.read_uint)
|
261
261
|
res=themis_secure_message_unwrap(nil, 0, public_key_, public_key_length_, message_, message_length_, unwrapped_message, unwrapped_message_length)
|
262
|
-
raise ThemisError, "
|
262
|
+
raise ThemisError, "Secure Message failed verifying: #{res}" unless res == SUCCESS
|
263
263
|
return unwrapped_message.get_bytes(0, unwrapped_message_length.read_uint);
|
264
264
|
end
|
265
265
|
|
@@ -284,28 +284,28 @@ module Themis
|
|
284
284
|
case @mode
|
285
285
|
when SEAL_MODE
|
286
286
|
res=themis_secure_cell_encrypt_seal(@key, @key_length, context_, context_length_, message_, message_length_, nil, encrypted_message_length)
|
287
|
-
raise ThemisError, "
|
287
|
+
raise ThemisError, "Secure Cell (Seal) failed encrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
288
288
|
encrypted_message = FFI::MemoryPointer.new(:char, encrypted_message_length.read_uint)
|
289
289
|
res=themis_secure_cell_encrypt_seal(@key, @key_length, context_, context_length_, message_, message_length_, encrypted_message, encrypted_message_length)
|
290
|
-
raise ThemisError, "
|
290
|
+
raise ThemisError, "Secure Cell (Seal) failed encrypting: #{res}" unless res == SUCCESS
|
291
291
|
return encrypted_message.get_bytes(0, encrypted_message_length.read_uint)
|
292
292
|
when TOKEN_PROTECT_MODE
|
293
293
|
res=themis_secure_cell_encrypt_token_protect(@key, @key_length, context_, context_length_, message_, message_length_, nil, enccontext_length, nil, encrypted_message_length)
|
294
|
-
raise ThemisError, "
|
294
|
+
raise ThemisError, "Secure Cell (Token protect) failed encrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
295
295
|
encrypted_message = FFI::MemoryPointer.new(:char, encrypted_message_length.read_uint)
|
296
296
|
enccontext = FFI::MemoryPointer.new(:char, enccontext_length.read_uint)
|
297
297
|
res=themis_secure_cell_encrypt_token_protect(@key, @key_length, context_, context_length_, message_, message_length_, enccontext, enccontext_length, encrypted_message, encrypted_message_length)
|
298
|
-
raise ThemisError, "
|
298
|
+
raise ThemisError, "Secure Cell (Token Protect) failed encrypting: #{res}" unless res == SUCCESS
|
299
299
|
return enccontext.get_bytes(0, enccontext_length.read_uint), encrypted_message.get_bytes(0, encrypted_message_length.read_uint)
|
300
300
|
when CONTEXT_IMPRINT_MODE
|
301
301
|
res=themis_secure_cell_encrypt_context_imprint(@key, @key_length, message_, message_length_, context_, context_length_, nil, encrypted_message_length)
|
302
|
-
raise ThemisError, "
|
302
|
+
raise ThemisError, "Secure Cell (Context Imprint) failed encrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
303
303
|
encrypted_message = FFI::MemoryPointer.new(:char, encrypted_message_length.read_uint)
|
304
304
|
res=themis_secure_cell_encrypt_context_imprint(@key, @key_length, message_, message_length_, context_, context_length_, encrypted_message, encrypted_message_length)
|
305
|
-
raise ThemisError, "
|
305
|
+
raise ThemisError, "Secure Cell (Context Imprint) failed encrypting: #{res}" unless res == SUCCESS
|
306
306
|
return encrypted_message.get_bytes(0, encrypted_message_length.read_uint)
|
307
307
|
else
|
308
|
-
raise ThemisError, "
|
308
|
+
raise ThemisError, "Secure Cell failed encrypting, undefined mode"
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
@@ -316,31 +316,31 @@ module Themis
|
|
316
316
|
when SEAL_MODE
|
317
317
|
message_, message_length_ = string_to_pointer_size(message)
|
318
318
|
res=themis_secure_cell_decrypt_seal(@key, @key_length, context_, context_length_, message_, message_length_, nil, decrypted_message_length)
|
319
|
-
raise ThemisError, "
|
319
|
+
raise ThemisError, "Secure Cell (Seal) failed decrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
320
320
|
decrypted_message = FFI::MemoryPointer.new(:char, decrypted_message_length.read_uint)
|
321
321
|
res=themis_secure_cell_decrypt_seal(@key, @key_length, context_, context_length_, message_, message_length_, decrypted_message, decrypted_message_length)
|
322
|
-
raise ThemisError, "
|
322
|
+
raise ThemisError, "Secure Cell (Seal) failed decrypting: #{res}" unless res == SUCCESS
|
323
323
|
return decrypted_message.get_bytes(0, decrypted_message_length.read_uint)
|
324
324
|
when TOKEN_PROTECT_MODE
|
325
325
|
enccontext, message_ = message
|
326
326
|
message__, message_length__ = string_to_pointer_size(message_)
|
327
327
|
enccontext_, enccontext_length = string_to_pointer_size(enccontext)
|
328
328
|
res=themis_secure_cell_decrypt_token_protect(@key, @key_length, context_, context_length_, message__, message_length__, enccontext_, enccontext_length, nil, decrypted_message_length)
|
329
|
-
raise ThemisError, "
|
329
|
+
raise ThemisError, "Secure Cell (Token Protect) failed decrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
330
330
|
decrypted_message = FFI::MemoryPointer.new(:char, decrypted_message_length.read_uint)
|
331
331
|
res=themis_secure_cell_decrypt_token_protect(@key, @key_length, context_, context_length_, message__, message_length__, enccontext_, enccontext_length, decrypted_message, decrypted_message_length)
|
332
|
-
raise ThemisError, "
|
332
|
+
raise ThemisError, "Secure Cell (Token Protect) failed decrypting: #{res}" unless res == SUCCESS
|
333
333
|
return decrypted_message.get_bytes(0, decrypted_message_length.read_uint)
|
334
334
|
when CONTEXT_IMPRINT_MODE
|
335
335
|
message_, message_length_ = string_to_pointer_size(message)
|
336
336
|
res=themis_secure_cell_decrypt_context_imprint(@key, @key_length, message_, message_length_, context_, context_length_, nil, decrypted_message_length)
|
337
|
-
raise ThemisError, "
|
337
|
+
raise ThemisError, "Secure Cell (Context Imprint) failed decrypting: #{res}" unless res == BUFFER_TOO_SMALL
|
338
338
|
decrypted_message = FFI::MemoryPointer.new(:char, decrypted_message_length.read_uint)
|
339
339
|
res=themis_secure_cell_decrypt_context_imprint(@key, @key_length, message_, message_length_, context_, context_length_, decrypted_message, decrypted_message_length)
|
340
|
-
raise ThemisError, "
|
340
|
+
raise ThemisError, "Secure Cell (Context Imprint) failed decrypting: #{res}" unless res == SUCCESS
|
341
341
|
return decrypted_message.get_bytes(0, decrypted_message_length.read_uint)
|
342
342
|
else
|
343
|
-
raise ThemisError, "
|
343
|
+
raise ThemisError, "Secure Cell failed encrypting, undefined mode"
|
344
344
|
end
|
345
345
|
end
|
346
346
|
end
|
@@ -356,23 +356,23 @@ module Themis
|
|
356
356
|
def initialize(shared_secret)
|
357
357
|
shared_secret_buf, shared_secret_length = string_to_pointer_size(shared_secret)
|
358
358
|
@comparator=secure_comparator_create()
|
359
|
-
raise ThemisError, "
|
359
|
+
raise ThemisError, "Secure Comparator failed creating" unless @comparator
|
360
360
|
res=secure_comparator_append_secret(@comparator, shared_secret_buf, shared_secret_length)
|
361
|
-
raise ThemisError, "
|
361
|
+
raise ThemisError, "Secure Comparator failed appending secret" unless res==SUCCESS
|
362
362
|
end
|
363
363
|
|
364
364
|
def finalize()
|
365
365
|
res=secure_comparator_destroy(@comparator)
|
366
|
-
raise ThemisError, "
|
366
|
+
raise ThemisError, "Secure Comparator failed destroying" unless res==SUCCESS
|
367
367
|
end
|
368
368
|
|
369
369
|
def begin_compare()
|
370
370
|
res_length=FFI::MemoryPointer.new(:uint)
|
371
371
|
res=secure_comparator_begin_compare(@comparator, nil, res_length)
|
372
|
-
raise ThemisError, "
|
372
|
+
raise ThemisError, "Secure Comparator failed making initialisation message" unless res==BUFFER_TOO_SMALL
|
373
373
|
res_buffer=FFI::MemoryPointer.new(:char, res_length.read_uint)
|
374
374
|
res=secure_comparator_begin_compare(@comparator, res_buffer, res_length)
|
375
|
-
raise ThemisError, "
|
375
|
+
raise ThemisError, "Secure Comparator failed making initialisation message" unless res==SUCCESS || res==SEND_AS_IS
|
376
376
|
return res_buffer.get_bytes(0,res_length.read_uint)
|
377
377
|
end
|
378
378
|
|
@@ -380,13 +380,13 @@ module Themis
|
|
380
380
|
message, message_length = string_to_pointer_size(control_message)
|
381
381
|
res_length=FFI::MemoryPointer.new(:uint)
|
382
382
|
res=secure_comparator_proceed_compare(@comparator, message, message_length, nil, res_length)
|
383
|
-
raise ThemisError, "
|
383
|
+
raise ThemisError, "Secure Comparator failed proeeding message" unless res==SUCCESS || res == BUFFER_TOO_SMALL
|
384
384
|
if res == SUCCESS
|
385
385
|
return ""
|
386
386
|
end
|
387
387
|
res_buffer=FFI::MemoryPointer.new(:char, res_length.read_uint)
|
388
388
|
res=secure_comparator_proceed_compare(@comparator, message, message_length, res_buffer, res_length)
|
389
|
-
raise ThemisError, "
|
389
|
+
raise ThemisError, "Secure Comparator failed proeeding message" unless res==SUCCESS || res==SEND_AS_IS
|
390
390
|
return res_buffer.get_bytes(0,res_length.read_uint)
|
391
391
|
end
|
392
392
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubythemis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CossackLabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements:
|
63
|
-
- libthemis, v0.9.
|
63
|
+
- libthemis, v0.9.3
|
64
64
|
rubyforge_project:
|
65
65
|
rubygems_version: 2.4.5
|
66
66
|
signing_key:
|