summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-12-12 12:03:29 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-22 22:45:56 +0000
commitf242ad0f6fcfc9dc9195af06fe79301a9bd74113 (patch)
treeb567260051be820629c4fb19170e2297bfa034aa
parenta77541f94f731f5f7755264e9b49b7826aa48dfe (diff)
downloadvboot-f242ad0f6fcfc9dc9195af06fe79301a9bd74113.tar.gz
futility: remove obsolete dev_sign_file command
This wasn't being used anywhere, so out it goes. BUG=chromium:231457 BRANCH=none TEST=make runtests Change-Id: If3865f54ac29655ee7d520f00e618f490f25c619 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235481 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--Makefile3
-rw-r--r--futility/cmd_dev_sign_file.c355
-rw-r--r--futility/futility.c34
-rwxr-xr-xtests/futility/test_main.sh14
4 files changed, 1 insertions, 405 deletions
diff --git a/Makefile b/Makefile
index 9b1c2aaa..288752dd 100644
--- a/Makefile
+++ b/Makefile
@@ -567,9 +567,7 @@ FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
# These are the executables that are now built in to futility. We'll create
# symlinks for these so the old names will still work.
-# TODO: Do we still need dev_sign_file for anything?
FUTIL_SYMLINKS = \
- dev_sign_file \
dump_fmap \
dump_kernel_config \
gbb_utility \
@@ -586,7 +584,6 @@ FUTIL_STATIC_SRCS = \
FUTIL_SRCS = \
${FUTIL_STATIC_SRCS} \
- futility/cmd_dev_sign_file.c \
futility/cmd_dump_kernel_config.c \
futility/cmd_load_fmap.c \
futility/cmd_pcr.c \
diff --git a/futility/cmd_dev_sign_file.c b/futility/cmd_dev_sign_file.c
deleted file mode 100644
index d107bea0..00000000
--- a/futility/cmd_dev_sign_file.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/* Copyright 2011 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Developer file-signing utility
- */
-
-#include <errno.h>
-#include <getopt.h>
-#include <inttypes.h> /* For PRIu64 */
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "cryptolib.h"
-#include "futility.h"
-#include "host_common.h"
-#include "kernel_blob.h"
-#include "vboot_common.h"
-
-/* Command line options */
-enum {
- OPT_MODE_SIGN = 1000,
- OPT_MODE_VERIFY,
- OPT_KEYBLOCK,
- OPT_SIGNPRIVATE,
- OPT_VBLOCK,
-};
-
-static const struct option long_opts[] = {
- {"sign", 1, 0, OPT_MODE_SIGN},
- {"verify", 1, 0, OPT_MODE_VERIFY},
- {"keyblock", 1, 0, OPT_KEYBLOCK},
- {"signprivate", 1, 0, OPT_SIGNPRIVATE},
- {"vblock", 1, 0, OPT_VBLOCK},
- {"debug", 0, &debugging_enabled, 1},
- {NULL, 0, 0, 0}
-};
-
-/* Print help and return error */
-static void PrintHelp(const char *progname)
-{
- printf("\n"
- "Usage: " MYNAME " %s --sign <file> [PARAMETERS]\n"
- "\n"
- " Required parameters:\n"
- " --keyblock <file> Key block in .keyblock format\n"
- " --signprivate <file>"
- " Private key to sign file data,\n"
- " in .vbprivk format\n"
- " --vblock <file>"
- " Output signature in .vblock format\n"
- "\n", progname);
- printf("OR\n\n"
- "Usage: " MYNAME " %s --verify <file> [PARAMETERS]\n"
- "\n"
- " Required parameters:\n"
- " --vblock <file>"
- " Signature file in .vblock format\n"
- "\n"
- " Optional parameters:\n"
- " --keyblock <file>"
- " Extract .keyblock to file\n"
- "\n", progname);
-}
-
-/* Sign a file. We'll reuse the same structs used to sign kernels, to avoid
- having to declare yet another one for just this purpose. */
-static int Sign(const char *filename, const char *keyblock_file,
- const char *signprivate_file, const char *outfile)
-{
- uint8_t *file_data;
- uint64_t file_size;
- VbKeyBlockHeader *key_block;
- uint64_t key_block_size;
- VbPrivateKey *signing_key;
- VbSignature *body_sig;
- VbKernelPreambleHeader *preamble;
- FILE *output_fp;
-
- /* Read the file that we're going to sign. */
- file_data = ReadFile(filename, &file_size);
- if (!file_data) {
- VbExError("Error reading file to sign.\n");
- return 1;
- }
-
- /* Get the key block and read the private key corresponding to it. */
- key_block =
- (VbKeyBlockHeader *) ReadFile(keyblock_file, &key_block_size);
- if (!key_block) {
- VbExError("Error reading key block.\n");
- return 1;
- }
- signing_key = PrivateKeyRead(signprivate_file);
- if (!signing_key) {
- VbExError("Error reading signing key.\n");
- return 1;
- }
-
- /* Sign the file data */
- body_sig = CalculateSignature(file_data, file_size, signing_key);
- if (!body_sig) {
- VbExError("Error calculating body signature\n");
- return 1;
- }
-
- /* Create preamble */
- preamble = CreateKernelPreamble((uint64_t) 0,
- (uint64_t) 0,
- (uint64_t) 0,
- (uint64_t) 0,
- body_sig, (uint64_t) 0, signing_key);
- if (!preamble) {
- VbExError("Error creating preamble.\n");
- return 1;
- }
-
- /* Write the output file */
- Debug("writing %s...\n", outfile);
- output_fp = fopen(outfile, "wb");
- if (!output_fp) {
- VbExError("Can't open output file %s\n", outfile);
- return 1;
- }
- Debug("0x%" PRIx64 " bytes of key_block\n", key_block_size);
- Debug("0x%" PRIx64 " bytes of preamble\n", preamble->preamble_size);
- if ((1 != fwrite(key_block, key_block_size, 1, output_fp)) ||
- (1 != fwrite(preamble, preamble->preamble_size, 1, output_fp))) {
- VbExError("Can't write output file %s\n", outfile);
- fclose(output_fp);
- unlink(outfile);
- return 1;
- }
- fclose(output_fp);
-
- /* Done */
- free(preamble);
- free(body_sig);
- free(signing_key);
- free(key_block);
- free(file_data);
-
- /* Success */
- return 0;
-}
-
-static int Verify(const char *filename, const char *vblock_file,
- const char *keyblock_file)
-{
- uint8_t *file_data;
- uint64_t file_size;
- uint8_t *buf;
- uint64_t buf_size;
- VbKeyBlockHeader *key_block;
- VbKernelPreambleHeader *preamble;
- VbPublicKey *data_key;
- RSAPublicKey *rsa;
- uint64_t current_buf_offset = 0;
-
- /* Read the file that we're going to verify. */
- file_data = ReadFile(filename, &file_size);
- if (!file_data) {
- VbExError("Error reading file to sign.\n");
- return 1;
- }
-
- /* Read the vblock that we're going to use on it */
- buf = ReadFile(vblock_file, &buf_size);
- if (!buf) {
- VbExError("Error reading vblock_file.\n");
- return 1;
- }
-
- /* Find the key block */
- key_block = (VbKeyBlockHeader *) buf;
- Debug("Keyblock is 0x%" PRIx64 " bytes\n", key_block->key_block_size);
- current_buf_offset += key_block->key_block_size;
- if (current_buf_offset > buf_size) {
- VbExError
- ("key_block_size advances past the end of the buffer\n");
- return 1;
- }
-
- /* Find the preamble */
- preamble = (VbKernelPreambleHeader *) (buf + current_buf_offset);
- Debug("Preamble is 0x%" PRIx64 " bytes\n", preamble->preamble_size);
- current_buf_offset += preamble->preamble_size;
- if (current_buf_offset > buf_size) {
- VbExError
- ("preamble_size advances past the end of the buffer\n");
- return 1;
- }
-
- Debug("Current buf offset is at 0x%" PRIx64 " bytes\n",
- current_buf_offset);
-
- /* Check the key block (hash only) */
- if (0 != KeyBlockVerify(key_block, key_block->key_block_size,
- NULL, 1)) {
- VbExError("Error verifying key block.\n");
- return 1;
- }
-
- printf("Key block:\n");
- data_key = &key_block->data_key;
- printf(" Size: 0x%" PRIx64 "\n",
- key_block->key_block_size);
- printf(" Data key algorithm: %" PRIu64 " %s\n", data_key->algorithm,
- (data_key->algorithm <
- kNumAlgorithms ? algo_strings[data_key->
- algorithm] : "(invalid)"));
- printf(" Data key version: %" PRIu64 "\n", data_key->key_version);
- printf(" Flags: %" PRIu64 "\n",
- key_block->key_block_flags);
-
- /* Verify preamble */
- rsa = PublicKeyToRSA(&key_block->data_key);
- if (!rsa) {
- VbExError("Error parsing data key.\n");
- return 1;
- }
- if (0 != VerifyKernelPreamble(preamble, preamble->preamble_size, rsa)) {
- VbExError("Error verifying preamble.\n");
- return 1;
- }
-
- printf("Preamble:\n");
- printf(" Size: 0x%" PRIx64 "\n",
- preamble->preamble_size);
- printf(" Header version: %" PRIu32 ".%" PRIu32 "\n",
- preamble->header_version_major, preamble->header_version_minor);
- printf(" Kernel version: %" PRIu64 "\n",
- preamble->kernel_version);
- printf(" Body load address: 0x%" PRIx64 "\n",
- preamble->body_load_address);
- printf(" Body size: 0x%" PRIx64 "\n",
- preamble->body_signature.data_size);
- printf(" Bootloader address: 0x%" PRIx64 "\n",
- preamble->bootloader_address);
- printf(" Bootloader size: 0x%" PRIx64 "\n",
- preamble->bootloader_size);
-
- /* Verify body */
- if (0 !=
- VerifyData(file_data, file_size, &preamble->body_signature, rsa)) {
- VbExError("Error verifying kernel body.\n");
- return 1;
- }
- printf("Body verification succeeded.\n");
-
- if (keyblock_file) {
- if (0 !=
- WriteFile(keyblock_file, key_block,
- key_block->key_block_size)) {
- VbExError("Unable to export keyblock file\n");
- return 1;
- }
- printf("Key block exported to %s\n", keyblock_file);
- }
-
- return 0;
-}
-
-static int do_dev_sign_file(int argc, char *argv[])
-{
- char *filename = NULL;
- char *keyblock_file = NULL;
- char *signprivate_file = NULL;
- char *vblock_file = NULL;
- int mode = 0;
- int parse_error = 0;
- int option_index;
-
- while ((option_index =
- getopt_long(argc, argv, ":", long_opts, NULL)) != -1
- && !parse_error) {
- switch (option_index) {
- default:
- case '?':
- /* Unhandled option */
- parse_error = 1;
- break;
-
- case 0:
- /* silently handled option */
- break;
-
- case OPT_MODE_SIGN:
- case OPT_MODE_VERIFY:
- if (mode && (mode != option_index)) {
- fprintf(stderr,
- "Only one mode can be specified\n");
- parse_error = 1;
- break;
- }
- mode = option_index;
- filename = optarg;
- break;
-
- case OPT_KEYBLOCK:
- keyblock_file = optarg;
- break;
-
- case OPT_SIGNPRIVATE:
- signprivate_file = optarg;
- break;
-
- case OPT_VBLOCK:
- vblock_file = optarg;
- break;
- }
- }
-
- if (parse_error) {
- PrintHelp(argv[0]);
- return 1;
- }
-
- switch (mode) {
- case OPT_MODE_SIGN:
- if (!keyblock_file || !signprivate_file || !vblock_file) {
- fprintf(stderr, "Some required options are missing\n");
- PrintHelp(argv[0]);
- return 1;
- }
- return Sign(filename, keyblock_file, signprivate_file,
- vblock_file);
-
- case OPT_MODE_VERIFY:
- if (!vblock_file) {
- fprintf(stderr, "Some required options are missing\n");
- PrintHelp(argv[0]);
- return 1;
- }
- return Verify(filename, vblock_file, keyblock_file);
-
- default:
- fprintf(stderr, "You must specify either --sign or --verify\n");
- PrintHelp(argv[0]);
- return 1;
- }
-
- /* NOTREACHED */
- return 1;
-}
-
-DECLARE_FUTIL_COMMAND(dev_sign_file, do_dev_sign_file,
- "Sign or verify dev-mode files (DEPRECATED)",
- PrintHelp);
diff --git a/futility/futility.c b/futility/futility.c
index d710fdce..ba9fb163 100644
--- a/futility/futility.c
+++ b/futility/futility.c
@@ -248,31 +248,6 @@ DECLARE_FUTIL_COMMAND(version, do_version,
"Show the futility source revision and build date",
NULL);
-/*
- * These are built-in functions that we'd like to abandon completely someday.
- * TODO: If no one complains, get rid of them.
- */
-static const char *const dep_cmds[] = {
- "dev_sign_file",
-};
-
-static const char *const dep_usage = "\n"
-"The program \"%s\" is deprecated and may go away soon.\n"
-"\n"
-"If you feel this is in error, please open a bug at\n"
-"\n"
-" http://dev.chromium.org/for-testers/bug-reporting-guidelines\n"
-"\n"
-"In the meantime, you may continue to use the program by invoking it as\n"
-"\n" MYNAME " %s [...]\n"
-"\n";
-
-static int deprecated(const char *depname)
-{
- fprintf(stderr, dep_usage, depname, depname);
- return 1;
-}
-
int run_command(const struct futil_cmd_t *cmd, int argc, char *argv[])
{
/* Handle the "CMD --help" case ourselves */
@@ -301,7 +276,6 @@ int main(int argc, char *argv[], char *envp[])
{
char *progname;
const struct futil_cmd_t *cmd;
- int i;
log_args(argc, argv);
@@ -310,14 +284,8 @@ int main(int argc, char *argv[], char *envp[])
/* See if the program name is a command we recognize */
cmd = find_command(progname);
- if (cmd) {
- /* Block any deprecated functions invoked directly. */
- for (i = 0; i < ARRAY_SIZE(dep_cmds); i++)
- if (0 == strcmp(dep_cmds[i], progname))
- return deprecated(progname);
-
+ if (cmd)
return run_command(cmd, argc, argv);
- }
/* The program name means nothing, so we require an argument. */
if (argc < 2) {
diff --git a/tests/futility/test_main.sh b/tests/futility/test_main.sh
index 83fc53db..9ed72d79 100755
--- a/tests/futility/test_main.sh
+++ b/tests/futility/test_main.sh
@@ -25,20 +25,6 @@ grep ${FUTILITY} ${LOG}
rm -f ${LOG}
[ -f ${LOG}.backup ] && mv ${LOG}.backup ${LOG}
-# Make sure deprecated functions fail via symlink
-DEPRECATED="dev_sign_file"
-
-for i in $DEPRECATED; do
- ln -sf ${FUTILITY} $i
- if ./$i 2>${TMP}.outmsg ; then false; fi
- grep deprecated ${TMP}.outmsg
- # They may still fail when invoked through futility
- # but with a different error message.
- ${FUTILITY} $i 1>${TMP}.outmsg2 2>&1 || true
- if grep deprecated ${TMP}.outmsg2; then false; fi
- rm -f $i
-done
-
# Use some known digests to verify that things work...
DEVKEYS=${SRCDIR}/tests/devkeys
SHA=e78ce746a037837155388a1096212ded04fb86eb