-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b56913d
commit 673202f
Showing
23 changed files
with
203 additions
and
59 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
// | ||
// This program is free software: you can redistribute it and/or modify it under | ||
// the terms of the GNU Lesser General Public License as published by the Free | ||
// Software Foundation, either version 3 of the License, or (at your option) any | ||
// later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License along | ||
// with this program (see COPYING). If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
#ifndef MACHINE_HASHER_H | ||
#define MACHINE_HASHER_H | ||
|
||
#include "sha-256-hasher.h" | ||
|
||
namespace cartesi { | ||
|
||
using machine_hasher_type = sha_256_hasher; | ||
|
||
} | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
// | ||
// This program is free software: you can redistribute it and/or modify it under | ||
// the terms of the GNU Lesser General Public License as published by the Free | ||
// Software Foundation, either version 3 of the License, or (at your option) any | ||
// later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License along | ||
// with this program (see COPYING). If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
#ifndef SHA256_HASHER_H | ||
#define SHA256_HASHER_H | ||
|
||
#include <type_traits> | ||
|
||
#include "i-hasher.h" | ||
|
||
extern "C" { | ||
#include "sha256.h" | ||
} | ||
|
||
namespace cartesi { | ||
|
||
class sha_256_hasher final : public i_hasher<sha_256_hasher, std::integral_constant<int, 32>> { | ||
sha256_context m_ctx{}; | ||
|
||
friend i_hasher<sha_256_hasher, std::integral_constant<int, 32>>; | ||
|
||
void do_begin(void) { | ||
sha256_init(&m_ctx); | ||
} | ||
|
||
void do_add_data(const unsigned char *data, size_t length) { | ||
sha256_hash(&m_ctx, data, length); | ||
} | ||
|
||
void do_end(hash_type &hash) { | ||
sha256_done(&m_ctx, hash.data()); | ||
} | ||
|
||
public: | ||
/// \brief Default constructor | ||
sha_256_hasher(void) = default; | ||
|
||
/// \brief Default destructor | ||
~sha_256_hasher(void) = default; | ||
|
||
/// \brief No copy constructor | ||
sha_256_hasher(const sha_256_hasher &) = delete; | ||
/// \brief No move constructor | ||
sha_256_hasher(sha_256_hasher &&) = delete; | ||
/// \brief No copy assignment | ||
sha_256_hasher &operator=(const sha_256_hasher &) = delete; | ||
/// \brief No move assignment | ||
sha_256_hasher &operator=(sha_256_hasher &&) = delete; | ||
}; | ||
|
||
} // namespace cartesi | ||
|
||
#endif |
Oops, something went wrong.