diff options
author | Ivan Mikhaylov <fr0st61te@gmail.com> | 2023-03-08 04:13:39 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-03-15 01:08:51 +0300 |
commit | 4023dc9c95ccb5bcb3719c1c10e3d4dce967e0a2 (patch) | |
tree | fb4e2966687221cd1cba730be6446eb0e32bf6ed /tools/binman/etype/fit.py | |
parent | 0f40e23fd2282809f62d2be6ea4eb8c1d995a09b (diff) | |
download | u-boot-4023dc9c95ccb5bcb3719c1c10e3d4dce967e0a2.tar.xz |
binman: add sign option for binman
Introduce proof of concept for binman's new option which provides sign
and replace FIT containers in binary images.
Usage as example:
from:
mkimage -G privateky -r -o sha256,rsa4096 -F fit
binman replace -i flash.bin -f fit.fit fit
to:
binman sign -i flash.bin -k privatekey -a sha256,rsa4096 -f fit.fit fit
and to this one if it's need to be extracted, signed with key and put it
back in image:
binman sign -i flash.bin -k privatekey -a sha256,rsa4096 fit
Signed-off-by: Ivan Mikhaylov <fr0st61te@gmail.com>
Diffstat (limited to 'tools/binman/etype/fit.py')
-rw-r--r-- | tools/binman/etype/fit.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 03fe88e7a6..3aea9865bf 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -835,3 +835,21 @@ class Entry_fit(Entry_section): def CheckEntries(self): pass + + def UpdateSignatures(self, privatekey_fname, algo, input_fname): + uniq = self.GetUniqueName() + args = [ '-G', privatekey_fname, '-r', '-o', algo, '-F' ] + if input_fname: + fname = input_fname + else: + fname = tools.get_output_filename('%s.fit' % uniq) + tools.write_file(fname, self.GetData()) + args.append(fname) + + if self.mkimage.run_cmd(*args) is None: + # Bintool is missing; just use empty data as the output + self.record_missing_bintool(self.mkimage) + return + + data = tools.read_file(fname) + self.WriteData(data) |