OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * Verified boot kernel utility | 5 * Verified boot kernel utility |
6 */ | 6 */ |
7 | 7 |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <getopt.h> | 9 #include <getopt.h> |
10 #include <inttypes.h> /* For PRIu64 */ | 10 #include <inttypes.h> /* For PRIu64 */ |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return rv; | 743 return rv; |
744 } | 744 } |
745 | 745 |
746 | 746 |
747 int main(int argc, char* argv[]) { | 747 int main(int argc, char* argv[]) { |
748 char* filename = NULL; | 748 char* filename = NULL; |
749 char* oldfile = NULL; | 749 char* oldfile = NULL; |
750 char* key_block_file = NULL; | 750 char* key_block_file = NULL; |
751 char* signpubkey = NULL; | 751 char* signpubkey = NULL; |
752 char* signprivate = NULL; | 752 char* signprivate = NULL; |
753 uint64_t version = 0; | 753 int version = -1; |
754 char* vmlinuz = NULL; | 754 char* vmlinuz = NULL; |
755 char* bootloader = NULL; | 755 char* bootloader = NULL; |
756 char* config_file = NULL; | 756 char* config_file = NULL; |
757 int vblockonly = 0; | 757 int vblockonly = 0; |
758 int verbose = 0; | 758 int verbose = 0; |
759 uint64_t pad = DEFAULT_PADDING; | 759 uint64_t pad = DEFAULT_PADDING; |
760 int mode = 0; | 760 int mode = 0; |
761 int parse_error = 0; | 761 int parse_error = 0; |
762 char* e; | 762 char* e; |
763 int i,r; | 763 int i,r; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 switch(mode) { | 855 switch(mode) { |
856 case OPT_MODE_PACK: | 856 case OPT_MODE_PACK: |
857 bp = NewBlob(version, vmlinuz, bootloader, config_file); | 857 bp = NewBlob(version, vmlinuz, bootloader, config_file); |
858 if (!bp) | 858 if (!bp) |
859 return 1; | 859 return 1; |
860 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly); | 860 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly); |
861 FreeBlob(bp); | 861 FreeBlob(bp); |
862 return r; | 862 return r; |
863 | 863 |
864 case OPT_MODE_REPACK: | 864 case OPT_MODE_REPACK: |
865 if (!config_file && !key_block_file && !version) { | 865 if (!config_file && !key_block_file && (version<0)) { |
866 fprintf(stderr, | 866 fprintf(stderr, |
867 "You must supply at least one of " | 867 "You must supply at least one of " |
868 "--config, --keyblock or --version\n"); | 868 "--config, --keyblock or --version\n"); |
869 return 1; | 869 return 1; |
870 } | 870 } |
871 | 871 |
872 bp = OldBlob(oldfile); | 872 bp = OldBlob(oldfile); |
873 if (!bp) | 873 if (!bp) |
874 return 1; | 874 return 1; |
875 r = ReplaceConfig(bp, config_file); | 875 r = ReplaceConfig(bp, config_file); |
876 if (!r) { | 876 if (!r) { |
877 if (version) { | 877 if (version >= 0) { |
878 bp->kernel_version = version; | 878 » » bp->kernel_version = (uint64_t) version; |
879 } | 879 } |
880 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly); | 880 r = Pack(filename, key_block_file, signprivate, bp, pad, vblockonly); |
881 } | 881 } |
882 FreeBlob(bp); | 882 FreeBlob(bp); |
883 return r; | 883 return r; |
884 | 884 |
885 case OPT_MODE_VERIFY: | 885 case OPT_MODE_VERIFY: |
886 return Verify(filename, signpubkey, verbose); | 886 return Verify(filename, signpubkey, verbose); |
887 | 887 |
888 default: | 888 default: |
889 fprintf(stderr, | 889 fprintf(stderr, |
890 "You must specify a mode: --pack, --repack or --verify\n"); | 890 "You must specify a mode: --pack, --repack or --verify\n"); |
891 return PrintHelp(progname); | 891 return PrintHelp(progname); |
892 } | 892 } |
893 } | 893 } |
OLD | NEW |