• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: flashboot API header file.
15  *
16  * Create: 2023-05-26
17 */
18 
19 #ifndef DRV_FLASHBOOT_CIPHER_H
20 #define DRV_FLASHBOOT_CIPHER_H
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 #include "drv_klad.h"
25 #include "drv_rom_cipher.h"
26 
27 int drv_rom_cipher_config_odrk1(const crypto_klad_effective_key effective_key);
28 
29 int drv_rom_cipher_config_clear_key(const crypto_klad_clear_key clear_key);
30 
31 int drv_rom_cipher_fapc_config(unsigned int region, unsigned int start_addr, unsigned int end_addr,
32     const unsigned char *iv, unsigned int iv_length);
33 
34 int drv_rom_cipher_fapc_bypass_config(td_u32 region, td_u32 start_addr, td_u32 end_addr, td_bool lock);
35 
36 /* support data_length not 64 bytes aligned. */
37 int drv_rom_cipher_sm3(const unsigned char *data, unsigned int data_length, unsigned char *hash,
38     unsigned int hash_length);
39 
40 int drv_rom_cipher_pke_sm2_verify(const drv_rom_cipher_ecc_point *pub_key, const drv_rom_cipher_data *hash,
41     const drv_rom_cipher_ecc_sig *sig);
42 
43 int32_t drv_rom_cipher_symc_init(void);
44 
45 int32_t drv_rom_cipher_symc_deinit(void);
46 
47 int drv_rom_cipher_create_keyslot(uint32_t *keyslot_chn_num, const crypto_klad_effective_key *effective_key,
48     crypto_kdf_hard_key_type key_type);
49 
50 int drv_rom_cipher_destroy_keyslot(uint32_t keyslot_chn_num);
51 
52 int32_t drv_rom_cipher_symc_encrypt(uint32_t keyslot_chn_num, uint8_t *iv, uint32_t iv_length,
53     uint64_t src, uint64_t dst, uint32_t length);
54 
55 int32_t drv_rom_cipher_symc_decrypt(uint32_t keyslot_chn_num, uint8_t *iv, uint32_t iv_length,
56     uint64_t src, uint64_t dst, uint32_t length);
57 
58 #endif