1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "drv_osal_lib.h"
20 #include "drv_symc.h"
21 #include "drv_klad.h"
22
klad_load_hard_key(hi_u32 handle,hi_u32 ca_type,const hi_u8 * key,hi_u32 key_len)23 hi_s32 klad_load_hard_key(hi_u32 handle, hi_u32 ca_type, const hi_u8 *key, hi_u32 key_len)
24 {
25 hi_s32 ret;
26
27 ret = drv_cipher_klad_load_key(handle, ca_type, HI_CIPHER_KLAD_TARGET_AES, key, key_len);
28 if (ret != HI_SUCCESS) {
29 hi_log_print_func_err(drv_cipher_klad_load_key, ret);
30 return ret;
31 }
32
33 return HI_SUCCESS;
34 }
35
klad_encrypt_key(hi_u32 keysel,hi_u32 target,hi_u8 * clear,hi_u8 * encrypt,hi_u32 key_len)36 hi_s32 klad_encrypt_key(hi_u32 keysel, hi_u32 target, hi_u8 *clear, hi_u8 *encrypt, hi_u32 key_len)
37 {
38 hi_s32 ret;
39
40 ret = drv_cipher_klad_encrypt_key(keysel, target, clear, encrypt, key_len);
41 if (ret != HI_SUCCESS) {
42 hi_log_print_func_err(drv_cipher_klad_encrypt_key, ret);
43 return ret;
44 }
45
46 return HI_SUCCESS;
47 }
48
hi_drv_compat_init(void)49 hi_s32 hi_drv_compat_init(void)
50 {
51 hi_s32 ret;
52
53 ret = drv_cipher_klad_init();
54 if (ret != HI_SUCCESS) {
55 hi_log_print_func_err(drv_cipher_klad_init, ret);
56 return ret;
57 }
58
59 return HI_SUCCESS;
60 }
61
hi_drv_compat_deinit(void)62 hi_s32 hi_drv_compat_deinit(void)
63 {
64 drv_cipher_klad_deinit();
65
66 return HI_SUCCESS;
67 }
68
69