virgil-crypto 2.0.2b2 → 2.0.6r1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -1
- data/Gemfile +3 -0
- data/Rakefile +5 -4
- data/bin/console +1 -0
- data/ext/native/src/CMakeLists.txt +55 -3
- data/ext/native/src/ChangeLog +30 -0
- data/ext/native/src/VERSION +1 -1
- data/ext/native/src/lib/include/virgil/crypto/VirgilCryptoException.h +7 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilPBKDF.h +1 -1
- data/ext/native/src/lib/src/VirgilAsn1Writer.cxx +4 -4
- data/ext/native/src/lib/src/VirgilCryptoException.cxx +4 -0
- data/ext/native/src/lib/src/stream/VirgilStreamDataSource.cxx +1 -1
- data/ext/native/src/libs_ext/mbedtls/mbedtls.cmake +2 -2
- data/ext/native/src/tests/test_asn1_writer.cxx +6 -70
- data/ext/native/src/tests/test_cipher.cxx +20 -0
- data/ext/native/src/tests/test_stream_data_source.cxx +58 -0
- data/ext/native/src/utils/build.sh +8 -3
- data/ext/native/src/wrappers/go/CMakeLists.txt +92 -0
- data/ext/native/src/wrappers/net/CMakeLists.txt +1 -1
- data/ext/native/src/wrappers/net/src/VirgilStreamDataSink.cs +1 -3
- data/ext/native/src/wrappers/net/src/VirgilStreamDataSource.cs +1 -3
- data/ext/native/src/wrappers/ruby/CMakeLists.txt +4 -6
- data/ext/native/src/wrappers/swig/common.i +7 -0
- data/ext/native/src/wrappers/swig/go/common.i.in +66 -0
- data/ext/native/src/wrappers/swig/util.i +1 -0
- data/ext/rakefile.rb +65 -0
- data/lib/virgil/crypto.rb +2 -2
- data/lib/virgil/crypto/bytes.rb +4 -0
- data/lib/virgil/crypto/version.rb +1 -1
- data/lib/virgil/crypto/virgil_stream_data_sink.rb +4 -3
- data/lib/virgil/crypto/virgil_stream_data_source.rb +4 -3
- data/lib/virgil/native_crypto.rb +100 -0
- data/lib/virgil/os.rb +17 -0
- data/virgil-crypto.gemspec +12 -6
- metadata +20 -13
- data/ext/native/extconf.rb +0 -35
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'virgil/crypto/version'
|
2
|
+
require 'virgil/os'
|
3
|
+
require 'net/http'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'zlib'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'rake'
|
8
|
+
|
9
|
+
class NativeCrypto
|
10
|
+
LIBRARY_LIST_URL = "https://cdn.virgilsecurity.com/virgil-crypto/ruby/"
|
11
|
+
|
12
|
+
def self.load_library
|
13
|
+
library_file_name = 'virgil_crypto_ruby.'
|
14
|
+
library_file_name += required_library_os == 'linux' ? 'os' : 'bundle'
|
15
|
+
crypto_folder_path = "#{lib_path}/virgil/crypto"
|
16
|
+
download_library(get_library_path, library_file_name, crypto_folder_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def self.get_library_path
|
21
|
+
body = get_https(LIBRARY_LIST_URL)
|
22
|
+
raise "Can't download native library. Please try later." unless body
|
23
|
+
ruby_version = RUBY_VERSION.sub(/\.[^\.]+$/, "")
|
24
|
+
href_template = /virgil-crypto-#{required_library_version}\b-.+\b?-ruby-#{ruby_version}-#{required_library_os}(?!tgz).+tgz"/
|
25
|
+
href_list = body.scan href_template
|
26
|
+
|
27
|
+
if href_list.last.nil?
|
28
|
+
raise "Sorry. Correct version #{required_library_version} of Native Library is missing."
|
29
|
+
end
|
30
|
+
|
31
|
+
href_list.last.sub(/"$/, '')
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.get_https(url)
|
36
|
+
uri = URI(url)
|
37
|
+
Net::HTTP.start(uri.host, uri.port,
|
38
|
+
:use_ssl => true) do |http|
|
39
|
+
http.read_timeout = 100
|
40
|
+
request = Net::HTTP::Get.new uri
|
41
|
+
response = http.request request
|
42
|
+
case response
|
43
|
+
when Net::HTTPSuccess
|
44
|
+
response.body
|
45
|
+
when Net::HTTPServerError
|
46
|
+
warn "#{response.message}: try again later?"
|
47
|
+
nil
|
48
|
+
else
|
49
|
+
warn response.message
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.required_library_version
|
56
|
+
Virgil::Crypto::VERSION.scan(/\d+\.\d+\.\d+(\D*\d*)$/) do |postfix|
|
57
|
+
return Virgil::Crypto::VERSION.sub(postfix.last, '')
|
58
|
+
end
|
59
|
+
return ''
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.required_library_os
|
63
|
+
if OS.linux?
|
64
|
+
"linux"
|
65
|
+
elsif OS.mac?
|
66
|
+
"darwin"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.download_library(source_path, file_name, folder_path)
|
71
|
+
|
72
|
+
system('mkdir -p tmp')
|
73
|
+
archive_path = 'tmp/native_library.tar.gz'
|
74
|
+
|
75
|
+
open(archive_path, 'w') do |local_file|
|
76
|
+
begin
|
77
|
+
open(LIBRARY_LIST_URL + source_path) do |remote_file|
|
78
|
+
local_file.write(Zlib::GzipReader.new(remote_file).read)
|
79
|
+
end
|
80
|
+
rescue Exception => e
|
81
|
+
raise "Can't download native library from #{source_path} by reason: #{e}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
library_folder_name = source_path.sub('.tgz', '')
|
86
|
+
|
87
|
+
system("tar xvf #{archive_path} -C tmp/")
|
88
|
+
|
89
|
+
|
90
|
+
system("cp tmp/#{library_folder_name}/lib/#{file_name} #{folder_path}/#{file_name}")
|
91
|
+
system('rm -rf tmp')
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.lib_path
|
96
|
+
File.expand_path('../../..', __FILE__) + "/lib"
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
end
|
data/lib/virgil/os.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module OS
|
2
|
+
def OS.windows?
|
3
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
4
|
+
end
|
5
|
+
|
6
|
+
def OS.mac?
|
7
|
+
(/darwin/ =~ RUBY_PLATFORM) != nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def OS.unix?
|
11
|
+
!OS.windows?
|
12
|
+
end
|
13
|
+
|
14
|
+
def OS.linux?
|
15
|
+
OS.unix? and not OS.mac?
|
16
|
+
end
|
17
|
+
end
|
data/virgil-crypto.gemspec
CHANGED
@@ -1,31 +1,36 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'virgil/os'
|
4
5
|
require 'virgil/crypto/version'
|
5
6
|
|
7
|
+
abort "Windows is not supported yet." if OS.windows?
|
8
|
+
|
9
|
+
|
6
10
|
Gem::Specification.new do |spec|
|
7
11
|
spec.name = "virgil-crypto"
|
8
12
|
spec.version = Virgil::Crypto::VERSION
|
9
|
-
spec.authors = ["Dmitriy Dudkin"]
|
10
|
-
spec.email = ["dudkin.dmitriy@gmail.com"]
|
13
|
+
spec.authors = ["Dmitriy Dudkin", "Sergey Seroshtan"]
|
14
|
+
spec.email = ["dudkin.dmitriy@gmail.com", "sseroshtan@virgilsecurity.com"]
|
11
15
|
|
12
16
|
spec.summary = %q{Virgil Crypto library wrapper}
|
13
17
|
spec.description = %q{Virgil Crypto library wrapper}
|
14
18
|
spec.homepage = "http://github.com/VirgilSecurity/virgil-crypto-ruby"
|
15
|
-
spec.licenses = ['
|
19
|
+
spec.licenses = ['BSD-3-Clause']
|
16
20
|
|
17
21
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
22
|
spec.bindir = "exe"
|
19
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
24
|
spec.require_paths = ["lib"]
|
21
|
-
spec.extensions = ['ext/
|
22
|
-
|
23
|
-
spec.add_development_dependency "rake-compiler", "~> 1.0"
|
25
|
+
spec.extensions = [ 'ext/rakefile.rb']
|
26
|
+
spec.required_ruby_version = '>= 2.1.10'
|
24
27
|
spec.add_development_dependency "bundler", "~> 1.12"
|
28
|
+
spec.add_development_dependency "rake-compiler", "~> 1.0"
|
25
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
30
|
spec.add_development_dependency "minitest-reporters", "~> 1.1"
|
27
31
|
|
28
32
|
current_dir = File.expand_path(File.dirname(__FILE__))
|
33
|
+
|
29
34
|
# get an array of submodule dirs by executing 'pwd' inside each submodule
|
30
35
|
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
31
36
|
# for each submodule, change working directory to that submodule
|
@@ -51,3 +56,4 @@ Gem::Specification.new do |spec|
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
59
|
+
|
metadata
CHANGED
@@ -1,43 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virgil-crypto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6r1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Dudkin
|
8
|
+
- Sergey Seroshtan
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
+
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
+
version: '1.12'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
27
|
+
version: '1.12'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: rake-compiler
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
34
|
+
version: '1.0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
41
|
+
version: '1.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: rake
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,9 +70,10 @@ dependencies:
|
|
69
70
|
description: Virgil Crypto library wrapper
|
70
71
|
email:
|
71
72
|
- dudkin.dmitriy@gmail.com
|
73
|
+
- sseroshtan@virgilsecurity.com
|
72
74
|
executables: []
|
73
75
|
extensions:
|
74
|
-
- ext/
|
76
|
+
- ext/rakefile.rb
|
75
77
|
extra_rdoc_files: []
|
76
78
|
files:
|
77
79
|
- ".gitignore"
|
@@ -81,7 +83,6 @@ files:
|
|
81
83
|
- Rakefile
|
82
84
|
- bin/console
|
83
85
|
- bin/setup
|
84
|
-
- ext/native/extconf.rb
|
85
86
|
- ext/native/src/.gitignore
|
86
87
|
- ext/native/src/.travis.yml
|
87
88
|
- ext/native/src/CMakeLists.txt
|
@@ -234,6 +235,7 @@ files:
|
|
234
235
|
- ext/native/src/tests/test_runner.cxx
|
235
236
|
- ext/native/src/tests/test_signer.cxx
|
236
237
|
- ext/native/src/tests/test_stream_cipher.cxx
|
238
|
+
- ext/native/src/tests/test_stream_data_source.cxx
|
237
239
|
- ext/native/src/tests/test_symmetric_cipher.cxx
|
238
240
|
- ext/native/src/tests/test_tag_filter.cxx
|
239
241
|
- ext/native/src/tests/test_tiny_cipher.cxx
|
@@ -248,6 +250,7 @@ files:
|
|
248
250
|
- ext/native/src/wrappers/asmjs/helpers.js
|
249
251
|
- ext/native/src/wrappers/asmjs/patch_embind.pl
|
250
252
|
- ext/native/src/wrappers/asmjs/wrapper.cxx
|
253
|
+
- ext/native/src/wrappers/go/CMakeLists.txt
|
251
254
|
- ext/native/src/wrappers/java/CMakeLists.txt
|
252
255
|
- ext/native/src/wrappers/java/src/VirgilStreamDataSink.java
|
253
256
|
- ext/native/src/wrappers/java/src/VirgilStreamDataSource.java
|
@@ -939,21 +942,25 @@ files:
|
|
939
942
|
- ext/native/src/wrappers/swig/csharp/VirgilByteArray.i
|
940
943
|
- ext/native/src/wrappers/swig/csharp/common.i
|
941
944
|
- ext/native/src/wrappers/swig/csharp/csharphead.swg.in
|
945
|
+
- ext/native/src/wrappers/swig/go/common.i.in
|
942
946
|
- ext/native/src/wrappers/swig/java/VirgilByteArray.i
|
943
947
|
- ext/native/src/wrappers/swig/java/common.i
|
944
948
|
- ext/native/src/wrappers/swig/php/VirgilByteArray.i
|
945
949
|
- ext/native/src/wrappers/swig/php/common.i
|
946
950
|
- ext/native/src/wrappers/swig/util.i
|
947
951
|
- ext/native/src/wrappers/swig/wrapper.i.in
|
952
|
+
- ext/rakefile.rb
|
948
953
|
- lib/virgil/crypto.rb
|
949
954
|
- lib/virgil/crypto/bytes.rb
|
950
955
|
- lib/virgil/crypto/version.rb
|
951
956
|
- lib/virgil/crypto/virgil_stream_data_sink.rb
|
952
957
|
- lib/virgil/crypto/virgil_stream_data_source.rb
|
958
|
+
- lib/virgil/native_crypto.rb
|
959
|
+
- lib/virgil/os.rb
|
953
960
|
- virgil-crypto.gemspec
|
954
961
|
homepage: http://github.com/VirgilSecurity/virgil-crypto-ruby
|
955
962
|
licenses:
|
956
|
-
-
|
963
|
+
- BSD-3-Clause
|
957
964
|
metadata: {}
|
958
965
|
post_install_message:
|
959
966
|
rdoc_options: []
|
@@ -963,7 +970,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
963
970
|
requirements:
|
964
971
|
- - ">="
|
965
972
|
- !ruby/object:Gem::Version
|
966
|
-
version:
|
973
|
+
version: 2.1.10
|
967
974
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
968
975
|
requirements:
|
969
976
|
- - ">"
|
@@ -971,7 +978,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
971
978
|
version: 1.3.1
|
972
979
|
requirements: []
|
973
980
|
rubyforge_project:
|
974
|
-
rubygems_version: 2.
|
981
|
+
rubygems_version: 2.4.5.2
|
975
982
|
signing_key:
|
976
983
|
specification_version: 4
|
977
984
|
summary: Virgil Crypto library wrapper
|
data/ext/native/extconf.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'mkmf'
|
2
|
-
|
3
|
-
CMAKE = find_executable "cmake"
|
4
|
-
abort "cmake >= 3.2 is required" unless CMAKE
|
5
|
-
|
6
|
-
SCRIPT_DIR = File.expand_path('../', __FILE__)
|
7
|
-
SRC_DIR = File.join(SCRIPT_DIR, 'src')
|
8
|
-
CURRENT_DIR = Dir.pwd
|
9
|
-
LIB_DIR = File.expand_path('../../lib', SCRIPT_DIR)
|
10
|
-
INSTALL_DIR = File.join(LIB_DIR, 'virgil', 'crypto')
|
11
|
-
INCLUDE_DIRS = [
|
12
|
-
RUBY_INCLUDE_DIR = RbConfig::CONFIG['rubyhdrdir'],
|
13
|
-
RUBY_CONFIG_INCLUDE_DIR=RbConfig::CONFIG['rubyarchhdrdir']
|
14
|
-
].join(' ').quote
|
15
|
-
RUBY_LIB_DIR = RbConfig::CONFIG['libdir']
|
16
|
-
|
17
|
-
CMAKE_COMMAND = [
|
18
|
-
CMAKE,
|
19
|
-
'-DCMAKE_BUILD_TYPE=Release',
|
20
|
-
"-DRUBY_VERSION=#{RUBY_VERSION}",
|
21
|
-
"-DRUBY_INCLUDE_DIR=#{RUBY_INCLUDE_DIR}",
|
22
|
-
"-DRUBY_CONFIG_INCLUDE_DIR=#{RUBY_CONFIG_INCLUDE_DIR}",
|
23
|
-
"-DRUBY_INCLUDE_DIRS=#{INCLUDE_DIRS}",
|
24
|
-
"-DRUBY_LIBRARY=#{RUBY_LIB_DIR}",
|
25
|
-
'-DRUBY_LIB_NAME=native',
|
26
|
-
'-DSWIG_MODULE_NAME=\"virgil::crypto::native\"',
|
27
|
-
'-DCMAKE_SWIG_FLAGS=-autorename',
|
28
|
-
"-DCMAKE_INSTALL_PREFIX=#{CURRENT_DIR}",
|
29
|
-
"-DINSTALL_API_DIR_NAME=#{INSTALL_DIR}",
|
30
|
-
"-DINSTALL_LIB_DIR_NAME=#{INSTALL_DIR}",
|
31
|
-
'-DLANG=ruby',
|
32
|
-
SRC_DIR
|
33
|
-
].join(' ')
|
34
|
-
|
35
|
-
system(CMAKE_COMMAND)
|