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.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.gitmodules +0 -0
- data/.travis.yml +13 -0
- data/Gemfile +0 -0
- data/README.md +113 -9
- data/Rakefile +0 -0
- data/ext/native/src/.clang-format +37 -0
- data/ext/native/src/.gitignore +3 -0
- data/ext/native/src/.travis.yml +2 -1
- data/ext/native/src/CMakeLists.txt +66 -63
- data/ext/native/src/ChangeLog +114 -2
- data/ext/native/src/Dockerfile_Golang +29 -8
- data/ext/native/src/Jenkinsfile +61 -50
- data/ext/native/src/LICENSE +0 -0
- data/ext/native/src/README.md +137 -167
- data/ext/native/src/VERSION +1 -1
- data/ext/native/src/benchmark.md +140 -0
- data/ext/native/src/benchmark/CMakeLists.txt +0 -0
- data/ext/native/src/benchmark/benchmark_cipher.cxx +0 -0
- data/ext/native/src/benchmark/benchmark_hash.cxx +0 -0
- data/ext/native/src/benchmark/benchmark_keys.cxx +0 -0
- data/ext/native/src/benchmark/benchmark_pythia.cxx +61 -0
- data/ext/native/src/benchmark/benchmark_random.cxx +0 -0
- data/ext/native/src/benchmark/benchmark_signer.cxx +0 -0
- data/ext/native/src/ci/install-dependencies.sh +8 -12
- data/ext/native/src/ci/publish-docs.sh +107 -22
- data/ext/native/src/ci/travis-deployment-key.enc +0 -0
- data/ext/native/src/cmake/TransitiveArgs.cmake +78 -0
- data/ext/native/src/cmake/TransitiveToolchainArgs.cmake +105 -0
- data/ext/native/src/cmake/add_mono_metadata.cmake +103 -0
- data/ext/native/src/cmake/apple.cmake +56 -11
- data/ext/native/src/cmake/aux_source_directory_to_file.cmake +0 -0
- data/ext/native/src/cmake/check_pointer_size.cmake +0 -0
- data/ext/native/src/cmake/copy_all_files.cmake +0 -0
- data/ext/native/src/cmake/file_regex_replace.cmake +0 -0
- data/ext/native/src/cmake/find_host_utils.cmake +0 -0
- data/ext/native/src/cmake/uppercase_first_char.cmake +0 -0
- data/ext/native/src/cmake/uppercase_namespaces.cmake +3 -0
- data/ext/native/src/cmake/virgil_depends.cmake +0 -0
- data/ext/native/src/cmake/virgil_depends_local.cmake +2 -0
- data/ext/native/src/docs/.gitignore +0 -0
- data/ext/native/src/lib/CMakeLists.txt +59 -1
- data/ext/native/src/lib/Doxyfile.in +1 -1
- data/ext/native/src/lib/Info.plist.in +0 -0
- data/ext/native/src/lib/cmake/config.cmake.in +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilByteArrayUtils.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilChunkCipher.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilCipherBase.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilContentInfo.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilCrypto.h +13 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilCryptoError.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilCustomParams.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilKeyPair.h +30 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilSignerBase.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilStreamCipher.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilStreamSigner.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilTinyCipher.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/VirgilVersion.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilAsymmetricCipher.h +17 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilHKDF.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilPBKDF.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/VirgilSystemCryptoError.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/asn1/VirgilAsn1Compatible.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSContent.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSContentInfo.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSEncryptedContent.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSEnvelopedData.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSKeyTransRecipient.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/foundation/cms/VirgilCMSPasswordRecipient.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFS.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSEncryptedMessage.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSInitiatorPrivateInfo.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSInitiatorPublicInfo.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSPrivateKey.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSPublicKey.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSResponderPrivateInfo.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSResponderPublicInfo.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pfs/VirgilPFSSession.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationCipher.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationDH.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationHash.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationKDF.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/primitive/VirgilOperationRandom.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythia.h +181 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaBlindResult.h +89 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaContext.h +72 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaError.h +161 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaProveResult.h +89 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaTransformResult.h +91 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/VirgilPythiaTransformationKeyPair.h +87 -0
- data/ext/native/src/lib/include/virgil/crypto/pythia/virgil_pythia_c.h +203 -0
- data/ext/native/src/lib/include/virgil/crypto/stream/VirgilBytesDataSink.h +0 -0
- data/ext/native/src/lib/include/virgil/crypto/stream/VirgilBytesDataSource.h +0 -0
- data/ext/native/src/lib/mainpage.dox +6 -0
- data/ext/native/src/lib/module.modulemap +7 -0
- data/ext/native/src/lib/src/VirgilAsn1Alg.cxx +0 -0
- data/ext/native/src/lib/src/VirgilAsn1Alg.h +0 -0
- data/ext/native/src/lib/src/VirgilAsn1Compatible.cxx +0 -0
- data/ext/native/src/lib/src/VirgilAsymmetricCipher.cxx +82 -0
- data/ext/native/src/lib/src/VirgilByteArrayUtils.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCMSContent.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCMSContentInfo.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCMSEncryptedContent.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCMSEnvelopedData.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCMSKeyTransRecipient.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCMSPasswordRecipient.cxx +0 -0
- data/ext/native/src/lib/src/VirgilChunkCipher.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCipherBase.cxx +0 -0
- data/ext/native/src/lib/src/VirgilConfig.cxx +51 -0
- data/ext/native/src/lib/src/VirgilConfig.h.in +43 -1
- data/ext/native/src/lib/src/VirgilContentInfo.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCryptoError.cxx +0 -0
- data/ext/native/src/lib/src/VirgilCustomParams.cxx +0 -0
- data/ext/native/src/lib/src/VirgilDataSink.cxx +0 -0
- data/ext/native/src/lib/src/VirgilHKDF.cxx +0 -0
- data/ext/native/src/lib/src/VirgilKeyPair.cxx +19 -0
- data/ext/native/src/lib/src/VirgilOID.h +0 -0
- data/ext/native/src/lib/src/VirgilPBKDF.cxx +0 -0
- data/ext/native/src/lib/src/VirgilSignerBase.cxx +0 -0
- data/ext/native/src/lib/src/VirgilStreamCipher.cxx +0 -0
- data/ext/native/src/lib/src/VirgilStreamSigner.cxx +0 -0
- data/ext/native/src/lib/src/VirgilSystemCryptoError.cxx +0 -0
- data/ext/native/src/lib/src/VirgilTagFilter.cxx +0 -0
- data/ext/native/src/lib/src/VirgilTagFilter.h +0 -0
- data/ext/native/src/lib/src/VirgilTinyCipher.cxx +0 -0
- data/ext/native/src/lib/src/VirgilVersion.cxx.in +0 -0
- data/ext/native/src/lib/src/mbedtls_context.h +0 -0
- data/ext/native/src/lib/src/mbedtls_context_policy_spec.h +0 -0
- data/ext/native/src/lib/src/mbedtls_type_utils.h +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFS.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSEncryptedMessage.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSInitiatorPrivateInfo.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSInitiatorPublicInfo.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSPrivateKey.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSPublicKey.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSResponderPrivateInfo.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSResponderPublicInfo.cxx +0 -0
- data/ext/native/src/lib/src/pfs/VirgilPFSSession.cxx +0 -0
- data/ext/native/src/lib/src/primitive/VirgilOperationCipher.cxx +0 -0
- data/ext/native/src/lib/src/primitive/VirgilOperationDH.cxx +0 -0
- data/ext/native/src/lib/src/primitive/VirgilOperationHash.cxx +0 -0
- data/ext/native/src/lib/src/primitive/VirgilOperationKDF.cxx +0 -0
- data/ext/native/src/lib/src/primitive/VirgilOperationRandom.cxx +0 -0
- data/ext/native/src/lib/src/pythia/VirgilPythia.cxx +202 -0
- data/ext/native/src/lib/src/pythia/VirgilPythiaContext.cxx +116 -0
- data/ext/native/src/lib/src/pythia/VirgilPythiaError.cxx +58 -0
- data/ext/native/src/lib/src/pythia/virgil_pythia_c.cxx +129 -0
- data/ext/native/src/lib/src/stream/VirgilBytesDataSink.cxx +0 -0
- data/ext/native/src/lib/src/stream/VirgilBytesDataSource.cxx +0 -0
- data/ext/native/src/lib/src/utils.h +3 -2
- data/ext/native/src/libs_ext/mbedtls/configs/config.h +0 -0
- data/ext/native/src/libs_ext/mbedtls/configs/config_desktop.h +0 -0
- data/ext/native/src/libs_ext/mbedtls/mbedtls.cmake +0 -0
- data/ext/native/src/{cmake/cmake_args.cmake → libs_ext/pythia/pythia.cmake} +24 -28
- data/ext/native/src/libs_ext/rapidjson/rapidjson.cmake +0 -0
- data/ext/native/src/libs_ext/tinyformat/cmake/config.cmake.in +0 -0
- data/ext/native/src/libs_ext/tinyformat/tinyformat.cmake +0 -0
- data/ext/native/src/migration-2.0.md +0 -0
- data/ext/native/src/tests/CMakeLists.txt +0 -0
- data/ext/native/src/tests/catch.hpp +0 -0
- data/ext/native/src/tests/data/test_data_pfs_with_otc.json +0 -0
- data/ext/native/src/tests/data/test_data_pfs_without_otc.json +0 -0
- data/ext/native/src/tests/deterministic_keys.h +293 -0
- data/ext/native/src/tests/rsa_keys.h +229 -123
- data/ext/native/src/tests/test_asn1_writer.cxx +0 -0
- data/ext/native/src/tests/test_asymmetric_cipher.cxx +65 -0
- data/ext/native/src/tests/test_base64.cxx +0 -0
- data/ext/native/src/tests/test_byte_array_utils.cxx +0 -0
- data/ext/native/src/tests/test_chunk_cipher.cxx +0 -0
- data/ext/native/src/tests/test_cipher.cxx +8 -4
- data/ext/native/src/tests/test_cipher_base.cxx +0 -0
- data/ext/native/src/tests/test_contract_copy_move.cxx +4 -1
- data/ext/native/src/tests/test_data_pfs.h +0 -0
- data/ext/native/src/tests/test_hash.cxx +0 -0
- data/ext/native/src/tests/test_hkdf.cxx +0 -0
- data/ext/native/src/tests/test_key_pair.cxx +65 -3
- data/ext/native/src/tests/test_pbe.cxx +0 -0
- data/ext/native/src/tests/test_pbkdf.cxx +0 -0
- data/ext/native/src/tests/test_pfs.cxx +0 -0
- data/ext/native/src/tests/test_pythia.cxx +157 -0
- data/ext/native/src/tests/test_random.cxx +0 -0
- data/ext/native/src/tests/test_runner.cxx +0 -0
- data/ext/native/src/tests/test_signer.cxx +0 -0
- data/ext/native/src/tests/test_stream_cipher.cxx +0 -0
- data/ext/native/src/tests/test_stream_data_source.cxx +0 -0
- data/ext/native/src/tests/test_symmetric_cipher.cxx +0 -0
- data/ext/native/src/tests/test_tag_filter.cxx +0 -0
- data/ext/native/src/tests/test_tiny_cipher.cxx +0 -0
- data/ext/native/src/utils/build.bat +0 -0
- data/ext/native/src/utils/build.sh +238 -68
- data/ext/native/src/utils/zip.vbs +0 -0
- data/ext/native/src/virgil-crypto.sublime-project +15 -0
- data/ext/native/src/wrappers/asmjs/CMakeLists.txt +0 -8
- data/ext/native/src/wrappers/emsdk/CMakeLists.txt +2 -2
- data/ext/native/src/wrappers/emsdk/error.js +0 -0
- data/ext/native/src/wrappers/emsdk/example.html +152 -31
- data/ext/native/src/wrappers/emsdk/helpers.js +140 -135
- data/ext/native/src/wrappers/emsdk/patch_embind.pl +0 -0
- data/ext/native/src/wrappers/emsdk/wrapper.cxx +55 -0
- data/ext/native/src/wrappers/go/CMakeLists.txt +6 -5
- data/ext/native/src/wrappers/java/CMakeLists.txt +27 -4
- data/ext/native/src/wrappers/java/src/JniLoader.java +167 -0
- data/ext/native/src/wrappers/java/src/VirgilStreamDataSink.java +0 -0
- data/ext/native/src/wrappers/java/src/VirgilStreamDataSource.java +0 -0
- data/ext/native/src/wrappers/net/CMakeLists.txt +41 -8
- data/ext/native/src/wrappers/net/cmake/UseCSharp.cmake +5 -5
- data/ext/native/src/wrappers/net/src/VirgilStreamDataSink.cs +0 -0
- data/ext/native/src/wrappers/net/src/VirgilStreamDataSource.cs +0 -0
- data/ext/native/src/wrappers/nodejs/checksum.txt +66 -0
- data/ext/native/src/wrappers/php/CMakeLists.txt +2 -5
- data/ext/native/src/wrappers/php/tests/CMakeLists.txt +6 -0
- data/ext/native/src/wrappers/php/tests/VirgilChunkCipher_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilCustomParams_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilKDF_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilPBE_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilPBKDF_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilPythia_Test.php.in +87 -0
- data/ext/native/src/wrappers/php/tests/VirgilStreamCipher_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilStreamSigner_Test.php.in +0 -0
- data/ext/native/src/wrappers/php/tests/VirgilVersion_Test.php.in +0 -0
- data/ext/native/src/wrappers/python/CMakeLists.txt +4 -1
- data/ext/native/src/wrappers/ruby/CMakeLists.txt +4 -1
- data/ext/native/src/wrappers/swig/common.i +0 -0
- data/ext/native/src/wrappers/swig/csharp/FixedArray.i +0 -0
- data/ext/native/src/wrappers/swig/csharp/VirgilByteArray.i +0 -0
- data/ext/native/src/wrappers/swig/csharp/common.i +0 -0
- data/ext/native/src/wrappers/swig/csharp/csharphead.swg.in +0 -0
- data/ext/native/src/wrappers/swig/go/common.i.in +7 -0
- data/ext/native/src/wrappers/swig/java/VirgilByteArray.i +0 -0
- data/ext/native/src/wrappers/swig/java/common.i +6 -0
- data/ext/native/src/wrappers/swig/php/common.i +0 -0
- data/ext/native/src/wrappers/swig/php/php7/VirgilByteArray.i +0 -0
- data/ext/native/src/wrappers/swig/util.i +0 -0
- data/ext/native/src/wrappers/swig/wrapper.i.in +18 -7
- data/ext/native/src/wrappers/webasm/CMakeLists.txt +0 -8
- data/ext/rakefile.rb +77 -56
- data/lib/virgil/crypto.rb +53 -9
- data/lib/virgil/crypto/access_token_signer.rb +79 -0
- data/lib/virgil/crypto/bytes.rb +81 -17
- data/lib/virgil/crypto/card_crypto.rb +115 -0
- data/lib/virgil/crypto/crypto_exception.rb +40 -0
- data/lib/virgil/crypto/hash_algorithm.rb +82 -0
- data/lib/virgil/crypto/key_pair.rb +41 -0
- data/lib/virgil/crypto/key_pair_type.rb +98 -0
- data/lib/virgil/crypto/private_key.rb +40 -0
- data/lib/virgil/crypto/private_key_exporter.rb +67 -0
- data/lib/virgil/crypto/public_key.rb +40 -0
- data/lib/virgil/crypto/{virgil_stream_data_sink.rb → stream_data_sink.rb} +12 -12
- data/lib/virgil/crypto/{virgil_stream_data_source.rb → stream_data_source.rb} +12 -12
- data/lib/virgil/crypto/validation.rb +59 -0
- data/lib/virgil/crypto/version.rb +35 -1
- data/lib/virgil/crypto/virgil_crypto.rb +595 -0
- data/lib/virgil/native_crypto.rb +80 -60
- data/lib/virgil/os.rb +40 -6
- data/secrets.tar.enc +0 -0
- data/virgil-crypto.gemspec +6 -7
- metadata +62 -12
- data/ext/native/src/cmake/android.toolchain.cmake +0 -1697
@@ -0,0 +1,41 @@
|
|
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
|
+
|
35
|
+
module Virgil
|
36
|
+
module Crypto
|
37
|
+
# Class containing key pair information
|
38
|
+
KeyPair = Struct.new(:private_key, :public_key) do
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,98 @@
|
|
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
|
+
|
35
|
+
module Virgil
|
36
|
+
module Crypto
|
37
|
+
# Enumeration containing supported KeyPairTypes
|
38
|
+
class KeyPairType
|
39
|
+
# Exception raised when Unknown Type passed to convertion method
|
40
|
+
class UnknownTypeException < StandardError
|
41
|
+
def initialize(key_pair_type)
|
42
|
+
@key_pair_type = key_pair_type
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
"KeyPairType not found: #{@key_pair_type}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Default = :Default
|
52
|
+
RSA_2048 = :RSA_2048
|
53
|
+
RSA_3072 = :RSA_3072
|
54
|
+
RSA_4096 = :RSA_4096
|
55
|
+
RSA_8192 = :RSA_8192
|
56
|
+
EC_SECP256R1 = :EC_SECP256R1
|
57
|
+
EC_SECP384R1 = :EC_SECP384R1
|
58
|
+
EC_SECP521R1 = :EC_SECP521R1
|
59
|
+
EC_BP256R1 = :EC_BP256R1
|
60
|
+
EC_BP384R1 = :EC_BP384R1
|
61
|
+
EC_BP512R1 = :EC_BP512R1
|
62
|
+
EC_SECP256K1 = :EC_SECP256K1
|
63
|
+
EC_CURVE25519 = :EC_CURVE25519
|
64
|
+
FAST_EC_X25519 = :FAST_EC_X25519
|
65
|
+
FAST_EC_ED25519 = :FAST_EC_ED25519
|
66
|
+
|
67
|
+
TYPES_TO_NATIVE = {
|
68
|
+
Default: Core::VirgilKeyPair::Type_FAST_EC_ED25519,
|
69
|
+
RSA_2048: Core::VirgilKeyPair::Type_RSA_2048,
|
70
|
+
RSA_3072: Core::VirgilKeyPair::Type_RSA_3072,
|
71
|
+
RSA_4096: Core::VirgilKeyPair::Type_RSA_4096,
|
72
|
+
RSA_8192: Core::VirgilKeyPair::Type_RSA_8192,
|
73
|
+
EC_SECP256R1: Core::VirgilKeyPair::Type_EC_SECP256R1,
|
74
|
+
EC_SECP384R1: Core::VirgilKeyPair::Type_EC_SECP384R1,
|
75
|
+
EC_SECP521R1: Core::VirgilKeyPair::Type_EC_SECP521R1,
|
76
|
+
EC_BP256R1: Core::VirgilKeyPair::Type_EC_BP256R1,
|
77
|
+
EC_BP384R1: Core::VirgilKeyPair::Type_EC_BP384R1,
|
78
|
+
EC_BP512R1: Core::VirgilKeyPair::Type_EC_BP512R1,
|
79
|
+
EC_SECP256K1: Core::VirgilKeyPair::Type_EC_SECP256K1,
|
80
|
+
EC_CURVE25519: Core::VirgilKeyPair::Type_EC_CURVE25519,
|
81
|
+
FAST_EC_X25519: Core::VirgilKeyPair::Type_FAST_EC_X25519,
|
82
|
+
FAST_EC_ED25519: Core::VirgilKeyPair::Type_FAST_EC_ED25519,
|
83
|
+
}.freeze
|
84
|
+
|
85
|
+
# Converts type enum value to native value
|
86
|
+
# @param key_pair_type [Symbol] type id for conversion.
|
87
|
+
# @return [Integer] Native library key pair type id.
|
88
|
+
# @raise [UnknownTypeException] if type is not supported.
|
89
|
+
def self.convert_to_native(key_pair_type)
|
90
|
+
if TYPES_TO_NATIVE.key?(key_pair_type)
|
91
|
+
return TYPES_TO_NATIVE[key_pair_type]
|
92
|
+
end
|
93
|
+
|
94
|
+
raise VirgilCryptoException, key_pair_type
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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
|
+
|
35
|
+
module Virgil
|
36
|
+
module Crypto
|
37
|
+
# Class containing private key information
|
38
|
+
VirgilPrivateKey = Struct.new(:id, :raw_key)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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
|
+
|
35
|
+
module Virgil
|
36
|
+
module Crypto
|
37
|
+
# Provides export [PrivateKey] into its material representation bytes and
|
38
|
+
# import [PrivateKey] from its material representation bytes.
|
39
|
+
class VirgilPrivateKeyExporter
|
40
|
+
attr_reader :virgil_crypto
|
41
|
+
attr_reader :password
|
42
|
+
|
43
|
+
# Initializes a new instance of the [VirgilPrivateKeyExporter] class.
|
44
|
+
# @param password [String] private key password, nil by default.
|
45
|
+
# @param crypto the instance of [Crypto::VirgilCrypto]
|
46
|
+
# that is used for export and import of [PrivateKey]
|
47
|
+
def initialize(crypto: nil, password: nil)
|
48
|
+
@password = password
|
49
|
+
@virgil_crypto = crypto || VirgilCrypto.new
|
50
|
+
end
|
51
|
+
|
52
|
+
# Exports the provided [PrivateKey] into material representation bytes.
|
53
|
+
# @param private_key [PrivateKey] The private key.
|
54
|
+
# @return [Crypto::Bytes] Private key material representation bytes.
|
55
|
+
def export_private_key(private_key)
|
56
|
+
@virgil_crypto.export_private_key(private_key, @password)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Imports the private key from its material representation.
|
60
|
+
# @param private_key_bytes [Crypto::Bytes] private key material.
|
61
|
+
# @return [VirgilPrivateKey] Imported private key.
|
62
|
+
def import_private_key(private_key_bytes)
|
63
|
+
@virgil_crypto.import_private_key(private_key_bytes, @password)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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
|
+
|
35
|
+
module Virgil
|
36
|
+
module Crypto
|
37
|
+
# Class containing public key information
|
38
|
+
VirgilPublicKey = Struct.new(:id, :raw_key)
|
39
|
+
end
|
40
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C)
|
1
|
+
# Copyright (C) 2015-2019 Virgil Security Inc.
|
2
2
|
#
|
3
3
|
# Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
4
4
|
#
|
@@ -8,17 +8,17 @@
|
|
8
8
|
# modification, are permitted provided that the following conditions are
|
9
9
|
# met:
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
13
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
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
18
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
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
22
|
#
|
23
23
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
24
24
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
@@ -26,7 +26,7 @@
|
|
26
26
|
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
27
27
|
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
28
28
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
-
# SERVICES; LOSS OF USE,
|
29
|
+
# SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
30
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
31
31
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
32
32
|
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
module Virgil
|
36
36
|
module Crypto
|
37
|
-
class VirgilStreamDataSink <
|
37
|
+
class VirgilStreamDataSink < Core::VirgilDataSink
|
38
38
|
attr_reader :stream
|
39
39
|
|
40
40
|
def initialize(stream)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C)
|
1
|
+
# Copyright (C) 2015-2019 Virgil Security Inc.
|
2
2
|
#
|
3
3
|
# Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
4
4
|
#
|
@@ -8,17 +8,17 @@
|
|
8
8
|
# modification, are permitted provided that the following conditions are
|
9
9
|
# met:
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
13
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
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
18
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
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
22
|
#
|
23
23
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
24
24
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
@@ -26,7 +26,7 @@
|
|
26
26
|
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
27
27
|
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
28
28
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
-
# SERVICES; LOSS OF USE,
|
29
|
+
# SERVICES; LOSS OF USE, bytes, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
30
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
31
31
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
32
32
|
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
module Virgil
|
36
36
|
module Crypto
|
37
|
-
class VirgilStreamDataSource <
|
37
|
+
class VirgilStreamDataSource < Core::VirgilDataSource
|
38
38
|
attr_reader :stream, :buffer_size
|
39
39
|
|
40
40
|
def initialize(stream, buffer_size = 1024)
|
@@ -0,0 +1,59 @@
|
|
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
|
+
|
35
|
+
module Virgil
|
36
|
+
module Crypto
|
37
|
+
module Validation
|
38
|
+
def self.check_array_argument!(val)
|
39
|
+
raise TypeError, 'argument must be an array' unless val.is_a?(Array)
|
40
|
+
|
41
|
+
val
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.check_filled_array_argument!(val)
|
45
|
+
check_array_argument!(val)
|
46
|
+
raise ArgumentError, 'argument must not be an empty array' if val.empty?
|
47
|
+
|
48
|
+
val
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.check_type_argument!(cclass, val)
|
52
|
+
raise TypeError, "argument must have type #{cclass.name}" unless val.is_a?(cclass)
|
53
|
+
|
54
|
+
val
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|