aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* docs: python bindings howtoben/export-keysBen McGinnes2018-06-281-0/+358
| | | | | * Updated official doc (the org-mode file) with the instructions on importing and exporting both public and secret keys.
* python bindings examplesBen McGinnes2018-06-281-0/+110
| | | | | | * Added a secret key export variant which saves output as both GPG binary and ASCII armoured, plus saves in $GNUPGHOME and uses multiple methods of determining what that location is.
* python bindings examplesBen McGinnes2018-06-271-0/+73
| | | | | * Added a key import variant which accesses the SKS keyservers in a RESTful fashion and then imports or attempts to import the response.
* python bindings: import exampleBen McGinnes2018-06-271-0/+91
| | | | | * Added an example script for importing a key from a file (either ASCII armoured or not).
* python bindings: export public keysBen McGinnes2018-06-271-6/+18
| | | | | | * Updated key_export and key_export_minimal to return None where a pattern matched no keys in a manner simnilar to the possible result of key_export_secret.
* python bindings examples: three export scriptsBen McGinnes2018-06-273-0/+223
| | | | | | | | * Example of default exporting keys. * Example of exporting minimised keys. * Example of exporting secret keys to a file with correct permissions. Signed-off-by: Ben McGinnes <[email protected]>
* python bindings: export secret keysBen McGinnes2018-06-271-1/+42
| | | | | | | | | | | | | | * The holy grail: a function to export secret keys. * GPGME will still invoke pinentry and gpg-agent as usual to authorise the export. * Mostly similar to the two previous export functions for public keys except that it will return None if the result had a length of zero bytes. Meaning that the difference between the specified pattern (if any) not matching available keys and an incorrect passphrase is not able to be determined from this function (or the underlying one for that matter). Signed-off-by: Ben McGinnes <[email protected]>
* python bindings: export public keysBen McGinnes2018-06-271-1/+58
| | | | | | | | | | | | * Added functions for exporting public keys to gpg.core in both complete form and in minimised form. * Rather than letting people need to worry about the export modes we are simply separating the functions as people would be more familiar with from the command line usage anyway. * Functions added for Context are: ctx.key_export_minimal and ctx.key_export as the default or full export. Signed-off-by: Ben McGinnes <[email protected]>
* 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.
* python bindings: core import statementsBen McGinnes2018-06-171-3/+3
| | | | * Fixed the bit I broke while fixing the PEP8 compliance issues.
* python bindings: core — PEP8 complianceBen McGinnes2018-06-171-77/+101
| | | | | | | | * Fixed most of the PEP8 errors in core.py * Those remaining may need more than little edits and are a bit strange (too clearly the result of a programmer who has spent far too much time dealing with Lisp so that for Python it looks ... strange).
* python bindings: core - key importgsoc/jacob-key-importBen McGinnes2018-06-171-9/+37
| | | | | | | | | | * Wrapped the key import function in the try/exception statements needed to catch at least the most likely unsuccessful import attempt errors. * Mostly draws on the file error and no data import statuses for errors, with a couple of exceptions. Signed-off-by: Ben McGinnes <[email protected]>
* python bindings: core key importBen McGinnes2018-06-163-5/+31
| | | | | | | | | | | | * The foundation of a pythonic key import function authored by Jacob Adams. * A unit testing script for the same function originally authored by Tobias Mueller * Added DCO reference for Jacob Adams to the GPGME AUTHORS file. * Additional details regarding this patch are available here: https://dev.gnupg.org/T4001 Signed-off-by: Ben McGinnes <[email protected]>
* script: groups.pyBen McGinnes2018-06-101-1/+7
| | | | | * Added check for if it is run on a Windows system so that the correct binary filename is invoked.
* cpp: Add proper gpgme_op_createkeyAndre Heinecke2018-06-083-0/+26
| | | | | | | | | | * lang/cpp/src/context.cpp, lang/cpp/src/context.h (Context::createKeyEx): New. -- The createKeyEx function follows the usual pattern that the synchronous call returns a result directly while for the async an extra call is neccessary.
* 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.
* examples: python howtoBen McGinnes2018-06-073-0/+262
| | | | | | | | | | | | | * Uses the groups module to prepare a list of recipients and encrypt to those. * The main version (encrypt-to-group.py) tries to check for invalid recipients, but still falls back to always trust for the second encryption attempt. * The gullible version doesn't try pruning the recipient list at all, it just tries to encrypt and if it fails, switches straight to always trust. * The trustno1 version doesn't use the always trust model at all and only attempts pruning the list of invalid recipients.
* core: Return a better error code on certain decryption failures.Werner Koch2018-06-061-12/+47
| | | | | | | | | | | * src/decrypt.c (op_data_t): Add field first_status_error. (parse_status_error): Set it. (_gpgme_decrypt_status_handler): Prefer an ERROR code over a NO_SECKEY. -- GnuPG-bug-id: 3983 Signed-off-by: Werner Koch <[email protected]>
* json: Allow to compile with libgpg-error < 1.28Werner Koch2018-06-051-2/+2
| | | | | | | | | | | | | | | | * src/cJSON.c: Use gpgrt fucntion only if available. -- We have a hack in gpgme-json to allow building with older libgpg-error versions. That whole thing will not work but the instead the binary will print an error at runtime that it needs to be build with a newer libgcrypt. There was a little bug here for the Debian packages libgpg-error versions which failed to build cJSON. cJSON is only needed be the full gpgme-json but nevertheless the Makefile wants to build it. The fix is straightforward. GnuPG-bug-id: 3971 Signed-off-by: Werner Koch <[email protected]>
* docs: python bindings howtoBen McGinnes2018-06-021-66/+73
| | | | | | | | | * Another attempt at fixing the org-mode version. * A proof reader ascertained there were tabs in it instead of whitespace. * Stripped the lot out and replaced with standard 4 spaces, fixed every incorrect example ... and it still breaks upon save and/or export. * Added the reference to the mutt-groups.py script to demonstrate the groups.py module/code.
* Authors: DCOBen McGinnes2018-06-021-1/+4
| | | | | * Added mine to the GPGME AUTHORS file. Mainly so I'm doing what I say myself when about to request another from someone ... ;)
* cpp: Add gpgme_(get)set_ctx_flagAndre Heinecke2018-06-013-3/+20
| | | | | | * NEWS: Mention API extensions. * lang/cpp/src/context.cpp, lang/cpp/src/context.h (Context::setFlag, Context::getFlag): New.
* cpp: Add legacy_cipher_nomdcAndre Heinecke2018-06-012-0/+8
| | | | | | | * lang/cpp/src/decryptionresult.cpp, lang/cpp/src/decryptionresult.h (DecryptionResult::isLegacyCipherNoMDC): New. --
* core: New context flag "ignore-mdc-error".Werner Koch2018-05-318-4/+65
| | | | | | | | | | | | | | | | | * src/context.h (gpgme_context): Add field ignore_mdc_error. * src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Set/get it. * src/engine-gpg.c (engine_gpg): Add flags.ignore_mdc_error. (gpg_set_engine_flags): Set it. (build_argv): Pass option to gpg. * src/decrypt.c (_gpgme_decrypt_status_handler): Take care of flag. (gpgme_op_decrypt_result): Clear flag. (gpgme_op_decrypt): Clear flag. * src/decrypt-verify.c (gpgme_op_decrypt_verify): Clear flag (gpgme_op_decrypt_ext): Clear flag. * tests/run-decrypt.c (show_usage): Add option --ignore-mdc-error. Signed-off-by: Werner Koch <[email protected]>
* core: New decryption result flag 'legacy_cipher_nomdc'.Werner Koch2018-05-315-7/+34
| | | | | | | | | | * src/gpgme.h.in (_gpgme_op_decrypt_result): Add flag legacy_cipher_nomdc. * src/decrypt.c (parse_status_error): Set this flag. * tests/run-decrypt.c (print_result): print it. (main): Print the result even on error. Signed-off-by: Werner Koch <[email protected]>
* core: Remove cruft from the engine-gpg code.Werner Koch2018-05-3113-78/+23
| | | | | | | | | | | | | | | | * src/engine-gpg.c (read_status): Remove the handling of GPGME_STATUS_END_STREAM; this was used only by the former experimental --pipemode of gpg but that is not even anymore invoked here. (struct engine_gpg): Remove cmd.linked_data and .linked_idx. (build_argv): Remove code for linked_data. (gpg_new): Ditto. (gpg_set_command_handler): Remove arr linked_data. * src/engine-backend.h (engine_ops): Remove arg data from set_command_handler. * src/engine.c (_gpgme_engine_set_command_handler): Remove arg linked_data and adjust all callers. Signed-off-by: Werner Koch <[email protected]>
* core: Minor cleanup in engine-gpg and -gpgsm.Werner Koch2018-05-312-6/+3
| | | | | | | | | | * src/engine-gpg.c: Remove errno.h. (build_argv): Use gpg_error_from_syserror instead of ERRNO. * src/engine-gpgsm.c: Remove errno.h. (status_handler): Remove check for EINTR; gpgme_data_write already handles EINTR. Signed-off-by: Werner Koch <[email protected]>
* cpp: Add gpgme_data_rewind to cpp APIAndre Heinecke2018-05-294-0/+28
| | | | | | | | | | | * lang/cpp/src/data.h, lang/cpp/src/data.cpp (Data::rewind): New. * lang/qt/tests/t-various.cpp (testDataRewind): Test it. -- The advantage of this convieniance function in GPGME is that it avoids the messiness that are declarations with off_t. GnuPG-Bug-Id: T3996
* 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.
* 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.
* examples: mutt crypt-hooks generatorBen McGinnes2018-05-241-0/+64
| | | | | | | * Added a script which demonstrates how the groups module works. * Script generates Mutt/Neomutt crypt-hooks for every group entry in gpg.conf, including those entries for multiple keys (Mutt handles that differently).
* docs: python bindings howtoBen McGinnes2018-05-242-9/+13
| | | | | | | * Fixed the groups.py script so it really does what is described (the old code had the same result for groups, group_lines and group_lists). * Updated the corresponding example in the doc to match.