aboutsummaryrefslogtreecommitdiffstats
path: root/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* core, w32: Add w64 handling for regkeysAndre Heinecke2018-05-171-3/+22
| | | | | | | | | | | | | | | * src/w32-util.c (_gpgme_get_gpg_path): Use new defines. (GNUPG_REGKEY_2): x64 aware regkey as used by GnuPG in Gpg4win 2.x (GNUPG_REGKEY_3): x64 aware regkey as used by GnuPG in Gpg4win 3.x (_gpgme_get_gpgconf_path): Use new regkeys. Add another fallback. -- This should fix more "unsupported protocol" issues if Gpg4win / GnuPG is installed in a non standard path on 64bit systems. The regkey handling is similar to that of gpgex and gpgol. GnuPG-Bug-Id: T3988
* core: Always fail if an OpenPG message is not integrity protected.Werner Koch2018-05-171-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | * src/decrypt.c (struct op_data_t): Add field not_integrity_protected. (parse_decryption_info): Set this. Also rename mode to aead_algo for clarity. (_gpgme_decrypt_status_handler): Force failure in case of a missing MDC. -- This extra check makes sure that a missing or stripped MDC in - gpg < 2.1 - or gpg 2.2 with an old cipher algorithm will lead to a decryption failure. gpg 2.3 will always fail in this case. Implementing this check here and not backporting the 2.3 change to 2.2 has the benefit that all GPGME using applications are protected but scripts relying on rfc2440 (i.e. without MDC) will only break when migrating to 2.3. Note that S/MIME has no integrity protection mechanism but gpgsm neither emits a DECRYPTION_INFO status line, so an error will not be triggered. If in the future gpgsm supports authenticated encryption it may issue a DECRYPTION_INFO line to force a failure here but it will in that case also emit a DECRYPTION_FAILED anyway. GnuPG-bug-id: 3981 Signed-off-by: Werner Koch <[email protected]>
* 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]>
* core: Make the status-fd monitor work for all gpgsm commands.Werner Koch2018-05-091-1/+10
| | | | | | | * src/engine-gpgsm.c (status_handler): Call the status monitor also here. Signed-off-by: Werner Koch <[email protected]>
* core: Do not modify args for ignored failuresAndre Heinecke2018-04-201-4/+3
| | | | | | | | | | | | | * src/op-support.c (_gpgme_parse_failure): Ignore gpg-exit failures before modifying args. -- For op_decrypt_verify the status handler for both decrypt and verify would parse the failure when the first parser ignored the failure. This resulted in an ERR_INV_ENGINE as the first call to parse_failure modified the args. GnuPG-Bug-Id: T3919
* core: Remove another debug output leftover.Werner Koch2018-04-201-1/+0
| | | | | | * src/decrypt.c (_gpgme_decrypt_status_handler): Remove log debug. Signed-off-by: Werner Koch <[email protected]>
* json: Remove the -noinstall flag used during development.Werner Koch2018-04-191-2/+0
| | | | | | | | * src/Makefile.am (gpgme-json_LDFLAGS): Remove. -- Reported-by: Alon Bar-Lev <[email protected]> Signed-off-by: Werner Koch <[email protected]>
* core: Remove leftover debug output.Werner Koch2018-04-191-1/+0
| | | | | | | | | | | | * src/verify.c (_gpgme_verify_status_handler): Remove debug output. -- Actually this is a real bug because it uses a debug function available only in the new libgpg-error versions. Time to call Jenkins back from vacation; there are rumors that he has been seen in the city looking for a new Ryzen tail coat. 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]>
* doc: Update copyright years and change two URLs.Werner Koch2018-04-182-2/+3
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* doc: Unify comment style in gpgme.hWerner Koch2018-04-181-160/+175
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* core: New convenience constant GPGME_KEYLIST_MODE_LOCATE.Werner Koch2018-04-182-2/+3
| | | | | | * 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]>
* core: Add 'is_mime' flags to the verify and decrypt results.Werner Koch2018-04-185-11/+32
| | | | | | | | | | | | | | | | | | | * src/op-support.c (_gpgme_parse_plaintext): Add arg r_mime. * src/decrypt.c (_gpgme_decrypt_status_handler): Ser mime flag. * src/verify.c (_gpgme_verify_status_handler): Ditto. * src/gpgme.h.in (gpgme_op_verify_result_t): Append fields 'is_mime' and '_unused'. (gpgme_op_decrypt_result_t): New field 'is_mime'. Shrink '_unused'. * tests/run-decrypt.c (print_result): Print MIME flag. * tests/run-verify.c (print_result): Ditto. -- Note that this flag (Liternal Data packet's 'm' mode) is only specified in RFC-4880bis. To use it you currently need to add "rfc4880bis" to the the gpg.conf. Signed-off-by: Werner Koch <[email protected]>
* core: Fix possible compliance mode detection error.Werner Koch2018-04-181-0/+1
| | | | | | | | | | | | | * src/verify.c (_gpgme_verify_status_handler): Insert missing break. -- Before the insertion of the compliance status checking the break in the default clause was used by the STATUS_PLAINTEXT code. That got lost. I don't see any actual harm due to different values currently in use for the compliance status. Fixes-commit: 05fa2a9c7764b28fdac35eb72631439df948ca0e 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: Extend decryption result with symkey_algo.Werner Koch2018-04-174-11/+114
| | | | | | | | | | | | | | | | | * src/gpgme.h.in (gpgme_op_decrypt_result_t): Add field 'symkey_algo'. * src/decrypt.c (release_op_data): Free SYMKEY_ALGO. (gpgme_op_decrypt_result): Make sure SYMKEY_ALGO is not NULL. (parse_decryption_info): New. (_gpgme_decrypt_status_handler): Parse DECRYPTION_INFO status. * src/conversion.c (_gpgme_cipher_algo_name): New. (_gpgme_cipher_mode_name): New. * tests/run-decrypt.c (print_result): Print SYMKEY_ALGO * src/util.h (_gpgme_map_gnupg_error): Remove obsolete prototype. -- Signed-off-by: Werner Koch <[email protected]>
* core: New keyword --file for OpenPGP recpstring.Werner Koch2018-04-171-3/+17
| | | | | | | | | | * src/engine-gpg.c (append_args_from_recipients_string): Add new flags. -- Now you can use gpgme to encrypt without first importing a key. Signed-off-by: Werner Koch <[email protected]>
* core: For OpenPGP let offline mode disable dirmngr.Werner Koch2018-04-171-5/+22
| | | | | | | | | | * src/engine-gpg.c (struct engine_gpg): New flag.offline. (gpg_set_engine_flags): Set it. Also fix setting of no_symkey_cache. (build_argv): Pass --disable-dirmngr in offline mode. -- GnuPG-bug-id: 3831 Signed-off-by: Werner Koch <[email protected]>
* core: Allow for --hidden keyword in OpenPGP recpstrings.Werner Koch2018-04-171-3/+9
| | | | | | | | | * src/engine-gpg.c (append_args_from_recipients_string): Add special keywords. -- GnuPG-bug-id: 3775 Signed-off-by: Werner Koch <[email protected]>
* core: New encryption flag GPGME_ENCRYPT_WANT_ADDRESS.Werner Koch2018-04-173-9/+80
| | | | | | | | | | | | * 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-1712-131/+405
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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]>
* core: Tweak STATUS_FAILURE handling.Werner Koch2018-04-121-1/+9
| | | | | | | | | * src/op-support.c (_gpgme_parse_failure): Ignore failures with location "gpg-exit". * tests/gpg/t-verify.c (main): Adjust for the now working checking of the second key. Signed-off-by: Werner Koch <[email protected]>
* core: For a failed verification return the sig's fingerprint.Werner Koch2018-04-121-2/+19
| | | | | | | | | | | * src/verify.c (parse_new_sig): Parse the new ERRSIG fpr. -- This works only when the signatures features an ISSUER_FPR sub-packet and with GnuPG >= 2.2.7. If that is not the case the keyid is kept in the FPR field. Signed-off-by: Werner Koch <[email protected]>
* core: Add new context flag "no-symkey-cache".Werner Koch2018-04-123-1/+33
| | | | | | | | | | | | | | | * src/gpgme.c (gpgme_set_ctx_flag): Set flag. (gpgme_get_ctx_flag): Get flag. * src/context.h (struct gpgme_context): Add field no_symkey_cache. * src/engine-gpg.c (struct engine_gpg): Ditto. (gpg_set_engine_flags): Set flag. (build_argv): Pass option --no-symkey-cache to gpg. * tests/run-decrypt.c (print_result): Fix segv for symmetric messages. (main): New option --no-symkey-cache. * tests/run-encrypt.c (main): New option --no-symkey-cache. 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]>
* core: Initialize key return value in gpgme_get_keyAndre Heinecke2018-03-271-0/+2
| | | | | | | | | | | | | | | | | * src/keylist.c (gpgme_get_key): Set r_key to NULL. -- The c++ bindings and others assumed that r_key is set to NULL on error. This is the behavior gpgme_op_keylist_next also has. Even if it is not specified what happens to r_key on error setting it to NULL should not hurt and is more expected behavior. This directly fixes an uninitialized memory access error in the c++ bindings / Kleopatra: GnuPG-Bug-Id: T3865 And will fix some additional random crashes in Kleopatra and GpgOL.
* core: Need to increase an array in the gpg engine.Werner Koch2018-03-231-1/+1
| | | | | | | * src/engine-gpg.c (build_argv): Allcate one slot more for ARGV. -- Fixes-commit: b9000bc293164ff62efa7e91e5cf6d5fc19d482f
* 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]>
* core: New gpgme_set_ctx_flag "request-origin".Werner Koch2018-03-2313-7/+149
| | | | | | | | | | | | | | | | | | | | | | | | * src/context.h (gpgme_context): Add 'request_origin'. * src/gpgme.c (gpgme_release): Free that field. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "request-origin". * src/engine-backend.h (engine_ops): Add 'set_engine_ops' func ptr and adjust all users. * src/engine.c (_gpgme_engine_set_engine_flags): New. * src/op-support.c (_gpgme_op_reset): Call that func. * src/engine-gpg.c (struct engine_gpg): Add 'request_origin'. (gpg_set_engine_flags): New. (_gpgme_engine_ops_gpg): Hook it. (build_argv): Use command line option --request-origin. * src/engine-gpgsm.c (struct engine_gpgsm): Add 'request_origin'. (gpgsm_set_engine_flags): New. (_gpgme_engine_ops_gpgsm): Hook it. (start): Send OPTION "request-origin". * src/engine-assuan.c (struct engine_llass): Add 'request_origin'. (gpgsm_set_engine_flags): New. (_gpgme_engine_ops_assuan): Hook it. (start): Send OPTION "pretend-request-origin". 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]>
* Merge branch 'json-tool'Werner Koch2018-03-235-2/+3195
|\
| * 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: Add a new function to cJSON.Werner Koch2018-03-232-0/+13
| | | | | | | | * src/cJSON.c (cJSON_CreateStringConvey): New.