Menu

Is it possible to add your custom revocation key to private key of the user?

2016-09-09
2016-09-12
  • Vitaliy Demchuk

    Vitaliy Demchuk - 2016-09-09

    Hello colleagues.
    Is it possible to add your custom revocation key to private key of the user?
    I'm trying to write a function:

    addRevocationKey: function() {
        var userKey = '12345678';
        var idRevocationKey = '12345678';
    
        var args = EnigmailGpg.getStandardArgs(false);
        args = args.concat(["--edit-key", userKey]);
        args = args.concat('addrevoker');
        args = args.concat(idRevocationKey);
        args = args.concat('y');
    
        var procBuilder = new EnigmailExecution.processBuilder();
        procBuilder.setCommand('pgp');
        procBuilder.setArguments(args);
        procBuilder.setEnvironment(EnigmailCore.getEnvList());
        var proc = procBuilder.build();
        subprocess.call(proc).wait();
      },
    

    And have error:

    Error: NS_ERROR_FILE_UNRECOGNIZED_PATH: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.initWithPath]
    Source: resource://enigmail/subprocess.jsm
    Line: 380
    

    Please, help.

     
  • Vitaliy Demchuk

    Vitaliy Demchuk - 2016-09-09

    I fix this error:

    addRevocationKey: function() {
        var args = EnigmailGpg.getStandardArgs(false);
        args = args.concat(["--edit-key", this.idUserKey]);
        args.push('addrevoker');
        args.push(this.idRevocationKey);
        args.push('y');
    
        var esvc = {};
        esvc.environment = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
        EnigmailGpgAgent.setAgentPath(window, esvc);
        var command = EnigmailGpgAgent.agentPath;
    
        var procBuilder = new EnigmailExecution.processBuilder();
        procBuilder.setCommand(command);
        procBuilder.setArguments(args);
        procBuilder.setEnvironment(EnigmailCore.getEnvList());
        var proc = procBuilder.build();
        subprocess.call(proc).wait();
      },
    

    But how i do command without terminal interaction?
    Current situation:

     

    Last edit: Vitaliy Demchuk 2016-09-09
  • Patrick Brunschwig

    You cannot do this by simply adding everything to the command line arguments. You have to implement a state machine that reacts on the output from gpg.

    You have to do it the same way as all other key editing commands in keyEditor.jsm. See for example how "adduid" is implemented.

     
  • Vitaliy Demchuk

    Vitaliy Demchuk - 2016-09-09

    I changed the code and got a new error :(

    Components.utils.import("resource://enigmail/keyEditor.jsm");
    
    var enigmailextended = {
      /* Last 8 FINGERPRINT characters */
      idRevocationKey: '12345678',
      idUserKey: '12345678',
    
      addRevocationKey: function() {
        EnigmailKeyEditor.addRevoker = function(parent, idUserKey, idRevocationKey, callbackFunc) {
          return editKey(parent, false, null, idUserKey, "addrevoker", {
              trustLevel: 2
            },
            this.addRevokerCallback,
            null,
            callbackFunc);
        };
    
        EnigmailKeyEditor.addRevoker(window,
          this.idUserKey,
          this.idRevocationKey,
          null
        );
      },
    
      addRevokerCallback: function(inputData, keyEdit, ret) {
        // some code ...
      },
    }
    

    Not understanding why the function editKey() does not work, but the functions are declared through const EnigmailKeyEditor work ..(example: EnigmailKeyEditor.addUid(...))

    Error: ReferenceError: editKey is not defined
    Source: chrome://enigmailextended/content/scripts/overlay.js
    
     
  • Patrick Brunschwig

    editKey is defined in keyEditor.jsm, and is not exported; you cannot access it from outside of keyEditor.jsm. Therefore, you can't do this in an overlay.

     
  • Vitaliy Demchuk

    Vitaliy Demchuk - 2016-09-12

    Thank you explained.

     

Log in to post a comment.