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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -1
  3. data/Gemfile +3 -0
  4. data/Rakefile +5 -4
  5. data/bin/console +1 -0
  6. data/ext/native/src/CMakeLists.txt +55 -3
  7. data/ext/native/src/ChangeLog +30 -0
  8. data/ext/native/src/VERSION +1 -1
  9. data/ext/native/src/lib/include/virgil/crypto/VirgilCryptoException.h +7 -0
  10. data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilPBKDF.h +1 -1
  11. data/ext/native/src/lib/src/VirgilAsn1Writer.cxx +4 -4
  12. data/ext/native/src/lib/src/VirgilCryptoException.cxx +4 -0
  13. data/ext/native/src/lib/src/stream/VirgilStreamDataSource.cxx +1 -1
  14. data/ext/native/src/libs_ext/mbedtls/mbedtls.cmake +2 -2
  15. data/ext/native/src/tests/test_asn1_writer.cxx +6 -70
  16. data/ext/native/src/tests/test_cipher.cxx +20 -0
  17. data/ext/native/src/tests/test_stream_data_source.cxx +58 -0
  18. data/ext/native/src/utils/build.sh +8 -3
  19. data/ext/native/src/wrappers/go/CMakeLists.txt +92 -0
  20. data/ext/native/src/wrappers/net/CMakeLists.txt +1 -1
  21. data/ext/native/src/wrappers/net/src/VirgilStreamDataSink.cs +1 -3
  22. data/ext/native/src/wrappers/net/src/VirgilStreamDataSource.cs +1 -3
  23. data/ext/native/src/wrappers/ruby/CMakeLists.txt +4 -6
  24. data/ext/native/src/wrappers/swig/common.i +7 -0
  25. data/ext/native/src/wrappers/swig/go/common.i.in +66 -0
  26. data/ext/native/src/wrappers/swig/util.i +1 -0
  27. data/ext/rakefile.rb +65 -0
  28. data/lib/virgil/crypto.rb +2 -2
  29. data/lib/virgil/crypto/bytes.rb +4 -0
  30. data/lib/virgil/crypto/version.rb +1 -1
  31. data/lib/virgil/crypto/virgil_stream_data_sink.rb +4 -3
  32. data/lib/virgil/crypto/virgil_stream_data_source.rb +4 -3
  33. data/lib/virgil/native_crypto.rb +100 -0
  34. data/lib/virgil/os.rb +17 -0
  35. data/virgil-crypto.gemspec +12 -6
  36. metadata +20 -13
  37. data/ext/native/extconf.rb +0 -35
