B2G/gecko/modules/libmar/tests/unit/test_sign_verify.js
/**
   * Import a MAR signature.
   *
   * @param inMAR        The MAR file who's signature should be imported to
   * @param sigIndex     The index of the signature to import to
   * @param sigFile      The file where the base64 signature exists
   * @param outMAR       The same as inMAR but with the specified signature
   *                     swapped at the specified index.
   * @param wantSuccess  True if a successful signmar return code is desired
  */
Import a MAR signature.
@param inMAR        The MAR file who's signature should be imported to
@param sigIndex     The index of the signature to import to
@param sigFile      The file where the base64 signature exists
@param outMAR       The same as inMAR but with the specified signature
swapped at the specified index.
@param wantSuccess  True if a successful signmar return code is desired
Import a MAR signature . @param inMAR The MAR file who ' s signature should be imported to @param sigIndex The index of the signature to import to @param sigFile The file where the base64 signature exists @param outMAR The same as inMAR but with the specified signature swapped at the specified index . @param wantSuccess True if a successful signmar return code is desired
function importMARSignature(inMAR, sigIndex, sigFile, outMAR, wantSuccess) {
    let process = Cc["@mozilla.org/process/util;1"].
                  createInstance(Ci.nsIProcess);
    let signmarBin = do_get_file("signmar" + BIN_SUFFIX);
    do_check_true(signmarBin.exists());
    do_check_true(signmarBin.isExecutable());
    let args = ["-n" + sigIndex, "-I", inMAR.path, sigFile.path, outMAR.path];
    process.init(signmarBin);
    try {
      process.run(true, args, args.length);
    } catch(e) {
      process.exitValue = -1;
    }
    if (wantSuccess) {
      do_check_eq(process.exitValue, 0);
    } else {
      do_check_neq(process.exitValue, 0);
    }
  }
function importMARSignature ( inMAR , sigIndex , sigFile , outMAR , wantSuccess ) { let process = Cc [ "@mozilla.org/process/util;1" ] . createInstance ( Ci . nsIProcess ) ; let signmarBin = do_get_file ( "signmar" + BIN_SUFFIX ) ; do_check_true ( signmarBin . exists ( ) ) ; do_check_true ( signmarBin . isExecutable ( ) ) ; let args = [ "-n" + sigIndex , "-I" , inMAR . path , sigFile . path , outMAR . path ] ; process . init ( signmarBin ) ; try { process . run ( true , args , args . length ) ; } catch ( e ) { process . exitValue = - 1 ; } if ( wantSuccess ) { do_check_eq ( process . exitValue , 0 ) ; } else { do_check_neq ( process . exitValue , 0 ) ; } }
Import a MAR signature.
Import a MAR signature .
// Get a process to the signmar binary from the dist/bin directory. // Make sure the signmar binary exists and is an executable. // Setup the command line arguments to import the signature in the MAR. // On Windows negative return value throws an exception // Verify signmar returned 0 for success.