File tree Expand file tree Collapse file tree 5 files changed +32
-7
lines changed
Expand file tree Collapse file tree 5 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ config OF_LIBFDT
107107 bool "Flattened Device Tree Support"
108108 default y
109109
110+ if SECURE
111+ config SECURE_FDT
112+ bool "Decrypt and verify Flattended Device Tree Blob"
113+ default n
114+ endif
115+
110116config OF_OVERRIDE_DTB_NAME
111117 string "Override Flattened Device Tree Blob filename"
112118 depends on OF_LIBFDT && SDCARD
Original file line number Diff line number Diff line change @@ -421,7 +421,7 @@ int load_kernel(struct image_info *image)
421421 bootargs = board_override_cmd_line_ext (image -> cmdline_args );
422422#endif
423423#if defined(CONFIG_SECURE )
424- ret = secure_check (image -> dest );
424+ ret = secure_check (image );
425425 if (ret )
426426 return ret ;
427427 image -> dest += sizeof (at91_secure_header_t );
@@ -441,6 +441,11 @@ int load_kernel(struct image_info *image)
441441 kernel_entry = (void (* )(int , int , unsigned int ))entry_point ;
442442
443443#ifdef CONFIG_OF_LIBFDT
444+
445+ #if defined(CONFIG_SECURE_FDT )
446+ image -> of_dest += sizeof (at91_secure_header_t );
447+ #endif
448+
444449 ret = setup_dt_blob ((char * )image -> of_dest );
445450 if (ret )
446451 return ret ;
Original file line number Diff line number Diff line change @@ -125,22 +125,36 @@ static void __attribute__((optimize("O0"))) wipe_keys()
125125 memset (iv , 0 , sizeof (iv ));
126126}
127127
128- int secure_check (void * data )
128+ int secure_check (struct image_info * image )
129129{
130130 const at91_secure_header_t * header ;
131131 void * file ;
132132 int ret = -1 ;
133133
134- if (secure_decrypt (data , sizeof (* header ), 0 ))
134+ if (secure_decrypt (image -> dest , sizeof (* header ), 0 ))
135135 goto secure_wipe_keys ;
136136
137- header = (const at91_secure_header_t * )data ;
137+ header = (const at91_secure_header_t * )image -> dest ;
138138 if (header -> magic != AT91_SECURE_MAGIC )
139139 goto secure_wipe_keys ;
140140
141- file = (unsigned char * )data + sizeof (* header );
141+ file = (unsigned char * )image -> dest + sizeof (* header );
142142 ret = secure_decrypt (file , header -> file_size , 1 );
143143
144+ #ifdef CONFIG_SECURE_FDT
145+ if (secure_decrypt (image -> of_dest , sizeof (* header ), 0 )) {
146+ goto secure_wipe_keys ;
147+ }
148+
149+ header = (const at91_secure_header_t * )image -> of_dest ;
150+ if (header -> magic != AT91_SECURE_MAGIC ) {
151+ goto secure_wipe_keys ;
152+ }
153+
154+ file = (unsigned char * )image -> of_dest + sizeof (* header );
155+ ret = secure_decrypt (file , header -> file_size , 1 );
156+ #endif
157+
144158secure_wipe_keys :
145159 wipe_keys ();
146160 return ret ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ typedef struct at91_secure_header {
1919 unsigned int reserved [2 ];
2020} at91_secure_header_t ;
2121
22- int secure_check (void * data );
22+ int secure_check (struct image_info * image );
2323
2424#if defined(CONFIG_OCMS_STATIC )
2525void ocms_init_keys (void );
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ int main(void)
127127
128128#if defined(CONFIG_SECURE )
129129 if (!ret )
130- ret = secure_check (image . dest );
130+ ret = secure_check (& image );
131131 image .dest += sizeof (at91_secure_header_t );
132132#endif
133133
You can’t perform that action at this time.
0 commit comments