aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpgme-json.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* json: Add information about revocation keys to key list resultIngo Klöcker2024-05-211-0/+28
| | | | | | | | | | | | | | * src/gpgme-json.c (revocation_key_to_json): New. (key_to_json): Add list of revocation keys. * tests/json/Makefile.am (pubring-stamp): Import new pub key. * tests/json/key-with-revokers.asc: New. * tests/json/t-json.c (tests): Add "t-keylist-revokers". * tests/json/t-keylist-revokers.in.json, tests/json/t-keylist-revokers.in.json: New. -- GnuPG-bug-id: 7118
* json: New operation "identify" and convenience option --identify.Werner Koch2023-01-311-1/+126
| | | | | | | | | * src/gpgme-json.c (data_type_to_string): New. (op_identify): New. (process_request): Add to command list. (cmd_identify): New. (main): Add option --identify. --
* core: Support --locate-external-keys command of gpgIngo Klöcker2022-04-271-0/+5
| | | | | | | | | | | | | | * src/gpgme.h.in (GPGME_KEYLIST_MODE_FORCE_EXTERN): New. (GPGME_KEYLIST_MODE_LOCATE_EXTERNAL): New. * src/gpgme.c (gpgme_set_keylist_mode): Check for invalid mode. * src/engine-gpg.c (gpg_keylist_build_options): Use "--locate-external-keys" instead of "--locate-keys" if flag is set. * src/gpgme-json.c (op_keylist): New flag "force-extern". * src/gpgme-tool.c (gt_get_keylist_mode, cmd_keylist_mode): Handle new mode. -- GnuPG-bug-id: 5951
* Require at least libgpg-error 1.36Werner Koch2020-11-091-24/+0
| | | | | | | | | | | | | | | | * configure.ac (NEED_GPG_ERROR_VERSION): Require 1.36. * src/cJSON.c: Remove code for older version. * src/engine.c (gpgme_get_engine_info): Ditto. * src/gpgme-json.c: Ditto. * src/op-support.c: Ditto. * src/util.h: Ditto. -- Libgpg-error 1.36 has been released more than 18 months ago so it is time to avoid hacks and require this verion. This will for example help Kleopatra to support PIV cards and improves the gpgme-json. Signed-off-by: Werner Koch <[email protected]>
* core: New keylist mode GPGME_KEYLIST_MODE_WITH_KEYGRIP.Werner Koch2020-07-151-0/+6
| | | | | | | | | | | | | | | | * src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_KEYGRIP): New. * src/gpgme-json.c (op_keylist): New flag "keygrip". * src/engine-gpg.c (gpg_keylist_build_options): Pass the options. * lang/cpp/src/global.h (WithKeygrip): New. * lang/cpp/src/context.cpp: Add check. * lang/cpp/src/key.cpp (Key::update): Handle WithKeygrip. * lang/cpp/src/verificationresult.cpp: Ditto. * lang/cpp/src/util.h (add_to_gpgme_keylist_mode_t): Ditto. -- GnuPG-bug-id: 4939 Signed-off-by: Werner Koch <[email protected]>
* json: Fix cosmetic error in the repl.Werner Koch2019-02-281-1/+1
| | | | | | | * src/gpgme-json.c (native_messaging_repl): Use correct var with sizeof. -- Signed-off-by: Werner Koch <[email protected]>
* json: Better use gpgme_freeWerner Koch2019-01-251-1/+1
| | | | | | | | | | | * src/gpgme-json.c (subkey_to_json): here -- Avoid Windows ugliness of allowing different CRTs in the same process. Fixes-commit: 7f2423371964263784252cf839269023b6573bd2 Signed-off-by: Werner Koch <[email protected]>
* json: Fix minor memory leaks.Werner Koch2019-01-251-6/+14
| | | | | | | | | | * src/gpgme-json.c (interactive_repl): Fix memleak. (subkey_to_json): Ditto (op_config): Delay init of j_comps to avoid a leak on error. -- GnuPG-bug-id: 4341, 4342, 4343 Signed-off-by: Werner Koch <[email protected]>
* core: Silence newer compiler warnings.Werner Koch2018-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Add -Wno-format-truncation and -Wno-sizeof-pointer-div. * src/b64dec.c (_gpgme_b64dec_proc): Add fallthrough annotation. * src/cJSON.c (parse_string): Ditto. * src/gpgme-json.c (main): Ditto. -- gcc 8 enables a couple of new warnings. Some of them are useless for us. In particular: util.h:42:26: warning: division 'sizeof (char *) / sizeof (char)' does not compute the number of array elements [-Wsizeof-pointer-div] #define DIM(v) (sizeof(v)/sizeof((v)[0])) ^ trustlist.c:101:22: note: in expansion of macro 'DIM' if (strlen (p) == DIM(item->keyid) - 1) Which is a real standard way to use DIM, here the right hand side is equivalent to sizeof but nevertheless it is correct. Yes sir, we know C. The format string warnings I have seen were assuming that the time structure returns valued out of scope - but if the system is that broken, the s_n_printf catches this. Signed-off-by: Werner Koch <[email protected]>
* Add SPDX identifiers to most source filesWerner Koch2018-11-161-3/+3
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* spelling: fix misspellingsDaniel Kahn Gillmor2018-11-081-6/+6
| | | | Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* doc: use https:// for www.gnu.orgDaniel Kahn Gillmor2018-10-181-1/+1
| | | | | | -- Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* json: Remove subkey-algo from createkey command.Werner Koch2018-09-191-82/+7
| | | | | | | | | | | | | | | | | * src/gpgme-json.c (op_createkey): Remove subkey-algo param. (GPG_AGENT_ALLOWS_KEYGEN_TRHOUGH_BROWSER): Fix typo. * lang/js/src/Keyring.js: Remove subkey-algo support. * lang/js/src/permittedOperations.js: Ditto. -- We do not want to expose details of the protocol's key generation and thus the subkey-algo does not make sense. Right now we support only the default and future-default algorithms. A user can configure them anyway using new-default-key-algo in gpg.conf. Eventually we may officially support a more flexible way of creating special structured OpenPGP keys but right now that is not part of the API. Signed-off-by: Werner Koch <[email protected]>
* json: Fix detached verifyAndre Heinecke2018-08-291-20/+23
| | | | | | | | | * src/gpgme-json.c (op_verify): Only create output and use it for clearsigned and opaque signed. -- Just passing output to gpgme_op_verify changes the behavior to no longer do a verify of the signature.
* json: Delete primary key if subkey gen failsAndre Heinecke2018-08-281-2/+22
| | | | | | | | | | | | * src/gpgme-json.c (op_delete): Delete primary key on subkey gen error. -- This can happen for example if the user cancels the pinentry to unlock the primary key when adding the subkey. To avoid an artifact of a pimary key without an encryption capable subkey we delete the created key and treat the whole operation as failed.
* json: Allow NULL request in encode and chunkAndre Heinecke2018-08-281-2/+1
| | | | | | | | | | | * src/gpgme-json.c (encode_and_chunk): Don't error on NULL request. -- This fixes the error that is passed when parthing the json object failed and request would be NULL. Instead of the JSON parser error it would otherwise report that encode and chunk failed.
* json: Do not put FILE_NAME into the verify result.Werner Koch2018-08-271-2/+1
| | | | | | | | | | | | | | | | | | | | * src/gpgme-json.c (verify_result_to_json): Remove "file_name". -- Having the file name in the verify result may lead developers to assume that the file name is covered by the signature. This is not the case and can easily be checked by hex-editing a signed message. We better don't output it at all. The same is true for the is_mime flag but that is anyway only an advisory and I can't see damage from a faulty one. Note that we keep file_name in gpgme's output for ABI stability and because some tools want to display meta information even if they are subject to tampering. This is similar to the non-encrypted subject in mails. Signed-off-by: Werner Koch <[email protected]>
* json: Add sender and file name to encryptAndre Heinecke2018-08-231-0/+21
| | | | | * src/gpgme-json.c (hlp_encrypt, op_encrypt): Support sender and file_name.
* json: Add proper decrypt_result_t handlingAndre Heinecke2018-08-211-7/+80
| | | | | | | | | | | | | * src/gpgme-json.c (recipient_to_json, decrypt_result_to_json): New. (op_decrypt, hlp_decrypt): Update. -- The op_decrypt as one of the first operations did not yet match the current 1 <> 1 mapping of gpgme types to json dictonaries. info and dec_info are bad names but used for compatibility reasons.
* json: Add subkey_algo and defaults to createkeyAndre Heinecke2018-08-201-4/+62
| | | | | | | | | | | | | * src/gpgme-json.c (op_createkey, hlp_createkey): Add subkey_algo handling. (hlp_createkey): Fix documentation of expiry. -- Due to the funny quick-gen-key interface generating a key with an explicit algo would result in bad defaults (only an SC key), without a subkey. This adds handling that should probably be in GnuPG proper to fix the semantics of createkey by adding default subkey_algo handling.
* json: Only use calloc instead of mallocAndre Heinecke2018-08-081-6/+15
| | | | | | | | | * src/cJSON.c, src/gpgme-json.c (CALLOC_ONLY): New define to change xmalloc / xtrymalloc to use calloc. -- Some people consider malloc dangerous as it might allow an information leak.
* json: Don't error out if chunksize is omittedAndre Heinecke2018-08-081-4/+1
| | | | | | | | | * src/gpgme-json.c (encode_and_chunk): Don't error out if no chunksize is provided. -- This fixes 82e4b900a96c837392259469a9a5821a95e7a707 which caused every call without chunksize to error out.
* json: Don't use strdup but the xtrystrdup wrapper.Werner Koch2018-07-191-5/+8
| | | | | | | | | | | | * src/gpgme-json.c (create_keylist_patterns): Use CNT as first arg for xcalloc. (process_request): s/strdup/xtrystrdup/. -- calloc takes two arguments so to be able to detect integer overflow. Thus if we switch from malloc to calloc we should utilize that. Signed-off-by: Werner Koch <[email protected]>
* json: Fix memleak in native msging replAndre Heinecke2018-07-181-0/+4
| | | | | | | | | * src/gpgme-json.c (native_messaging_repl): Free request and response after each loop. -- If we only accept once request we should not loop. If we loop we should do it properly.
* json: Ensure that native msging request is stringAndre Heinecke2018-07-181-1/+2
| | | | | | | | | | | * src/gpgme-json.c (native_messaging_repl): Ensure that the request is NULL terminated. -- This avoids potential memory leaks and access to unmapped memory in case the request was not terminated. Other request functions use es_read_line which gurantees NULL termination.
* json: Fix crash by ensuring response is never NULLAndre Heinecke2018-07-181-7/+43
| | | | | | | | | | * src/gpgme-json.c (encode_and_chunk): Try to always return at least an error. (process_request): Double check that it does not return NULL. -- If process_request returns NULL the following strlen on it would crash.
* json: Fix memory errors in create_keylist_patternsAndre Heinecke2018-07-181-5/+4
| | | | | | | | | | | * src/gpgme-json.c (create_keylist_patterns): Reserve two pointers more then linefeeds. (create_keylist_patterns): Fix loop to count linebreaks. (create_keylist_patterns): Use calloc for good measure. -- This fixes crashes and memory corruption as cnt did not match i.
* json: Fix crash on invalid jsonAndre Heinecke2018-07-161-2/+2
| | | | | | | | | * src/gpgme-json.c (process_request): Init res. Check for json object before encode and chunk. -- If json is invalid we can't read chunksize and would crash in encode and chunk.
* json: Fix uninitialized key unref in op_deleteAndre Heinecke2018-07-161-1/+1
| | | | * src/gpgme-json.c (op_delete): Init key.
* json: Add with-sec-fprs param to exportAndre Heinecke2018-07-111-5/+68
| | | | | | | | | | | | | | | * src/gpgme-json.c (add_secret_fprs): New helper. (op_export, hlp_export): Extend for with-sec fprs. -- This is a request from Mailvelope, to import an export they need the information for which keys from the export a secret key is also available. For simplicity it is much preferred to get this information in a single call without the need to do and parse a keylisting additionally in a second native-messaging call. So we make it optional to include that info in the export.
* json: Add with-secret without secret onlyAndre Heinecke2018-07-091-4/+11
| | | | | * src/gpgme-json.c (op_keylist, hlp_keylist): Add "with-secret" as a flag to do a public keylist with secret information.
* json: Add keylist mode locateAndre Heinecke2018-07-041-0/+6
| | | | | | | | * src/gpgme-json.c (op_keylist, hlp_keylist): Add locate. -- The same rationale for the KEYLIST_MODE_LOCATE in GPGME also applies here. It makes the API a little less magic.
* json: Add file handling for debug outputAndre Heinecke2018-06-201-2/+16
| | | | | | | | | | | | | | | * src/gpgme-json.c (main): Add possibilty to set log file. -- This is similar to how GPGME_DEBUG works. It takes ; on Windows as seperator and : on linux. Followed by a file name. For Linux it might make sense to use a different seperator to allow setting a socket explicitly. But this is better in line with the current GPGME_DEBUG behavior. The change helps on Windows where we don't have a log socket.
* json: Return fingerprint as createkey resultAndre Heinecke2018-06-081-2/+10
| | | | * src/gpgme-json.c (op_createkey): Return fingerprint of new key.
* json: Add op_createkeyAndre Heinecke2018-06-081-0/+86
| | | | | | | | | | | * src/gpgme-json.c (hlp_createkey, op_createkey): New. (process_request, hlp_help): Add it. -- This uses an unrestricted context for now until GnuPG-Bug-Id: T4010 is implemented in GnuPG.
* json: Generalize chunking and getmoreAndre Heinecke2018-06-081-125/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme-json.c (MIN_REPLY_CHUNK_SIZE): Lower value to new real minimum. (DEF_REPLY_CHUNK_SIZE): Don't chunk by default. (pending_data): Remove type and base64. (make_data_object): Remove chunksize handling as this is now generic. (encode_and_chunk): Setup the pending_data buffer for chunking if required. (op_getmore): Changed to generically work on a response. (hlp_getmore): Update accordingly. (hlp_help): Document chunksize as generic parameter for all commands. (process_request): Use encode_and_chunk on the response. (hlp_encrypt, op_encrypt, hlp_decrypt, op_decrypt), (hlp_verify, op_verify, hlp_sign, op_sign), (op_keylist, hlp_keylist, hlp_export, op_export): Update accordingly. -- To include handling for json properties e.g. in a keylist in the chunk mechanism the mechanism is now more general. If the chunksize property is provided the response will always look exactly like a "getmore" response. E.g. e.g.: { "op": "keylist", "chunksize": 64 } Results in: { "more": true, "base64": true, "response": "ewoJImtleXMiOglbewoJCQkicmV2b2tlZCI6" } For simplicity this is even true if the chunksize is larger then the response. The client has to combine all "response" chunks and base64 decode them to get valid json. The complete response (including json) is never larger then the chunksize but might be smaller. Except for interactive use due to additional format characters.
* json: Rework verify_result_to_jsonAndre Heinecke2018-06-071-39/+159
| | | | | | | | | | | | * src/gpgme-json.c (sigsum_to_json): Add bool repr. (signature_to_json, verify_result_to_json): Extend and follow better pattern. (hlp_decrypt, hlp_verify): Expand doc. -- This should make it more clear which values are mapped as the naming is more direct and clear and help to use the gpgme documentation to understand the verify_result values.
* json: Add direct way to query a config optionAndre Heinecke2018-06-071-12/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme-json.c (op_config_opt, hlp_config_opt): New operation. (process_request, hlp_help): Add it. -- This is more conveniant API for most query operations where a single option is required. An example would be: { "op": "config_opt", "component": "gpg", "option": "default-key" } Which results in: { "option": { "name": "default-key", "description": "use NAME as default secret key", "argname": "NAME", "flags": 0, "level": 0, "type": 1, "alt_type": 1, "value": [{ "string": "F462B6B1", "is_none": false }] } }
* json: Add op_config to query gpgconfAndre Heinecke2018-06-071-1/+207
| | | | | | | * src/gpgme-json.c (op_config, hlp_config): New. (hlp_help, process_request): Add config. (conf_arg_to_json, conf_opt_to_json, conf_comp_to_json): New helpers.
* json: Fix compiler warning.Werner Koch2018-05-281-0/+4
| | | | | | * src/gpgme-json.c (op_version): Mark request as unused. Signed-off-by: Werner Koch <[email protected]>
* json: Do not allow to export or delete secret keys.Werner Koch2018-05-281-7/+11
| | | | | | | | | | | | | | | | * src/gpgme-json.c (op_export, op_delete): Return GPG_ERR_FORBIDDEN if "secret" is used. -- This should not be possible from a browser and we need to make this fully clear. Actually gpg-agent won't allow that anyway but having this explicitly is better. If that is ever needed a dedicated command line option may enable this, for example when used by regular programs and not by the browser. But that requires other changes as well. Signed-off-by: Werner Koch <[email protected]>
* json: Fix use of get_context.Werner Koch2018-05-281-11/+48
| | | | | | | | | | | | | | * src/gpgme-json.c (create_onetime_context): New. (release_onetime_context): New. (op_sign): Use the new fucntions to create a separate context. (op_encrypt): Use a separate context for key listings. (create_keylist_patterns): Remove unneeded cast. -- get_context retruns a static per-process context and can thus not be used as a separate context. Use dedicated fucntions for this. Signed-off-by: Werner Koch <[email protected]>
* json: Implement encrypt-signAndre Heinecke2018-05-251-14/+60
| | | | | | | | | * src/gpgme-json.c (op_encrypt): Add optional signing_keys param. (get_keys, create_keylist_patterns): Add param for json object name. -- If the optional parameter signing_keys is provided to encrypt it becomes an encrypt-sign operation.
* json: Implement delete commandAndre Heinecke2018-05-251-0/+72
| | | | | | | | | * src/gpgme-json.c (op_delete): New. (hlp_help, process_request): Add it. -- As with import / export delete also does not work for the browser origin.
* json: Implement op_exportAndre Heinecke2018-05-251-1/+111
| | | | | | | | * src/gpgme-json.c (op_export): New. (hlp_getmore, process_request): Add it. -- Secret key export does not work with request-origin browser.
* json: Fix double ctx allocAndre Heinecke2018-05-251-3/+0
| | | | * src/gpgme-json.c (op_keylist): Only get one ctx.
* json: Add guard in create_keylist_patternsAndre Heinecke2018-05-251-1/+1
| | | | | * src/gpgme-json.c (create_keylist_patterns): Guard against a string ending with a linbreak.
* json: Implement import operationAndre Heinecke2018-05-251-1/+126
| | | | | | * src/gpgme-json.c (op_import): New. (import_status_to_json, import_result_to_json): New. (hlp_help, process_request): Add import.
* json: Improve keylist helpAndre Heinecke2018-05-251-2/+3
| | | | * src/gpgme-json.c (hlp_keylist): Clarify doc about keys parameter.
* json: Fix keylist pattern handlingAndre Heinecke2018-05-251-20/+64
| | | | | | * src/gpgme-json.c (xfree_array): New helper. (create_keylist_patterns): Convert keystring to gpgme patterns. (op_sign, op_keylist): Use it.