lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file upi_hash.h |
| 3 | * @brief ¹«¹²½Ó¿Ú¼°ÐÅÏ¢ |
| 4 | * |
| 5 | * Copyright (C) 2017 Sanechips Technology Co., Ltd. |
| 6 | * @author |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef _UPI_HASH_H |
| 11 | #define _UPI_HASH_H |
| 12 | |
| 13 | /******************************************************************************* |
| 14 | * Include header files * |
| 15 | ******************************************************************************/ |
| 16 | #include <stdio.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <unistd.h> |
| 19 | #include <string.h> |
| 20 | #include <errno.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <sys/stat.h> |
| 23 | |
| 24 | |
| 25 | #include "upi_mtd.h" |
| 26 | /******************************************************************************* |
| 27 | * Macro definitions * |
| 28 | ******************************************************************************/ |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | /******************************************************************************* |
| 36 | * Type definitions * |
| 37 | ******************************************************************************/ |
| 38 | |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 39 | typedef enum E_HASH_TYPE |
| 40 | { |
| 41 | HASH_SHA512 = 0, |
| 42 | HASH_SHA526 = 1 |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 43 | } hash_type_e; |
| 44 | |
| 45 | /******************************************************************************* |
| 46 | * Global variable declarations * |
| 47 | ******************************************************************************/ |
| 48 | |
| 49 | |
| 50 | /******************************************************************************* |
| 51 | * Global function declarations * |
| 52 | ******************************************************************************/ |
| 53 | int check_image_hash(partition_mtd_info_t *mtd_info, int len, char * digest); |
| 54 | |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 55 | int get_hash_from_fd(int hash_type, int fd, unsigned int offset, unsigned int len, unsigned int read_size_per_time, |
| 56 | unsigned char* digest); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 57 | |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 58 | int get_hash_from_file_path_segment(int hash_type, const char* file_path, unsigned int offset, unsigned int len, |
| 59 | unsigned char* digest); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 60 | |
| 61 | |
| 62 | /******************************************************************************* |
| 63 | * Inline function implementations * |
| 64 | ******************************************************************************/ |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | #endif // _UPI_HASH_H |
| 70 | |