self_crypto 0.0.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 +7 -0
- data/Rakefile +19 -0
- data/ext/self_crypto/account.c +292 -0
- data/ext/self_crypto/extconf.rb +15 -0
- data/ext/self_crypto/omemo.c +170 -0
- data/ext/self_crypto/pk.c +15 -0
- data/ext/self_crypto/pk_decryption.c +129 -0
- data/ext/self_crypto/pk_encryption.c +93 -0
- data/ext/self_crypto/pk_signing.c +102 -0
- data/ext/self_crypto/sas.c +190 -0
- data/ext/self_crypto/self_crypto.c +68 -0
- data/ext/self_crypto/self_crypto.h +15 -0
- data/ext/self_crypto/session.c +363 -0
- data/ext/self_crypto/utility.c +143 -0
- data/lib/self_crypto.rb +14 -0
- data/lib/self_crypto/account.rb +30 -0
- data/lib/self_crypto/group_message.rb +34 -0
- data/lib/self_crypto/group_session.rb +8 -0
- data/lib/self_crypto/message.rb +6 -0
- data/lib/self_crypto/olm_error.rb +70 -0
- data/lib/self_crypto/olm_message.rb +25 -0
- data/lib/self_crypto/pre_key_message.rb +6 -0
- data/lib/self_crypto/sas.rb +28 -0
- data/lib/self_crypto/sas_data.rb +71 -0
- data/lib/self_crypto/session.rb +16 -0
- data/lib/self_crypto/utility.rb +7 -0
- data/lib/self_crypto/version.rb +5 -0
- data/test/examples/test_bob_no_answer.rb +62 -0
- data/test/examples/test_exchange.rb +60 -0
- data/test/spec/test_account.rb +100 -0
- data/test/unit/test_account_methods.rb +64 -0
- metadata +134 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/reporters'
|
3
|
+
require 'self_crypto'
|
4
|
+
|
5
|
+
reporter_options = { color: true }
|
6
|
+
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(reporter_options)]
|
7
|
+
|
8
|
+
describe "Account" do
|
9
|
+
|
10
|
+
let(:account){ SelfCrypto::Account.new }
|
11
|
+
|
12
|
+
# returns cached one-time-keys which have not yet been marked as published
|
13
|
+
#
|
14
|
+
describe "#otk" do
|
15
|
+
|
16
|
+
it("returns a Hash"){ _(account.otk['curve25519']).must_be_kind_of Hash }
|
17
|
+
|
18
|
+
describe "return value" do
|
19
|
+
|
20
|
+
describe "before #gen_otk" do
|
21
|
+
|
22
|
+
describe "before #mark_otk" do
|
23
|
+
|
24
|
+
it("is empty"){ _(account.otk['curve25519'].size).must_equal 0 }
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "after #mark_otk" do
|
29
|
+
|
30
|
+
before{ account.mark_otk }
|
31
|
+
|
32
|
+
it("is empty"){ _(account.otk['curve25519'].size).must_equal 0 }
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "after #gen_otk" do
|
39
|
+
let(:n){ 100 }
|
40
|
+
|
41
|
+
before{ account.gen_otk(n) }
|
42
|
+
|
43
|
+
describe "before #mark_otk" do
|
44
|
+
|
45
|
+
it("has n keys"){ _(account.otk['curve25519'].size).must_equal n }
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "after #mark_otk" do
|
50
|
+
|
51
|
+
before{ account.mark_otk }
|
52
|
+
|
53
|
+
it("is empty"){ _(account.otk['curve25519'].size).must_equal 0 }
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
# creates inbound and outbound sessions
|
64
|
+
#
|
65
|
+
describe "session factory" do
|
66
|
+
|
67
|
+
let(:remote){ SelfCrypto::Account.new }
|
68
|
+
|
69
|
+
before do
|
70
|
+
remote.gen_otk
|
71
|
+
account.gen_otk
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#outbound_session" do
|
75
|
+
|
76
|
+
it("creates session") { _(account.outbound_session(remote.ik['curve25519'], remote.otk['curve25519'].values.first)).must_be_kind_of SelfCrypto::Session }
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#inbound_session" do
|
81
|
+
|
82
|
+
let(:remote_session){ remote.outbound_session(account.ik['curve25519'], account.otk['curve25519'].values.first) }
|
83
|
+
let(:remote_message){ remote_session.encrypt("hello") }
|
84
|
+
|
85
|
+
it("creates session") { _(account.inbound_session(remote_message)).must_be_kind_of SelfCrypto::Session }
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#inbound_session from known remote" do
|
90
|
+
|
91
|
+
let(:remote_session){ remote.outbound_session(account.ik['curve25519'], account.otk['curve25519'].values.first) }
|
92
|
+
let(:remote_message){ remote_session.encrypt("hello") }
|
93
|
+
|
94
|
+
it("creates session") { _(account.inbound_session(remote_message, remote.ik['curve25519'])).must_be_kind_of SelfCrypto::Session }
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'self_crypto'
|
3
|
+
|
4
|
+
class TestAccount < Minitest::Test
|
5
|
+
|
6
|
+
include SelfCrypto
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@state = Account.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_identity_keys
|
13
|
+
assert_instance_of Hash, @state.identity_keys
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_one_time_keys
|
17
|
+
assert_instance_of Hash, @state.one_time_keys
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_generate_one_time_keys
|
21
|
+
assert_equal @state, @state.generate_one_time_keys(rand(1..10))
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_last_error
|
25
|
+
assert_equal OlmError::SUCCESS, @state.last_error
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_sign
|
29
|
+
assert_instance_of String, @state.sign("hello")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_mark_keys_as_published
|
33
|
+
assert_equal @state, @state.mark_keys_as_published
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_max_number_of_one_time_keys
|
37
|
+
assert_kind_of Integer, @state.max_number_of_one_time_keys
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_to_pickle
|
41
|
+
assert_kind_of String, @state.to_pickle
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_from_pickle
|
45
|
+
Account.from_pickle(@state.to_pickle)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_from_pickle_with_key
|
49
|
+
Account.from_pickle(@state.to_pickle("hey"), "hey")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_from_pickle_invalid
|
53
|
+
assert_raises OlmError::BAD_ACCOUNT_KEY do
|
54
|
+
Account.from_pickle("")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_from_pickle_bad_key
|
59
|
+
assert_raises OlmError::BAD_ACCOUNT_KEY do
|
60
|
+
Account.from_pickle(@state.to_pickle, "hey")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: self_crypto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Bevan
|
8
|
+
- Cameron Harper
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake-compiler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: minitest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest-reporters
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description:
|
71
|
+
email: ops@selfid.net
|
72
|
+
executables: []
|
73
|
+
extensions:
|
74
|
+
- ext/self_crypto/extconf.rb
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- Rakefile
|
78
|
+
- ext/self_crypto/account.c
|
79
|
+
- ext/self_crypto/extconf.rb
|
80
|
+
- ext/self_crypto/omemo.c
|
81
|
+
- ext/self_crypto/pk.c
|
82
|
+
- ext/self_crypto/pk_decryption.c
|
83
|
+
- ext/self_crypto/pk_encryption.c
|
84
|
+
- ext/self_crypto/pk_signing.c
|
85
|
+
- ext/self_crypto/sas.c
|
86
|
+
- ext/self_crypto/self_crypto.c
|
87
|
+
- ext/self_crypto/self_crypto.h
|
88
|
+
- ext/self_crypto/session.c
|
89
|
+
- ext/self_crypto/utility.c
|
90
|
+
- lib/self_crypto.rb
|
91
|
+
- lib/self_crypto/account.rb
|
92
|
+
- lib/self_crypto/group_message.rb
|
93
|
+
- lib/self_crypto/group_session.rb
|
94
|
+
- lib/self_crypto/message.rb
|
95
|
+
- lib/self_crypto/olm_error.rb
|
96
|
+
- lib/self_crypto/olm_message.rb
|
97
|
+
- lib/self_crypto/pre_key_message.rb
|
98
|
+
- lib/self_crypto/sas.rb
|
99
|
+
- lib/self_crypto/sas_data.rb
|
100
|
+
- lib/self_crypto/session.rb
|
101
|
+
- lib/self_crypto/utility.rb
|
102
|
+
- lib/self_crypto/version.rb
|
103
|
+
- test/examples/test_bob_no_answer.rb
|
104
|
+
- test/examples/test_exchange.rb
|
105
|
+
- test/spec/test_account.rb
|
106
|
+
- test/unit/test_account_methods.rb
|
107
|
+
homepage: https://github.com/aldgate-ventures/self-crypto-ruby
|
108
|
+
licenses:
|
109
|
+
- Apache-2.0
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '2.0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubygems_version: 3.1.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Group end to end encryption for self
|
130
|
+
test_files:
|
131
|
+
- test/unit/test_account_methods.rb
|
132
|
+
- test/examples/test_exchange.rb
|
133
|
+
- test/examples/test_bob_no_answer.rb
|
134
|
+
- test/spec/test_account.rb
|