@@ -39,6 +39,7 @@ static void exithelp(void) {
3939 "\t -d Decrypt\n"
4040 "\t -n No output (dry run)\n"
4141 "\t -c Without checksum signature\n"
42+ "\t -C Skip encryption/decryption\n"
4243 "\t -v VID:PID append DFU suffix (encrypt only)\n"
4344 );
4445 exit (0 );
@@ -129,16 +130,20 @@ int main(int argc, char **argv)
129130 int dir = 1 ;
130131 int crc = 1 ;
131132 int dry = 0 ;
133+ int enc = 1 ;
132134 char * infile = NULL ;
133135 char * outfile = NULL ;
134136 int c ;
135137 uint32_t vidpid = 0 ;
136138
137139 opterr = 0 ;
138140
139- while ((c = getopt (argc , argv , "edchni :o:v:" )) != -1 )
141+ while ((c = getopt (argc , argv , "edchnCi :o:v:" )) != -1 )
140142 switch (c )
141143 {
144+ case 'C' :
145+ enc = 0 ;
146+ break ;
142147 case 'e' :
143148 dir = 1 ;
144149 break ;
@@ -176,6 +181,11 @@ int main(int argc, char **argv)
176181 exithelp ();
177182 }
178183
184+ if (!enc && !crc ) {
185+ printf ("Nothing to do. Exiting.\n" );
186+ exit (0 );
187+ }
188+
179189 FILE * fi = fopen (infile , "rb" );
180190 if (fi == NULL ) {
181191 printf ("Failed to open file: %s\n" , argv [optind ]);
@@ -228,11 +238,15 @@ int main(int argc, char **argv)
228238#endif
229239
230240#if (DFU_CIPHER != _DISABLE )
231- if (length % aes_blksize ) {
232- length += (aes_blksize - (length % aes_blksize ));
241+ if (enc ) {
242+ if (length % aes_blksize ) {
243+ length += (aes_blksize - (length % aes_blksize ));
244+ }
245+ printf ("Encrypting %zd bytes using %s cipher.\n" , length , aes_name );
246+ aes_encrypt (buf , buf , length );
247+ } else {
248+ printf ("Skipping encryption.\n" );
233249 }
234- printf ("Encrypting %zd bytes using %s cipher.\n" , length , aes_name );
235- aes_encrypt (buf , buf , length );
236250#endif
237251
238252 if (vidpid != 0 ) {
@@ -253,8 +267,12 @@ int main(int argc, char **argv)
253267 } else {
254268
255269#if (DFU_CIPHER != _DISABLE )
256- printf ("Decrypting %zd bytes using %s cipher.\n" , length , aes_name );
257- aes_decrypt (buf , buf , length );
270+ if (enc ) {
271+ printf ("Decrypting %zd bytes using %s cipher.\n" , length , aes_name );
272+ aes_decrypt (buf , buf , length );
273+ } else {
274+ printf ("Skipping decryption.\n" );
275+ }
258276#endif
259277
260278#if (DFU_VERIFY_CHECKSUM != _DISABLE )
0 commit comments