B2G/gecko/modules/libmar/tests/unit/test_sign_verify.js
/**
   * Signs a MAR file.
   *
   * @param inMAR The MAR file that should be signed
   * @param outMAR The MAR file to create
  */
Signs a MAR file.
@param inMAR The MAR file that should be signed
@param outMAR The MAR file to create
Signs a MAR file . @param inMAR The MAR file that should be signed @param outMAR The MAR file to create
function signMAR(inMAR, outMAR, certs, wantSuccess, useShortHandCmdLine) {
    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 NSSConfigDir = do_get_file("data");
    let args = ["-d", NSSConfigDir.path];
    if (certs.length == 1 && useShortHandCmdLine) {
      args.push("-n", certs[0]);
    } else {
      for (i = 0; i < certs.length; i++) {
        args.push("-n" + i, certs[i]);
      }
    }
    args.push("-s", inMAR.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 signMAR ( inMAR , outMAR , certs , wantSuccess , useShortHandCmdLine ) { 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 NSSConfigDir = do_get_file ( "data" ) ; let args = [ "-d" , NSSConfigDir . path ] ; if ( certs . length == 1 && useShortHandCmdLine ) { args . push ( "-n" , certs [ 0 ] ) ; } else { for ( i = 0 ; i < certs . length ; i ++ ) { args . push ( "-n" + i , certs [ i ] ) ; } } args . push ( "-s" , inMAR . 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 ) ; } }
Signs a MAR file.
Signs a MAR file .
// 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 sign the MAR. // On Windows negative return value throws an exception // Verify signmar returned 0 for success.