blob: a94ff2c8deeeb681bb81e40052ddec6a84f033f9 [file] [log] [blame]
Bill Richardson25593382015-01-30 12:22:28 -08001/*
2 * Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6#ifndef VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_
7#define VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_
8
9/* What type of things do I know how to handle? */
10enum futil_file_type {
11 FILE_TYPE_UNKNOWN,
12 FILE_TYPE_PUBKEY, /* VbPublicKey */
13 FILE_TYPE_KEYBLOCK, /* VbKeyBlockHeader */
14 FILE_TYPE_FW_PREAMBLE, /* VbFirmwarePreambleHeader */
15 FILE_TYPE_GBB, /* GoogleBinaryBlockHeader */
16 FILE_TYPE_BIOS_IMAGE, /* Chrome OS BIOS image */
17 FILE_TYPE_OLD_BIOS_IMAGE, /* Old Chrome OS BIOS image */
18 FILE_TYPE_KERN_PREAMBLE, /* VbKernelPreambleHeader */
19
20 /* These are FILE_TYPE_UNKNOWN, but we've been told more about them */
21 FILE_TYPE_RAW_FIRMWARE, /* FW_MAIN_A, etc. */
22 FILE_TYPE_RAW_KERNEL, /* vmlinuz, *.uimg, etc. */
23
24 FILE_TYPE_CHROMIUMOS_DISK, /* At least it has a GPT */
Bill Richardson4805f182015-01-30 22:21:10 -080025 FILE_TYPE_PRIVKEY, /* VbPrivateKey */
Bill Richardson25593382015-01-30 12:22:28 -080026
27 NUM_FILE_TYPES
28};
29
30/* Names for them */
31const char * const futil_file_type_str(enum futil_file_type type);
32
33/*
34 * This tries to match the buffer content to one of the known file types.
35 */
36enum futil_file_type futil_file_type_buf(uint8_t *buf, uint32_t len);
37
38/*
39 * This opens a file and tries to match it to one of the known file types.
40 * It's not an error if it returns FILE_TYPE_UKNOWN.
41 */
42enum futil_file_err futil_file_type(const char *filename,
43 enum futil_file_type *type);
44
45/* Routines to identify particular file types. */
46enum futil_file_type recognize_bios_image(uint8_t *buf, uint32_t len);
47enum futil_file_type recognize_gbb(uint8_t *buf, uint32_t len);
48enum futil_file_type recognize_vblock1(uint8_t *buf, uint32_t len);
49enum futil_file_type recognize_gpt(uint8_t *buf, uint32_t len);
Bill Richardson4805f182015-01-30 22:21:10 -080050enum futil_file_type recognize_privkey(uint8_t *buf, uint32_t len);
Bill Richardson25593382015-01-30 12:22:28 -080051
52#endif /* VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_ */