virgil-crypto 2.3.0 → 3.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.gitmodules +0 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +0 -0
  6. data/README.md +113 -9
  7. data/Rakefile +0 -0
  8. data/ext/native/src/.clang-format +37 -0
  9. data/ext/native/src/.gitignore +3 -0
  10. data/ext/native/src/.travis.yml +2 -1
  11. data/ext/native/src/CMakeLists.txt +66 -63
  12. data/ext/native/src/ChangeLog +114 -2
  13. data/ext/native/src/Dockerfile_Golang +29 -8
  14. data/ext/native/src/Jenkinsfile +61 -50
  15. data/ext/native/src/LICENSE +0 -0
  16. data/ext/native/src/README.md +137 -167
  17. data/ext/native/src/VERSION +1 -1
  18. data/ext/native/src/benchmark.md +140 -0
  19. data/ext/native/src/benchmark/CMakeLists.txt +0 -0
  20. data/ext/native/src/benchmark/benchmark_cipher.cxx +0 -0
  21. data/ext/native/src/benchmark/benchmark_hash.cxx +0 -0
  22. data/ext/native/src/benchmark/benchmark_keys.cxx +0 -0
  23. data/ext/native/src/benchmark/benchmark_pythia.cxx +61 -0
  24. data/ext/native/src/benchmark/benchmark_random.cxx +0 -0
  25. data/ext/native/src/benchmark/benchmark_signer.cxx +0 -0
  26. data/ext/native/src/ci/install-dependencies.sh +8 -12
  27. data/ext/native/src/ci/publish-docs.sh +107 -22
  28. data/ext/native/src/ci/travis-deployment-key.enc +0 -0
  29. data/ext/native/src/cmake/TransitiveArgs.cmake +78 -0
  30. data/ext/native/src/cmake/TransitiveToolchainArgs.cmake +105 -0
  31. data/ext/native/src/cmake/add_mono_metadata.cmake +103 -0
  32. data/ext/native/src/cmake/apple.cmake +56 -11
  33. data/ext/native/src/cmake/aux_source_directory_to_file.cmake +0 -0
  34. data/ext/native/src/cmake/check_pointer_size.cmake +0 -0
  35. data/ext/native/src/cmake/copy_all_files.cmake +0 -0
  36. data/ext/native/src/cmake/file_regex_replace.cmake +0 -0
  37. data/ext/native/src/cmake/find_host_utils.cmake +0 -0
  38. data/ext/native/src/cmake/uppercase_first_char.cmake +0 -0
  39. data/ext/native/src/cmake/uppercase_namespaces.cmake +3 -0
  40. data/ext/native/src/cmake/virgil_depends.cmake +0 -0
  41. data/ext/native/src/cmake/virgil_depends_local.cmake +2 -0
  42. data/ext/native/src/docs/.gitignore +0 -0
  43. data/ext/native/src/lib/CMakeLists.txt +59 -1
  44. data/ext/native/src/lib/Doxyfile.in +1 -1
  45. data/ext/native/src/lib/Info.plist.in +0 -0
  46. data/ext/native/src/lib/cmake/config.cmake.in +0 -0
  47. data/ext/native/src/lib/include/virgil/crypto/VirgilByteArrayUtils.h +0 -0
  48. data/ext/native/src/lib/include/virgil/crypto/VirgilChunkCipher.h +0 -0
  49. data/ext/native/src/lib/include/virgil/crypto/VirgilCipherBase.h +0 -0
  50. data/ext/native/src/lib/include/virgil/crypto/VirgilContentInfo.h +0 -0
  51. data/ext/native/src/lib/include/virgil/crypto/VirgilCrypto.h +13 -0
  52. data/ext/native/src/lib/include/virgil/crypto/VirgilCryptoError.h +0 -0
  53. data/ext/native/src/lib/include/virgil/crypto/VirgilCustomParams.h +0 -0
  54. data/ext/native/src/lib/include/virgil/crypto/VirgilKeyPair.h +30 -0
  55. data/ext/native/src/lib/include/virgil/crypto/VirgilSignerBase.h +0 -0
  56. data/ext/native/src/lib/include/virgil/crypto/VirgilStreamCipher.h +0 -0
  57. data/ext/native/src/lib/include/virgil/crypto/VirgilStreamSigner.h +0 -0
  58. data/ext/native/src/lib/include/virgil/crypto/VirgilTinyCipher.h +0 -0
  59. data/ext/native/src/lib/include/virgil/crypto/VirgilVersion.h +0 -0
  60. data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilAsymmetricCipher.h +17 -0
  61. data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilHKDF.h +0 -0
  62. data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilPBKDF.h +0 -0
  63. data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilSystemCryptoError.h +0 -0
  64. data/ext/native/src/lib/include/virgil/crypto/foundation/asn1/VirgilAsn1Compatible.h +0 -0
  65. data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSContent.h +0 -0
  66. data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSContentInfo.h +0 -0
  67. data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSEncryptedContent.h +0 -0
  68. data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSEnvelopedData.h +0 -0
  69. data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSKeyTransRecipient.h +0 -0
  70. data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSPasswordRecipient.h +0 -0
  71. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFS.h +0 -0
  72. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSEncryptedMessage.h +0 -0
  73. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSInitiatorPrivateInfo.h +0 -0
  74. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSInitiatorPublicInfo.h +0 -0
  75. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSPrivateKey.h +0 -0
  76. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSPublicKey.h +0 -0
  77. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSResponderPrivateInfo.h +0 -0
  78. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSResponderPublicInfo.h +0 -0
  79. data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSSession.h +0 -0
  80. data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationCipher.h +0 -0
  81. data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationDH.h +0 -0
  82. data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationHash.h +0 -0
  83. data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationKDF.h +0 -0
  84. data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationRandom.h +0 -0
  85. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythia.h +181 -0
  86. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaBlindResult.h +89 -0
  87. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaContext.h +72 -0
  88. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaError.h +161 -0
  89. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaProveResult.h +89 -0
  90. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaTransformResult.h +91 -0
  91. data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaTransformationKeyPair.h +87 -0
  92. data/ext/native/src/lib/include/virgil/crypto/pythia/virgil_pythia_c.h +203 -0
  93. data/ext/native/src/lib/include/virgil/crypto/stream/VirgilBytesDataSink.h +0 -0
  94. data/ext/native/src/lib/include/virgil/crypto/stream/VirgilBytesDataSource.h +0 -0
  95. data/ext/native/src/lib/mainpage.dox +6 -0
  96. data/ext/native/src/lib/module.modulemap +7 -0
  97. data/ext/native/src/lib/src/VirgilAsn1Alg.cxx +0 -0
  98. data/ext/native/src/lib/src/VirgilAsn1Alg.h +0 -0
  99. data/ext/native/src/lib/src/VirgilAsn1Compatible.cxx +0 -0
  100. data/ext/native/src/lib/src/VirgilAsymmetricCipher.cxx +82 -0
  101. data/ext/native/src/lib/src/VirgilByteArrayUtils.cxx +0 -0
  102. data/ext/native/src/lib/src/VirgilCMSContent.cxx +0 -0
  103. data/ext/native/src/lib/src/VirgilCMSContentInfo.cxx +0 -0
  104. data/ext/native/src/lib/src/VirgilCMSEncryptedContent.cxx +0 -0
  105. data/ext/native/src/lib/src/VirgilCMSEnvelopedData.cxx +0 -0
  106. data/ext/native/src/lib/src/VirgilCMSKeyTransRecipient.cxx +0 -0
  107. data/ext/native/src/lib/src/VirgilCMSPasswordRecipient.cxx +0 -0
  108. data/ext/native/src/lib/src/VirgilChunkCipher.cxx +0 -0
  109. data/ext/native/src/lib/src/VirgilCipherBase.cxx +0 -0
  110. data/ext/native/src/lib/src/VirgilConfig.cxx +51 -0
  111. data/ext/native/src/lib/src/VirgilConfig.h.in +43 -1
  112. data/ext/native/src/lib/src/VirgilContentInfo.cxx +0 -0
  113. data/ext/native/src/lib/src/VirgilCryptoError.cxx +0 -0
  114. data/ext/native/src/lib/src/VirgilCustomParams.cxx +0 -0
  115. data/ext/native/src/lib/src/VirgilDataSink.cxx +0 -0
  116. data/ext/native/src/lib/src/VirgilHKDF.cxx +0 -0
  117. data/ext/native/src/lib/src/VirgilKeyPair.cxx +19 -0
  118. data/ext/native/src/lib/src/VirgilOID.h +0 -0
  119. data/ext/native/src/lib/src/VirgilPBKDF.cxx +0 -0
  120. data/ext/native/src/lib/src/VirgilSignerBase.cxx +0 -0
  121. data/ext/native/src/lib/src/VirgilStreamCipher.cxx +0 -0
  122. data/ext/native/src/lib/src/VirgilStreamSigner.cxx +0 -0
  123. data/ext/native/src/lib/src/VirgilSystemCryptoError.cxx +0 -0
  124. data/ext/native/src/lib/src/VirgilTagFilter.cxx +0 -0
  125. data/ext/native/src/lib/src/VirgilTagFilter.h +0 -0
  126. data/ext/native/src/lib/src/VirgilTinyCipher.cxx +0 -0
  127. data/ext/native/src/lib/src/VirgilVersion.cxx.in +0 -0
  128. data/ext/native/src/lib/src/mbedtls_context.h +0 -0
  129. data/ext/native/src/lib/src/mbedtls_context_policy_spec.h +0 -0
  130. data/ext/native/src/lib/src/mbedtls_type_utils.h +0 -0
  131. data/ext/native/src/lib/src/pfs/VirgilPFS.cxx +0 -0
  132. data/ext/native/src/lib/src/pfs/VirgilPFSEncryptedMessage.cxx +0 -0
  133. data/ext/native/src/lib/src/pfs/VirgilPFSInitiatorPrivateInfo.cxx +0 -0
  134. data/ext/native/src/lib/src/pfs/VirgilPFSInitiatorPublicInfo.cxx +0 -0
  135. data/ext/native/src/lib/src/pfs/VirgilPFSPrivateKey.cxx +0 -0
  136. data/ext/native/src/lib/src/pfs/VirgilPFSPublicKey.cxx +0 -0
  137. data/ext/native/src/lib/src/pfs/VirgilPFSResponderPrivateInfo.cxx +0 -0
  138. data/ext/native/src/lib/src/pfs/VirgilPFSResponderPublicInfo.cxx +0 -0
  139. data/ext/native/src/lib/src/pfs/VirgilPFSSession.cxx +0 -0
  140. data/ext/native/src/lib/src/primitive/VirgilOperationCipher.cxx +0 -0
  141. data/ext/native/src/lib/src/primitive/VirgilOperationDH.cxx +0 -0
  142. data/ext/native/src/lib/src/primitive/VirgilOperationHash.cxx +0 -0
  143. data/ext/native/src/lib/src/primitive/VirgilOperationKDF.cxx +0 -0
  144. data/ext/native/src/lib/src/primitive/VirgilOperationRandom.cxx +0 -0
  145. data/ext/native/src/lib/src/pythia/VirgilPythia.cxx +202 -0
  146. data/ext/native/src/lib/src/pythia/VirgilPythiaContext.cxx +116 -0
  147. data/ext/native/src/lib/src/pythia/VirgilPythiaError.cxx +58 -0
  148. data/ext/native/src/lib/src/pythia/virgil_pythia_c.cxx +129 -0
  149. data/ext/native/src/lib/src/stream/VirgilBytesDataSink.cxx +0 -0
  150. data/ext/native/src/lib/src/stream/VirgilBytesDataSource.cxx +0 -0
  151. data/ext/native/src/lib/src/utils.h +3 -2
  152. data/ext/native/src/libs_ext/mbedtls/configs/config.h +0 -0
  153. data/ext/native/src/libs_ext/mbedtls/configs/config_desktop.h +0 -0
  154. data/ext/native/src/libs_ext/mbedtls/mbedtls.cmake +0 -0
  155. data/ext/native/src/{cmake/cmake_args.cmake → libs_ext/pythia/pythia.cmake} +24 -28
  156. data/ext/native/src/libs_ext/rapidjson/rapidjson.cmake +0 -0
  157. data/ext/native/src/libs_ext/tinyformat/cmake/config.cmake.in +0 -0
  158. data/ext/native/src/libs_ext/tinyformat/tinyformat.cmake +0 -0
  159. data/ext/native/src/migration-2.0.md +0 -0
  160. data/ext/native/src/tests/CMakeLists.txt +0 -0
  161. data/ext/native/src/tests/catch.hpp +0 -0
  162. data/ext/native/src/tests/data/test_data_pfs_with_otc.json +0 -0
  163. data/ext/native/src/tests/data/test_data_pfs_without_otc.json +0 -0
  164. data/ext/native/src/tests/deterministic_keys.h +293 -0
  165. data/ext/native/src/tests/rsa_keys.h +229 -123
  166. data/ext/native/src/tests/test_asn1_writer.cxx +0 -0
  167. data/ext/native/src/tests/test_asymmetric_cipher.cxx +65 -0
  168. data/ext/native/src/tests/test_base64.cxx +0 -0
  169. data/ext/native/src/tests/test_byte_array_utils.cxx +0 -0
  170. data/ext/native/src/tests/test_chunk_cipher.cxx +0 -0
  171. data/ext/native/src/tests/test_cipher.cxx +8 -4
  172. data/ext/native/src/tests/test_cipher_base.cxx +0 -0
  173. data/ext/native/src/tests/test_contract_copy_move.cxx +4 -1
  174. data/ext/native/src/tests/test_data_pfs.h +0 -0
  175. data/ext/native/src/tests/test_hash.cxx +0 -0
  176. data/ext/native/src/tests/test_hkdf.cxx +0 -0
  177. data/ext/native/src/tests/test_key_pair.cxx +65 -3
  178. data/ext/native/src/tests/test_pbe.cxx +0 -0
  179. data/ext/native/src/tests/test_pbkdf.cxx +0 -0
  180. data/ext/native/src/tests/test_pfs.cxx +0 -0
  181. data/ext/native/src/tests/test_pythia.cxx +157 -0
  182. data/ext/native/src/tests/test_random.cxx +0 -0
  183. data/ext/native/src/tests/test_runner.cxx +0 -0
  184. data/ext/native/src/tests/test_signer.cxx +0 -0
  185. data/ext/native/src/tests/test_stream_cipher.cxx +0 -0
  186. data/ext/native/src/tests/test_stream_data_source.cxx +0 -0
  187. data/ext/native/src/tests/test_symmetric_cipher.cxx +0 -0
  188. data/ext/native/src/tests/test_tag_filter.cxx +0 -0
  189. data/ext/native/src/tests/test_tiny_cipher.cxx +0 -0
  190. data/ext/native/src/utils/build.bat +0 -0
  191. data/ext/native/src/utils/build.sh +238 -68
  192. data/ext/native/src/utils/zip.vbs +0 -0
  193. data/ext/native/src/virgil-crypto.sublime-project +15 -0
  194. data/ext/native/src/wrappers/asmjs/CMakeLists.txt +0 -8
  195. data/ext/native/src/wrappers/emsdk/CMakeLists.txt +2 -2
  196. data/ext/native/src/wrappers/emsdk/error.js +0 -0
  197. data/ext/native/src/wrappers/emsdk/example.html +152 -31
  198. data/ext/native/src/wrappers/emsdk/helpers.js +140 -135
  199. data/ext/native/src/wrappers/emsdk/patch_embind.pl +0 -0
  200. data/ext/native/src/wrappers/emsdk/wrapper.cxx +55 -0
  201. data/ext/native/src/wrappers/go/CMakeLists.txt +6 -5
  202. data/ext/native/src/wrappers/java/CMakeLists.txt +27 -4
  203. data/ext/native/src/wrappers/java/src/JniLoader.java +167 -0
  204. data/ext/native/src/wrappers/java/src/VirgilStreamDataSink.java +0 -0
  205. data/ext/native/src/wrappers/java/src/VirgilStreamDataSource.java +0 -0
  206. data/ext/native/src/wrappers/net/CMakeLists.txt +41 -8
  207. data/ext/native/src/wrappers/net/cmake/UseCSharp.cmake +5 -5
  208. data/ext/native/src/wrappers/net/src/VirgilStreamDataSink.cs +0 -0
  209. data/ext/native/src/wrappers/net/src/VirgilStreamDataSource.cs +0 -0
  210. data/ext/native/src/wrappers/nodejs/checksum.txt +66 -0
  211. data/ext/native/src/wrappers/php/CMakeLists.txt +2 -5
  212. data/ext/native/src/wrappers/php/tests/CMakeLists.txt +6 -0
  213. data/ext/native/src/wrappers/php/tests/VirgilChunkCipher_Test.php.in +0 -0
  214. data/ext/native/src/wrappers/php/tests/VirgilCustomParams_Test.php.in +0 -0
  215. data/ext/native/src/wrappers/php/tests/VirgilKDF_Test.php.in +0 -0
  216. data/ext/native/src/wrappers/php/tests/VirgilPBE_Test.php.in +0 -0
  217. data/ext/native/src/wrappers/php/tests/VirgilPBKDF_Test.php.in +0 -0
  218. data/ext/native/src/wrappers/php/tests/VirgilPythia_Test.php.in +87 -0
  219. data/ext/native/src/wrappers/php/tests/VirgilStreamCipher_Test.php.in +0 -0
  220. data/ext/native/src/wrappers/php/tests/VirgilStreamSigner_Test.php.in +0 -0
  221. data/ext/native/src/wrappers/php/tests/VirgilVersion_Test.php.in +0 -0
  222. data/ext/native/src/wrappers/python/CMakeLists.txt +4 -1
  223. data/ext/native/src/wrappers/ruby/CMakeLists.txt +4 -1
  224. data/ext/native/src/wrappers/swig/common.i +0 -0
  225. data/ext/native/src/wrappers/swig/csharp/FixedArray.i +0 -0
  226. data/ext/native/src/wrappers/swig/csharp/VirgilByteArray.i +0 -0
  227. data/ext/native/src/wrappers/swig/csharp/common.i +0 -0
  228. data/ext/native/src/wrappers/swig/csharp/csharphead.swg.in +0 -0
  229. data/ext/native/src/wrappers/swig/go/common.i.in +7 -0
  230. data/ext/native/src/wrappers/swig/java/VirgilByteArray.i +0 -0
  231. data/ext/native/src/wrappers/swig/java/common.i +6 -0
  232. data/ext/native/src/wrappers/swig/php/common.i +0 -0
  233. data/ext/native/src/wrappers/swig/php/php7/VirgilByteArray.i +0 -0
  234. data/ext/native/src/wrappers/swig/util.i +0 -0
  235. data/ext/native/src/wrappers/swig/wrapper.i.in +18 -7
  236. data/ext/native/src/wrappers/webasm/CMakeLists.txt +0 -8
  237. data/ext/rakefile.rb +77 -56
  238. data/lib/virgil/crypto.rb +53 -9
  239. data/lib/virgil/crypto/access_token_signer.rb +79 -0
  240. data/lib/virgil/crypto/bytes.rb +81 -17
  241. data/lib/virgil/crypto/card_crypto.rb +115 -0
  242. data/lib/virgil/crypto/crypto_exception.rb +40 -0
  243. data/lib/virgil/crypto/hash_algorithm.rb +82 -0
  244. data/lib/virgil/crypto/key_pair.rb +41 -0
  245. data/lib/virgil/crypto/key_pair_type.rb +98 -0
  246. data/lib/virgil/crypto/private_key.rb +40 -0
  247. data/lib/virgil/crypto/private_key_exporter.rb +67 -0
  248. data/lib/virgil/crypto/public_key.rb +40 -0
  249. data/lib/virgil/crypto/{virgil_stream_data_sink.rb → stream_data_sink.rb} +12 -12
  250. data/lib/virgil/crypto/{virgil_stream_data_source.rb → stream_data_source.rb} +12 -12
  251. data/lib/virgil/crypto/validation.rb +59 -0
  252. data/lib/virgil/crypto/version.rb +35 -1
  253. data/lib/virgil/crypto/virgil_crypto.rb +595 -0
  254. data/lib/virgil/native_crypto.rb +80 -60
  255. data/lib/virgil/os.rb +40 -6
  256. data/secrets.tar.enc +0 -0
  257. data/virgil-crypto.gemspec +6 -7
  258. metadata +62 -12
  259. data/ext/native/src/cmake/android.toolchain.cmake +0 -1697
