forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/shared_model-crypto_provider_interfaces' into f…
…eature/shared_model
- Loading branch information
Showing
16 changed files
with
215 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
shared_model/cryptography/crypto_provider/crypto_signer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef IROHA_CRYPTO_SIGNER_HPP | ||
#define IROHA_CRYPTO_SIGNER_HPP | ||
|
||
#include "cryptography/blob.hpp" | ||
#include "cryptography/crypto_provider/crypto_defaults.hpp" | ||
#include "cryptography/keypair.hpp" | ||
#include "cryptography/signed.hpp" | ||
|
||
namespace shared_model { | ||
namespace crypto { | ||
/** | ||
* CryptoSigner - wrapper for generalization signing for different | ||
* cryptographic algorithms | ||
* @tparam Algorithm - cryptographic algorithm for singing | ||
*/ | ||
template <typename Algorithm = DefaultCryptoAlgorithmType> | ||
class CryptoSigner { | ||
public: | ||
/** | ||
* Generate signature for target data | ||
* @param blob - data for signing | ||
* @param keypair - (public, private) keys for signing | ||
* @return signature's blob | ||
*/ | ||
static Signed sign(const Blob &blob, const Keypair &keypair) { | ||
return Algorithm::sign(blob, keypair); | ||
} | ||
|
||
/// close constructor for forbidding instantiation | ||
CryptoSigner() = delete; | ||
}; | ||
} // namespace crypto | ||
} // namespace shared_model | ||
#endif // IROHA_CRYPTO_SIGNER_HPP |
54 changes: 54 additions & 0 deletions
54
shared_model/cryptography/crypto_provider/crypto_verifier.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef IROHA_CRYPTO_VERIFIER_HPP | ||
#define IROHA_CRYPTO_VERIFIER_HPP | ||
|
||
#include "cryptography/blob.hpp" | ||
#include "cryptography/crypto_provider/crypto_defaults.hpp" | ||
#include "cryptography/keypair.hpp" | ||
#include "cryptography/signed.hpp" | ||
|
||
namespace shared_model { | ||
namespace crypto { | ||
/** | ||
* CryptoVerifier - wrapper for generalization verification of cryptographic | ||
* signatures | ||
* @tparam Algorithm - cryptographic algorithm for verification | ||
*/ | ||
template <typename Algorithm = DefaultCryptoAlgorithmType> | ||
class CryptoVerifier { | ||
public: | ||
/** | ||
* Verify signature attached to source data | ||
* @param signedData - cryptographic signature | ||
* @param source - data that was signed | ||
* @param pubKey - public key of signatory | ||
* @return true if signature correct | ||
*/ | ||
static bool verify(const Signed &signedData, | ||
const Blob &source, | ||
const PublicKey &pubKey) { | ||
return Algorithm::verify(signedData, source, pubKey); | ||
} | ||
|
||
/// close constructor for forbidding instantiation | ||
CryptoVerifier() = delete; | ||
}; | ||
} // namespace crypto | ||
} // namespace shared_model | ||
#endif // IROHA_CRYPTO_VERIFIER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
shared_model/cryptography/ed25519_sha3_impl/hash_provider.hpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.