]>
git.proxmox.com Git - grub2.git/blob - util/import_gcry.py
2 #* GRUB -- GRand Unified Bootloader
3 #* Copyright (C) 2009 Free Software Foundation, Inc.
5 #* GRUB is free software: you can redistribute it and/or modify
6 #* it under the terms of the GNU General Public License as published by
7 #* the Free Software Foundation, either version 3 of the License, or
8 #* (at your option) any later version.
10 #* GRUB is distributed in the hope that it will be useful,
11 #* but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #* GNU General Public License for more details.
15 #* You should have received a copy of the GNU General Public License
16 #* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
25 if len ( sys
. argv
) < 3 :
26 print ( "Usage: %s SOURCE DESTINATION" % sys
. argv
[ 0 ])
31 basedir
= os
. path
. join ( outdir
, "lib/libgcrypt-grub" )
35 print ( "WARNING: %s already exists" % basedir
)
36 cipher_dir_in
= os
. path
. join ( indir
, "cipher" )
37 cipher_dir_out
= os
. path
. join ( basedir
, "cipher" )
39 os
. makedirs ( cipher_dir_out
)
41 print ( "WARNING: %s already exists" % cipher_dir_out
)
42 mpidir
= os
. path
. join ( basedir
, "mpi" )
46 print ( "WARNING: %s already exists" % mpidir
)
48 srcdir
= os
. path
. join ( basedir
, "src" )
52 print ( "WARNING: %s already exists" % srcdir
)
54 cipher_files
= sorted ( os
. listdir ( cipher_dir_in
))
55 conf
= codecs
. open ( os
. path
. join ( "grub-core" , "Makefile.gcry.def" ), "w" , "utf-8" )
56 conf
. write ( "AutoGen definitions Makefile.tpl; \n\n " )
57 confutil
= codecs
. open ( "Makefile.utilgcry.def" , "w" , "utf-8" )
58 confutil
. write ( "AutoGen definitions Makefile.tpl; \n\n " )
59 confutil
. write ( "library = { \n " );
60 confutil
. write ( " name = libgrubgcry.a; \n " );
61 confutil
. write ( " cflags = '$(CFLAGS_GCRY)'; \n " );
62 confutil
. write ( " cppflags = '$(CPPFLAGS_GCRY)'; \n " );
63 confutil
. write ( " extra_dist = grub-core/lib/libgcrypt-grub/cipher/ChangeLog; \n " );
64 confutil
. write ( " \n " );
68 # Strictly speaking CRC32/CRC24 work on bytes so this value should be 1
69 # But libgcrypt uses 64. Let's keep the value for compatibility. Since
70 # noone uses CRC24/CRC32 for HMAC this is no problem
71 mdblocksizes
= { "_gcry_digest_spec_crc32" : 64 ,
72 "_gcry_digest_spec_crc32_rfc1510" : 64 ,
73 "_gcry_digest_spec_crc24_rfc2440" : 64 ,
74 "_gcry_digest_spec_md4" : 64 ,
75 "_gcry_digest_spec_md5" : 64 ,
76 "_gcry_digest_spec_rmd160" : 64 ,
77 "_gcry_digest_spec_sha1" : 64 ,
78 "_gcry_digest_spec_sha224" : 64 ,
79 "_gcry_digest_spec_sha256" : 64 ,
80 "_gcry_digest_spec_sha384" : 128 ,
81 "_gcry_digest_spec_sha512" : 128 ,
82 "_gcry_digest_spec_tiger" : 64 ,
83 "_gcry_digest_spec_tiger1" : 64 ,
84 "_gcry_digest_spec_tiger2" : 64 ,
85 "_gcry_digest_spec_whirlpool" : 64 }
87 cryptolist
= codecs
. open ( os
. path
. join ( cipher_dir_out
, "crypto.lst" ), "w" , "utf-8" )
89 # rijndael is the only cipher using aliases. So no need for mangling, just
91 cryptolist
. write ( "RIJNDAEL: gcry_rijndael \n " );
92 cryptolist
. write ( "RIJNDAEL192: gcry_rijndael \n " );
93 cryptolist
. write ( "RIJNDAEL256: gcry_rijndael \n " );
94 cryptolist
. write ( "AES128: gcry_rijndael \n " );
95 cryptolist
. write ( "AES-128: gcry_rijndael \n " );
96 cryptolist
. write ( "AES-192: gcry_rijndael \n " );
97 cryptolist
. write ( "AES-256: gcry_rijndael \n " );
99 cryptolist
. write ( "ADLER32: adler32 \n " );
100 cryptolist
. write ( "CRC64: crc64 \n " );
102 for cipher_file
in cipher_files
:
103 infile
= os
. path
. join ( cipher_dir_in
, cipher_file
)
104 outfile
= os
. path
. join ( cipher_dir_out
, cipher_file
)
105 if cipher_file
== "ChangeLog" or cipher_file
== "ChangeLog-2011" :
107 chlognew
= " * %s " % cipher_file
108 if re
. match ( "(Manifest|Makefile\.am|ac\.c|cipher\.c|hash-common\.c|hmac-tests\.c|md\.c|pubkey\.c)$" , cipher_file
) or cipher_file
== "kdf.c" or cipher_file
== "elgamal.c" or cipher_file
== "primegen.c" or cipher_file
== "ecc.c" or cipher_file
== "test-getrusage.c" :
109 chlog
= " %s%s : Removed \n " % ( chlog
, chlognew
)
111 # Autogenerated files. Not even worth mentionning in ChangeLog
112 if re
. match ( "Makefile\.in$" , cipher_file
):
115 if re
. match ( ".*\.[ch]$" , cipher_file
):
116 isc
= re
. match ( ".*\.c$" , cipher_file
)
117 f
= codecs
. open ( infile
, "r" , "utf-8" )
118 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
119 fw
. write ( "/* This file was automatically imported with \n " )
120 fw
. write ( " import_gcry.py. Please don't modify it */ \n " )
121 fw
. write ( "#include <grub/dl.h> \n " )
122 if cipher_file
== "camellia.h" :
123 fw
. write ( "#include <grub/misc.h> \n " )
124 fw
. write ( "void camellia_setup128(const unsigned char *key, grub_uint32_t *subkey); \n " )
125 fw
. write ( "void camellia_setup192(const unsigned char *key, grub_uint32_t *subkey); \n " )
126 fw
. write ( "void camellia_setup256(const unsigned char *key, grub_uint32_t *subkey); \n " )
127 fw
. write ( "void camellia_encrypt128(const grub_uint32_t *subkey, grub_uint32_t *io); \n " )
128 fw
. write ( "void camellia_encrypt192(const grub_uint32_t *subkey, grub_uint32_t *io); \n " )
129 fw
. write ( "void camellia_encrypt256(const grub_uint32_t *subkey, grub_uint32_t *io); \n " )
130 fw
. write ( "void camellia_decrypt128(const grub_uint32_t *subkey, grub_uint32_t *io); \n " )
131 fw
. write ( "void camellia_decrypt192(const grub_uint32_t *subkey, grub_uint32_t *io); \n " )
132 fw
. write ( "void camellia_decrypt256(const grub_uint32_t *subkey, grub_uint32_t *io); \n " )
133 fw
. write ( "#define memcpy grub_memcpy \n " )
134 # Whole libgcrypt is distributed under GPLv3+ or compatible
136 fw
. write ( "GRUB_MOD_LICENSE ( \" GPLv3+ \" ); \n " )
149 iscryptostart
= False
152 skip_statement
= False
154 modname
= cipher_file
[ 0 : len ( cipher_file
) - 2 ]
155 if re
. match ( ".*-glue$" , modname
):
156 modname
= modname
. replace ( "-glue" , "" )
158 modname
= "gcry_ %s " % modname
162 if not re
. search ( ";" , line
) is None :
163 skip_statement
= False
170 if not re
. search ( " *};" , line
) is None :
174 s
= re
. search ( " * \" ([A-Z0-9_a-z]*) \" " , line
)
177 cryptolist
. write (( " %s : %s \n " ) % ( sg
, modname
))
178 iscryptostart
= False
180 spl
= line
. split ( "," )
181 if mdarg
+ len ( spl
) > 9 and mdarg
<= 9 and ( "sizeof" in spl
[ 9 - mdarg
]):
182 mdctxsizes
. append ( spl
[ 9 - mdarg
]. lstrip (). rstrip ())
183 mdarg
= mdarg
+ len ( spl
) - 1
184 if ismd
or iscipher
or ispk
:
185 if not re
. search ( " *};" , line
) is None :
188 fw
. write ( "#ifdef GRUB_UTIL \n " );
189 fw
. write ( " .modname = \" %s \" , \n " % modname
);
190 fw
. write ( "#endif \n " );
192 if not ( mdname
in mdblocksizes
):
193 print ( "ERROR: Unknown digest blocksize: %s \n "
196 fw
. write ( " .blocksize = %s \n "
197 % mdblocksizes
[ mdname
])
202 iscomma
= not re
. search ( ",$" , line
) is None
203 # Used only for selftests.
204 m
= re
. match ( "(static byte|static unsigned char) (weak_keys_chksum)\[[0-9]*\] =" , line
)
207 fname
= m
. groups ()[ 1 ]
208 chmsg
= "( %s ): Removed." % fname
210 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
212 chlognew
= " %s %s " % ( chlognew
, chmsg
)
217 # We're optimising for size and exclude anything needing good
219 if not re
. match ( "(run_selftests|selftest|_gcry_aes_c.._..c|_gcry_[a-z0-9]*_hash_buffer|tripledes_set2keys|do_tripledes_set_extra_info|_gcry_rmd160_mixblock|serpent_test|dsa_generate_ext|test_keys|gen_k|sign|gen_x931_parm_xp|generate_x931|generate_key|dsa_generate|dsa_sign|ecc_sign|generate|generate_fips186|_gcry_register_pk_dsa_progress|_gcry_register_pk_ecc_progress|progress|scanval|ec2os|ecc_generate_ext|ecc_generate|compute_keygrip|ecc_get_param|_gcry_register_pk_dsa_progress|gen_x931_parm_xp|gen_x931_parm_xi|rsa_decrypt|rsa_sign|rsa_generate_ext|rsa_generate|secret|check_exponent|rsa_blind|rsa_unblind|extract_a_from_sexp|curve_free|curve_copy|point_set)" , line
) is None :
222 if not re
. match ( "selftest" , line
) is None and cipher_file
== "idea.c" :
225 if not re
. match ( "serpent_test" , line
) is None :
226 fw
. write ( "static const char *serpent_test (void) { return 0; } \n " );
227 if not re
. match ( "dsa_generate" , line
) is None :
228 fw
. write ( "#define dsa_generate 0" );
229 if not re
. match ( "ecc_generate" , line
) is None :
230 fw
. write ( "#define ecc_generate 0" );
231 if not re
. match ( "rsa_generate " , line
) is None :
232 fw
. write ( "#define rsa_generate 0" );
233 if not re
. match ( "rsa_sign" , line
) is None :
234 fw
. write ( "#define rsa_sign 0" );
235 if not re
. match ( "rsa_decrypt" , line
) is None :
236 fw
. write ( "#define rsa_decrypt 0" );
237 if not re
. match ( "dsa_sign" , line
) is None :
238 fw
. write ( "#define dsa_sign 0" );
239 if not re
. match ( "ecc_sign" , line
) is None :
240 fw
. write ( "#define ecc_sign 0" );
241 fname
= re
. match ( "[a-zA-Z0-9_]*" , line
). group ()
242 chmsg
= "( %s ): Removed." % fname
244 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
246 chlognew
= " %s %s " % ( chlognew
, chmsg
)
251 m
= re
. match ( "# *include <(.*)>" , line
)
253 chmsg
= "Removed including of %s " % m
. groups ()[ 0 ]
255 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
257 chlognew
= " %s : %s " % ( chlognew
, chmsg
)
260 m
= re
. match ( "gcry_cipher_spec_t" , line
)
261 if isc
and not m
is None :
264 assert ( not iscipher
)
265 assert ( not iscryptostart
)
266 ciphername
= line
[ len ( "gcry_cipher_spec_t" ):]. strip ()
267 ciphername
= re
. match ( "[a-zA-Z0-9_]*" , ciphername
). group ()
268 ciphernames
. append ( ciphername
)
272 m
= re
. match ( "gcry_pk_spec_t" , line
)
273 if isc
and not m
is None :
276 assert ( not iscipher
)
277 assert ( not iscryptostart
)
278 pkname
= line
[ len ( "gcry_pk_spec_t" ):]. strip ()
279 pkname
= re
. match ( "[a-zA-Z0-9_]*" , pkname
). group ()
280 pknames
. append ( pkname
)
284 m
= re
. match ( "gcry_md_spec_t" , line
)
285 if isc
and not m
is None :
288 assert ( not iscipher
)
289 assert ( not iscryptostart
)
290 mdname
= line
[ len ( "gcry_md_spec_t" ):]. strip ()
291 mdname
= re
. match ( "[a-zA-Z0-9_]*" , mdname
). group ()
292 mdnames
. append ( mdname
)
296 m
= re
. match ( "static const char \*selftest.*;$" , line
)
298 fname
= line
[ len ( "static const char \*" ):]
299 fname
= re
. match ( "[a-zA-Z0-9_]*" , fname
). group ()
300 chmsg
= "( %s ): Removed declaration." % fname
302 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
304 chlognew
= " %s %s " % ( chlognew
, chmsg
)
307 m
= re
. match ( "static gcry_mpi_t gen_k .*;$" , line
)
309 chmsg
= "(gen_k): Removed declaration."
311 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
313 chlognew
= " %s %s " % ( chlognew
, chmsg
)
316 m
= re
. match ( "static (int|void) test_keys .*;$" , line
)
318 chmsg
= "(test_keys): Removed declaration."
320 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
322 chlognew
= " %s %s " % ( chlognew
, chmsg
)
325 m
= re
. match ( "static void secret .*;$" , line
)
327 chmsg
= "(secret): Removed declaration."
329 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
331 chlognew
= " %s %s " % ( chlognew
, chmsg
)
334 m
= re
. match ( "static void \(\*progress_cb\).*;$" , line
)
336 chmsg
= "(progress_cb): Removed declaration."
338 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
340 chlognew
= " %s %s " % ( chlognew
, chmsg
)
343 m
= re
. match ( "static void \*progress_cb_data.*;$" , line
)
345 chmsg
= "(progress_cb): Removed declaration."
347 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
349 chlognew
= " %s %s " % ( chlognew
, chmsg
)
353 m
= re
. match ( "(static const char( |)\*|static gpg_err_code_t|void|static int|static gcry_err_code_t|static gcry_mpi_t|static void|void|static elliptic_curve_t) *$" , line
)
358 m
= re
. match ( "static int tripledes_set2keys \(.*\);" , line
)
361 m
= re
. match ( "static int tripledes_set3keys \(.*\);" , line
)
364 m
= re
. match ( "static int tripledes_set2keys \(" , line
)
366 skip_statement
= True
368 m
= re
. match ( "static int tripledes_set3keys \(" , line
)
370 skip_statement
= True
372 m
= re
. match ( "static const char sample_secret_key" , line
)
374 skip_statement
= True
376 m
= re
. match ( "static const char sample_public_key" , line
)
378 skip_statement
= True
380 m
= re
. match ( "static void sign|static gpg_err_code_t sign|static gpg_err_code_t generate" ,
383 skip_statement
= True
386 m
= re
. match ( "cipher_extra_spec_t" , line
)
387 if isc
and not m
is None :
389 fname
= line
[ len ( "cipher_extra_spec_t " ):]
390 fname
= re
. match ( "[a-zA-Z0-9_]*" , fname
). group ()
391 chmsg
= "( %s ): Removed." % fname
393 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
395 chlognew
= " %s %s " % ( chlognew
, chmsg
)
398 m
= re
. match ( "pk_extra_spec_t" , line
)
399 if isc
and not m
is None :
401 fname
= line
[ len ( "pk_extra_spec_t " ):]
402 fname
= re
. match ( "[a-zA-Z0-9_]*" , fname
). group ()
403 chmsg
= "( %s ): Removed." % fname
405 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
407 chlognew
= " %s %s " % ( chlognew
, chmsg
)
410 m
= re
. match ( "md_extra_spec_t" , line
)
411 if isc
and not m
is None :
413 fname
= line
[ len ( "md_extra_spec_t " ):]
414 fname
= re
. match ( "[a-zA-Z0-9_]*" , fname
). group ()
415 chmsg
= "( %s ): Removed." % fname
417 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
419 chlognew
= " %s %s " % ( chlognew
, chmsg
)
423 if len ( ciphernames
) > 0 or len ( mdnames
) > 0 or len ( pknames
) > 0 :
425 modfiles
= "lib/libgcrypt-grub/cipher/ %s lib/libgcrypt-grub/cipher/ %s " \
426 % ( cipher_file
, cipher_file
. replace ( "-glue.c" , ".c" ))
428 modfiles
= "lib/libgcrypt-grub/cipher/ %s " % cipher_file
429 if len ( ciphernames
) > 0 or len ( mdnames
) > 0 :
430 modules_sym_md
. append ( modname
)
431 chmsg
= "(GRUB_MOD_INIT( %s )): New function \n " % modname
433 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
435 chlognew
= " %s%s " % ( chlognew
, chmsg
)
437 fw
. write ( " \n\n GRUB_MOD_INIT( %s ) \n " % modname
)
439 for ciphername
in ciphernames
:
440 chmsg
= "Register cipher %s " % ciphername
441 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
442 fw
. write ( " grub_cipher_register (& %s ); \n " % ciphername
)
443 for ctxsize
in mdctxsizes
:
444 fw
. write ( " COMPILE_TIME_ASSERT( %s <= GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE); \n " % ctxsize
)
445 for mdname
in mdnames
:
446 chmsg
= "Register digest %s " % mdname
447 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
448 fw
. write ( " grub_md_register (& %s ); \n " % mdname
)
449 for pkname
in pknames
:
450 chmsg
= "Register pk %s " % mdname
451 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
452 fw
. write ( " grub_crypto_pk_ %s = & %s ; \n "
453 % ( pkname
. replace ( "_gcry_pubkey_spec_" , "" ), pkname
))
455 chmsg
= "(GRUB_MOD_FINI( %s )): New function \n " % modname
456 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
457 fw
. write ( " \n\n GRUB_MOD_FINI( %s ) \n " % modname
)
459 for ciphername
in ciphernames
:
460 chmsg
= "Unregister cipher %s " % ciphername
461 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
462 fw
. write ( " grub_cipher_unregister (& %s ); \n " % ciphername
)
463 for mdname
in mdnames
:
464 chmsg
= "Unregister MD %s " % mdname
465 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
466 fw
. write ( " grub_md_unregister (& %s ); \n " % mdname
)
467 for pkname
in pknames
:
468 chmsg
= "Unregister pk %s " % mdname
469 chlognew
= " %s \n %s " % ( chlognew
, chmsg
)
470 fw
. write ( " grub_crypto_pk_ %s = 0; \n "
471 % ( pkname
. replace ( "_gcry_pubkey_spec_" , "" )))
473 conf
. write ( "module = { \n " )
474 conf
. write ( " name = %s ; \n " % modname
)
475 for src
in modfiles
. split ():
476 conf
. write ( " common = %s ; \n " % src
)
477 if len ( ciphernames
) > 0 or len ( mdnames
) > 0 :
478 confutil
. write ( " common = grub-core/ %s ; \n " % src
)
479 if modname
== "gcry_ecc" :
480 conf
. write ( " common = lib/libgcrypt-grub/mpi/ec.c; \n " )
481 conf
. write ( " cflags = '$(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare'; \n " )
482 elif modname
== "gcry_rijndael" or modname
== "gcry_md4" or modname
== "gcry_md5" or modname
== "gcry_rmd160" or modname
== "gcry_sha1" or modname
== "gcry_sha256" or modname
== "gcry_sha512" or modname
== "gcry_tiger" :
483 # Alignment checked by hand
484 conf
. write ( " cflags = '$(CFLAGS_GCRY) -Wno-cast-align'; \n " );
486 conf
. write ( " cflags = '$(CFLAGS_GCRY)'; \n " );
487 conf
. write ( " cppflags = '$(CPPFLAGS_GCRY)'; \n " );
488 conf
. write ( "}; \n\n " )
492 chlog
= " %s%s \n " % ( chlog
, chlognew
)
493 elif isc
and cipher_file
!= "camellia.c" :
494 print ( "WARNING: C file isn't a module: %s " % cipher_file
)
498 chlog
= " %s \n * %s : Removed" % ( chlog
, cipher_file
)
500 chlog
= " %s%s Skipped unknown file \n " % ( chlog
, chlognew
)
501 print ( "WARNING: unknown file %s " % cipher_file
)
505 for src
in sorted ( os
. listdir ( os
. path
. join ( indir
, "src" ))):
506 if src
== "versioninfo.rc.in" or src
== "ath.c" or src
== "ChangeLog-2011" \
507 or src
== "dumpsexp.c" or src
== "fips.c" or src
== "gcrypt.h.in" \
508 or src
== "gcryptrnd.c" or src
== "getrandom.c" \
509 or src
== "global.c" or src
== "hmac256.c" \
510 or src
== "hwfeatures.c" or src
== "libgcrypt-config.in" \
511 or src
== "libgcrypt.def" or src
== "libgcrypt.m4" \
512 or src
== "libgcrypt.vers" or src
== "Makefile.am" \
513 or src
== "Manifest" or src
== "misc.c" \
514 or src
== "missing-string.c" or src
== "module.c" \
515 or src
== "secmem.c" or src
== "sexp.c" \
516 or src
== "stdmem.c" or src
== "visibility.c" :
518 outfile
= os
. path
. join ( basedir
, "src" , src
)
519 infile
= os
. path
. join ( indir
, "src" , src
)
520 if os
. path
. isdir ( infile
):
522 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
523 if src
== "gcrypt-module.h" :
526 if src
== "visibility.h" :
527 fw
. write ( "# include <grub/gcrypt/gcrypt.h> \n " )
530 f
= codecs
. open ( infile
, "r" , "utf-8" )
532 fw
. write ( f
. read (). replace ( "float f;" , "" ). replace ( "double g;" , "" ))
541 for src
in sorted ( os
. listdir ( os
. path
. join ( indir
, "mpi" ))):
542 if src
== "config.links" or src
== "ChangeLog-2011" \
543 or src
== "mpi-scan.c" or src
== "Manifest" \
544 or src
== "Makefile.am" :
546 infile
= os
. path
. join ( indir
, "mpi" , src
)
547 outfile
= os
. path
. join ( basedir
, "mpi" , src
)
548 if os
. path
. isdir ( infile
):
550 f
= codecs
. open ( infile
, "r" , "utf-8" )
551 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
552 fw
. write ( "/* This file was automatically imported with \n " )
553 fw
. write ( " import_gcry.py. Please don't modify it */ \n " )
563 # We're optimising for size and exclude anything needing good
565 if not re
. match ( "(_gcry_mpi_get_hw_config|gcry_mpi_randomize)" , line
) is None :
570 m
= re
. match ( "(const char( |)\*|void) *$" , line
)
575 m
= re
. match ( "#include \" mod-source-info\.h \" " , line
)
580 chlog
= " %s * crypto.lst: New file. \n " % chlog
582 outfile
= os
. path
. join ( cipher_dir_out
, "types.h" )
583 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
584 fw
. write ( "#include <grub/types.h> \n " )
585 fw
. write ( "#include <cipher_wrap.h> \n " )
586 chlog
= " %s * types.h: New file. \n " % chlog
589 outfile
= os
. path
. join ( cipher_dir_out
, "memory.h" )
590 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
591 fw
. write ( "#include <cipher_wrap.h> \n " )
592 chlog
= " %s * memory.h: New file. \n " % chlog
596 outfile
= os
. path
. join ( cipher_dir_out
, "cipher.h" )
597 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
598 fw
. write ( "#include <grub/crypto.h> \n " )
599 fw
. write ( "#include <cipher_wrap.h> \n " )
600 chlog
= " %s * cipher.h: Likewise. \n " % chlog
603 outfile
= os
. path
. join ( cipher_dir_out
, "g10lib.h" )
604 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
605 fw
. write ( "#include <cipher_wrap.h> \n " )
606 chlog
= " %s * g10lib.h: Likewise. \n " % chlog
609 infile
= os
. path
. join ( cipher_dir_in
, "ChangeLog" )
610 outfile
= os
. path
. join ( cipher_dir_out
, "ChangeLog" )
614 initfile
= codecs
. open ( os
. path
. join ( cipher_dir_out
, "init.c" ), "w" , "utf-8" )
615 initfile
. write ( "#include <grub/crypto.h> \n " )
616 for module
in modules_sym_md
:
617 initfile
. write ( "extern void grub_ %s _init (void); \n " % module
)
618 initfile
. write ( "extern void grub_ %s _fini (void); \n " % module
)
619 initfile
. write ( " \n " )
620 initfile
. write ( "void \n " )
621 initfile
. write ( "grub_gcry_init_all (void) \n " )
622 initfile
. write ( "{ \n " )
623 for module
in modules_sym_md
:
624 initfile
. write ( " grub_ %s _init (); \n " % module
)
625 initfile
. write ( "} \n " )
626 initfile
. write ( " \n " )
627 initfile
. write ( "void \n " )
628 initfile
. write ( "grub_gcry_fini_all (void) \n " )
629 initfile
. write ( "{ \n " )
630 for module
in modules_sym_md
:
631 initfile
. write ( " grub_ %s _fini (); \n " % module
)
632 initfile
. write ( "} \n " )
635 confutil
. write ( " common = grub-core/lib/libgcrypt-grub/cipher/init.c; \n " )
636 confutil
. write ( "}; \n " );
640 f
= codecs
. open ( infile
, "r" , "utf-8" )
641 fw
= codecs
. open ( outfile
, "w" , "utf-8" )
642 dt
= datetime
. date
. today ()
643 fw
. write ( " %0 4d- %0 2d- %0 2d Automatic import tool \n " % \
644 ( dt
. year
, dt
. month
, dt
. day
))
646 fw
. write ( " Imported ciphers to GRUB \n " )