WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
upg_encry_porting.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2024-2024. All rights reserved.
3 * Description: UPG encry Interface Header.
4 */
5#ifndef UPG_ENCRY_PORTING_H
6#define UPG_ENCRY_PORTING_H
7
8#ifdef CONFIG_MIDDLEWARE_SUPPORT_UPG_COMPRESS_ENCRY
9#include "upg.h"
10#include "upg_lzmadec.h"
11#include "crypto_km_struct.h"
12
13#ifdef __cplusplus
14#if __cplusplus
15extern "C" {
16#endif
17#endif
18
19#define IMAGE_HEADER_LEN ((KEY_AREA_STRUCTURE_LENGTH) + (CODE_INFO_STRUCTURE_LENGTH))
20#define FLASH_ENCRY_FLAG 0x1E6987C3
21#define OTA_ENCRY_FLAG 0x3C7896E1
22#define OTA_IMAGE_SALT_LEN 28
23#define MAX_DUMP_LENGHT 64
24#define BYTES_IN_ONE_LINE 16
25#ifndef KERN_CONT
26#define KERN_CONT
27#endif
28
29typedef enum {
30 CRYPTO_KDF_ENCRY = 0,
31 CRYPTO_KDF_DENCRY,
32 CRYPTO_KDF_BUFF,
33} upg_crypto_type;
34
35typedef struct {
36 crypto_kdf_hard_key_type key_type; /* 加密key类型 */
37 uint32_t chnum; /* 加密通道号 */
38 uint8_t salt[OTA_IMAGE_SALT_LEN];
39 uint8_t iv[IV_LEN];
40} ota_cryto_cfg;
41
42typedef struct {
43 ota_cryto_cfg decry_cfg;
44 ota_cryto_cfg encry_cfg;
45} upg_cryto_cfg;
46
47/*
48 * 加解密初始化
49 * image 需要镜像的enc_pk_l1及iv
50 */
51errcode_t upg_cryto_init(const upg_image_header_t *image);
52
53/*
54 * 加解密去初始化
55 * image 需要镜像的re_enc_flag判断是否去初始化
56 */
57errcode_t upg_cryto_deinit(const upg_image_header_t *image);
58
59/*
60 * 加密参数处理
61 * head_offset 出参,返回镜像偏移
62 * is_image_head 入参,判断是否为镜像头
63 */
64errcode_t upg_process_cryto_info(uint32_t *head_offset, td_bool *is_image_head);
65
66/*
67 * 数据解密
68 * buf 需要解密的数据
69 * len 数据长度
70 * image 镜像信息,判断是否需要解密
71 */
72errcode_t upg_decry_fota_pkt(uint8_t *buf, uint32_t len, const upg_image_header_t *image);
73
74/*
75 * 数据加密
76 * buf 需要加密的数据
77 * len 数据长度
78 * image 镜像信息,判断是否需要加密
79 */
80errcode_t upg_encry_fota_pkt(uint8_t *buf, uint32_t len, const upg_image_header_t *image);
81
82#ifdef __cplusplus
83#if __cplusplus
84}
85#endif
86#endif
87
88#endif /* UPG_LZMADEC_H */
89#endif
crypto_kdf_hard_key_type
KDF 密钥派生时派生key类型选择。
Definition crypto_km_struct.h:79
uint32_t errcode_t
Definition of error code.
Definition errcode.h:30
#define IV_LEN
IV 长度。
Definition upg.h:63
升级包镜像头类型
Definition upg.h:250
td_u8 td_bool
Definition td_type.h:50