Files
OpenCellular/futility/file_type.h
Bill Richardson 64b3697297 futility: show some information about .pem files
We use the .pem files to generate our public and private key
files. Since we display the sha1sums of those files to help keep
track of them, we might as well also display the same information
about the RSA .pem files, too.

BUG=chromium:231574
BRANCH=none
TEST=make runtests

  futility show tests/testkeys/*.pem

Change-Id: Ibfd1e016d65981d477ed7d117d23dedf48b95873
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/246769
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-10 23:45:30 +00:00

58 lines
2.2 KiB
C

/*
* Copyright (c) 2013 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.
*/
#ifndef VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_
#define VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_
/* What type of things do I know how to handle? */
enum futil_file_type {
FILE_TYPE_UNKNOWN,
FILE_TYPE_PUBKEY, /* VbPublicKey */
FILE_TYPE_KEYBLOCK, /* VbKeyBlockHeader */
FILE_TYPE_FW_PREAMBLE, /* VbFirmwarePreambleHeader */
FILE_TYPE_GBB, /* GoogleBinaryBlockHeader */
FILE_TYPE_BIOS_IMAGE, /* Chrome OS BIOS image */
FILE_TYPE_OLD_BIOS_IMAGE, /* Old Chrome OS BIOS image */
FILE_TYPE_KERN_PREAMBLE, /* VbKernelPreambleHeader */
/* These are FILE_TYPE_UNKNOWN, but we've been told more about them */
FILE_TYPE_RAW_FIRMWARE, /* FW_MAIN_A, etc. */
FILE_TYPE_RAW_KERNEL, /* vmlinuz, *.uimg, etc. */
FILE_TYPE_CHROMIUMOS_DISK, /* At least it has a GPT */
FILE_TYPE_PRIVKEY, /* VbPrivateKey */
FILE_TYPE_VB2_PUBKEY, /* struct vb2_public_key */
FILE_TYPE_VB2_PRIVKEY, /* struct vb2_private_key */
FILE_TYPE_PEM, /* RSA .pem file */
NUM_FILE_TYPES
};
/* Names for them */
const char * const futil_file_type_str(enum futil_file_type type);
/*
* This tries to match the buffer content to one of the known file types.
*/
enum futil_file_type futil_file_type_buf(uint8_t *buf, uint32_t len);
/*
* This opens a file and tries to match it to one of the known file types.
* It's not an error if it returns FILE_TYPE_UKNOWN.
*/
enum futil_file_err futil_file_type(const char *filename,
enum futil_file_type *type);
/* Routines to identify particular file types. */
enum futil_file_type recognize_bios_image(uint8_t *buf, uint32_t len);
enum futil_file_type recognize_gbb(uint8_t *buf, uint32_t len);
enum futil_file_type recognize_vblock1(uint8_t *buf, uint32_t len);
enum futil_file_type recognize_gpt(uint8_t *buf, uint32_t len);
enum futil_file_type recognize_vb1_key(uint8_t *buf, uint32_t len);
enum futil_file_type recognize_vb2_key(uint8_t *buf, uint32_t len);
enum futil_file_type recognize_pem(uint8_t *buf, uint32_t len);
#endif /* VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_ */