yuezonghe | 824eb0c | 2024-06-27 02:32:26 -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 | |
| 39 | typedef enum E_HASH_TYPE{ |
| 40 | HASH_SHA512 = 0, |
| 41 | HASH_SHA526 = 1 |
| 42 | } hash_type_e; |
| 43 | |
| 44 | /******************************************************************************* |
| 45 | * Global variable declarations * |
| 46 | ******************************************************************************/ |
| 47 | |
| 48 | |
| 49 | /******************************************************************************* |
| 50 | * Global function declarations * |
| 51 | ******************************************************************************/ |
| 52 | int check_image_hash(partition_mtd_info_t *mtd_info, int len, char * digest); |
| 53 | |
| 54 | int get_hash_from_fd(int hash_type, int fd, unsigned int offset, unsigned int len, unsigned int read_size_per_time, unsigned char* digest); |
| 55 | |
| 56 | int get_hash_from_file_path_segment(int hash_type, const char* file_path, unsigned int offset, unsigned int len, unsigned char* digest); |
| 57 | |
| 58 | |
| 59 | /******************************************************************************* |
| 60 | * Inline function implementations * |
| 61 | ******************************************************************************/ |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | #endif // _UPI_HASH_H |
| 67 | |