1 #include <mach/mt_sec_hal.h>
2 #include "sec_boot_lib.h"
5 /**************************************************************************
7 **************************************************************************/
10 int masp_ccci_signfmt_verify_file(char *file_path
, unsigned int *data_offset
, unsigned int *data_sec_len
)
12 unsigned int ret
= SEC_OK
;
13 SEC_IMG_HEADER img_hdr
;
18 ret
= sec_signfmt_verify_file(file_path
, &img_hdr
, data_offset
, data_sec_len
);
20 /* image is not signed */
21 if( ret
== ERR_SIGN_FORMAT_MAGIC_WRONG
)
23 if((sec_modem_auth_enabled() == 0) && (sec_schip_enabled() == 0))
25 SMSG(true,"[%s] image has no sec header\n",MOD
);
31 SMSG(true,"[%s] (img not signed) sec_modem_auth_enabled() = %d\n",MOD
,sec_modem_auth_enabled());
32 SMSG(true,"[%s] (img not signed) sec_schip_enabled() = %d\n",MOD
,sec_schip_enabled());
33 ret
= ERR_SIGN_FORMAT_MAGIC_WRONG
;
40 SMSG(true,"[%s] file '%s' verify failed\n",MOD
,file_path
);
44 SMSG(true,"[%s] data_offset is %d\n",MOD
,*data_offset
);
45 SMSG(true,"[%s] data_sec_len is %d\n",MOD
,*data_sec_len
);
52 int masp_ccci_version_info(void)
57 int sec_ccci_file_open(char *file_path
)
61 fp_id
= osal_filp_open_read_only(file_path
);
63 if(fp_id
!= OSAL_FILE_NULL
)
71 int sec_ccci_file_close(int fp_id
)
73 return osal_filp_close(fp_id
);
77 int masp_ccci_is_cipherfmt(int fp_id
, unsigned int start_off
, unsigned int *img_len
)
79 if( SEC_OK
!= sec_cipherfmt_check_cipher(fp_id
, start_off
, img_len
) )
88 int masp_ccci_decrypt_cipherfmt(int fp_id
, unsigned int start_off
, char *buf
, unsigned int buf_len
, unsigned int *data_offset
)
90 return sec_cipherfmt_decrypted(fp_id
, start_off
, buf
, buf_len
, data_offset
);
93 void masp_secure_algo(unsigned char Direction
, unsigned int ContentAddr
, unsigned int ContentLen
, unsigned char *CustomSeed
, unsigned char *ResText
)
95 return masp_hal_secure_algo(Direction
, ContentAddr
, ContentLen
, CustomSeed
, ResText
);
98 /* return the result of hwEnableClock ( )
99 - TRUE (1) means crypto engine init success
100 - FALSE (0) means crypto engine init fail */
101 unsigned char masp_secure_algo_init(void)
103 return masp_hal_secure_algo_init();
106 /* return the result of hwDisableClock ( )
107 - TRUE (1) means crypto engine de-init success
108 - FALSE (0) means crypto engine de-init fail */
109 unsigned char masp_secure_algo_deinit(void)
111 return masp_hal_secure_algo_deinit();