@@ -1,3 +1,37 @@
1
+ # Copyright (C) 2015-2019 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+
1
35
  require 'virgil/crypto/version'
2
36
  require 'virgil/os'
3
37
  require 'net/http'
@@ -6,94 +40,80 @@ require 'zlib'
6
40
  require 'fileutils'
7
41
  require 'rake'
8
42
 
9
- class NativeCrypto
10
- LIBRARY_LIST_URL = "https://cdn.virgilsecurity.com/virgil-crypto/ruby/"
43
+ module NativeCrypto
11
44
 
12
- def self.load_library
13
- file_name = 'virgil_crypto_ruby.'
14
- file_name += required_library_os == 'linux' ? 'so' : 'bundle'
15
- crypto_folder_path = "#{lib_path}/virgil/crypto"
16
- download_library(get_library_path, file_name, crypto_folder_path)
17
- end
45
+ LIBRARIES_URL = 'https://cdn.virgilsecurity.com/virgil-crypto/ruby/'.freeze
18
46
 
47
+ def self.download
48
+ file_name = "virgil_crypto_ruby.#{os_ext == 'linux' ? 'so' : 'bundle'}"
49
+ source_url = LIBRARIES_URL + library_path
50
+ puts "Downloading #{source_url}..."
51
+ system('mkdir -p tmp')
52
+ core_path = 'tmp/crypto_core.tar.gz'
53
+ download_archive(source_url, core_path)
54
+ extract_library(core_path, file_name)
55
+ end
19
56
 
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
57
+ private
26
58
 
