bigbiff bigbiff | 56cf564 | 2016-08-19 17:43:45 -0400 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2012 to 2017 TeamWin |
| 3 | This file is part of TWRP/TeamWin Recovery Project. |
| 4 | |
| 5 | TWRP is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | TWRP is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with TWRP. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | #ifndef __TWRPSHA_H |
| 19 | #define __TWRPSHA_H |
| 20 | |
| 21 | #include <openssl/sha.h> |
| 22 | #include "twrpDigest.hpp" |
| 23 | |
| 24 | class twrpSHA256: public twrpDigest { |
| 25 | public: |
| 26 | twrpSHA256(); // Initialize the SHA256 digest for streaming activities only |
| 27 | void init(); // Initialize the SHA256 digest algorithm |
| 28 | |
| 29 | protected: |
| 30 | void update(const unsigned char* stream, size_t len); // Update the SHA256 digest stream |
| 31 | void finalize(); // Finalize the SHA256 digest for computation |
| 32 | std::string return_digest_string(); // Return the digest string computed to the callee |
| 33 | |
| 34 | private: |
| 35 | uint8_t sha256_store[SHA256_DIGEST_LENGTH]; // Initialize the SHA256 digest array that holds the computation |
| 36 | SHA256_CTX sha256_ctx; // Initialize the SHA256 control structure |
| 37 | }; |
| 38 | |
| 39 | class twrpSHA512: public twrpDigest { |
| 40 | public: |
| 41 | twrpSHA512(); // Initialize the SHA512 digest for streaming activities only |
| 42 | void init(); // Initialize the SHA512 digest algorithm |
| 43 | |
| 44 | protected: |
| 45 | void update(const unsigned char* stream, size_t len); // Update the SHA512 digest stream |
| 46 | void finalize(); // Finalize the SHA512 digest for computation |
| 47 | std::string return_digest_string(); // Return the digest string computed to the callee |
| 48 | |
| 49 | private: |
| 50 | uint8_t sha512_store[SHA512_DIGEST_LENGTH]; // Initialize the SHA512 digest array that holds the computation |
| 51 | SHA512_CTX sha512_ctx; // Initialize the SHA512 control structure |
| 52 | }; |
| 53 | |
| 54 | #endif //__TWRPSHA_H |