1 #include <mach/mt_typedefs.h>
2 #include <mach/mt_reg_base.h>
4 #include "../hacc_mach.h"
6 /******************************************************************************
7 * this file contains the hardware secure engine low-level operations
8 * note that : all the functions in this file are ONLY for HACC internal usages.
9 ******************************************************************************/
11 /******************************************************************************
12 * CONSTANT DEFINITIONS
13 ******************************************************************************/
15 #define HACC_TEST (FALSE)
17 /******************************************************************************
19 ******************************************************************************/
20 #define SEC_DEBUG (FALSE)
28 /******************************************************************************
30 ******************************************************************************/
31 extern BOOL bHACC_HWWrapKeyInit
;
32 extern BOOL bHACC_SWKeyInit
;
34 /******************************************************************************
36 ******************************************************************************/
37 //static struct hacc_context hacc_ctx;
39 /******************************************************************************
41 ******************************************************************************/
44 static void hacc_test(void)
46 U32 i
, test_sz
= HACC_AES_MAX_KEY_SZ
* 24;
47 U32 test_keysz
= AES_KEY_256
;
48 U8
*test_src
= (U8
*) HACC_AES_TEST_SRC
;
49 U8
*test_dst
= (U8
*) HACC_AES_TEST_DST
;
50 U8
*test_tmp
= (U8
*) HACC_AES_TEST_TMP
;
53 for (i
= 0; i
< test_sz
; i
++) {
57 hacc_set_key(AES_HW_WRAP_KEY
, test_keysz
);
58 hacc_do_aes(AES_ENC
, test_src
, test_tmp
, test_sz
);
59 hacc_set_key(AES_HW_WRAP_KEY
, test_keysz
);
60 hacc_do_aes(AES_DEC
, test_tmp
, test_dst
, test_sz
);
62 for (i
= 0; i
< test_sz
; i
++) {
63 if (test_src
[i
] != test_dst
[i
]) {
64 DMSG("[%s] test_src[%d] = 0x%x != test_dst[%d] = 0x%x\n", MOD
, i
, test_src
[i
], i
, test_dst
[i
]);
68 DMSG("[%s] encrypt & descrypt unit test pass. (Key = %dbits)\n", MOD
, test_keysz
<< 3);
71 #define hacc_test() do{}while(0)
74 /******************************************************************************
76 ******************************************************************************/
78 static U32
hacc_set_cfg(AES_CFG
*cfg
)
83 static U32
hacc_set_mode(AES_MODE mode
)
89 U32
hacc_set_key(AES_KEY_ID id
, AES_KEY key
)
94 U32
hacc_do_aes(AES_OPS ops
, U8
*src
, U8
*dst
, U32 size
)
104 U32
hacc_init(AES_KEY_SEED
*keyseed
)