tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mar_cmdline.h (3941B)


      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/. */
      4 
      5 #ifndef MAR_CMDLINE_H__
      6 #define MAR_CMDLINE_H__
      7 
      8 /* We use NSPR here just to import the definition of uint32_t */
      9 
     10 #ifdef __cplusplus
     11 extern "C" {
     12 #endif
     13 
     14 struct ProductInformationBlock;
     15 
     16 /**
     17 * Determines MAR file information.
     18 *
     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.
     33 */
     34 int get_mar_file_info(const char* path, int* hasSignatureBlock,
     35                      uint32_t* numSignatures, int* hasAdditionalBlocks,
     36                      uint32_t* offsetAdditionalBlocks,
     37                      uint32_t* numAdditionalBlocks);
     38 
     39 /**
     40 * Reads the product info block from the MAR file's additional block section.
     41 * The caller is responsible for freeing the fields in infoBlock
     42 * if the return is successful.
     43 *
     44 * @param infoBlock Out parameter for where to store the result to
     45 * @return 0 on success, -1 on failure
     46 */
     47 int read_product_info_block(char* path,
     48                            struct ProductInformationBlock* infoBlock);
     49 
     50 /**
     51 * Refreshes the product information block with the new information.
     52 * The input MAR must not be signed or the function call will fail.
     53 *
     54 * @param path             The path to the MAR file whose product info block
     55 *                         should be refreshed.
     56 * @param infoBlock        Out parameter for where to store the result to
     57 * @return 0 on success, -1 on failure
     58 */
     59 int refresh_product_info_block(const char* path,
     60                               struct ProductInformationBlock* infoBlock);
     61 
     62 /**
     63 * Writes out a copy of the MAR at src but with the signature block stripped.
     64 *
     65 * @param  src  The path of the source MAR file
     66 * @param  dest The path of the MAR file to write out that
     67                has no signature block
     68 * @return 0 on success
     69 *         -1 on error
     70 */
     71 int strip_signature_block(const char* src, const char* dest);
     72 
     73 /**
     74 * Extracts a signature from a MAR file, base64 encodes it, and writes it out
     75 *
     76 * @param  src       The path of the source MAR file
     77 * @param  sigIndex  The index of the signature to extract
     78 * @param  dest      The path of file to write the signature to
     79 * @return 0 on success
     80 *         -1 on error
     81 */
     82 int extract_signature(const char* src, uint32_t sigIndex, const char* dest);
     83 
     84 /**
     85 * Imports a base64 encoded signature into a MAR file
     86 *
     87 * @param  src           The path of the source MAR file
     88 * @param  sigIndex      The index of the signature to import
     89 * @param  base64SigFile A file which contains the signature to import
     90 * @param  dest          The path of the destination MAR file with replaced
     91 *                       signature
     92 * @return 0 on success
     93 *         -1 on error
     94 */
     95 int import_signature(const char* src, uint32_t sigIndex,
     96                     const char* base64SigFile, const char* dest);
     97 
     98 #ifdef __cplusplus
     99 }
    100 #endif
    101 
    102 #endif /* MAR_CMDLINE_H__ */