ruby_olm 0.1.1 → 0.1.2
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/ext/ruby_olm/ext_lib_olm/staging/session.cpp +1 -0
- data/lib/ruby_olm/account.rb +3 -21
- data/lib/ruby_olm/version.rb +1 -1
- data/test/examples/test_bob_no_answer.rb +1 -1
- data/test/examples/test_exchange.rb +1 -1
- data/test/spec/test_account.rb +6 -58
- data/test/unit/test_account_methods.rb +0 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 343a748fd94cf6a9ba9da585f648e914899776d4ac4d134e177654003cefb6e5
|
4
|
+
data.tar.gz: ee4c37d996fad9269e6631872af88eba4e86b86adfa900b27bec2a941f1a122e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30cbfddf91af001b34daaa17b2718967acf52e452a83ad2a4288fa135e8c1551da172818b960ce0ea520ad45bd5305b82a7ebfdda2c5e73aa555d4db7ede2601
|
7
|
+
data.tar.gz: c8cd801bed9193b4fc00cb912dd083c09d6c0f403dcc2533c7f53b8af0df936aa709656ba092155003c39290d8b7b549d05abb5cc2790406d2c5def05579864b
|
@@ -213,6 +213,7 @@ std::size_t olm::Session::session_id(
|
|
213
213
|
return session_id_length();
|
214
214
|
}
|
215
215
|
|
216
|
+
|
216
217
|
bool olm::Session::matches_inbound_session(
|
217
218
|
_olm_curve25519_public_key const * their_identity_key,
|
218
219
|
std::uint8_t const * one_time_key_message, std::size_t message_length
|
data/lib/ruby_olm/account.rb
CHANGED
@@ -9,32 +9,14 @@ module RubyOlm
|
|
9
9
|
Account.new(pickle: pickle, password: password)
|
10
10
|
end
|
11
11
|
|
12
|
-
# @param [type] defaults to 'curve25519'
|
13
|
-
# @return [String]
|
14
|
-
def ik(type='curve25519')
|
15
|
-
raise RangeError unless identity_keys[type]
|
16
|
-
identity_keys[type]
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param [type] defaults to 'curve25519'
|
20
|
-
# @param [value] return only the key values and not the ids
|
21
|
-
#
|
22
|
-
# @return [Array<Hash>] if !values
|
23
|
-
# @return [Array<String>] if values
|
24
|
-
def otk(values=true, type='curve25519')
|
25
|
-
if values
|
26
|
-
one_time_keys[type].values
|
27
|
-
else
|
28
|
-
one_time_keys[type]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
12
|
def gen_otk(number=1)
|
33
13
|
generate_one_time_keys(number)
|
34
14
|
end
|
35
15
|
|
16
|
+
alias_method :ik, :identity_keys
|
17
|
+
alias_method :otk, :one_time_keys
|
36
18
|
alias_method :mark_otk, :mark_keys_as_published
|
37
|
-
alias_method :max_otk,
|
19
|
+
alias_method :max_otk, :max_number_of_one_time_keys
|
38
20
|
alias_method :update_otk, :remove_one_time_keys
|
39
21
|
|
40
22
|
end
|
data/lib/ruby_olm/version.rb
CHANGED
@@ -20,7 +20,7 @@ class TestExchange < Minitest::Test
|
|
20
20
|
bob.gen_otk
|
21
21
|
|
22
22
|
# Alice must have Bob's identity and one-time-key to make a session
|
23
|
-
alice_session = alice.outbound_session(bob.ik, bob.otk.first)
|
23
|
+
alice_session = alice.outbound_session(bob.ik['curve25519'], bob.otk['curve25519'].values.first)
|
24
24
|
|
25
25
|
# Bob marks all one-time-keys as published
|
26
26
|
bob.mark_otk
|
@@ -19,7 +19,7 @@ class TestExchange < Minitest::Test
|
|
19
19
|
bob.gen_otk
|
20
20
|
|
21
21
|
# Alice must have Bob's identity and one-time-key to make a session
|
22
|
-
alice_session = alice.outbound_session(bob.ik, bob.otk.first)
|
22
|
+
alice_session = alice.outbound_session(bob.ik['curve25519'], bob.otk['curve25519'].values.first)
|
23
23
|
|
24
24
|
# Bob marks all one-time-keys as published
|
25
25
|
bob.mark_otk
|
data/test/spec/test_account.rb
CHANGED
@@ -5,65 +5,13 @@ describe "Account" do
|
|
5
5
|
|
6
6
|
let(:account){ RubyOlm::Account.new }
|
7
7
|
|
8
|
-
# returns curve2599 identity key
|
9
|
-
#
|
10
|
-
describe "#ik" do
|
11
|
-
|
12
|
-
let(:rv){ account.ik }
|
13
|
-
|
14
|
-
it("returns a String"){ rv.must_be_instance_of String }
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#identity_keys" do
|
19
|
-
|
20
|
-
let(:rv){ account.identity_keys }
|
21
|
-
|
22
|
-
it("returns a Hash"){ rv.must_be_instance_of Hash }
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
# returns the maximum number of one-time-keys able to be
|
27
|
-
# cached by account
|
28
|
-
#
|
29
|
-
describe "#max_otk" do
|
30
|
-
|
31
|
-
let(:rv){ account.max_otk }
|
32
|
-
|
33
|
-
it("returns an unsigned integer") do
|
34
|
-
rv.must_be_kind_of Integer
|
35
|
-
rv.must_be :'>=', 0
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
# generates zero or more one-time-keys which will then be cached
|
41
|
-
# by account until such time they are:
|
42
|
-
#
|
43
|
-
# - overwritten by future calls to #generate_otk
|
44
|
-
# - removed by session establishment
|
45
|
-
#
|
46
|
-
describe "#gen_otk" do
|
47
|
-
|
48
|
-
it("returns self"){ account.gen_otk.must_equal account }
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
# marks one-time-keys as published
|
53
|
-
#
|
54
|
-
describe "#mark_otk" do
|
55
|
-
|
56
|
-
it("returns self"){ account.mark_otk.must_equal account }
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
8
|
# returns cached one-time-keys which have not yet been marked as published
|
61
9
|
#
|
62
10
|
describe "#otk" do
|
63
11
|
|
64
|
-
let(:rv){ account.otk }
|
12
|
+
let(:rv){ account.otk['curve25519'] }
|
65
13
|
|
66
|
-
it("returns
|
14
|
+
it("returns a Hash"){ rv.must_be_kind_of Hash }
|
67
15
|
|
68
16
|
describe "return value" do
|
69
17
|
|
@@ -125,13 +73,13 @@ describe "Account" do
|
|
125
73
|
|
126
74
|
describe "#outbound_session" do
|
127
75
|
|
128
|
-
it("creates session") { account.outbound_session(remote.ik, remote.otk.first).must_be_kind_of RubyOlm::Session }
|
76
|
+
it("creates session") { account.outbound_session(remote.ik['curve25519'], remote.otk['curve25519'].values.first).must_be_kind_of RubyOlm::Session }
|
129
77
|
|
130
78
|
end
|
131
79
|
|
132
80
|
describe "#inbound_session" do
|
133
81
|
|
134
|
-
let(:remote_session){ remote.outbound_session(account.ik, account.otk.first) }
|
82
|
+
let(:remote_session){ remote.outbound_session(account.ik['curve25519'], account.otk['curve25519'].values.first) }
|
135
83
|
let(:remote_message){ remote_session.encrypt("hello") }
|
136
84
|
|
137
85
|
it("creates session") { account.inbound_session(remote_message).must_be_kind_of RubyOlm::Session }
|
@@ -140,10 +88,10 @@ describe "Account" do
|
|
140
88
|
|
141
89
|
describe "#inbound_session from known remote" do
|
142
90
|
|
143
|
-
let(:remote_session){ remote.outbound_session(account.ik, account.otk.first) }
|
91
|
+
let(:remote_session){ remote.outbound_session(account.ik['curve25519'], account.otk['curve25519'].values.first) }
|
144
92
|
let(:remote_message){ remote_session.encrypt("hello") }
|
145
93
|
|
146
|
-
it("creates session") { account.inbound_session(remote_message, remote.ik).must_be_kind_of RubyOlm::Session }
|
94
|
+
it("creates session") { account.inbound_session(remote_message, remote.ik['curve25519']).must_be_kind_of RubyOlm::Session }
|
147
95
|
|
148
96
|
end
|
149
97
|
|
@@ -13,27 +13,14 @@ class TestAccount < Minitest::Test
|
|
13
13
|
assert_instance_of Hash, @state.identity_keys
|
14
14
|
end
|
15
15
|
|
16
|
-
def test_ik_default
|
17
|
-
assert_equal @state.identity_keys['curve25519'], @state.ik
|
18
|
-
end
|
19
|
-
|
20
16
|
def test_one_time_keys
|
21
17
|
assert_instance_of Hash, @state.one_time_keys
|
22
18
|
end
|
23
19
|
|
24
|
-
def test_otk_default
|
25
|
-
assert_instance_of Array, @state.otk
|
26
|
-
assert_equal @state.one_time_keys['curve25519'].values, @state.otk
|
27
|
-
end
|
28
|
-
|
29
20
|
def test_generate_one_time_keys
|
30
21
|
assert_equal @state, @state.generate_one_time_keys(rand(1..10))
|
31
22
|
end
|
32
23
|
|
33
|
-
def test_gen_otk
|
34
|
-
test_generate_one_time_keys
|
35
|
-
end
|
36
|
-
|
37
24
|
def test_last_error
|
38
25
|
assert_equal OlmError::SUCCESS, @state.last_error
|
39
26
|
end
|
@@ -46,18 +33,10 @@ class TestAccount < Minitest::Test
|
|
46
33
|
assert_equal @state, @state.mark_keys_as_published
|
47
34
|
end
|
48
35
|
|
49
|
-
def test_mark_otk
|
50
|
-
test_mark_keys_as_published
|
51
|
-
end
|
52
|
-
|
53
36
|
def test_max_number_of_one_time_keys
|
54
37
|
assert_kind_of Integer, @state.max_number_of_one_time_keys
|
55
38
|
end
|
56
39
|
|
57
|
-
def test_max_otk
|
58
|
-
test_max_number_of_one_time_keys
|
59
|
-
end
|
60
|
-
|
61
40
|
def test_to_pickle
|
62
41
|
assert_kind_of String, @state.to_pickle
|
63
42
|
end
|