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,89 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (C) 2015-2018 Virgil Security Inc.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* (1) Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* (2) Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in
|
15
|
+
* the documentation and/or other materials provided with the
|
16
|
+
* distribution.
|
17
|
+
*
|
18
|
+
* (3) Neither the name of the copyright holder nor the names of its
|
19
|
+
* contributors may be used to endorse or promote products derived from
|
20
|
+
* this software without specific prior written permission.
|
21
|
+
*
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
23
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
24
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
25
|
+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
26
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
28
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
30
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
31
|
+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
*
|
34
|
+
* Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifndef VIRGIL_PYTHIA_BLIND_RESULT_H
|
38
|
+
#define VIRGIL_PYTHIA_BLIND_RESULT_H
|
39
|
+
|
40
|
+
#include "../VirgilByteArray.h"
|
41
|
+
|
42
|
+
namespace virgil {
|
43
|
+
namespace crypto {
|
44
|
+
namespace pythia {
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @brief Handles result of the method VirgilPythia::blind().
|
48
|
+
* @ingroup pythia
|
49
|
+
*/
|
50
|
+
class VirgilPythiaBlindResult {
|
51
|
+
public:
|
52
|
+
/**
|
53
|
+
* @brief Encapsulate given data.
|
54
|
+
*
|
55
|
+
* @param blindedPassword - G1 password obfuscated into a pseudo-random string.
|
56
|
+
* @param blindingSecret - BN random value used to blind user's password.
|
57
|
+
*/
|
58
|
+
explicit VirgilPythiaBlindResult(
|
59
|
+
VirgilByteArray blindedPassword, VirgilByteArray blindingSecret)
|
60
|
+
: blindedPassword_(std::move(blindedPassword)),
|
61
|
+
blindingSecret_(std::move(blindingSecret)) {
|
62
|
+
|
63
|
+
auto a = 5;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @return G1 password obfuscated into a pseudo-random string.
|
68
|
+
*/
|
69
|
+
const VirgilByteArray& blindedPassword() const {
|
70
|
+
return blindedPassword_;
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @return BN random value used to blind user's password.
|
75
|
+
*/
|
76
|
+
const VirgilByteArray& blindingSecret() const {
|
77
|
+
return blindingSecret_;
|
78
|
+
}
|
79
|
+
|
80
|
+
private:
|
81
|
+
const VirgilByteArray blindedPassword_;
|
82
|
+
const VirgilByteArray blindingSecret_;
|
83
|
+
};
|
84
|
+
|
85
|
+
} // namespace pythia
|
86
|
+
} // namespace crypto
|
87
|
+
} // namespace virgil
|
88
|
+
|
89
|
+
#endif /* VIRGIL_PYTHIA_BLIND_RESULT_H */
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (C) 2015-2018 Virgil Security Inc.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* (1) Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* (2) Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in
|
15
|
+
* the documentation and/or other materials provided with the
|
16
|
+
* distribution.
|
17
|
+
*
|
18
|
+
* (3) Neither the name of the copyright holder nor the names of its
|
19
|
+
* contributors may be used to endorse or promote products derived from
|
20
|
+
* this software without specific prior written permission.
|
21
|
+
*
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
23
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
24
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
25
|
+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
26
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
28
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
30
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
31
|
+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
*
|
34
|
+
* Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifndef VIRGIL_PYTHIA_CONTEXT_H
|
38
|
+
#define VIRGIL_PYTHIA_CONTEXT_H
|
39
|
+
|
40
|
+
#include <memory>
|
41
|
+
|
42
|
+
namespace virgil {
|
43
|
+
namespace crypto {
|
44
|
+
namespace pythia {
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @brief This class encapsulates Pythia initialization routine.
|
48
|
+
*
|
49
|
+
* Motivation:
|
50
|
+
* Pythia context locates in a global storage or a thread storage
|
51
|
+
* duration, so it's initialization must be handled properly.
|
52
|
+
*
|
53
|
+
* Usage:
|
54
|
+
* This class object must be defined as a function local variable, or
|
55
|
+
* non-static class member.
|
56
|
+
*
|
57
|
+
* @ingroup pythia
|
58
|
+
*/
|
59
|
+
class VirgilPythiaContext {
|
60
|
+
public:
|
61
|
+
/**
|
62
|
+
* @brief Initialize Pythia context.
|
63
|
+
*
|
64
|
+
*/
|
65
|
+
VirgilPythiaContext();
|
66
|
+
};
|
67
|
+
|
68
|
+
} // namespace pythia
|
69
|
+
} // namespace crypto
|
70
|
+
} // namespace virgil
|
71
|
+
|
72
|
+
#endif /* VIRGIL_PYTHIA_CONTEXT_H */
|
@@ -0,0 +1,161 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (C) 2015-2018 Virgil Security Inc.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* (1) Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* (2) Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in
|
15
|
+
* the documentation and/or other materials provided with the
|
16
|
+
* distribution.
|
17
|
+
*
|
18
|
+
* (3) Neither the name of the copyright holder nor the names of its
|
19
|
+
* contributors may be used to endorse or promote products derived from
|
20
|
+
* this software without specific prior written permission.
|
21
|
+
*
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
23
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
24
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
25
|
+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
26
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
28
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
30
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
31
|
+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
*
|
34
|
+
* Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifndef VIRGIL_PYTHIA_ERROR_H
|
38
|
+
#define VIRGIL_PYTHIA_ERROR_H
|
39
|
+
|
40
|
+
#include <system_error>
|
41
|
+
|
42
|
+
#include "../VirgilCryptoError.h"
|
43
|
+
|
44
|
+
namespace virgil {
|
45
|
+
namespace crypto {
|
46
|
+
namespace pythia {
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @brief Error category that handles error codes from the system crypto library.
|
50
|
+
* @ingroup error
|
51
|
+
* @ingroup pythia
|
52
|
+
*/
|
53
|
+
class VirgilPythiaErrorCategory : public std::error_category {
|
54
|
+
public:
|
55
|
+
/**
|
56
|
+
* @brief Return name of the system crypto category.
|
57
|
+
* @return Name of the system crypto category.
|
58
|
+
*/
|
59
|
+
const char* name() const noexcept override;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @brief Return description for the given error code.
|
63
|
+
* @param ev Error code.
|
64
|
+
* @return Error Description.
|
65
|
+
*/
|
66
|
+
std::string message(int ev) const noexcept override;
|
67
|
+
};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @brief Return singleton instance of the system crypto error category.
|
71
|
+
* @return Instance of the syste, crypto error categoty.
|
72
|
+
* @ingroup error
|
73
|
+
*/
|
74
|
+
const VirgilPythiaErrorCategory& pythia_error_category() noexcept;
|
75
|
+
|
76
|
+
/**
|
77
|
+
* @brief Handle value returned by underling system crypto library.
|
78
|
+
*
|
79
|
+
* If given value is an error then VirgilCryptoException will be thrown with appropriate
|
80
|
+
* description. If given value is not an error then it will be returned.
|
81
|
+
*
|
82
|
+
* @param result Value returned by system crypto library.
|
83
|
+
* @return Value if it's not an error.
|
84
|
+
* @throw VirgilCryptoException with given error code and correspond category, if given value
|
85
|
+
* represents an error.
|
86
|
+
* @ingroup error
|
87
|
+
*/
|
88
|
+
inline int pythia_handler_get_result(int result) {
|
89
|
+
if (result >= 0) {
|
90
|
+
return result;
|
91
|
+
}
|
92
|
+
throw VirgilCryptoException(result, pythia_error_category());
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* @brief Handle value returned by underling system crypto library.
|
97
|
+
*
|
98
|
+
* If given value is an error then VirgilCryptoException will be thrown with appropriate
|
99
|
+
* description. If given value is not an error then do nothing.
|
100
|
+
*
|
101
|
+
* @param result Value returned by system crypto library.
|
102
|
+
* @throw VirgilCryptoException with given error code and correspond category, if given value
|
103
|
+
* represents an error.
|
104
|
+
* @ingroup error
|
105
|
+
*/
|
106
|
+
inline void pythia_handler(int result) {
|
107
|
+
(void)pythia_handler_get_result(result);
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* @brief Handle value returned by underling system crypto library.
|
112
|
+
*
|
113
|
+
* This function is usefull if thrown exception SHOULD be wrapped.
|
114
|
+
* Initial exception can be accessed via std::current_exception(), or std::throw_with_nested().
|
115
|
+
*
|
116
|
+
* If given value is an error then VirgilCryptoException will be thrown with appropriate
|
117
|
+
* description. If given value is not an error then it will be returned.
|
118
|
+
*
|
119
|
+
* @param result Value returned by system crypto library.
|
120
|
+
* @param catch_handler Function that can handle the error in a different way.
|
121
|
+
*
|
122
|
+
* @return Value if it's not an error.
|
123
|
+
* @ingroup error
|
124
|
+
*/
|
125
|
+
template <typename CatchHandler>
|
126
|
+
inline int pythia_handler_get_result(int result, CatchHandler catch_handler) {
|
127
|
+
if (result >= 0) {
|
128
|
+
return result;
|
129
|
+
}
|
130
|
+
try {
|
131
|
+
throw VirgilCryptoException(result, pythia_error_category());
|
132
|
+
} catch (...) {
|
133
|
+
catch_handler(result);
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
/**
|
139
|
+
* @brief Handle value returned by underling system crypto library.
|
140
|
+
*
|
141
|
+
* This function is usefull if thrown exception SHOULD be wrapped or error can be handled in a
|
142
|
+
* different way. Initial exception can be accessed via std::current_exception(), or
|
143
|
+
* std::throw_with_nested().
|
144
|
+
*
|
145
|
+
* If given value is an error then VirgilCryptoException will be thrown with appropriate
|
146
|
+
* description. If given value is not an error then do nothing.
|
147
|
+
*
|
148
|
+
* @param result Value returned by system crypto library.
|
149
|
+
* @param catch_handler Function that can handle the error in a different way.
|
150
|
+
* @ingroup error
|
151
|
+
*/
|
152
|
+
template <typename CatchHandler>
|
153
|
+
inline void pythia_handler(int result, CatchHandler catch_handler) {
|
154
|
+
(void)pythia_handler_get_result<CatchHandler>(result, catch_handler);
|
155
|
+
}
|
156
|
+
|
157
|
+
} // namespace pythia
|
158
|
+
} // namespace crypto
|
159
|
+
} // namespace virgil
|
160
|
+
|
161
|
+
#endif // VIRGIL_PYTHIA_ERROR_H
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (C) 2015-2018 Virgil Security Inc.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* (1) Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* (2) Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in
|
15
|
+
* the documentation and/or other materials provided with the
|
16
|
+
* distribution.
|
17
|
+
*
|
18
|
+
* (3) Neither the name of the copyright holder nor the names of its
|
19
|
+
* contributors may be used to endorse or promote products derived from
|
20
|
+
* this software without specific prior written permission.
|
21
|
+
*
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
23
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
24
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
25
|
+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
26
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
28
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
30
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
31
|
+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
*
|
34
|
+
* Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifndef VIRGIL_PYTHIA_PROVE_RESULT_H
|
38
|
+
#define VIRGIL_PYTHIA_PROVE_RESULT_H
|
39
|
+
|
40
|
+
#include "../VirgilByteArray.h"
|
41
|
+
|
42
|
+
namespace virgil {
|
43
|
+
namespace crypto {
|
44
|
+
namespace pythia {
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @brief Handles result of the method VirgilPythia::prove().
|
48
|
+
* @ingroup pythia
|
49
|
+
*/
|
50
|
+
class VirgilPythiaProveResult {
|
51
|
+
public:
|
52
|
+
/**
|
53
|
+
* @brief Encapsulate given data.
|
54
|
+
*
|
55
|
+
* @param proofValueC - BN first part of proof that transformed_password was created
|
56
|
+
* using transformation_private_key.
|
57
|
+
* @param proofValueU - BN second part of proof that transformed_password was created
|
58
|
+
* using transformation_private_key.
|
59
|
+
*/
|
60
|
+
explicit VirgilPythiaProveResult(VirgilByteArray proofValueC, VirgilByteArray proofValueU)
|
61
|
+
: proofValueC_(std::move(proofValueC)), proofValueU_(std::move(proofValueU)) {
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @return BN first part of proof that transformed_password was created
|
66
|
+
* using transformation_private_key.
|
67
|
+
*/
|
68
|
+
const VirgilByteArray& proofValueC() {
|
69
|
+
return proofValueC_;
|
70
|
+
}
|
71
|
+
|
72
|
+
/**
|
73
|
+
* @return BN second part of proof that transformed_password was created
|
74
|
+
* using transformation_private_key.
|
75
|
+
*/
|
76
|
+
const VirgilByteArray& proofValueU() {
|
77
|
+
return proofValueU_;
|
78
|
+
}
|
79
|
+
|
80
|
+
private:
|
81
|
+
const VirgilByteArray proofValueC_;
|
82
|
+
const VirgilByteArray proofValueU_;
|
83
|
+
};
|
84
|
+
|
85
|
+
} // namespace pythia
|
86
|
+
} // namespace crypto
|
87
|
+
} // namespace virgil
|
88
|
+
|
89
|
+
#endif /* VIRGIL_PYTHIA_PROVE_RESULT_H */
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (C) 2015-2018 Virgil Security Inc.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* (1) Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* (2) Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in
|
15
|
+
* the documentation and/or other materials provided with the
|
16
|
+
* distribution.
|
17
|
+
*
|
18
|
+
* (3) Neither the name of the copyright holder nor the names of its
|
19
|
+
* contributors may be used to endorse or promote products derived from
|
20
|
+
* this software without specific prior written permission.
|
21
|
+
*
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
|
23
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
24
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
25
|
+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
26
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
28
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
30
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
31
|
+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
*
|
34
|
+
* Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifndef VIRGIL_PYTHIA_TRANSFORM_RESULT_H
|
38
|
+
#define VIRGIL_PYTHIA_TRANSFORM_RESULT_H
|
39
|
+
|
40
|
+
#include "../VirgilByteArray.h"
|
41
|
+
|
42
|
+
namespace virgil {
|
43
|
+
namespace crypto {
|
44
|
+
namespace pythia {
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @brief Handles result of the method VirgilPythia::transform().
|
48
|
+
* @ingroup pythia
|
49
|
+
*/
|
50
|
+
class VirgilPythiaTransformResult {
|
51
|
+
public:
|
52
|
+
/**
|
53
|
+
* @brief Encapsulate given data.
|
54
|
+
*
|
55
|
+
* @param transformedPassword - GT blinded password, protected using server secret
|
56
|
+
* (pythia_secret + pythia_scope_secret + tweak).
|
57
|
+
* @param transformedTweak - G2 tweak value turned into an elliptic curve point.
|
58
|
+
* This value is used by Prove() operation.
|
59
|
+
*/
|
60
|
+
explicit VirgilPythiaTransformResult(
|
61
|
+
VirgilByteArray transformedPassword, VirgilByteArray transformedTweak)
|
62
|
+
: transformedPassword_(std::move(transformedPassword)),
|
63
|
+
transformedTweak_(std::move(transformedTweak)) {
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @return GT blinded password, protected using server secret
|
68
|
+
* (pythia_secret + pythia_scope_secret + tweak).
|
69
|
+
*/
|
70
|
+
const VirgilByteArray& transformedPassword() const {
|
71
|
+
return transformedPassword_;
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* @return G2 tweak value turned into an elliptic curve point.
|
76
|
+
* This value is used by VirgilPythia::prove() operation.
|
77
|
+
*/
|
78
|
+
const VirgilByteArray& transformedTweak() const {
|
79
|
+
return transformedTweak_;
|
80
|
+
}
|
81
|
+
|
82
|
+
private:
|
83
|
+
const VirgilByteArray transformedPassword_;
|
84
|
+
const VirgilByteArray transformedTweak_;
|
85
|
+
};
|
86
|
+
|
87
|
+
} // namespace pythia
|
88
|
+
} // namespace crypto
|
89
|
+
} // namespace virgil
|
90
|
+
|
91
|
+
#endif /* VIRGIL_PYTHIA_TRANSFORM_RESULT_H */
|