acrawriter 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb1713c9e193f3da47bd5e37482d6a1fc7f31d4a
4
+ data.tar.gz: d414ef2020257ec7024454267a18cfc6df2e6a83
5
+ SHA512:
6
+ metadata.gz: 5c5dd4a04fb758a23519ac99a68e0f313ca575c47152442f8d6b0e05a9bfc8bac34d42ff3a1eced5118a2e79151aa01d6def05f17e4e88fb595e80168a102d5d
7
+ data.tar.gz: 24070d55209f150326e1c0e01d0f3999efcee5ae27350f8825155eeca7fde3ea717603a876a0d68a972a948b2878e15bf9e1678fb4356531bf294f5546aa58d1
@@ -0,0 +1,33 @@
1
+ # Copyright 2016, Cossack Labs Limited
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'rubythemis'
16
+
17
+ SYMMETRIC_KEY_LENGTH = 32
18
+
19
+ BEGIN_TAG = '""""""""'.b
20
+ def create_acrastruct(data, acra_public_key, context=nil)
21
+ if data.nil? or data == ''
22
+ return data
23
+ end
24
+ generator = Themis::SKeyPairGen.new
25
+ private, public = generator.ec
26
+ smessage = Themis::Smessage.new(private.to_s, acra_public_key.to_s)
27
+ random_key = Random.new.bytes(SYMMETRIC_KEY_LENGTH)
28
+ wrapped_random_key = smessage.wrap(random_key.to_s)
29
+ scell = Themis::Scell.new(random_key.to_s, Themis::Scell::SEAL_MODE)
30
+ encrypted_data = scell.encrypt(data, context)
31
+ data_length = Array(encrypted_data.length).pack('Q<')
32
+ BEGIN_TAG + public + wrapped_random_key + data_length + encrypted_data
33
+ end
@@ -0,0 +1,11 @@
1
+ require 'minitest/autorun'
2
+ require 'rubythemis'
3
+ require 'acrawriter'
4
+
5
+ class TestAcrawriter < Minitest::Test
6
+ def test_create_acrastruct
7
+ generator = Themis::SKeyPairGen.new
8
+ private, public = generator.ec
9
+ create_acrastruct("some data", public, context=nil)
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acrawriter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Cossack Labs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubythemis
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Wrapper for acra
28
+ email: dev@cossacklabs.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/acrawriter.rb
34
+ - test/test_acrawriter.rb
35
+ homepage: https://www.cossacklabs.com/
36
+ licenses:
37
+ - Apache 2.0
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements:
54
+ - libthemis, v0.10.0
55
+ rubyforge_project:
56
+ rubygems_version: 2.6.7
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Wrapper for acra
60
+ test_files:
61
+ - test/test_acrawriter.rb