blob: eff0b8fbdd3397d85088385277742d13091937d8 [file] [log] [blame]
Daisuke Nojirie1741c52015-02-09 18:15:17 -08001/*
2 * Copyright (C) 2015 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14
15#ifndef _SECIMAGE_H_
16#define _SECIMAGE_H_
17
18#include <stdint.h>
19#include <sys/types.h>
20
21#define FIELD1_OFFSET 16
22#define FIELD2_OFFSET 18
23#define FIELD3_OFFSET 20
24#define FIELD4_OFFSET 36
25#define FIELD5_OFFSET 40
26#define FIELD6_OFFSET 44
27#define FIELD7_OFFSET 48
28#define FIELD8_OFFSET 50
29#define FIELD9_OFFSET 60
30
31typedef struct Header_t {
32 uint32_t Tag;
33 uint32_t Length;
34 uint32_t Reserved;
35 uint32_t crc;
36} HEADER;
37
38int DataWrite(char *filename, char *buf, int length);
39int DataRead(char *filename, uint8_t *buf, int *length);
40int AppendHMACSignature(uint8_t *data, uint32_t length, char *filename,
41 uint32_t offset);
42int ReadBinaryFile(char *fname, uint8_t *buf, int maxlen);
43uint32_t calc_crc32(uint32_t initval, uint8_t *charArr, uint32_t arraySize);
44void FillHeaderFromConfigFile(char *h, char *ConfigFileName);
45
46#endif /* _SECIMAGE_H_ */