59
+ def self.library_path
60
+ list = libraries_list(URI(LIBRARIES_URL))
61
+ ruby_v = "-ruby-#{RUBY_VERSION.sub(/\.[^\.]+$/, '')}-#{os_ext}"
62
+ href_template = /virgil-crypto-#{gem_v}(?:\b-.+\b?)?#{ruby_v}(?!tgz).+tgz"/
63
+ href_list = list.scan href_template
27
64
  if href_list.last.nil?
28
- raise "Sorry. Correct version #{required_library_version} of Native Library is missing."
65
+ raise "Sorry. Correct version #{gem_v} of Native Library is missing."
29
66
  end
30
-
31
67
  href_list.last.sub(/"$/, '')
32
-
33
68
  end
34
69
 
35
- def self.get_https(url)
36
- uri = URI(url)
37
- Net::HTTP.start(uri.host, uri.port,
38
- :use_ssl => true) do |http|
70
+ def self.libraries_list(uri)
71
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
39
72
  http.read_timeout = 100
40
73
  request = Net::HTTP::Get.new uri
41
74
  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
75
+ if response.is_a?(Net::HTTPOK)
76
+ return response.body
77
+ else
78
+ raise "Can't download native library. Please try later."
51
79
  end
52
80
  end
81
+
53
82
  end
54
83
 
55
- def self.required_library_version
84
+ def self.gem_v
85
+ # crypto core major version = gem major version - 1
56
86
  Virgil::Crypto::VERSION.scan(/(\d+\.\d+\.\d+)\D*\d*$/) do |postfix|
57
- return postfix * ''
87
+ core_v = (postfix * '').gsub(/^(\d+)\.*/) {|gem_maj_ver| "#{gem_maj_ver.to_i - 1}."}
88
+ return core_v
58
89
  end
59
- return ''
90
+ ''
60
91
  end
61
92
 
62
- def self.required_library_os
93
+ def self.os_ext
63
94
  if OS.linux?
64
- "linux"
95
+ 'linux'
65
96
  elsif OS.mac?
66
- "darwin"
97
+ 'darwin'
67
98
  end
68
99
  end
69
100
 
70
- def self.download_library(source_path, file_name, folder_path)
71
- puts "Downloading #{source_path}..."
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
-
101
+ def self.extract_library(archive_path, file_name)
102
+ folder_name = library_path.sub('.tgz', '')
87
103
  system("tar xvf #{archive_path} -C tmp/")
88
104
 
89
- system("cp tmp/#{library_folder_name}/lib/#{file_name} #{folder_path}/#{file_name}")
90
- system('rm -rf tmp')
91
-
105
+ target_file_path = "#{File.expand_path(__dir__)}/crypto/"
106
+ system("cp tmp/#{folder_name}/lib/#{file_name} #{target_file_path}")
92
107
  end
93
108
 
94
- def self.lib_path
95
- File.expand_path('../../..', __FILE__) + "/lib"
109
+ def self.download_archive(source_url, archive_path)
110
+ File.open(archive_path, 'wb') do |file|
111
+ begin
112
+ archive = libraries_list(URI(source_url))
113
+ file.write(archive)
114
+ rescue StandardError => e
115
+ raise "Can't download native library from #{source_url}. Reason: #{e}"
116
+ end
117
+ end
96
118
  end
97
-
98
-
99
119
  end
@@ -1,17 +1,51 @@
1
+ # Copyright (C) 2015-2019 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+
1
35
  module OS
2
- def OS.windows?
36
+ def self.windows?
3
37
  (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
4
38
  end
5
39
 
6
- def OS.mac?
40
+ def self.mac?
7
41
  (/darwin/ =~ RUBY_PLATFORM) != nil
8
42
  end
9
43
 
10
- def OS.unix?
11
- !OS.windows?
44
+ def self.unix?
45
+ !windows?
12
46
  end
13
47
 
14
- def OS.linux?
15
- OS.unix? and not OS.mac?
48
+ def self.linux?
49
+ unix? && !mac?
16
50
  end
17
51
  end
Binary file
@@ -10,15 +10,13 @@ abort "Windows is not supported yet." if OS.windows?
10
10
  Gem::Specification.new do |spec|
11
11
  spec.name = "virgil-crypto"
12
12
  spec.version = Virgil::Crypto::VERSION
13
- spec.authors = ["Dmitriy Dudkin", "Sergey Seroshtan", "Vasilina Bezuglaya"]
14
- spec.email = ["dudkin.dmitriy@gmail.com", "sseroshtan@virgilsecurity.com"]
13
+ spec.authors = ["Dmitriy Dudkin", "Vasilina Bezuglaya", "Sergey Seroshtan"]
14
+ spec.email = ["dudkin.dmitriy@gmail.com", "vbezuglaya@virgilsecurity.net", "sseroshtan@virgilsecurity.com"]
15
15
 
16
16
  spec.summary = %q{Virgil Crypto library wrapper}
17
- spec.description = %q{virgil-crypto provides:
18
- Encrypt data
19
- Decrypt data
20
- Sign data
21
- Verify data}
17
+ spec.description = %q{virgil-crypto provides: Asymmetric Key Generation,
18
+ Encryption/Decryption of data and streams,
19
+ Generation/Verification of digital signatures,PFS (Perfect Forward Secrecy)}
22
20
  spec.homepage = "http://github.com/VirgilSecurity/virgil-crypto-ruby"
23
21
  spec.licenses = ['BSD-3-Clause']
24
22
 
@@ -32,6 +30,7 @@ Gem::Specification.new do |spec|
32
30
  spec.add_development_dependency "rake-compiler", "~> 1.0"
33
31
  spec.add_development_dependency "rake", "~> 10.0"
34
32
  spec.add_development_dependency "minitest-reporters", "~> 1.1"
33
+ spec.add_development_dependency 'envyable', '~> 1.2'
35
34
 
36
35
  current_dir = File.expand_path(File.dirname(__FILE__))
37
36
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virgil-crypto
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Dudkin
8
- - Sergey Seroshtan
9
8
  - Vasilina Bezuglaya
9
+ - Sergey Seroshtan
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-03-02 00:00:00.000000000 Z
13
+ date: 2019-03-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -68,14 +68,27 @@ dependencies:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '1.1'
71
+ - !ruby/object:Gem::Dependency
72
+ name: envyable
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.2'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '1.2'
71
85
  description: |-
72
- virgil-crypto provides:
73
- Encrypt data
74
- Decrypt data
75
- Sign data
76
- Verify data
86
+ virgil-crypto provides: Asymmetric Key Generation,
87
+ Encryption/Decryption of data and streams,
88
+ Generation/Verification of digital signatures,PFS (Perfect Forward Secrecy)
77
89
  email:
78
90
  - dudkin.dmitriy@gmail.com
91
+ - vbezuglaya@virgilsecurity.net
79
92
  - sseroshtan@virgilsecurity.com
80
93
  executables: []
81
94
  extensions:
@@ -84,11 +97,13 @@ extra_rdoc_files: []
84
97
  files:
85
98
  - ".gitignore"
86
99
  - ".gitmodules"
100
+ - ".travis.yml"
87
101
  - Gemfile
88
102
  - README.md
89
103
  - Rakefile
90
104
  - bin/console
91
105
  - bin/setup
106
+ - ext/native/src/.clang-format
92
107
  - ext/native/src/.gitignore
93
108
  - ext/native/src/.travis.yml
94
109
  - ext/native/src/CMakeLists.txt
@@ -98,10 +113,12 @@ files:
98
113
  - ext/native/src/LICENSE
99
114
  - ext/native/src/README.md
100
115
  - ext/native/src/VERSION
116
+ - ext/native/src/benchmark.md
101
117
  - ext/native/src/benchmark/CMakeLists.txt
102
118
  - ext/native/src/benchmark/benchmark_cipher.cxx
103
119
  - ext/native/src/benchmark/benchmark_hash.cxx
104
120
  - ext/native/src/benchmark/benchmark_keys.cxx
121
+ - ext/native/src/benchmark/benchmark_pythia.cxx
105
122
  - ext/native/src/benchmark/benchmark_random.cxx
106
123
  - ext/native/src/benchmark/benchmark_signer.cxx
107
124
  - ext/native/src/benchmark/benchpress.hpp
@@ -110,11 +127,12 @@ files:
110
127
  - ext/native/src/ci/install-deployment-key.sh
111
128
  - ext/native/src/ci/publish-docs.sh
112
129
  - ext/native/src/ci/travis-deployment-key.enc
113
- - ext/native/src/cmake/android.toolchain.cmake
130
+ - ext/native/src/cmake/TransitiveArgs.cmake
131
+ - ext/native/src/cmake/TransitiveToolchainArgs.cmake
132
+ - ext/native/src/cmake/add_mono_metadata.cmake
114
133
  - ext/native/src/cmake/apple.cmake
115
134
  - ext/native/src/cmake/aux_source_directory_to_file.cmake
116
135
  - ext/native/src/cmake/check_pointer_size.cmake
117
- - ext/native/src/cmake/cmake_args.cmake
118
136
  - ext/native/src/cmake/copy_all_files.cmake
119
137
  - ext/native/src/cmake/file_regex_replace.cmake
120
138
  - ext/native/src/cmake/find_host_utils.cmake
@@ -179,11 +197,20 @@ files:
179
197
  - ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationHash.h
180
198
  - ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationKDF.h
181
199
  - ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationRandom.h
200
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythia.h
201
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaBlindResult.h
202
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaContext.h
203
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaError.h
204
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaProveResult.h
205
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaTransformResult.h
206
+ - ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaTransformationKeyPair.h
207
+ - ext/native/src/lib/include/virgil/crypto/pythia/virgil_pythia_c.h
182
208
  - ext/native/src/lib/include/virgil/crypto/stream/VirgilBytesDataSink.h
183
209
  - ext/native/src/lib/include/virgil/crypto/stream/VirgilBytesDataSource.h
184
210
  - ext/native/src/lib/include/virgil/crypto/stream/VirgilStreamDataSink.h
185
211
  - ext/native/src/lib/include/virgil/crypto/stream/VirgilStreamDataSource.h
186
212
  - ext/native/src/lib/mainpage.dox
213
+ - ext/native/src/lib/module.modulemap
187
214
  - ext/native/src/lib/src/VirgilAsn1Alg.cxx
188
215
  - ext/native/src/lib/src/VirgilAsn1Alg.h
189
216
  - ext/native/src/lib/src/VirgilAsn1Compatible.cxx
@@ -201,6 +228,7 @@ files:
201
228
  - ext/native/src/lib/src/VirgilChunkCipher.cxx
202
229
  - ext/native/src/lib/src/VirgilCipher.cxx
203
230
  - ext/native/src/lib/src/VirgilCipherBase.cxx
231
+ - ext/native/src/lib/src/VirgilConfig.cxx
204
232
  - ext/native/src/lib/src/VirgilConfig.h.in
205
233
  - ext/native/src/lib/src/VirgilContentInfo.cxx
206
234
  - ext/native/src/lib/src/VirgilCryptoError.cxx
@@ -242,6 +270,10 @@ files:
242
270
  - ext/native/src/lib/src/primitive/VirgilOperationHash.cxx
243
271
  - ext/native/src/lib/src/primitive/VirgilOperationKDF.cxx
244
272
  - ext/native/src/lib/src/primitive/VirgilOperationRandom.cxx
273
+ - ext/native/src/lib/src/pythia/VirgilPythia.cxx
274
+ - ext/native/src/lib/src/pythia/VirgilPythiaContext.cxx
275
+ - ext/native/src/lib/src/pythia/VirgilPythiaError.cxx
276
+ - ext/native/src/lib/src/pythia/virgil_pythia_c.cxx
245
277
  - ext/native/src/lib/src/stream/VirgilBytesDataSink.cxx
246
278
  - ext/native/src/lib/src/stream/VirgilBytesDataSource.cxx
247
279
  - ext/native/src/lib/src/stream/VirgilStreamDataSink.cxx
@@ -250,6 +282,7 @@ files:
250
282
  - ext/native/src/libs_ext/mbedtls/configs/config.h
251
283
  - ext/native/src/libs_ext/mbedtls/configs/config_desktop.h
252
284
  - ext/native/src/libs_ext/mbedtls/mbedtls.cmake
285
+ - ext/native/src/libs_ext/pythia/pythia.cmake
253
286
  - ext/native/src/libs_ext/rapidjson/rapidjson.cmake
254
287
  - ext/native/src/libs_ext/tinyformat/cmake/config.cmake.in
255
288
  - ext/native/src/libs_ext/tinyformat/src/tinyformat.h
@@ -259,6 +292,7 @@ files:
259
292
  - ext/native/src/tests/catch.hpp
260
293
  - ext/native/src/tests/data/test_data_pfs_with_otc.json
261
294
  - ext/native/src/tests/data/test_data_pfs_without_otc.json
295
+ - ext/native/src/tests/deterministic_keys.h
262
296
  - ext/native/src/tests/rsa_keys.h
263
297
  - ext/native/src/tests/test_asn1_writer.cxx
264
298
  - ext/native/src/tests/test_asymmetric_cipher.cxx
@@ -275,6 +309,7 @@ files:
275
309
  - ext/native/src/tests/test_pbe.cxx
276
310
  - ext/native/src/tests/test_pbkdf.cxx
277
311
  - ext/native/src/tests/test_pfs.cxx
312
+ - ext/native/src/tests/test_pythia.cxx
278
313
  - ext/native/src/tests/test_random.cxx
279
314
  - ext/native/src/tests/test_runner.cxx
280
315
  - ext/native/src/tests/test_signer.cxx
@@ -287,6 +322,7 @@ files:
287
322
  - ext/native/src/utils/build.sh
288
323
  - ext/native/src/utils/env.sh
289
324
  - ext/native/src/utils/zip.vbs
325
+ - ext/native/src/virgil-crypto.sublime-project
290
326
  - ext/native/src/wrappers/CMakeLists.txt
291
327
  - ext/native/src/wrappers/asmjs/CMakeLists.txt
292
328
  - ext/native/src/wrappers/emsdk/CMakeLists.txt
@@ -297,6 +333,7 @@ files:
297
333
  - ext/native/src/wrappers/emsdk/wrapper.cxx
298
334
  - ext/native/src/wrappers/go/CMakeLists.txt
299
335
  - ext/native/src/wrappers/java/CMakeLists.txt
336
+ - ext/native/src/wrappers/java/src/JniLoader.java
300
337
  - ext/native/src/wrappers/java/src/VirgilStreamDataSink.java
301
338
  - ext/native/src/wrappers/java/src/VirgilStreamDataSource.java
302
339
  - ext/native/src/wrappers/net/CMakeLists.txt
@@ -330,6 +367,7 @@ files:
330
367
  - ext/native/src/wrappers/php/tests/VirgilKDF_Test.php.in
331
368
  - ext/native/src/wrappers/php/tests/VirgilPBE_Test.php.in
332
369
  - ext/native/src/wrappers/php/tests/VirgilPBKDF_Test.php.in
370
+ - ext/native/src/wrappers/php/tests/VirgilPythia_Test.php.in
333
371
  - ext/native/src/wrappers/php/tests/VirgilRandom_Test.php.in
334
372
  - ext/native/src/wrappers/php/tests/VirgilSigner_Test.php.in
335
373
  - ext/native/src/wrappers/php/tests/VirgilStreamCipher_Test.php.in
@@ -362,12 +400,24 @@ files:
362
400
  - ext/native/src/wrappers/webasm/CMakeLists.txt
363
401
  - ext/rakefile.rb
364
402
  - lib/virgil/crypto.rb
403
+ - lib/virgil/crypto/access_token_signer.rb
365
404
  - lib/virgil/crypto/bytes.rb
405
+ - lib/virgil/crypto/card_crypto.rb
406
+ - lib/virgil/crypto/crypto_exception.rb
407
+ - lib/virgil/crypto/hash_algorithm.rb
408
+ - lib/virgil/crypto/key_pair.rb
409
+ - lib/virgil/crypto/key_pair_type.rb
410
+ - lib/virgil/crypto/private_key.rb
411
+ - lib/virgil/crypto/private_key_exporter.rb
412
+ - lib/virgil/crypto/public_key.rb
413
+ - lib/virgil/crypto/stream_data_sink.rb
414
+ - lib/virgil/crypto/stream_data_source.rb
415
+ - lib/virgil/crypto/validation.rb
366
416
  - lib/virgil/crypto/version.rb
367
- - lib/virgil/crypto/virgil_stream_data_sink.rb
368
- - lib/virgil/crypto/virgil_stream_data_source.rb
417
+ - lib/virgil/crypto/virgil_crypto.rb
369
418
  - lib/virgil/native_crypto.rb
370
419
  - lib/virgil/os.rb
420
+ - secrets.tar.enc
371
421
  - virgil-crypto.gemspec
372
422
  homepage: http://github.com/VirgilSecurity/virgil-crypto-ruby
373
423
  licenses: