aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpgme-json.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* json: Add additional commands to helpAndre Heinecke2018-05-251-0/+3
| | | | * src/gpgme-json.c (hlp_help): Add additional commands.
* json: Refactor signature and ei codeAndre Heinecke2018-05-251-162/+81
| | | | | | | | | | | | | | * src/gpgme-json.c (add_summary_to_object): Changed to: sigsum_to_json. (add_signature_to_object): Changed to signature_to_json. (add_signatures_to_object): Changed to verify_result_to_json. (add_ei_to_object): Changed to engine_info_to_json. (op_decrypt, op_verify, op_version): Use new functions. -- This pattern of gpgme_type to json object conversion is much cleaner then the error returning "add to object" functions.
* json: Implement keylistAndre Heinecke2018-05-251-18/+486
| | | | | | | | | | | | | | | | | | | * src/gpgme-json.c (xjson_AddStringToObject0) (xjson_AddItemToObject): New helpers. (sig_notation_to_json, key_sig_to_json, tofu_to_json) (uid_to_json, subkey_to_json, key_to_json): New GPGME to JSON functions. (op_keylist): New. (process_request): Add op_keylist. -- The conversion from GPGME data structures to JSON follow the same pattern for the keylist functions using the xjson wrappers instead of error checking every cJSON call. For large keylists the keylist command also needs a data / getmore handling somehow.
* json: Deduplicate input handling codeAndre Heinecke2018-05-251-184/+62
| | | | | | | | | * gpgme-json.c (get_string_data): New. (op_verify, op_sign, op_decrypt, op_encrypt): Use it. -- This handles the common base64 decoding and creation of the gpgme_data object.
* json: Add code to gpg_error based messagesAndre Heinecke2018-05-241-50/+104
| | | | | | | | | | * src/gpgme-json.c (gpg_error_object): New. (error_object_v): Extend to take error. -- Having the error code is helpful, especially as the strerrors are localized. E.g. to detect an ERROR_CANCELED.
* json: Implement op_versionAndre Heinecke2018-05-241-0/+86
| | | | | | * src/gpgme-json.c (op_version): New. (process_request): Extend for version. (protocol_to_string, add_ei_to_object): New helpers.
* json: Implement op_verifyAndre Heinecke2018-05-241-1/+158
| | | | | | | | | | * src/gpgme-json.c (op_verify): New. (hlp_help): Add verify. (process_request): Add verify. -- Mostly works, except for detached, base64 encoded signatures, they are somehow not yet written to gpgme.
* json: Put signature info before data outputAndre Heinecke2018-05-241-9/+9
| | | | | | | | * src/gpgme-json.c (op_decrypt): Move info before data. -- This should enable it to first parse signatures before handling very large chunks of data.
* json: Add sign to helpAndre Heinecke2018-05-241-0/+1
| | | | * src/gpgme-json.c (hlp_help): Add sign.
* json: Add op_signAndre Heinecke2018-05-241-0/+177
| | | | * src/gpgme-json.c (op_sign): New.
* json: Fix invalid function callAndre Heinecke2018-05-241-1/+1
| | | | | | | | | * src/gpgme-json.c (add_signatures_to_object): Fix call to xjson_CreateArray. -- That is what happens if you edit code while reviewing changes, without testing it again,..
* json: Print signatures for decrypt/verifyAndre Heinecke2018-05-241-0/+211
| | | | | | | | | * gpgme-json.c (xJSON_CreateArray), (add_summary_to_object, validity_to_string): New helpers. (add_signature_to_object, add_signatures_to_object) (add_signatures_object): New. (op_decrypt): Handle verify_result. (hlp_help): Mention decrypt.
* json: Minor typo fixesAndre Heinecke2018-05-241-3/+3
| | | | * src/gpgme-json.c: Minor typo fixes.
* json: Improve auto-base64 encoding to not split UTF-8 chars.Werner Koch2018-05-091-8/+14
| | | | | | | * src/gpgme-json.c (make_data_object): Switch to Base64 also for UTF-8 characters. Signed-off-by: Werner Koch <[email protected]>
* json: Add stpcpy replacement.Werner Koch2018-04-181-0/+13
| | | | | | * src/gpgme-json.c [!HAVE_STPCPY](_my_stpcpy): New. Signed-off-by: Werner Koch <[email protected]>
* core: New convenience constant GPGME_KEYLIST_MODE_LOCATE.Werner Koch2018-04-181-2/+1
| | | | | | * src/gpgme.h.in (GPGME_KEYLIST_MODE_LOCATE): New. Signed-off-by: Werner Koch <[email protected]>
* json: Add command "decrypt" to gpgme-json.Werner Koch2018-04-181-7/+139
| | | | | | | | | | * src/gpgme-json.c (make_data_object): Enable auto-detection of base-64. (op_encrypt): Support a 'mime' flag. (op_decrypt): New. (process_request): Add command "encrypt". Signed-off-by: Werner Koch <[email protected]>
* json: Improve help meta command in gpgme-json.Werner Koch2018-04-181-7/+17
| | | | | | * src/gpgme-json.c (process_meta_commands): Add ",help CMD". Signed-off-by: Werner Koch <[email protected]>
* json: Add command "getmore" to gpgme-json.Werner Koch2018-04-181-46/+228
| | | | | | | | | | | | | | | | | | | | | * src/gpgme-json.c (MIN_REPLY_CHUNK_SIZE): New const. (DEF_REPLY_CHUNK_SIZE): New const. (MAX_REPLY_CHUNK_SIZE): New const. (pending_data): New var. (add_base64_to_object): Chnage to take a plain data pointer. (get_chunksize): New. (make_data_object): New. (op_encrypt): Get chunksize and use make_data_object. (op_getmore): New. (process_request): Release pending data for all commands but "getmore" and "help". -- Native messaging has a limit on the data it may receive in one request. Thus the caller needs to watch for the "more" flag and request the remaining data using "getmore" in a loop. Signed-off-by: Werner Koch <[email protected]>
* json: Add meta command ,read to gpgme-json.Werner Koch2018-04-181-1/+58
| | | | | | | | * src/gpgme-json.c: Include stat.h. (get_file): New. (process_meta_commands): Implement ",read". Signed-off-by: Werner Koch <[email protected]>
* core: New encryption flag GPGME_ENCRYPT_WANT_ADDRESS.Werner Koch2018-04-171-0/+5
| | | | | | | | | | | | * src/gpgme.h.in (GPGME_ENCRYPT_WANT_ADDRESS): New flag. * src/engine-gpg.c (add_arg_recipient): New. (add_arg_recipient_string): New. (append_args_from_recipients): Call new helper function. (append_args_from_recipients_string): Ditto. * src/gpgme-json.c (op_encrypt): Add flag "want-address". -- Signed-off-by: Werner Koch <[email protected]>
* core: Add extended versions of the encrypt functions.Werner Koch2018-04-171-38/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme.h.in (gpgme_op_encrypt_ext_start) New. (gpgme_op_encrypt_ext): New. (gpgme_op_encrypt_sign_ext_start): New. (gpgme_op_encrypt_sign_ext): New. * src/libgpgme.vers, tests/run-encrypt.c: Add them. * src/encrypt.c (encrypt_start): Add arg recpstring. (gpgme_op_encrypt): Factor code out to ... (gpgme_op_encrypt_ext): new function with new arg recpstring. (gpgme_op_encrypt_start): Factor code out to ... (gpgme_op_encrypt_ext_start): new function with new arg recpstring. * src/encrypt-sign.c (encrypt_sign_start): Add arg recpstring. (gpgme_op_encrypt_sign): Factor code out to ... (gpgme_op_encrypt_sign_ext): new function with new arg recpstring. (gpgme_op_encrypt_sign_start): Factor code out to ... (gpgme_op_encrypt_sign_ext_start): new function with new arg recpstring. * src/engine-backend.h (struct engine_ops): Change fields encrypt and encrypt_sign. * src/engine.c (_gpgme_engine_op_encrypt): Add arg recpstring and pass to engine. (_gpgme_engine_op_encrypt_sign): Ditto. * src/engine-gpg.c (append_args_from_recipients_string): New. (gpg_encrypt): Add arg recpstring and call new function as needed. (gpg_encrypt_sign): Ditto. * src/engine-gpgsm.c (set_recipients_from_string): New. (gpgsm_encrypt): Add arg recpstring and call new function as needed. * src/engine-uiserver.c (set_recipients_from_string): New. (uiserver_encrypt): Add arg recpstring and call new function as needed. * tests/run-encrypt.c (xstrdup): New. (main): Add option --keystring. * src/gpgme-json.c (get_keys): Simplify. (op_encrypt): Modify to make use of the extended encrypt function. -- This new feature can be used to avoid the need for a key lookup and thus several extra calls to the backend. Note that run-test uses a semicolon as delimiter because that make testing the feature on the command line much easier. Signed-off-by: Werner Koch <[email protected]>
* json: Build only a dummy if libgpg-error is < 1.28Werner Koch2018-03-291-0/+5
| | | | Signed-off-by: Werner Koch <[email protected]>
* json: Remove the "message" object thingy again.Werner Koch2018-03-281-21/+9
| | | | | | | | | | * src/gpgme-json.c (process_request): Remove 'nm_mode'. -- This was an error in the javascript testing code. Thus the Mozilla specs are correct that the request is send verbatim. Signed-off-by: Werner Koch <[email protected]>
* json: Make native messaging work.Werner Koch2018-03-281-13/+64
| | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme-json.c (opt_debug): New. (process_request): Add optional arg nm_mode. In this mode take the request from a "message" object. (native_messaging_repl): Add debug output and call process_request in NM_MODE. (main): Add option --debug. Parse envvar GPGME_JSON_DEBUG as an alternative way to enable this. Use a default log file. -- Note that the default log file is ~/.gnupg/S.gpgme-json.log . Thus to debug a javascript application you should start watchgnupg --time-only --force ~/.gnupg/S.gpgme-json.log in a separate tty and then use GPGME_JSON_DEBUG=1 firefox & to run firefox. Signed-off-by: Werner Koch <[email protected]>
* json: Use a request origin of "browser".Werner Koch2018-03-231-0/+1
| | | | | | * src/gpgme-json.c (_create_new_context): Set flag. Signed-off-by: Werner Koch <[email protected]>
* build: Allow building with released libgpg-error.Werner Koch2018-03-231-0/+4
| | | | | | | * src/gpgme-json.c (add_base64_to_object): Return an error if building with an older libgpg-error. Signed-off-by: Werner Koch <[email protected]>
* json: Finish op:encrypt.Werner Koch2018-03-231-12/+171
| | | | | | | | | | * src/gpgme-json.c (add_base64_to_object): New. (data_from_base64_string): New. (op_encrypt): Employ them. (process_request): Print unformated json. -- Signed-off-by: Werner Koch <[email protected]>
* json: Use gpgrt_argparse instead of argsparse.cWerner Koch2018-03-211-7/+18
| | | | | | | | | | | * src/gpgme-json.c: Remove header argparse.h. Define GPGRT_ENABLE_ARGPARSE_MACROS. (interactive_repl): Replace strusage by gpgrt_strusage. (my_strusage): Add SPDX level. (main): Switch to gpgrt_argparse stuff but keep very limited functionality when building with an older libgpg-error. Signed-off-by: Werner Koch <[email protected]>
* json: Implement op:encryptWerner Koch2018-03-201-61/+393
| | | | Signed-off-by: Werner Koch <[email protected]>
* json: Add framework for the gpgme-json toolWerner Koch2018-03-161-0/+825
* src/gpgme-json.c: New. * src/Makefile.am (bin_PROGRAMS): Add gpgme-json. (gpgme_json_SOURCES, gpgme_json_LDADD): New. Signed-off-by: Werner Koch <[email protected]>