import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / masp / mt8127 / mach / mtee / hacc_sk.c
1 #include <mach/mt_typedefs.h>
2 #include <mach/mt_reg_base.h>
3 #include "sec_error.h"
4 #include "../hacc_mach.h"
5
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 ******************************************************************************/
10
11 /******************************************************************************
12 * CONSTANT DEFINITIONS
13 ******************************************************************************/
14 #define MOD "HACC"
15 #define HACC_TEST (FALSE)
16
17 /******************************************************************************
18 * DEBUG
19 ******************************************************************************/
20 #define SEC_DEBUG (FALSE)
21 #define SMSG printk
22 #if SEC_DEBUG
23 #define DMSG printk
24 #else
25 #define DMSG
26 #endif
27
28 /******************************************************************************
29 * EXTERNAL VARIABLE
30 ******************************************************************************/
31 extern BOOL bHACC_HWWrapKeyInit;
32 extern BOOL bHACC_SWKeyInit;
33
34 /******************************************************************************
35 * LOCAL VERIABLE
36 ******************************************************************************/
37 //static struct hacc_context hacc_ctx;
38
39 /******************************************************************************
40 * LOCAL FUNCTIONS
41 ******************************************************************************/
42
43 #if HACC_TEST
44 static void hacc_test(void)
45 {
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;
51
52 /* prepare data */
53 for (i = 0; i < test_sz; i++) {
54 test_src[i] = i + 1;
55 }
56
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);
61
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]);
65 DMSG(0);
66 }
67 }
68 DMSG("[%s] encrypt & descrypt unit test pass. (Key = %dbits)\n", MOD, test_keysz << 3);
69 }
70 #else
71 #define hacc_test() do{}while(0)
72 #endif
73
74 /******************************************************************************
75 * GLOBAL FUNCTIONS
76 ******************************************************************************/
77 #if 0
78 static U32 hacc_set_cfg(AES_CFG *cfg)
79 {
80 return SEC_OK;
81 }
82
83 static U32 hacc_set_mode(AES_MODE mode)
84 {
85 return SEC_OK;
86 }
87 #endif
88
89 U32 hacc_set_key(AES_KEY_ID id, AES_KEY key)
90 {
91 return SEC_OK;
92 }
93
94 U32 hacc_do_aes(AES_OPS ops, U8 *src, U8 *dst, U32 size)
95 {
96 return SEC_OK;
97 }
98
99 U32 hacc_deinit(void)
100 {
101 return SEC_OK;
102 }
103
104 U32 hacc_init(AES_KEY_SEED *keyseed)
105 {
106 return SEC_OK;
107 }
108