1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef MAR_CMDLINE_H__
6 #define MAR_CMDLINE_H__
8 /* We use NSPR here just to import the definition of uint32_t */
14 struct ProductInformationBlock
;
17 * Determines MAR file information.
19 * @param path The path of the MAR file to check.
20 * @param hasSignatureBlock Optional out parameter specifying if the MAR
21 * file has a signature block or not.
22 * @param numSignatures Optional out parameter for storing the number
23 * of signatures in the MAR file.
24 * @param hasAdditionalBlocks Optional out parameter specifying if the MAR
25 * file has additional blocks or not.
26 * @param offsetAdditionalBlocks Optional out parameter for the offset to the
27 * first additional block. Value is only valid if
28 * hasAdditionalBlocks is not equal to 0.
29 * @param numAdditionalBlocks Optional out parameter for the number of
30 * additional blocks. Value is only valid if
31 * has_additional_blocks is not equal to 0.
32 * @return 0 on success and non-zero on failure.
34 int get_mar_file_info(const char *path
,
35 int *hasSignatureBlock
,
36 uint32_t *numSignatures
,
37 int *hasAdditionalBlocks
,
38 uint32_t *offsetAdditionalBlocks
,
39 uint32_t *numAdditionalBlocks
);
42 * Reads the product info block from the MAR file's additional block section.
43 * The caller is responsible for freeing the fields in infoBlock
44 * if the return is successful.
46 * @param infoBlock Out parameter for where to store the result to
47 * @return 0 on success, -1 on failure
50 read_product_info_block(char *path
,
51 struct ProductInformationBlock
*infoBlock
);
54 * Refreshes the product information block with the new information.
55 * The input MAR must not be signed or the function call will fail.
57 * @param path The path to the MAR file whose product info block
58 * should be refreshed.
59 * @param infoBlock Out parameter for where to store the result to
60 * @return 0 on success, -1 on failure
63 refresh_product_info_block(const char *path
,
64 struct ProductInformationBlock
*infoBlock
);
67 * Writes out a copy of the MAR at src but with the signature block stripped.
69 * @param src The path of the source MAR file
70 * @param dest The path of the MAR file to write out that
71 has no signature block
72 * @return 0 on success
76 strip_signature_block(const char *src
, const char * dest
);
79 * Extracts a signature from a MAR file, base64 encodes it, and writes it out
81 * @param src The path of the source MAR file
82 * @param sigIndex The index of the signature to extract
83 * @param dest The path of file to write the signature to
84 * @return 0 on success
88 extract_signature(const char *src
, uint32_t sigIndex
, const char * dest
);
91 * Imports a base64 encoded signature into a MAR file
93 * @param src The path of the source MAR file
94 * @param sigIndex The index of the signature to import
95 * @param base64SigFile A file which contains the signature to import
96 * @param dest The path of the destination MAR file with replaced signature
97 * @return 0 on success
101 import_signature(const char *src
,
103 const char * base64SigFile
,
110 #endif /* MAR_CMDLINE_H__ */