blob: f511e53f6abf75f8db099fd505edfb70d052ecc6 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
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
lh758261d2023-07-13 05:52:04 -070039typedef enum E_HASH_TYPE
40{
41 HASH_SHA512 = 0,
42 HASH_SHA526 = 1
lh9ed821d2023-04-07 01:36:19 -070043} hash_type_e;
44
45/*******************************************************************************
46 * Global variable declarations *
47 ******************************************************************************/
48
49
50/*******************************************************************************
51 * Global function declarations *
52 ******************************************************************************/
53int check_image_hash(partition_mtd_info_t *mtd_info, int len, char * digest);
54
lh758261d2023-07-13 05:52:04 -070055int 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);
lh9ed821d2023-04-07 01:36:19 -070057
lh758261d2023-07-13 05:52:04 -070058int get_hash_from_file_path_segment(int hash_type, const char* file_path, unsigned int offset, unsigned int len,
59 unsigned char* digest);
lh9ed821d2023-04-07 01:36:19 -070060
61
62/*******************************************************************************
63 * Inline function implementations *
64 ******************************************************************************/
65
66
67
68
69#endif // _UPI_HASH_H
70