LibreOffice Module onlineupdate (master) 1
Functions
mar_cmdline.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int get_mar_file_info (const char *path, int *hasSignatureBlock, uint32_t *numSignatures, int *hasAdditionalBlocks, uint32_t *offsetAdditionalBlocks, uint32_t *numAdditionalBlocks)
 Determines MAR file information. More...
 
int read_product_info_block (char *path, struct ProductInformationBlock *infoBlock)
 Reads the product info block from the MAR file's additional block section. More...
 
int refresh_product_info_block (const char *path, struct ProductInformationBlock *infoBlock)
 Refreshes the product information block with the new information. More...
 
int strip_signature_block (const char *src, const char *dest)
 Writes out a copy of the MAR at src but with the signature block stripped. More...
 
int extract_signature (const char *src, uint32_t sigIndex, const char *dest)
 Extracts a signature from a MAR file, base64 encodes it, and writes it out. More...
 
int import_signature (const char *src, uint32_t sigIndex, const char *base64SigFile, const char *dest)
 Imports a base64 encoded signature into a MAR file. More...
 

Function Documentation

◆ extract_signature()

int extract_signature ( const char *  src,
uint32_t  sigIndex,
const char *  dest 
)

Extracts a signature from a MAR file, base64 encodes it, and writes it out.

Parameters
srcThe path of the source MAR file
sigIndexThe index of the signature to extract
destThe path of file to write the signature to
Returns
0 on success -1 on error

Definition at line 489 of file mar_sign.c.

References FILE, i, ntohl(), NULL, remove(), and SIGNATURE_BLOCK_OFFSET.

Referenced by main().

◆ get_mar_file_info()

int get_mar_file_info ( const char *  path,
int hasSignatureBlock,
uint32_t *  numSignatures,
int hasAdditionalBlocks,
uint32_t *  offsetAdditionalBlocks,
uint32_t *  numAdditionalBlocks 
)

Determines MAR file information.

Parameters
pathThe path of the MAR file to check.
hasSignatureBlockOptional out parameter specifying if the MAR file has a signature block or not.
numSignaturesOptional out parameter for storing the number of signatures in the MAR file.
hasAdditionalBlocksOptional out parameter specifying if the MAR file has additional blocks or not.
offsetAdditionalBlocksOptional out parameter for the offset to the first additional block. Value is only valid if hasAdditionalBlocks is not equal to 0.
numAdditionalBlocksOptional out parameter for the number of additional blocks. Value is only valid if has_additional_blocks is not equal to 0.
Returns
0 on success and non-zero on failure.

Determines MAR file information.

Parameters
pathThe path of the MAR file to check.
hasSignatureBlockOptional out parameter specifying if the MAR file has a signature block or not.
numSignaturesOptional out parameter for storing the number of signatures in the MAR file.
hasAdditionalBlocksOptional out parameter specifying if the MAR file has additional blocks or not.
offsetAdditionalBlocksOptional out parameter for the offset to the first additional block. Value is only valid if hasAdditionalBlocks is not equal to 0.
numAdditionalBlocksOptional out parameter for the number of additional blocks. Value is only valid if has_additional_blocks is not equal to 0.
Returns
0 on success and non-zero on failure.

Definition at line 551 of file mar_read.c.

References FILE, and get_mar_file_info_fp().

Referenced by main(), mar_repackage_and_sign(), refresh_product_info_block(), and strip_signature_block().

◆ import_signature()

int import_signature ( const char *  src,
uint32_t  sigIndex,
const char *  base64SigFile,
const char *  dest 
)

Imports a base64 encoded signature into a MAR file.

Parameters
srcThe path of the source MAR file
sigIndexThe index of the signature to import
base64SigFileA file which contains the signature to import
destThe path of the destination MAR file with replaced signature
Returns
0 on success -1 on error

Definition at line 605 of file mar_sign.c.

References BLOCKSIZE, FILE, i, MAX_SIGNATURES, ntohl(), NULL, ReadAndWrite(), remove(), and SIGNATURE_BLOCK_OFFSET.

Referenced by main().

◆ read_product_info_block()

int read_product_info_block ( char *  path,
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.

Parameters
infoBlockOut parameter for where to store the result to
Returns
0 on success, -1 on failure

Definition at line 369 of file mar_read.c.

References MarFile_::fp, and mar_read_product_info_block().

Referenced by main().

◆ refresh_product_info_block()

int refresh_product_info_block ( const char *  path,
struct ProductInformationBlock infoBlock 
)

Refreshes the product information block with the new information.

The input MAR must not be signed or the function call will fail.

Parameters
pathThe path to the MAR file whose product info block should be refreshed.
infoBlockOut parameter for where to store the result to
Returns
0 on success, -1 on failure

Definition at line 193 of file mar_create.c.

References FILE, get_mar_file_info(), i, mar_concat_product_info_block(), ntohl(), NULL, and PRODUCT_INFO_BLOCK_ID.

Referenced by main().

◆ strip_signature_block()

int strip_signature_block ( const char *  src,
const char *  dest 
)

Writes out a copy of the MAR at src but with the signature block stripped.

Parameters
srcThe path of the source MAR file
destThe path of the MAR file to write out that has no signature block
Returns
0 on success -1 on error

Definition at line 255 of file mar_sign.c.

References AdjustIndexContentOffsets(), BLOCKSIZE, CryptoX_Error, FILE, get_mar_file_info(), HOST_TO_NETWORK64, htonl(), i, MAR_ID_SIZE, NETWORK_TO_HOST64, ntohl(), NULL, ReadAndWrite(), and remove().

Referenced by main().