@@ -74,7 +74,8 @@ function show_usage {
74
74
  echo -e " * net_android - build .NET library under Android platform, requirements: Mono, \$ANDROID_NDK;"
75
75
  echo -e " * asmjs - build AsmJS library, requirements: \$EMSDK_HOME;"
76
76
  echo -e " * nodejs - build NodeJS module;"
77
- echo -e " * pnacl - build Portable Native library for Google Chrome, requirements: \$NACL_SDK_ROOT."
77
+ echo -e " * pnacl - build Portable Native library for Google Chrome, requirements: \$NACL_SDK_ROOT;"
78
+ echo -e " * go - build Golang library."
78
79
  echo -e " - <src_dir> - (default = .) path to the directory where root CMakeLists.txt file is located"
79
80
  echo -e " - <build_dir> - (default = build/<target>) path to the directory where temp files will be stored"
80
81
  echo -e " - <install_dir> - (default = install/<target>) path to the directory where library files will be installed".
@@ -238,10 +239,14 @@ show_info "<install_dir>: ${INSTALL_DIR}"
238
239
  # Define common build parameters
239
240
  CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release"
240
241
 
241
- if [[ ${TARGET_NAME} =~ ^(cpp|osx|java|net|php|python|ruby|nodejs)$ ]]; then
242
+ if [[ ${TARGET_NAME} =~ ^(cpp|osx|java|net|php|python|ruby|nodejs|go)$ ]]; then
242
243
  CMAKE_ARGS+=" -DPLATFORM_ARCH=$(uname -m)"
243
244
  fi
244
245
 
246
+ if [ "${TARGET_NAME}" == "go" ]; then
247
+ CMAKE_ARGS+=" -DINSTALL_CORE_LIBS=ON"
248
+ fi
249
+
245
250
  if [ ! -z "${TARGET_VERSION}" ]; then
246
251
  CMAKE_ARGS+=" -DLANG_VERSION=${TARGET_VERSION}"
247
252
  fi
@@ -255,7 +260,7 @@ cd "${INSTALL_DIR}" && rm -fr ./*
255
260
  cd "${BUILD_DIR}" && rm -fr ./*
256
261
 
257
262
  # Build for native platforms
258
- if [[ ${TARGET_NAME} =~ ^(cpp|java|net|php|python|ruby|nodejs)$ ]]; then
263
+ if [[ ${TARGET_NAME} =~ ^(cpp|java|net|php|python|ruby|nodejs|go)$ ]]; then
259
264
  cmake ${CMAKE_ARGS} -DLANG=${TARGET_NAME} -DPLATFORM_VERSION=${SYSTEM_KERNEL_RELEASE_VERSION} "${SRC_DIR}"
260
265
  make -j4 install
261
266
  fi
@@ -0,0 +1,92 @@
1
+ #
2
+ # Copyright (C) 2015-2016 Virgil Security Inc.
3
+ #
4
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
5
+ #
6
+ # All rights reserved.
7
+ #
8
+ # Redistribution and use in source and binary forms, with or without
9
+ # modification, are permitted provided that the following conditions are
10
+ # met:
11
+ #
12
+ # (1) Redistributions of source code must retain the above copyright
13
+ # notice, this list of conditions and the following disclaimer.
14
+ #
15
+ # (2) Redistributions in binary form must reproduce the above copyright
16
+ # notice, this list of conditions and the following disclaimer in
17
+ # the documentation and/or other materials provided with the
18
+ # distribution.
19
+ #
20
+ # (3) Neither the name of the copyright holder nor the names of its
21
+ # contributors may be used to endorse or promote products derived from
22
+ # this software without specific prior written permission.
23
+ #
24
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
25
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
28
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
+ # POSSIBILITY OF SUCH DAMAGE.
35
+ #
36
+
37
+ cmake_minimum_required (VERSION 3.2 FATAL_ERROR)
38
+
39
+ project (${WRAPPED_LIB_NAME}_go)
40
+
41
+ set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
42
+ set (GO_MODULE_NAME ${PROJECT_NAME})
43
+ set (SWIG_MODULE_NAME ${GO_MODULE_NAME})
44
+
45
+ find_host_package (SWIG REQUIRED)
46
+ include (${SWIG_USE_FILE})
47
+
48
+ set (CMAKE_SWIG_FLAGS "")
49
+
50
+ set (SWIG_WRAP_COPY_CONSTRUCTOR YES)
51
+ set (WRAPPER_INTERFACE_FILE "${CMAKE_CURRENT_BINARY_DIR}/wrapper.i")
52
+ configure_file (
53
+ "${wrappers_SOURCE_DIR}/swig/wrapper.i.in"
54
+ "${WRAPPER_INTERFACE_FILE}"
55
+ )
56
+
57
+ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
58
+ set (SWIG_TARGET_LINUX 1)
59
+ endif ()
60
+
61
+ configure_file (
62
+ "${wrappers_SOURCE_DIR}/swig/go/common.i.in"
63
+ "${CMAKE_CURRENT_BINARY_DIR}/go/common.i"
64
+ @ONLY
65
+ )
66
+
67
+ if (CMAKE_SIZEOF_VOID_P)
68
+ math(EXPR GO_INT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}")
69
+ else ()
70
+ math(EXPR GO_INT_SIZE 32)
71
+ endif ()
72
+
73
+ message (STATUS "Size of Golang integer: ${GO_INT_SIZE}")
74
+
75
+ set_property (SOURCE "${WRAPPER_INTERFACE_FILE}" PROPERTY CPLUSPLUS ON)
76
+ set_property (SOURCE "${WRAPPER_INTERFACE_FILE}" PROPERTY SWIG_FLAGS "-ignoremissing;-cgo;-intgosize;${GO_INT_SIZE}")
77
+
78
+ set (swig_generated_sources)
79
+ swig_module_initialize (${GO_MODULE_NAME} go)
80
+ swig_add_source_to_module (${GO_MODULE_NAME} swig_generated_source "${WRAPPER_INTERFACE_FILE}")
81
+
82
+ set (GO_SWIG_TARGET_NAME ${SWIG_MODULE_${GO_MODULE_NAME}_REAL_NAME})
83
+
84
+ add_library (${GO_SWIG_TARGET_NAME} STATIC ${swig_generated_source})
85
+
86
+ install (PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${GO_MODULE_NAME}.go" DESTINATION ".")
87
+
88
+ install (TARGETS ${GO_SWIG_TARGET_NAME}
89
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR_NAME}"
90
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR_NAME}"
91
+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR_NAME}"
92
+ )
@@ -123,7 +123,7 @@ if (UNIX AND NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin"))
123
123
  string(REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME>" ""
124
124
  CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
125
125
  else ()
126
- set_target_properties (${JAVA_SWIG_TARGET_NAME}
126
+ set_target_properties (${CSHARP_SWIG_TARGET_NAME}
127
127
  PROPERTIES NO_SONAME OFF VERSION ${VIRGIL_VERSION} SOVERSION ${VIRGIL_SOVERSION})
128
128
  endif ()
129
129
  endif ()
@@ -36,9 +36,7 @@
36
36
  */
37
37
  #endregion
38
38
 
39
- using virgil.crypto;
40
-
41
- namespace virgil.crypto {
39
+ namespace Virgil.Crypto {
42
40
 
43
41
  public class VirgilStreamDataSink : VirgilDataSink
44
42
  {
@@ -36,9 +36,7 @@
36
36
  */
37
37
  #endregion
38
38
 
39
- using virgil.crypto;
40
-
41
- namespace virgil.crypto {
39
+ namespace Virgil.Crypto {
42
40
 
43
41
  public class VirgilStreamDataSource : VirgilDataSource
44
42
  {
@@ -36,12 +36,11 @@
36
36
 
37
37
  cmake_minimum_required (VERSION 3.2 FATAL_ERROR)
38
38
 
39
- set (RUBY_LIB_NAME ${WRAPPED_LIB_NAME}_ruby CACHE STRING "Generated lib name")
40
- project (${RUBY_LIB_NAME})
39
+ project (${WRAPPED_LIB_NAME}_ruby)
41
40
 
42
41
  set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
43
42
  set (RUBY_MODULE_NAME ${PROJECT_NAME})
44
- set (SWIG_MODULE_NAME ${RUBY_MODULE_NAME} CACHE STRING "Generated ruby module name")
43
+ set (SWIG_MODULE_NAME ${RUBY_MODULE_NAME})
45
44
 
46
45
  find_host_package (Ruby REQUIRED)
47
46
  include_directories (SYSTEM ${RUBY_INCLUDE_DIRS})
@@ -56,7 +55,7 @@ endif (RUBY_VERSION)
56
55
  find_host_package (SWIG REQUIRED)
57
56
  include (${SWIG_USE_FILE})
58
57
 
59
- set (CMAKE_SWIG_FLAGS "" CACHE STRING "CMAKE SWIG FLAGS")
58
+ set (CMAKE_SWIG_FLAGS "")
60
59
 
61
60
  set (SWIG_WRAP_COPY_CONSTRUCTOR YES)
62
61
  set (WRAPPER_INTERFACE_FILE "${CMAKE_CURRENT_BINARY_DIR}/wrapper.i")
@@ -66,10 +65,9 @@ configure_file (
66
65
  )
67
66
 
68
67
  set_property (SOURCE "${WRAPPER_INTERFACE_FILE}" PROPERTY CPLUSPLUS ON)
69
- set_property (SOURCE "${WRAPPER_INTERFACE_FILE}" PROPERTY SWIG_FLAGS "-ignoremissing")
68
+ set_property (SOURCE "${WRAPPER_INTERFACE_FILE}" PROPERTY SWIG_FLAGS "-ignoremissing;-autorename")
70
69
 
71
70
  swig_add_module (${RUBY_MODULE_NAME} ruby "${WRAPPER_INTERFACE_FILE}")
72
-
73
71
  set (SWIG_TARGET ${SWIG_MODULE_${RUBY_MODULE_NAME}_REAL_NAME})
74
72
 
75
73
  if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -34,6 +34,9 @@
34
34
  * POSSIBILITY OF SUCH DAMAGE.
35
35
  */
36
36
 
37
+ // Define type map for size_t
38
+ %apply unsigned int { size_t };
39
+
37
40
  // Ignore C++ operators
38
41
  %ignore operator=;
39
42
  %ignore operator==;
@@ -51,6 +54,10 @@
51
54
  %include "java/common.i"
52
55
  #endif
53
56
 
57
+ #if defined(SWIGGO)
58
+ %include "go/common.i"
59
+ #endif
60
+
54
61
  // Define VirgilByteArray typemap if was not defined yet
55
62
  #ifndef SWIG_VIRGIL_BYTE_ARRAY
56
63
  #define SWIG_VIRGIL_BYTE_ARRAY
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (C) 2015-2016 Virgil Security Inc.
3
+ *
4
+ * Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
5
+ *
6
+ * All rights reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions are
10
+ * met:
11
+ *
12
+ * (1) Redistributions of source code must retain the above copyright
13
+ * notice, this list of conditions and the following disclaimer.
14
+ *
15
+ * (2) Redistributions in binary form must reproduce the above copyright
16
+ * notice, this list of conditions and the following disclaimer in
17
+ * the documentation and/or other materials provided with the
18
+ * distribution.
19
+ *
20
+ * (3) Neither the name of the copyright holder nor the names of its
21
+ * contributors may be used to endorse or promote products derived from
22
+ * this software without specific prior written permission.
23
+ *
24
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
25
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
28
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
+ * POSSIBILITY OF SUCH DAMAGE.
35
+ */
36
+
37
+ #cmakedefine SWIG_TARGET_LINUX
38
+
39
+ %insert(cgo_comment_typedefs) %{
40
+ #cgo CPPFLAGS: -I${SRCDIR}/include
41
+ #cgo LDFLAGS: -L${SRCDIR}/lib -lvirgil_crypto_go -lvirgil_crypto -lmbedcrypto -led25519 -lstdc++
42
+ %}
43
+ #if defined(SWIG_TARGET_LINUX)
44
+ %insert(cgo_comment_typedefs) %{
45
+ #cgo LDFLAGS: -lm
46
+ %}
47
+ #endif
48
+
49
+ %define SWIG_CATCH_STDEXCEPT
50
+ /* catching std::exception */
51
+ catch (std::invalid_argument& e) {
52
+ SWIG_exception(SWIG_ValueError, e.what() );
53
+ } catch (std::domain_error& e) {
54
+ SWIG_exception(SWIG_ValueError, e.what() );
55
+ } catch (std::overflow_error& e) {
56
+ SWIG_exception(SWIG_OverflowError, e.what() );
57
+ } catch (std::out_of_range& e) {
58
+ SWIG_exception(SWIG_IndexError, e.what() );
59
+ } catch (std::length_error& e) {
60
+ SWIG_exception(SWIG_IndexError, e.what() );
61
+ } catch (std::runtime_error& e) {
62
+ SWIG_exception(SWIG_RuntimeError, e.what() );
63
+ } catch (std::exception& e) {
64
+ SWIG_exception(SWIG_SystemError, e.what() );
65
+ }
66
+ %enddef
@@ -53,6 +53,7 @@ DEFINE_NAMESPACE(className, package)
53
53
  #include <includePath/className.h>
54
54
  %}
55
55
  %ignore package::className::className(className&&);
56
+ %ignore package::className::operator=(className&&);
56
57
  %include <includePath/className.h>
57
58
  %enddef
58
59
 
data/ext/rakefile.rb ADDED
@@ -0,0 +1,65 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+
5
+ task :default do
6
+ require 'virgil/native_crypto'
7
+ require 'mkmf'
8
+
9
+ abort "Sorry, we don't support Ruby with version 2.0! Please Upgrade you Ruby version." if RUBY_VERSION =~ /^2\.0\./
10
+
11
+ begin
12
+ NativeCrypto.load_library
13
+
14
+ rescue
15
+
16
+ SCRIPT_DIR = File.expand_path('../', __FILE__)
17
+ ROOT_DIR = File.expand_path('../..', __FILE__)
18
+ SRC_DIR = File.join(SCRIPT_DIR, 'native/src')
19
+ CURRENT_DIR = Dir.pwd
20
+ LIB_DIR = File.join(ROOT_DIR, "lib")
21
+ INSTALL_DIR = File.join(LIB_DIR, 'virgil', 'crypto')
22
+ ext = OS.linux? ? "so" : "bundle"
23
+
24
+ # unless File.exists?(File.join(INSTALL_DIR, "virgil_crypto_ruby.#{ext}"))
25
+ BUILD_DIR = File.join(ROOT_DIR, "build")
26
+ mkdir_p BUILD_DIR
27
+ cd BUILD_DIR
28
+
29
+ CMAKE = find_executable "cmake"
30
+ abort "cmake >= 3.2 is required" unless CMAKE
31
+
32
+
33
+ INCLUDE_DIRS = [
34
+ RUBY_INCLUDE_DIR = RbConfig::CONFIG['rubyhdrdir'],
35
+ RUBY_CONFIG_INCLUDE_DIR=RbConfig::CONFIG['rubyarchhdrdir']
36
+ ].join(' ').quote
37
+ RUBY_LIB_DIR = RbConfig::CONFIG['libdir']
38
+
39
+ CMAKE_COMMAND = [
40
+ CMAKE,
41
+ '-DCMAKE_BUILD_TYPE=Release',
42
+ "-DRUBY_VERSION=#{RUBY_VERSION}",
43
+ "-DRUBY_INCLUDE_DIR=#{RUBY_INCLUDE_DIR}",
44
+ "-DRUBY_CONFIG_INCLUDE_DIR=#{RUBY_CONFIG_INCLUDE_DIR}",
45
+ "-DRUBY_INCLUDE_DIRS=#{INCLUDE_DIRS}",
46
+ "-DRUBY_LIBRARY=#{RUBY_LIB_DIR}",
47
+ '-DCMAKE_SWIG_FLAGS=-autorename',
48
+ "-DCMAKE_INSTALL_PREFIX=#{CURRENT_DIR}",
49
+ "-DINSTALL_API_DIR_NAME=#{INSTALL_DIR}",
50
+ "-DINSTALL_LIB_DIR_NAME=#{INSTALL_DIR}",
51
+ '-DLANG=ruby',
52
+ SRC_DIR
53
+ ].join(' ')
54
+
55
+ system(CMAKE_COMMAND)
56
+ system('make -j4')
57
+ system('make install')
58
+
59
+ cd '../'
60
+ rm_rf BUILD_DIR
61
+ end
62
+ # end
63
+ end
64
+
65
+
data/lib/virgil/crypto.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require "virgil/crypto/version"
2
-
3
2
  module Virgil
4
3
  module Crypto
5
- autoload :Native, 'virgil/crypto/native'
4
+ autoload :Virgil_crypto_ruby, 'virgil/crypto/virgil_crypto_ruby'
6
5
  autoload :Bytes, 'virgil/crypto/bytes'
7
6
  autoload :VirgilStreamDataSink, 'virgil/crypto/virgil_stream_data_sink'
8
7
  autoload :VirgilStreamDataSource, 'virgil/crypto/virgil_stream_data_source'
8
+ Native = Virgil_crypto_ruby
9
9
  end
10
10
  end
@@ -52,6 +52,10 @@ module Virgil
52
52
  def to_json(*a)
53
53
  Base64.strict_encode64(to_s).to_json(*a)
54
54
  end
55
+
56
+ def to_base64
57
+ Base64.strict_encode64(to_s)
58
+ end
55
59
  end
56
60
  end
57
61
  end
@@ -1,5 +1,5 @@
1
1
  module Virgil
2
2
  module Crypto
3
- VERSION = "2.0.2b2"
3
+ VERSION = "2.0.6r1"
4
4
  end
5
5
  end
@@ -34,19 +34,20 @@
34
34
 
35
35
  module Virgil
36
36
  module Crypto
37
- class VirgilStreamDataSink < Virgil::Crypto::Native::VirgilDataSink
37
+ class VirgilStreamDataSink < Native::VirgilDataSink
38
38
  attr_reader :stream
39
39
 
40
40
  def initialize(stream)
41
41
  @stream = stream
42
+ super()
42
43
  end
43
44
 
44
45
  def is_good
45
- !steam.closed? && !stream.eof?
46
+ !stream.closed_write?
46
47
  end
47
48
 
48
49
  def write(data)
49
- stream.write(Bytes.new(data))
50
+ stream.write(data.pack('c*'))
50
51
  end
51
52
  end
52
53
  end
@@ -34,20 +34,21 @@
34
34
 
35
35
  module Virgil
36
36
  module Crypto
37
- class VirgilStreamDataSource < Virgil::Crypto::Native::VirgilDataSource
37
+ class VirgilStreamDataSource < Native::VirgilDataSource
38
38
  attr_reader :stream, :buffer_size
39
39
 
40
40
  def initialize(stream, buffer_size = 1024)
41
41
  @stream = stream
42
42
  @buffer_size = buffer_size
43
+ super()
43
44
  end
44
45
 
45
46
  def has_data
46
- !steam.closed? && !stream.eof?
47
+ !stream.closed_read? && !stream.eof?
47
48
  end
48
49
 
49
50
  def read
50
- stream.read(buffer_size)
51
+ Bytes.from_string(stream.read(buffer_size))
51
52
  end
52
53
  end
53
54
  end