webpg-npapi 0.6.1
FB::variant webpgPluginAPI::gpgGenSubKeyWorker ( const std::string &  keyid,
const std::string &  subkey_type,
const std::string &  subkey_length,
const std::string &  subkey_expire,
bool  sign_flag,
bool  enc_flag,
bool  auth_flag,
void *  APIObj,
void(*)(void *self, const char *what, int type, int current, int total)  cb_status 
)

Creates a threaded worker to run the gpg keygen operation.

Parameters:
keyidThe ID of the key to create the subkey on.
subkey_typeThe subkey type to genereate.
subkey_lengthThe size of the subkey to generate.
subkey_expireThe expiration date to assign to the generated key.
sign_flagSet the sign capabilities flag.
enc_flagSet the encrypt capabilities flag.
auth_flagSet the auth capabilities flag.
APIObjA reference to webpgPluginAPI.
cb_statusThe progress callback for the operation.
subkey_typeThe subkey type to genereate.
subkey_lengthThe size of the subkey to generate.
subkey_expireThe expiration date to assign to the generated key.
sign_flagSet the sign capabilities flag.
enc_flagSet the encrypt capabilities flag.
APIObjA reference to webpgPluginAPI.
cb_statusThe progress callback for the operation.

Definition at line 2054 of file webpgPluginAPI.cpp.

References get_gpgme_ctx(), restoreGPGConfig(), and setTempGPGOption().

Referenced by threaded_gpgGenSubKey().

{

    // Set the option expert so we can access all of the subkey types
    setTempGPGOption("expert", "");

    gpgme_ctx_t ctx = get_gpgme_ctx();
    gpgme_error_t err;
    gpgme_data_t out = NULL;
    gpgme_key_t key = NULL;
    FB::VariantMap response;

    gen_subkey_type = subkey_type;
    gen_subkey_length = subkey_length;
    gen_subkey_expire = subkey_expire;
    gen_sign_flag = sign_flag;
    gen_enc_flag = enc_flag;
    gen_auth_flag = auth_flag;

    err = gpgme_op_keylist_start (ctx, keyid.c_str(), 0);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    err = gpgme_op_keylist_next (ctx, &key);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    err = gpgme_op_keylist_end (ctx);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    err = gpgme_data_new (&out);
    if (err != GPG_ERR_NO_ERROR)
        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);

    gpgme_set_progress_cb (ctx, cb_status, APIObj);

    edit_status = "gpgGenSubKeyWorker(keyid='" + keyid + "', subkey_type='" + subkey_type + 
        "', subkey_length='" + subkey_length + "', subkey_expire='" + subkey_expire + "', sign_flag='" + 
        i_to_str(sign_flag) + "', enc_flag='" + i_to_str(enc_flag) + "', auth_flag='" + 
        i_to_str(auth_flag) + "');\n";
    err = gpgme_op_edit (ctx, key, edit_fnc_add_subkey, out, out);

    if (err != GPG_ERR_NO_ERROR) {
        if (gpg_err_code(err) == GPG_ERR_CANCELED)
            this->FireEvent("onkeygencomplete", FB::variant_list_of("failed: cancelled"));
        else if (gpg_err_code(err) == GPG_ERR_BAD_PASSPHRASE)
            this->FireEvent("onkeygencomplete", FB::variant_list_of("failed: bad passphrase"));

        return get_error_map(__func__, gpgme_err_code (err), gpgme_strerror (err), __LINE__, __FILE__);
    }

    gpgme_data_release (out);
    gpgme_key_unref (key);
    gpgme_release (ctx);

    // Restore the options to normal
    restoreGPGConfig();

    const char* status = (char *) "complete";
    cb_status(APIObj, status, 33, 33, 33);
    return "done";
}

Here is the call graph for this function:

 All Classes Functions