tizen 2.4 release
[kernel/u-boot-tm1.git] / arch / arm / cpu / armv7 / tiger / sec_boot.c
1 #include <common.h>
2 #include <asm/arch/common.h>
3 #include <malloc.h>
4
5 #ifdef CONFIG_NAND_SPL
6 #define panic(x...) do{}while(0)
7 #define printf(x...) do{}while(0)
8 #endif
9 int test_rsa(void);
10 #if 1
11 //#ifdef CONFIG_NAND_SPL 
12 #define dump_all_buffer(x...) do{}while(0)
13 #else
14 void dump_all_buffer(unsigned char *buf, unsigned long len)
15 {
16     unsigned long row, col;
17     unsigned int offset;
18     unsigned long total_row, remain_col;
19     unsigned long flag = 1;
20
21     total_row = len / 16;
22     remain_col = len - total_row * 16;
23     offset = 0;
24     for (row = 0; row < total_row; row ++) {
25         if (flag == 1) {
26             printf("%08xh: ", offset);
27             for (col = 0; col < 16; col ++)
28                 printf("%02x ", buf[offset + col]);
29             printf("\n");
30         }
31         offset += 16;
32     }
33
34     if (remain_col > 0) {
35         if (flag == 1) {
36             printf("%08xh: ", offset);
37             for (col = 0; col < remain_col; col ++)
38                 printf("%02x ", buf[offset + col]);
39             printf("\n");
40         }
41     }
42
43     printf("\n");
44 }
45
46 #endif
47
48 #define MD5NUM_SZ (16)
49
50 typedef struct{
51         struct{
52                 uint32_t e;
53                 uint8_t m[128];
54                 uint8_t r2[128];
55         }key;
56         uint8_t reserved[4];
57 }bsc_info_t;
58
59 #define VLR_MAGIC (0x524c56ff)
60 typedef struct {
61         uint32_t magic;
62         uint8_t hash[128];
63         uint32_t setting;
64         uint32_t length;
65         uint8_t reserved[4];
66 }vlr_info_t;
67
68 typedef struct {
69         uint32_t *g_TraceValue;
70         uint8_t *efuse_harsh_data;
71         uint8_t *soft_harsh_data;
72         int (*CheckSecureBootEnable)(void);
73         int (*HarshVerify)(uint32_t *, uint32_t);
74         void (*RSA_ModPower)(uint32_t *p, uint32_t *m, uint32_t *r2, uint32_t e);
75         void (*MD5Init)(unsigned int *g_data_prt);
76         void (*MD5Final)(unsigned int *input, unsigned int inputLen, unsigned int *g_data_ptr);
77 }harsh_func_t;
78
79 const uint32_t __harsh_func_hack[] ={
80         0x40006000,
81         0x40006658,
82         0x40006668,
83         0xffff1405,
84         0xffff1481,
85         0xffff2604,
86         0xffff26ec,
87         0xffff314c,
88 };
89
90 /*
91  * p 128B
92  * m 128B
93  * r2 128B
94  * e 4B
95  */
96 #define MAKE_DWORD(a,b,c,d) (uint32_t)(((uint32_t)(a)<<24) | (uint32_t)(b)<<16 | ((uint32_t)(c)<<8) | ((uint32_t)(d)))
97
98 void RSA_Decrypt(unsigned char *p, unsigned char *m, unsigned char *r2, unsigned char *e)
99 {
100         return;
101 }
102
103 int secureboot_enabled(void)
104 {
105         return 0;
106 }
107 unsigned int md5_buf[20] = {0};
108 int harshVerify(uint8_t *data, uint32_t data_len, uint8_t *data_hash, uint8_t *data_key)
109 {
110         return 1;
111 }
112
113 void secure_check(uint8_t *data, uint32_t data_len, uint8_t *data_hash, uint8_t *data_key)
114 {
115         return;
116 }
117
118 #ifndef CONFIG_NAND_SPL
119 int cal_md5(void *data, uint32_t orig_len, void *harsh_data)
120 {
121         return 0;
122 }
123 #endif
124