LibreOffice Module onlineupdate (master) 1
|
Go to the source code of this file.
Classes | |
struct | ProductInformationBlock |
struct | MarItem_ |
The MAR item data structure. More... | |
struct | MarFile_ |
Macros | |
#define | MAX_SIGNATURES 8 |
#define | TABLESIZE 256 |
#define | MAR_MAX_CERT_SIZE (16*1024) |
Typedefs | |
typedef struct MarItem_ | MarItem |
The MAR item data structure. More... | |
typedef struct MarFile_ | MarFile |
typedef int(* | MarItemCallback) (MarFile *mar, const MarItem *item, void *data) |
Signature of callback function passed to mar_enum_items. More... | |
Functions | |
MOZ_STATIC_ASSERT (MAX_SIGNATURES<=9, "too many signatures") | |
MarFile * | mar_open (const char *path) |
Open a MAR file for reading. More... | |
void | mar_close (MarFile *mar) |
Close a MAR file that was opened using mar_open. More... | |
const MarItem * | mar_find_item (MarFile *mar, const char *item) |
Find an item in the MAR file by name. More... | |
int | mar_enum_items (MarFile *mar, MarItemCallback callback, void *data) |
Enumerate all MAR items via callback function. More... | |
int | mar_read (MarFile *mar, const MarItem *item, int offset, char *buf, int bufsize) |
Read from MAR item at given offset up to bufsize bytes. More... | |
int | mar_create (const char *dest, int numfiles, char **files, struct ProductInformationBlock *infoBlock) |
Create a MAR file from a set of files. More... | |
int | mar_extract (const char *path) |
Extract a MAR file to the current working directory. More... | |
int | mar_read_entire_file (const char *filePath, uint32_t maxSize, const uint8_t **data, uint32_t *size) |
int | mar_verify_signatures (MarFile *mar, const uint8_t *const *certData, const uint32_t *certDataSizes, uint32_t certCount) |
Verifies a MAR file by verifying each signature with the corresponding certificate. More... | |
int | mar_read_product_info_block (MarFile *mar, struct ProductInformationBlock *infoBlock) |
Reads the product info block from the MAR file's additional block section. More... | |
void mar_close | ( | MarFile * | mar | ) |
Close a MAR file that was opened using mar_open.
mar | The MarFile object to close. |
Definition at line 195 of file mar_read.c.
References MarFile_::fp, i, MarFile_::item_table, MarItem_::next, and TABLESIZE.
Referenced by ArchiveReader::Close(), main(), mar_extract(), mar_fpopen(), and mar_test().
int mar_create | ( | const char * | dest, |
int | num_files, | ||
char ** | files, | ||
struct ProductInformationBlock * | infoBlock | ||
) |
Create a MAR file from a set of files.
dest | The path to the file to create. This path must be compatible with fopen. |
numfiles | The number of files to store in the archive. |
files | The list of null-terminated file paths. Each file path must be compatible with fopen. |
infoBlock | The information to store in the product information block. |
Definition at line 293 of file mar_create.c.
References FILE, MarItemStack::head, HOST_TO_NETWORK64, htonl(), i, MarItemStack::last_offset, mar_concat_file(), mar_concat_product_info_block(), MAR_ID, MAR_ID_SIZE, mar_push(), MAX_SIZE_OF_MAR_FILE, NETWORK_TO_HOST64, ntohl(), remove(), and MarItemStack::size_used.
Referenced by main().
int mar_enum_items | ( | MarFile * | mar, |
MarItemCallback | callback, | ||
void * | data | ||
) |
Enumerate all MAR items via callback function.
mar | The MAR file to enumerate. |
callback | The function to call for each MAR item. |
data | A caller specified value that is passed along to the callback function. |
Definition at line 497 of file mar_read.c.
References i, MarFile_::item_table, MarItem_::next, and TABLESIZE.
Referenced by mar_extract(), and mar_test().
int mar_extract | ( | const char * | path | ) |
Extract a MAR file to the current working directory.
path | The path to the MAR file to extract. This path must be compatible with fopen. |
Definition at line 73 of file mar_extract.c.
References mar_close(), mar_enum_items(), mar_open(), mar_test_callback(), and NULL.
Referenced by main().
Find an item in the MAR file by name.
mar | The MarFile object to query. |
item | The name of the item to query. |
Definition at line 484 of file mar_read.c.
References MarFile_::item_table, mar_hash_name(), name, MarItem_::name, and MarItem_::next.
Referenced by ArchiveReader::ExtractFile(), and ArchiveReader::ExtractFileToStream().
MarFile * mar_open | ( | const char * | path | ) |
Open a MAR file for reading.
path | Specifies the path to the MAR file to open. This path must be compatible with fopen. |
Definition at line 167 of file mar_read.c.
References FILE, mar_fpopen(), and NULL.
Referenced by main(), mar_extract(), mar_test(), and ArchiveReader::Open().
Read from MAR item at given offset up to bufsize bytes.
mar | The MAR file to read. |
item | The MAR item to read. |
offset | The byte offset relative to the start of the item. |
buf | A pointer to a buffer to copy the data into. |
bufsize | The length of the buffer to copy the data into. |
Definition at line 514 of file mar_read.c.
References MarFile_::fp, MarItem_::length, and MarItem_::offset.
Referenced by ArchiveReader::ExtractItemToStream(), and mar_test_callback().
int mar_read_entire_file | ( | const char * | filePath, |
uint32_t | maxSize, | ||
const uint8_t ** | data, | ||
uint32_t * | size | ||
) |
int mar_read_product_info_block | ( | MarFile * | mar, |
struct ProductInformationBlock * | infoBlock | ||
) |
Reads the product info block from the MAR file's additional block section.
The caller is responsible for freeing the fields in infoBlock if the return is successful.
infoBlock | Out parameter for where to store the result to |
Definition at line 394 of file mar_read.c.
References MarFile_::fp, get_mar_file_info_fp(), i, ProductInformationBlock::MARChannelID, ntohl(), NULL, PRODUCT_INFO_BLOCK_ID, and ProductInformationBlock::productVersion.
Referenced by read_product_info_block(), and ArchiveReader::VerifyProductInformation().
int mar_verify_signatures | ( | MarFile * | mar, |
const uint8_t *const * | certData, | ||
const uint32_t * | certDataSizes, | ||
uint32_t | certCount | ||
) |
Verifies a MAR file by verifying each signature with the corresponding certificate.
That is, the first signature will be verified using the first certificate given, the second signature will be verified using the second certificate given, etc. The signature count must exactly match the number of certificates given, and all signature verifications must succeed. We do not check that the certificate was issued by any trusted authority. We assume it to be self-signed. We do not check whether the certificate is valid for this usage.
mar | The already opened MAR file. |
certData | Pointer to the first element in an array of certificate file data. |
certDataSizes | Pointer to the first element in an array for size of the cert data. |
certCount | The number of elements in certData and certDataSizes |
That is, the first signature will be verified using the first certificate given, the second signature will be verified using the second certificate given, etc. The signature count must exactly match the number of certificates given, and all signature verifications must succeed.
mar | The file who's signature should be calculated |
certData | Pointer to the first element in an array of certificate data |
certDataSizes | Pointer to the first element in an array for size of the data stored |
certCount | The number of elements in certData and certDataSizes |
Definition at line 136 of file mar_verify.c.
References CryptoX_Failed, CryptoX_FreePublicKey, CryptoX_InitCryptoProvider, CryptoX_InvalidHandleValue, CryptoX_LoadPublicKey, CryptoX_ProviderHandle, CryptoX_PublicKey, MarFile_::fp, mar_extract_and_verify_signatures_fp(), and MAX_SIGNATURES.
Referenced by main(), and VerifyLoadedCert().
MOZ_STATIC_ASSERT | ( | MAX_SIGNATURES<= | 9, |
"too many signatures" | |||
) |