Codebase list gpgme1.0 / a9e5128
Merge branch 'upstream' into experimental Daniel Kahn Gillmor 7 years ago
135 changed file(s) with 8101 addition(s) and 3150 deletion(s). Raw diff Collapse all Expand all
0 2017-03-28 Werner Koch <wk@gnupg.org>
1
2 Release 1.9.0.
3 + commit aa0390ec3b910bbbc323a15ec3c3351e77785a9a
4 * configure.ac <c>: Bump LT version to C29/A18/R0.
5 <cpp>: Bump LT version to C10/A4/R0.
6 <qt>: Bump LT version to C9/A2/R0.
7
8 core: Prepare for new key listing data send by gpg.
9 + commit 813ae5fa2d712aa9679b791c67c9c1c43d36ffe4
10 * src/gpgme.h.in (gpgme_user_id_t): New fields 'origin' and
11 'last_update'.
12 (gpgme_key_t): New fields 'origin' and 'last_update'.
13 * src/conversion.c (_gpgme_parse_timestamp_ul): New.
14 * src/keylist.c (keylist_colon_handler): Parse fields 19 and 20.
15
16 * tests/run-keylist.c (main): Print new fields.
17
18 2017-03-27 Andre Heinecke <aheinecke@intevation.de>
19
20 qt: Disable testEncryptDecryptNowrap.
21 + commit 57d60b20f16dd5f1bccbbcaa0a6ed75a554a6414
22 * lang/qt/tests/t-encrypt.cpp (EncryptTest::testEncryptDecryptNowrap):
23 Disable test.
24
25 2017-03-27 Justus Winter <justus@g10code.com>
26
27 python: Skip tests if running with GnuPG < 2.1.12.
28 + commit 348da58fe0c3656e6177c98fef6b4c4331326c8e
29 * lang/python/tests/support.py (assert_gpg_version): Fix error
30 message. Skip all tests when we use GnuPG older than 2.1.12.
31
32 2017-03-24 Andre Heinecke <aheinecke@intevation.de>
33
34 cpp: Respect decrypt flags in new functions.
35 + commit 18b7906078cf08962c54c1e711cf2d91a24fd4e5
36 * lang/cpp/src/context.cpp: Respect directly provided flags
37 in the new decrypt functions.
38
39 qt: Add unittest for decrypt unwrap.
40 + commit 5493164f8665fabf795f3b34a7084770a38ae940
41 * lang/qt/tests/t-encrypt.cpp
42 (EncryptTest::testEncryptDecryptNowrap): New.
43
44 cpp: Use gpgme_op_decrypt_ex and add new flags.
45 + commit 8ad37ecc297f208d0a63783c1ffae33ad4c3c81a
46 * lang/cpp/src/context.cpp: New decrypt and decryptVerify functions
47 that take flags as arguments. Use new variants in old functions.
48 (Context::setDecryptionFlags): New helper.
49 (Context::Private::Private): Initialize new member.
50 * lang/cpp/src/context_p.h (Context::Private::decryptFlags): New.
51 * lang/cpp/src/context.h (Context::DecryptFlags): New enum.
52 (Context::EncryptionFlags): Extend for EncryptWrap.
53
54 2017-03-24 Werner Koch <wk@gnupg.org>
55
56 core: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.
57 + commit 6ac1f2cdedb085b4ac9372c1e591497e2e618de4
58 * src/gpgme.h.in (GPGME_ENCRYPT_WRAP): New const.
59 (gpgme_decrypt_flags_t): New enum.
60 (GPGME_DECRYPT_VERIFY): New const
61 (GPGME_DECRYPT_UNWRAP): New const
62 (gpgme_op_decrypt_ext_start): New func.
63 (gpgme_op_decrypt_ext): New func.
64 * src/decrypt-verify.c (gpgme_op_decrypt_ext_start): New.
65 (gpgme_op_decrypt_ext): New.
66 (decrypt_verify_start): Add arg FLAGS. Replace call to
67 engine_op_decrypt_verify by the plain decrypt with the flag set.
68 (gpgme_op_decrypt_verify_start): Pass the flag.
69 (gpgme_op_decrypt_verify): Pass the flag.
70 * src/decrypt.c (decrypt_start): Rename to ...
71 (_gpgme_decrypt_start): this. Add arg FLAGS. Pass FLAGS to
72 engine_op_decrypt.
73 (gpgme_op_decrypt_start): Adjust for chnage pass 0 for FLAG.
74 (gpgme_op_decrypt_start): Ditto.
75 * src/engine.c (_gpgme_engine_op_decrypt_verify): Remove.
76 (_gpgme_engine_op_decrypt): Add arg FLAGS.
77 * src/gpgme.def, src/libgpgme.vers: Add new functions.
78 * src/engine-backend.h (struct engine_ops): Remove member
79 'decrypt_verify'. Add FLAGS to 'decrypt'. Adjust all initialization.
80 * src/engine-uiserver.c (uiserver_decrypt): Remove.
81 (uiserver_decrypt_verify): Remove.
82 (_uiserver_decrypt): Rename to ...
83 (uiserver_decrypt): this. Replace arg VERIFY by new arg FLAGS.
84 * src/engine-gpg.c (gpg_decrypt): Support GPGME_DECRYPT_UNWRAP.
85 (gpg_encrypt): Support GPGME_ENCRYPT_WRAP.
86
87 * tests/run-decrypt.c (main): New option --unwrap.
88 * tests/run-encrypt.c (main): New option --wrap.
89
90 2017-03-22 Andre Heinecke <aheinecke@intevation.de>
91
92 qt: Add test for Data::toKeys.
93 + commit 66c334650bd64fdb72c4bd5975e25b8659d320ec
94 * lang/qt/tests/t-various.cpp (TestVarious::testKeyFromFile): New.
95
96 cpp: Wrap keylist_from_data.
97 + commit 8ddb42ada46f00d8393f6c2df7d6b79a4a5878f0
98 * lang/cpp/data.h, lang/cpp/data.cpp (GpgME::Data::toKeys): New.
99
100 qt: Initialize library first in tests.
101 + commit 121873b821636052c10d9e0bd885eb9013c52096
102 * lang/qt/tests/t-support.cpp (QGpgMETest::initTestCase): Initialize
103 library.
104
105 2017-03-22 Justus Winter <justus@g10code.com>
106
107 python: Improve Python detection.
108 + commit 104635eb503ec764146731888a6975b4329660fd
109 * m4/python.m4 (_AM_PYTHON_INTERPRETER_LIST): Prefer the generic
110 'pythonX' over 'pythonX.Y'. This way we select the users preferred
111 version for both flavors. Prefer 'python' over 'python3' but not over
112 'python2' so that the algorithm still finds a 'python2' even if
113 'python' is a Python3.
114
115 2017-03-21 Werner Koch <wk@gnupg.org>
116
117 core: New API gpgme_op_set_uid_flag.
118 + commit 421ddd1e6706046c5062417fd69a87e10c9fc0a9
119 * src/gpgme.h.in (gpgme_op_set_uid_flag_start): New.
120 (gpgme_op_set_uid_flag_start): New.
121 * src/gpgme.def, src/libgpgme.vers: Add them.
122 * src/genkey.c (addrevuid_start): Change arg revoke to a flag.
123 (gpgme_op_revuid_start): Pass GENKEY_EXTRAFLAG_REVOKE for the fomer
124 revoke parameter.
125 (gpgme_op_revuid): Ditto.
126 (set_uid_flag): New.
127 (gpgme_op_set_uid_flag_start): New.
128 (gpgme_op_set_uid_flag): New.
129 * src/engine.h (GENKEY_EXTRAFLAG_SETPRIMARY): new.
130 * src/engine-gpg.c (gpg_adduid): Implement that flag.
131
132 * tests/run-genkey.c (main): New command --set-primary.
133
134 2017-03-21 Justus Winter <justus@g10code.com>
135
136 python: Wrap 'gpgme_op_keylist_from_data_start'.
137 + commit f3e8d8a4518de2768692e0b392262d0da6d0fd84
138 * NEWS: Update.
139 * lang/python/gpg/core.py (Context.keylist): New keyword argument
140 'source'. If given, list keys from 'source'.
141 * lang/python/gpgme.i: Wrap the argument to
142 'gpgme_op_keylist_from_data_start'.
143 * lang/python/tests/Makefile.am (py_tests): Add new test.
144 * lang/python/tests/support.py (EphemeralContext): Do not throw an
145 error if no agent has been started in the context.
146 * lang/python/tests/t-keylist-from-data.py: New file.
147
148 2017-03-21 Werner Koch <wk@gnupg.org>
149
150 core: Extend gpgme_get_dirinfo to return the gpg-wks-client name.
151 + commit 55ac5eed9f59081283d34098a9e0ada753d61d59
152 * src/dirinfo.c (WANT_GPG_WKS_CLIENT_NAME): New const.
153 (struct dirinfo): New field 'gpg_wks_client_name'.
154 (get_gpgconf_item): Build it on demand.
155 (gpgme_get_dirinfo): New value "gpg-wks-client-name" for WHAT.
156
157 core: New encryption flag GPGME_ENCRYPT_THROW_KEYIDS.
158 + commit fab8b1a166fff7265d8a7a7acbbf5f30d26cc93c
159 * src/gpgme.h.in (GPGME_ENCRYPT_THROW_KEYIDS): New flag.
160 * src/engine-gpg.c (gpg_encrypt): Implement flag
161 (gpg_encrypt_sign): Implement flag.
162
163 * tests/run-encrypt.c (main): New option --throw-keyids.
164
165 2017-03-21 Andre Heinecke <aheinecke@intevation.de>
166 Werner Koch <wk@gnupg.org>
167
168 core: New public API gpgme_op_keylist_from_data_start.
169 + commit 35023f313622fb1b34108dd934e84831c58b81aa
170 * src/gpgme.h.in: New API gpgme_op_keylist_from_data_start.
171 * src/libgpgme.vers, src/gpgme.def: Add it.
172 * src/keylist.c (gpgme_op_keylist_from_data_start): New.
173 * src/engine-backend.h (engine_ops): Add field 'keylist_data'. Change
174 all engines to pass NULL for it.
175 * src/engine.c (_gpgme_engine_op_keylist_data): New.
176 * src/engine-gpg.c (gpg_keylist_data): New.
177 (_gpgme_engine_ops_gpg): Register gpg_keylist_data.
178
179 * tests/run-keylist.c (main): New option --from-file.
180
181 2017-03-20 Werner Koch <wk@gnupg.org>
182
183 core,cpp: New key flag 'is_de_vs'.
184 + commit ea9686ec71a2dd2225ce2b6d6d4038821d36205f
185 * src/gpgme.h.in (_gpgme_subkey): New flag is_de_vs.
186 * tests/run-keylist.c (main): Print that flag.
187 * src/keylist.c (parse_pub_field18): New.
188 (keylist_colon_handler): Parse compliance flags.
189 * lang/cpp/src/key.cpp (Key::isDeVs): New.
190 (Subkey::isDeVs): New.
191
192 * lang/cpp/src/key.h (class Key): New method isDeVs.
193 (class Subkey): New method isDeVs.
194
195 2017-03-20 Justus Winter <justus@g10code.com>
196
197 tests: Fix distcheck.
198 + commit 392e51dd1181d035c19918222da65d08fdb2ee6d
199 * tests/start-stop-agent: Do not create 'gpg-agent.conf' if it does
200 not exist.
201
202 python: Fix version check.
203 + commit 57e64d019d993fdeb4323def5352f8ecc98c6fd9
204 * lang/python/tests/support.py (assert_gpg_version): Cope with
205 non-released versions.
206
207 tests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.
208 + commit 16b202d9999591b71fb8bb49f6db10ef96d4cbe8
209 * lang/python/tests/Makefile.am (gpg-agent.conf): Do not hard-code the
210 option. This breaks gpg-agent from GnuPG 2.0.
211 * tests/start-stop-agent: Rather, check if the option is supported and
212 add it to the configuration if it is.
213
214 python: Skip tests if GnuPG is too old.
215 + commit e1cf8bab319ba1dea41ba5d711dbb66ffd8e6fd6
216 * lang/python/tests/support.py (assert_gpg_version): New function.
217 * lang/python/tests/t-callbacks.py: Use the new function to skip the
218 test if GnuPG is too old.
219 * lang/python/tests/t-edit.py: Likewise.
220 * lang/python/tests/t-encrypt-sym.py: Likewise.
221 * lang/python/tests/t-quick-key-creation.py: Likewise.
222 * lang/python/tests/t-quick-key-manipulation.py: Likewise.
223 * lang/python/tests/t-quick-key-signing.py: Likewise.
224
225 python: Remove superfluous initialization.
226 + commit 4572e8d2ac1d3b45e75ce71265c99e591fbf0e28
227 * lang/python/tests/support.py (init_gpgme): Remove. This is an
228 remnant from the c tests. Nowadays, the Python bindings initialize
229 GPGME automagically.
230 * lang/python/tests/initial.py: Remove call to 'support.init_gpgme'.
231 * lang/python/tests/t-callbacks.py: Likewise.
232 * lang/python/tests/t-decrypt-verify.py: Likewise.
233 * lang/python/tests/t-decrypt.py: Likewise.
234 * lang/python/tests/t-edit.py: Likewise.
235 * lang/python/tests/t-encrypt-large.py: Likewise.
236 * lang/python/tests/t-encrypt-sign.py: Likewise.
237 * lang/python/tests/t-encrypt-sym.py: Likewise.
238 * lang/python/tests/t-encrypt.py: Likewise.
239 * lang/python/tests/t-export.py: Likewise.
240 * lang/python/tests/t-file-name.py: Likewise.
241 * lang/python/tests/t-idiomatic.py: Likewise.
242 * lang/python/tests/t-import.py: Likewise.
243 * lang/python/tests/t-keylist.py: Likewise.
244 * lang/python/tests/t-sig-notation.py: Likewise.
245 * lang/python/tests/t-sign.py: Likewise.
246 * lang/python/tests/t-signers.py: Likewise.
247 * lang/python/tests/t-trustlist.py: Likewise.
248 * lang/python/tests/t-verify.py: Likewise.
249 * lang/python/tests/t-wait.py: Likewise.
250
251 2017-03-14 Justus Winter <justus@g10code.com>
252
253 python: Make error message more helpful.
254 + commit 9d6825be092f1590f28b5bab462eeb944d9b800c
255 * lang/python/tests/run-tests.py: Make the error message shown when we
256 cannot locate the python module in the build tree more helpful.
257
258 python: Make tests more robust.
259 + commit ac4849953860547b06a167ca9612c4de369d02b6
260 * lang/python/tests/support.py (TemporaryDirectory): Always use our
261 own version even if 'tempfile.TemporaryDirectory' is provided, because
262 we need to use 'shutil.rmtree(..., ignore_errors=True)' to avoid it
263 tripping over gpg-agent deleting its own sockets.
264
265 python: Improve build system integration.
266 + commit a4201035fdc050f337a6b9f520c8ddbb569e2eb4
267 * lang/python/Makefile.am: Use 'set -e' when chaining shell commands
268 together in rules.
269
270 build: Improve Python detection.
271 + commit 6a371663886a7ba6073f385a3ab5f5a03de8e008
272 * configure.ac: Do not error out too early if we don't find a matching
273 Python version. We handle this case later.
274
275 build: Tune M4 macros for our needs.
276 + commit 5189c08af9468cdeb6f16a6ecd0fee53e1e3aa0e
277 * m4/ax_python_devel.m4: Do not emit 'HAVE_PYTHON'.
278 * m4/python.m4 (_AM_PYTHON_INTERPRETER_LIST): Add newer Python
279 versions, drop older ones. Also, sort the list with older versions at
280 the front, newer and generic versions towards the end. This makes the
281 algorithm pick the lowest version that meets the version requirement.
282
283 build: Add M4 macros for python.
284 + commit 067da472f919e78c95a0a01b68e79a8b7dff173b
285 * m4/python.m4: New file.
286
287 2017-03-13 Andre Heinecke <aheinecke@intevation.de>
288
289 qt: Add test for DN parser.
290 + commit 43aa3eed15dcc4f848915ceabeff35c29c1c57e4
291 * qt/tests/t-various.cpp (testDN): New.
292
293 qt: Use gpgrt_asprintf instead of qstrdup.
294 + commit 9d5048d47446450a34cae4f27eb81c02ea5d4afc
295 * lang/qt/src/dn.cpp (parse_dn_part): Use gpgrt_asprintf instead
296 of qstrdup.
297
298 2017-03-09 Werner Koch <wk@gnupg.org>
299
300 core: Fix status error return for gpgsm.
301 + commit d2240a2a1819874929bdab820bcbd3bee7f94407
302 * src/engine-gpgsm.c (gpgsm_assuan_simple_command): Make sure CB_ERR
303 is returned.
304 * src/import.c (parse_import_res): Do not return an error for the last
305 field.
306 (import_status_handler): Actually return the error from
307 parse_import_res.
308
309 2017-03-02 Justus Winter <justus@g10code.com>
310
311 python: Print path of the Python module used during tests.
312 + commit 41398779abbcb1ec2d7491e141469a752fc706ff
313 * lang/python/tests/initial.py: Print path of the Python module used
314 during tests. Useful to detect if by any mistake the wrong module is
315 picked up.
316
317 2017-03-02 Werner Koch <wk@gnupg.org>
318
319 core: Fix minor code style thing.
320 + commit ef035f079fb067f207e5477d5ed6c5a68fb41f59
321 * src/engine-gpg.c (gpg_add_algo_usage_expire): Use double parenthesis
322 for bit tests.
323
324 2017-03-02 Andre Heinecke <aheinecke@intevation.de>
325
326 cpp: Add subkey keygrip to API.
327 + commit 8071a6b2ca33c2a46ed1d50ae7283241daaafcd3
328 * lang/cpp/src/key.cpp (Subkey::keyGrip): New.
329 * lang/cpp/src/key.h: Update accordingly.
330
331 2017-03-01 Andre Heinecke <aheinecke@intevation.de>
332
333 cpp: Add interactor to generate keys on smartcard.
334 + commit d63258066d008de113ed1170f1b0e787a5bdaba1
335 * lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
336 Handle new states.
337 * lang/cpp/src/gpggencardkeyinteractor.cpp,
338 lang/cpp/src/gpggencardkeyinteractor.h: New.
339 * lang/cpp/src/Makefile.am: Update accordingly.
340
341 qt: Allow creation of default keys without name.
342 + commit fbafb5474d8898ba1b267f4b4dfbefe39f04e72f
343 * lang/qt/src/defaultkeygenerationjob.cpp
344 (DefaultKeyGenerationJob::start): Handle empty name and email.
345
346 2017-02-26 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
347
348 doc: Correct documentation for recp arg of gpgme_op_encrypt_sign_start.
349 + commit 5b49095b89b07591c69827df3973ffabfb3e97b8
350 * doc/gpgme.texi (gpgme_op_encrypt_sign_start): recp is an array of
351 gpgme_key_t, not a single element.
352
353 2017-02-20 Justus Winter <justus@g10code.com>
354
355 python: Fix test.
356 + commit a7c6353edab57b67180aa127ec77d9353c2366fb
357 * lang/python/tests/t-quick-key-manipulation.py: Modify the
358 configuration file in the ephemeral home directory, not the one used
359 by all the tests.
360
361 2017-02-17 Justus Winter <justus@g10code.com>
362
363 python: Support manipulating the TOFU policy.
364 + commit 15fbac9e72a4d1bff9a3b9e9822f9175b09fbcd5
365 * NEWS: Update.
366 * doc/gpgme.texi: Fix typos.
367 * lang/python/gpg/constants/__init__.py: Import new files.
368 * lang/python/gpg/constants/tofu/__init__.py: New file.
369 * lang/python/gpg/constants/tofu/policy.py: New file.
370 * lang/python/gpg/core.py (Context.key_tofu_policy): New function.
371 * lang/python/gpgme.i: Nice reprs for gpgme_tofu_info_t.
372 * lang/python/setup.py.in: Install new package.
373 * lang/python/tests/t-quick-key-manipulation.py: Extend test.
374
375 python: Support quick key signing.
376 + commit 48634e651fcd02431c0518d42ada1f3b402feb2c
377 * NEWS: Update.
378 * doc/gpgme.texi (gpgme_op_keysign): Fix the description of the
379 'expire' argument.
380 * lang/python/gpg/constants/__init__.py: Import new file.
381 * lang/python/gpg/constants/keysign.py: New file.
382 * lang/python/gpg/core.py (Context.key_sign): New function.
383 * lang/python/tests/Makefile.am (py_tests): Add new test.
384 * lang/python/tests/t-quick-key-signing.py: New test.
385
386 python: Fix teardown of ephemeral contexts.
387 + commit de8494b16bc50c60a8438f2cae1f8c88e8949f7a
388 * lang/python/tests/support.py (EphemeralContext): New function.
389 * lang/python/tests/t-quick-key-creation.py: Use the new function to
390 manage ephemeral contexts.
391 * lang/python/tests/t-quick-key-manipulation.py: Likewise.
392 * lang/python/tests/t-quick-subkey-creation.py: Likewise.
393
394 python: Fix using strings as commands in the assuan protocol.
395 + commit 9350168a1eed3f055040d7cc8a9bf4cdf745b23a
396 * lang/python/gpg/core.py (Context.assuan_transact): Fix testing
397 whether the command is a string on Python2.
398 * lang/python/tests/t-protocol-assuan.py: Improve the test to detect
399 this problem.
400
401 2017-02-16 Justus Winter <justus@g10code.com>
402
403 python: Support adding and revoking UIDs.
404 + commit 7641b7b5f2c9d5b38c60cd9326bcb4810c37dae5
405 * NEWS: Update.
406 * lang/python/gpg/core.py (Context.key_add_uid): New function.
407 (Context.key_revoke_uid): Likewise.
408 * lang/python/tests/Makefile.am (XTESTS): Add new test.
409 * lang/python/tests/t-quick-key-manipulation.py: New file.
410
411 python: Support quick subkey creation.
412 + commit 13bace25e3d8422f93fd24919994be36042fd220
413 * NEWS: Update.
414 * lang/python/gpg/core.py (Context.create_subkey): New function.
415 * lang/python/tests/Makefile.am (XTESTS): Add new test.
416 * lang/python/tests/t-quick-subkey-creation.py: New file.
417
418 python: Support quick key creation.
419 + commit 476b97822b169c30cc246c1de2ff94cf89084706
420 * NEWS: Update.
421 * lang/python/gpg/constants/__init__.py: Import new file.
422 * lang/python/gpg/constants/create.py: New file.
423 * lang/python/gpg/core.py (Context.create_key): New function.
424 * lang/python/tests/Makefile.am (XTESTS): Add new test.
425 * lang/python/tests/support.py (TemporaryDirectory): New class.
426 * lang/python/tests/t-quick-key-creation.py: New file.
427
428 python: Fix passphrase callback wrapping.
429 + commit 3bdce4aa3ddd4a3f55b24678faf978d61daa8909
430 * lang/python/helpers.c (pyPassphraseCb): Cope with 'passphrase_info'
431 being NULL.
432
433 python: Fix error handling.
434 + commit 048c5f74b61d5e4fa7617ce7c9111c6754bd4409
435 * lang/python/gpgme.i (typemap gpgme_key_t[]): Set an error if a
436 non-key element is discovered.
437
438 2017-02-15 Justus Winter <justus@g10code.com>
439
440 core: Fix expiration time handling when creating keys.
441 + commit de708e5934cda380dbc3ae51f587c09041de7562
442 * NEWS: Update.
443 * doc/gpgme.texi (gpgme_op_createkey): Clarify the meaning of the
444 'expire' parameter.
445 (GPGME_CREATE_NOEXPIRE): Document new flag.
446 (gpgme_op_createsubkey): Clarify the meaning of the 'expire'
447 parameter.
448 * src/engine-gpg.c (gpg_add_algo_usage_expire): Fix handling of the
449 expiration time.
450 * src/gpgme.h.in (GPGME_CREATE_NOEXPIRE): New macro.
451
452 python: Fix build system integration.
453 + commit 27544d0a74267ab6057dc816ea3311bc9149a200
454 * lang/python/Makefile.am (copystamp): Also copy the setup script, and
455 link the header files.
456 (all-local): Use local setup script.
457 (sdist): Fix Python source distribution creation.
458 (CLEANFILES): Remove now obsolete files.
459 (install-exec-local): Use local setup script.
460 * lang/python/setup.py.in: Adjust relative paths to in-tree files.
461
462 python: Update lists of functions returning gpgme_error_t.
463 + commit 25f0435a0022a70af77660d72d33f17bec2d4e51
464 * lang/python/gpg/core.py (Context._errorcheck): Add instructions how
465 to update the list. Update list.
466 (Data._errorcheck): Likewise.
467 (Context.set_engine_info): Simplify.
468
469 core: Fix error types.
470 + commit 6df6e01ed5a581765d245bf7303cda4497d0eb22
471 * NEWS: Update.
472 * src/data.c (gpgme_data_set_flag): Return a 'gpgme_error_t'.
473 * src/error.c (gpgme_strerror_r): Fix type of first argument.
474 * src/gpgme.h.in (gpgme_strerror_r): Adapt.
475 (gpgme_data_set_flag): Likewise.
476
477 2017-02-14 Justus Winter <justus@g10code.com>
478
479 python: Wrap utility functions.
480 + commit 92adc9bbf640eb5d9177d3ba0189e0f6cee4e995
481 * NEWS: Update.
482 * lang/python/gpg/core.py (pubkey_algo_string): New function.
483 (pubkey_algo_name): Add docstring.
484 (hash_algo_name): Likewise.
485 (get_protocol_name): Likewise.
486 (addrspec_from_uid): New function.
487 * lang/python/gpgme.i (gpgme_pubkey_algo_string): Result must be
488 freed.
489 (gpgme_addrspec_from_uid): Likewise.
490
491 python: Use the correct function to free buffers.
492 + commit 9fc9533c2835ec53c4fd4f822b09e9fec14626d0
493 * lang/python/gpgme.i (char *): Free using 'gpgme_free'.
494
495 python: Add keylist mode parameter.
496 + commit fdc4e33dc3f6c84fe9d7bf9795c603ae3cf5f28d
497 * NEWS: Update.
498 * lang/python/gpg/core.py (Context.keylist): Add 'mode' parameter.
499
500 python: Nicer repr for user ids.
501 + commit e17ab84129045512cf60c221ee43aa877507662f
502 * lang/python/gpgme.i (_gpgme_user_id): Provide a nicer repr() for
503 user ids.
504
505 python: Add convenience functions for the home directory.
506 + commit 99b7f4f34dd595579181a696ae976a678fe00d49
507 * NEWS: Update.
508 * lang/python/gpg/core.py (Context.__init__): Add 'home_dir' argument.
509 (__repr__): Include 'home_dir'.
510 (Context.home_dir): New property.
511
512 qt: Make sure to remove the tofu.db on clean.
513 + commit 30a603580e0f196c721fa4bd44d24077d9bc06c3
514 * lang/qt/tests/Makefile.am (CLEANFILES): Add 'tofu.db'.
515
516 2017-02-14 Tobias Mueller <muelli@cryptobitch.de>
517
518 python: Extend SWIG gpgme_{sub,}key with a __repr__ method.
519 + commit 01d5c17587578c729bbbb60f8a65635975e35592
520 * lang/python/gpgme.i: Added a genericrepr macro and use it for
521 gpgme_key, gpgme_subkey, and gpgme_key_sig.
522
523 python: Remove the -builtin flag for SWIG.
524 + commit aa49be1ab80c200ab6b62d33bf5d0f5aa334fc56
525 * lang/python/setup.py.in: Call SWIG without the builtin flag.
526
527 python: Call SWIG_NewPointerObj rather than SWIG_Python_NewPointerObj.
528 + commit d35651917097ae2eee7d52396d53d010bc34df19
529 * lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Provide a "self"
530 variable for SWIG_NewPointerObj and call SWIG_NewPointerObj rather than
531 SWIG_Python_NewPointerObj.
532
533 python: Conditionally provide py3 argument to SWIG.
534 + commit d184dbbba8987d9f387feb25791ed891e108dabc
535 * lang/python/setup.py.in: Only call with -py3 when we run under python3
536 or higher.
537
538 2017-02-13 Justus Winter <justus@g10code.com>
539
540 python: Use one copy of the source tree per Python version.
541 + commit fe65a26ab584bd70fad45c7c4d44330e30a748a4
542 * lang/python/Makefile.am (copystamp): Create one copy per Python
543 version.
544 (all-local): Adapt.
545 (clean-local): Likewise.
546 (install-exec-local): Likewise.
547 * lang/python/tests/run-tests.py: Likewise.
548
549 build: Use macOS' compatibility macros to enable all features.
550 + commit 60273e8b2c11d42215a5707bc55e3e0d8f350e07
551 * configure.ac: On macOS, use the compatibility macros to expose every
552 feature of the libc. This is the equivalent of _GNU_SOURCE on GNU
553 libc.
554
555 Revert "Disable fd-passing for Apple."
556 + commit f8db658f8b4c3c7941d0029273fb23fbe1ba74ad
557 The actual bug has been located, so this can be reverted.
558
559 This reverts commit ef5b4ae37d13142e89a051908dc080cda3d24baa.
560
561 2017-02-13 Igor Gnatenko <ignatenkobrain@fedoraproject.org>
562
563 qt: Add missing #include <functional>
564 + commit 60064c665ec98a2a994fc6c8ad701e60b963ce7e
565 * lang/qt/src/qgpgmenewcryptoconfig.cpp,
566 lang/qt/src/threadedjobmixin.h: Include functional.
567
568 2017-02-07 Andre Heinecke <aheinecke@intevation.de>
569
570 qt: Don't rely on implicit include in t-verify.
571 + commit 903bf16a416b1bf608b1e647937c9b06864b0141
572 * lang/qt/tests/t-various.cpp: Include QTemporaryDir
573
574 2017-02-06 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
575
576 doc: Document that gpgme_op_genkey() parms parameter is not XML.
577 + commit ad22bee5387b1e9a40e8c822a081db3228bb9def
578 * doc/gpgme.texi (GnupgKeyParms): document that input format is not
579 true XML.
580
581 2017-02-03 Werner Koch <wk@gnupg.org>
582
583 core: Optimize fork/exec for *BSD and Solaris.
584 + commit 51bd69f216a9e2930eeba4b5f6c20e952a381720
585 * configure.ac (closefrom): Add to ac_check_funcs.
586 * src/posix-io.c (_gpgme_io_spawn): Use closefrom.
587
588 core: Fix possible deadlock due to get_max_fds.
589 + commit 93a59070c699d569d1eac7ba22355fe3f5d10882
590 * src/posix-io.c (get_max_fds): Do not use the Linux optimization.
591
592 core: Minor cleanup of commit 195c735.
593 + commit afc308598d1ddaf20d54b4eab30b959066a4e5e6
594 * src/verify.c (parse_tofu_user): For cleanness use gpg_error ...
595 (_gpgme_verify_status_handler): ... and gpg_err_code.
596
597 2017-02-02 Andre Heinecke <aheinecke@intevation.de>
598
599 qt: Add test for tofu conflict.
600 + commit 43160a39f27f6c3507447620666c85af00b3499c
601 * lang/qt/tests/t-tofuinfo.cpp (TofuInfoTest::testTofuConflict): New.
602
603 core: Handle multiple TOFU_USER lines in verify.
604 + commit 195c73589232160f45d00f4901c9bb2b0162f0e5
605 * src/verify.c (op_data_t): Add conflict_user_seen.
606 (parse_tofu_user): Return ERR_DUP_VALUE for mutltiple TOFU_USERS.
607 (_gpgme_verify_status_handler): Handle ERR_DUP_VALUE from
608 parse_tofu_user to ignore the next TOFU_STATS.
609
610 2017-02-02 Werner Koch <wk@gnupg.org>
611
612 core: Replace all calls to *sprintf by gpgrt_*sprintf.
613 + commit 15050ce5fce4ed815503db7c029abb38d08970d6
614 * configure.ac (vasprintf): Remove check.
615 * src/vasprintf.c: Remove file.
616 * src/util.h (vasprintf, asprintf): Remove prototypes. Replace all
617 calls to vasprintf and asprintf by gpgrt_vasprintf or gpgrt_asprintf.
618 Also take care to use gpgrt_free on the returned value.
619 * src/w32-util.c (_gpgme_get_gpgconf_path): Replace a gpgrt_asprintf
620 by _gpgme_strconcat.
621 (snprintf): New macro to use gpgrt_snprintf instead of the system's
622 standard snprintf.
623
624 core: Remove unused check for funopen/fopencookie.
625 + commit 563420a88f8a4f561a2faea4d2b4a1c58b375fd8
626 * configure.ac (funopen): Remove check.
627 * src/funopen.c: Remove file.
628
629 core: Un-deprecate gpgme_data_rewind.
630 + commit d19bea52afe6efb66a46af6aa4d09928c5d05ee5
631 * src/gpgme.h.in (gpgme_data_rewind): Un-deprecate.
632 * src/data-compat.c (gpgme_data_rewind): Move to ...
633 * src/data.c (gpgme_data_rewind): here.
634
635 core: Move all deprecated stuff to the end of gpgme.h.
636 + commit 9b7d81998b734fabeb4fbc697f08fc7795eaa90a
637
638
639 2017-02-01 Andre Heinecke <aheinecke@intevation.de>
640
641 core: Cleanup gpgme_key_unref frees.
642 + commit 8ede86795a1d419c01b4910ec2fd1fb18b629452
643 * src/key.c (gpgme_key_unref): Nowadays we assume free(NULL) is ok.
644
645 core: Fix leakage of address for mail only uids.
646 + commit b5075030bec9b21bf4e515bc1686df3fa43eced2
647 * src/key.c (gpgme_key_unref): Always free address if set.
648 (_gpgme_key_append_name): Remove memory optimization for address.
649
650 core: Improve mailbox only uid handling.
651 + commit a28d31fdb623f2ee30e8094d09f1a0d1ae446a9b
652 * src/key.c (_gpgme_key_append_name): Set email and remove name
653 for uid only keys.
654
655 2017-01-31 Justus Winter <justus@g10code.com>
656
657 qt: Increase timeout when waiting for signals.
658 + commit ba594d85e35e63301755977234d3af88a167a215
659 * lang/qt/tests/t-support.h (QSIGNALSPY_TIMEOUT): New macro.
660 * lang/qt/tests/t-encrypt.cpp: Use the new macro as timeout when
661 waiting for signals.
662 * lang/qt/tests/t-keylist.cpp: Likewise.
663 * lang/qt/tests/t-keylocate.cpp: Likewise.
664 * lang/qt/tests/t-ownertrust.cpp: Likewise.
665 * lang/qt/tests/t-wkspublish.cpp: Likewise.
666
667 2017-01-31 Werner Koch <wk@gnupg.org>
668
669 core: Add new context flag "redraw".
670 + commit 752d3597ef02a95efd693373132bf1e246f0edb0
671 * src/context.h (struct gpgme_context): New field 'redraw_suggested'.
672 * src/op-support.c (_gpgme_op_reset): Clear REDRAW_SUGGESTED.
673 * src/progress.c (_gpgme_progress_status_handler): Set REDRAW_SUGGESTED.
674 * src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "redraw".
675 * tests/run-sign.c (main): Use it.
676
677 2017-01-30 Andre Heinecke <aheinecke@intevation.de>
678
679 tests: Reduce iterations / threads.
680 + commit 7bd6ab4a91d43d7cbf5d347c0c12e0e4f9f7e3bf
681 * tests/gpg/t-gpgconf.c (main): Reduce iterations to 10.
682 * tests/gpg/t-thread-keylist-verify.c,
683 tests/gpg/t-thread-keylist.c (THREAD_COUNT): Reduce to 10.
684
685 2017-01-26 Andre Heinecke <aheinecke@intevation.de>
686
687 python: Ensure quick-random is used if gpg is gpg2.
688 + commit f3ca2c9ce9fd4a03e293065f10b92589a7e642d6
689 * lang/python/tests/Makefile.am (gpg.conf): Configure
690 agent-program accordingly.
691
692 2017-01-25 Tobias Mueller <muelli@cryptobitch.de>
693
694 python: default op_keylist_start parameters.
695 + commit 9291ebaa4151a1f6c8c0601095ec45809b963383
696 * lang/python/gpgme.i: Added gpgme_op_keylist_start with defaults
697 * lang/python/tests/t-keylist.py: Added tests for default parameters
698
699 2017-01-25 Andre Heinecke <aheinecke@intevation.de>
700
701 tests: Use --debug-quick-random for tests.
702 + commit a98951a30a6ae603ffac4ec8c5168aa6d1019933
703 * tests/start-stop-agent: Don't autostart agent on --stop and
704 running check. Use --debug-quick-random when starting.
705
706 2017-01-23 Justus Winter <justus@g10code.com>
707
708 w32: Fix closing file descriptors.
709 + commit 6f02133bb07726afa6950e5b4685e75621276e60
710 * src/w32-io.c (writer): Only stop once the buffer is drained.
711 (destroy_writer): Wait for the writers buffer to be drained. This
712 aligns '_gpgme_io_close's behavior with close(2) and fclose(3).
713
714 2017-01-17 Andre Heinecke <aheinecke@intevation.de>
715
716 tests: Add safeguards against nullptr deref.
717 + commit ca69df8c8d3f044340aee2a118cc20d33cd600a1
718 * t-gpgconf.c (main): Test some values before dereferencing them.
719
720 2017-01-16 Andre Heinecke <aheinecke@intevation.de>
721
722 qt: Use QVERIFY instead of Q_ASSERT in conf test.
723 + commit abfd241d1a1ae8e30e18b7c5e0658b8c54d89544
724 * lang/qt/tests/t-config.cpp: Use QVERIFY instead of Q_ASSERT.
725
726 qt: Add test for CryptoConfig.
727 + commit 8aba08d1d0871f439fb7193adc4a2f43a81ee216
728 * lang/qt/tests/t-config.cpp: New.
729 * lang/qt/tests/Makefile.am: Update accordingly.
730
731 2017-01-16 Justus Winter <justus@g10code.com>
732
733 tests: Fix distcheck.
734 + commit 92543da94cbf8e807b1b33070d273f995cdd5c62
735 * tests/gpg/Makefile.am (CLEANFILES): Remove gpgconf backups.
736
737 Fix changing options with gpgconf.
738 + commit 0e242278dfaa64ce31a45b72f5fa0806a3dba898
739 * src/engine-gpgconf.c (gpgconf_write): Connect a pipe to the child's
740 stderr, and wait for it to be closed as an indication that gpgconf has
741 exited. Also improve error handling.
742
743 2017-01-12 Justus Winter <justus@g10code.com>
744
745 tests: Improve the gpgconf test.
746 + commit 186dcd3494eda7383de57a530fd15776410531a5
747 * tests/gpg/t-gpgconf.c: Include support functions.
748 (fail_if_err): Remove macro.
749 (init_gpgme): Remove function.
750 (lookup): New function.
751 (main): Update some values and verify that the changes are applied.
752 * tests/gpg/t-support.h (test): New assert-like macro.
753
754 2017-01-12 Andre Heinecke <aheinecke@intevation.de>
755
756 qt: Add support for stringValueList in CryptoConf.
757 + commit 9640dc58e498966b482dcded6990cf4b47c556ac
758 * lang/qt/src/Makefile.am (qgpgme_sources): Add cryptoconfig.cpp
759 * lang/qt/src/cryptoconfig.cpp: New.
760 * lang/qt/src/cryptoconfig.h (CryptoConfigEntry::stringValueList):
761 New.
762 * lang/qt/src/qgpgmenewcryptoconfig.cpp
763 (QGpgMENewCryptoConfigEntry::stringValueList): New.
764 * lang/qt/src/qgpgmenewcryptoconfig.h: Update accordingly.
765
766 qt: Don't use qstrdup in test passphrase cb.
767 + commit a09ed3f26a1fab54079c37c49df5c440cc792f78
768 * lang/qt/tests/t-support.h (TestPassphraseProvider::getPassphrase):
769 Use gpgrt_asprintf instead of strdup.
770
771 2017-01-11 Andre Heinecke <aheinecke@intevation.de>
772
773 qt: Clean up test dirs on failure.
774 + commit 56926c9b5012e8135541a933af1d69c5a81f02b3
775 * t-encrypt.cpp,
776 t-keylist.cpp,
777 t-keylocate.cpp,
778 t-ownertrust.cpp,
779 t-tofuinfo.cpp,
780 t-various.cpp,
781 t-verify.cpp,
782 t-wkspublish.cpp: Use QVERIFY instead of Q_ASSERT
783
784 qt: Add test for uid functions.
785 + commit 9e643ab67168dfbd189ccc0bfed8fb59253ee79c
786 * lang/qt/tests/t-various.cpp: New.
787 * lang/qt/tests/Makefile.am: Update accordingly.
788
789 cpp: Add revuid and adduid support.
790 + commit e416f9961837039f259558edf41fccbc181ad128
791 * lang/cpp/src/context.cpp
792 (Context::revUid, Context::startRevUid),
793 (Context::addUid, Context::startAddUid): New.
794 * lang/cpp/src/context.h: Declare new functions.
795 * lang/cpp/src/key.cpp (Key::UserID::revoke)
796 (Key::addUid): Idomatic helpers.
797 lang/cpp/src/key.h: Declare new functions.
798 * NEWS: Update accordingly.
799
800 Fix Qgpgme build for macos.
801 + commit efe58fe011f195d98adb4f03b1e1068a26ba287b
802 * lang/qt/src/dn.cpp: Include string.h
803 (parse_dn_part): Use qstrdup.
804 * lang/qt/tests/t-support.h (getPassphrase): Use qstrdup.
805
806 Fix cmake configuration files for MacOS.
807 + commit 2e661b9e1a9b50656a5c9646d7444a98477010c1
808 * configure.ac: Set HAVE_MACOS_SYSTEM conditional.
809 * lang/qt/src/Makefile.am,
810 lang/cpp/src/Makefile.am,
811 lang/qt/src/QGpgmeConfig.cmake.in.in,
812 lang/cpp/src/GpgmeConfig.cmake.in.in: Use libsuffix again to
813 distinguish between macos .dylib
814
815 2017-01-03 Justus Winter <justus@g10code.com>
816
817 python: Improve compatibility with Scheme tests.
818 + commit b14419f68b3aaa90025e0e97151de7c3da7806fb
819 * lang/python/tests/run-tests.py: Add stub --parallel option.
820
821 python: Add a switch '--quiet' to the test runner.
822 + commit d0e91d28f63b74e53673902e675be8a54b6b90d3
823 * lang/python/tests/run-tests.py: Add and honor a switch '--quiet'.
824 This way we can use this script to run Python tests one by one without
825 the noise, and the script will setup the necessary environment for us.
826
827 2017-01-02 Andre Heinecke <aheinecke@intevation.de>
828
829 qt: Update config sync doc / comment.
830 + commit ececfd5de81f1851943be7b284b672d5b02aceb4
831 * lang/qt/src/cryptoconfig.h (CryptoConfig::sync): Document
832 that runtime option is always set.
833 * lang/qt/Src/qgpgmenewcryptoconfig.cpp
834 (QGpgMENewCryptoConfigComponent::sync): Remove outdated comment
835 and warn on error.
836
837 core: Always use runtime for gpgconf changes.
838 + commit 7103315829847163f1c6f52cad25d1ddb33358f0
839 * src/engine-gpgconf.c (gpgconf_write): Add --runtime.
840 * src/gpgme.h.in (gpgme_conf_opt_change): Document this
841 behavior.
842
843 2017-01-01 Ben Kibbey <bjk@luxsci.net>
844
845 Fix gpg_addkey() to work with GPGME_CREATE_NOPASSWD as well.
846 + commit a4b9f1a2b404fd8627d5ac567617510abd55d980
847 * src/engine-gpg.c (gpg_addkey): Pass --batch to gpg when
848 GPGME_CREATE_NOPASSWD is set to fix pinentry without loopback mode.
849
850 2016-12-27 Ben Kibbey <bjk@luxsci.net>
851
852 Fix GPGME_CREATE_NOPASSWD without pinentry loopback.
853 + commit d83b8f0dc84d6cf7fe2e091bd1b103ceedfa3d6c
854 * src/engine-gpg.c(gpg_createkey): Pass --batch to gpg when
855 GPGME_CREATE_NOPASSWD is set.
856
857 2016-12-19 Raphael Kubo da Costa <rakuco@FreeBSD.org>
858
859 Qt: Make sure extended grep is used with '|'.
860 + commit 211844f049d714cd4d5aab96347705cb0c209c5d
861 * m4/qt.m4: Use grep -E when using the alternation character.
862
863 2016-12-16 Andre Heinecke <aheinecke@intevation.de>
864
865 cpp: Ensure that hasSecret is correct after update.
866 + commit da5343a9d2c8c0ca6431162aac4bd5c73b4ae6dd
867 * lang/cpp/src/key.cpp (Key::update): Check for
868 a secret key first before listing public keys.
869
870 2016-12-15 Andre Heinecke <aheinecke@intevation.de>
871
872 cpp: Fix addrSpec for keys without email.
873 + commit 85e05537e15346896a271d3f62bead9dd7e3f180
874 * lang/cpp/src/key.cpp (UserID::addrSpec): Use uid->address instead
875 of normalizing again.
876 (&operator<<(std::ostream &, const UserID &): Print it.
877
878 cpp: Fix update of partial key in verifyresult.
879 + commit 5673f3e54af535155893290a685b3afb44c7f58d
880 * lang/cpp/src/verificationresult.cpp
881 (Signature::key(bool,bool)): Don't update the returned copy
882 but the actual key of the signature.
883
884 2016-12-07 Andre Heinecke <aheinecke@intevation.de>
885
886 Clarify what "checking on bit" means.
887 + commit 7880335273382f05cbbe38aa965a566c4127ba6a
888 * doc/gpgme.texi (gpgme_sigsum_t summary): Clarify what "you
889 can check one bit means"
890
891 2016-12-05 Tobias Mueller <muelli@cryptobitch.de>
892
893 python: Try to be more helpful when given a string to encrypt().
894 + commit 05896c210f7fa9ce7b97784a75e49dc4489e9252
895 * lang/python/helpers.c (_gpg_obj2gpgme_data_t): Extended error
896 message.
897 * lang/python/tests/t-encrypt.py: Test for "encode" in error message.
898
899 python: Define a macro for wrapping fragile result objects.
900 + commit fb7f4cb973abc9f5eb05eb240607be35c1be986c
901 * lang/python/gpgme.i (wrapresult): New Macro.
902
903 2016-12-01 Tobias Mueller <muelli@cryptobitch.de>
904
905 python: Check "buffer" when writing to sys.stdout for python2 compat.
906 + commit ae21d2705fc46725e1f9af1651b68d16155d1501
907 * lang/python/tests/support.py (print_data): Add check for buffer.
908
909 python: Make Context have a repr method.
910 + commit 154389f2a5e4c13081cf0624222aad29ee480b56
911 * lang/python/gpg/core.py (Context.__repr__): New function.
912
913 python: Make Results have a nicer __repr__.
914 + commit db2f6c1ca3d2ef228f4ca6653d594537622c8588
915 * lang/python/gpg/results.py (Result.__str__): Renamed to '__repr__'
916 ...
917 * lang/python/gpg/results.py (Result.__repr__): ... and added fields.
918
919 2016-11-25 Justus Winter <justus@g10code.com>
920
921 python: Fix removing the TOFU database.
922 + commit fd4d476214ae06e33f4a6dac534d3deca5cc6cd3
923 * lang/python/Makefile.am (CLEANFILES): Move 'tofu.db'...
924 * lang/python/tests/Makefile.am (CLEANFILES): ... here.
925
926 tests: Remove tofu.db.
927 + commit 9b22f82afc5518961e4bea1fc516b79800e379a2
928 * lang/python/Makefile.am (CLEANFILES): Add 'tofu.db'.
929 * tests/gpg/Makefile.am (CLEANFILES): Likewise.
930
931 2016-11-17 Heiko Becker <heirecka@exherbo.org>
932
933 Remove a forgotten instance of @libsuffix@
934 + commit 572c1aac107125ce62230251713349348373db5a
935 * lang/cpp/src/GpgmeppConfig.cmake.in.in: Remove a forgotten
936 instance of @libsuffix@.
937
0938 2016-11-16 Werner Koch <wk@gnupg.org>
1939
2940 Release 1.8.0.
941 + commit f06220b691e9711afdabaa19886244ae7724eed5
3942 * configure.ac: Set version to 1.8.0. Set LT version C28/A17/RO.
4943 Set CPP LT version to C9/A3/R0. Set Qt LT version to C8/A1/R0.
5944
6945 core: Do not leak the override session key to ps(1).
946 + commit 9fc92a15bd0a30437a39d0eb28b6f40edc22e6e8
7947 * src/engine-gpg.c (struct engine_gpg): New field
8948 override_session_key.
9949 (gpg_release): Free that field.
14954 2016-11-16 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15955
16956 doc,tests: Require use of ctx_flag before use of session_key.
957 + commit 573064742145aa5f9bf04baa88af918c0c4d5e12
17958 * doc/gpgme.texi: Document requirements of verifying that it is OK to
18959 use session_key.
19960 * tests/run-decrypt.c: Ensure that we fail if we're unable to access
38979 2016-11-15 Andre Heinecke <aheinecke@intevation.de>
39980
40981 qt, cpp: Add cmake config files for w32.
982 + commit b2c07bd47bd608afa5cc819b60a7b5bb8c9dd96a
41983 * lang/cpp/src/GpgmeppConfig-w32.cmake.in.in
42984 lang/qt/src/QGpgmeConfig-w32.cmake.in.in: New.
43985 * lang/cpp/src/GpgmeppConfig.cmake.in.in,
47989 * configure.ac: Configure them.
48990
49991 qt: Use new style connect in th..mixin.
992 + commit 45abe6d142e314ba7099ad80b6365af171b06fec
50993 * lang/qt/src/threadedjobmixin.h
51994 (ThreadedJobMixin::lateInitialization): Use new style connect.
52995
53996 2016-11-15 Werner Koch <wk@gnupg.org>
54997
55998 core: Implement context flag "override-session-key".
999 + commit 7659d42468b604db2936b021425683f407eba4a7
561000 * src/gpgme.c (gpgme_set_ctx_flag): Add flags "export-session-key" and
571001 "override-session-key".
581002 (gpgme_get_ctx_flag): Ditto.
811025 (main): Add options --export-session-key and --override-session-key.
821026
831027 core: Add public function gpgme_get_ctx_flag.
1028 + commit 3234b1bf1d6939772677d64f6c1e1820ec98e3cd
841029 * src/gpgme.h.in (gpgme_get_ctx_flag): New.
851030 * src/gpgme.c (gpgme_set_ctx_flag): Move down the file and add a trace
861031 statement.
901035 2016-11-15 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
911036
921037 core: Enable extraction of session keys.
1038 + commit cad1210fb8a7402cb29e607f8f9680005314120d
931039 * src/gpgme.c (gpgme_set_export_session_keys): New function.
941040 (gpgme_get_export_session_keys): New function.
951041 * src/gpgme.h.in (struct _gpgme_op_decrypt_result): Add session_key
1261072 2016-11-14 Andre Heinecke <aheinecke@intevation.de>
1271073
1281074 qt: Add API to get the context for a Job.
1075 + commit 9451faa2ee333904cff59f92ab62918e13ab4b87
1291076 * lang/qt/src/job.cpp,
1301077 lang/qt/src/job.h (Job::context): New.
1311078 * lang/qt/src/threadedjobmixin.cpp
1341081 * NEWS: Update for cpp and qt.
1351082
1361083 cpp: Add get / set Sender API.
1084 + commit d09a84eaf1e4f8c6c2e462995fa15c1a5690a6ce
1371085 * cpp/src/context.cpp, cpp/src/context.h (Context::setSender),
1381086 (Context::getSender): Add simple wrappers.
1391087
1401088 qt, cpp: Enable dll build for windows.
1089 + commit f3790ddf56558fb0a08af95fdbae979cd6589aad
1411090 * lang/cpp/src/Makefile.am,
1421091 lang/qt/src/Makefile.am: Add -no-undefined to LDFLAGS.
1431092
1441093 w32: Fix build of w32-glib.
1094 + commit b91c383386fe9eadd90afdb9bb1f8ec6c528173b
1451095 * src/Makefile.am (main_sources): Remove system_components_not_extra.
1461096 (libgpgme_la_SOURCES): Add system_components_not_extra.
1471097 (libgpgme_glib_la_SOURCES): Remove duplicated ath files.
1491099 2016-11-11 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
1501100
1511101 doc: Correct deftypefun for gpgme_op_decrypt_verify_start.
1102 + commit 16a30205064914eef578d84d07141b5d51d82838
1521103 * doc/gpgme.texi: Documentationabout gpgme_op_decrypt_verify_start was
1531104 stored under the name gpgme_op_decrypt_verify instead.
1541105
1551106 doc: Correct text about gpgme_cancel_async.
1107 + commit d50bdb269e86db36a443958e3bfc6816a44d468e
1561108 * doc/gpgme.texi: Documentation about gpgme_cancel_async should refer
1571109 to the correct name.
1581110
1591111 core: Non-zero values should set _armor, _textmode, and _online.
1112 + commit da035768bd9a880becee5d0d553dfe12299f96eb
1601113 * src/gpgme.c (gpgme_set_armor, gpgme_set_textmode,
1611114 gpgme_set_offline): Ensure that non-zero values actually set the
1621115 appropriate internal bit.
1641117 2016-11-11 Alon Bar-Lev <alon.barlev@gmail.com>
1651118
1661119 tests,python: Atomic directory creation.
1120 + commit 41d8c7e51a8989be633b9ada124c58a01fae7d54
1671121 * lang/python/tests/Makefile.am: Use MIDIR_P.
1681122 * tests/gpg/Makefile.am: Ditto.
1691123 * tests/gpgsm/Makefile.am: Ditto.
1711125 2016-11-10 Werner Koch <wk@gnupg.org>
1721126
1731127 core: Use better error code when using select with a too high fd.
1128 + commit 6e57379c8e37c0863f7d12819a5a7d0781bd76d2
1741129 * src/posix-io.c (_gpgme_io_select): Return EMFILE instead of EBADF.
1751130
1761131 2016-11-10 Andre Heinecke <aheinecke@intevation.de>
1771132
1781133 tests: Reduce thread count in new thread tests.
1134 + commit ddd0a3cf90ac4b0a27ea610ebd7b9b8016ff43c4
1791135 * gpg/t-thread-keylist-verify.c,
1801136 gpg/t-thread-keylist.c: Reduce threads to 100
1811137
1821138 2016-11-10 Werner Koch <wk@gnupg.org>
1831139
1841140 core: Detect unreadable keyrings.
1141 + commit 2a39bd6c30d21c43c86645a7908ce6c57dad5e20
1851142 * src/keylist.c (op_data_t): Add field keydb_search_err.
1861143 (keylist_status_handler): Parse STATUS_ERROR into that var.
1871144 (gpgme_op_keylist_next): Use that err instead of GPG_ERR_EOF.
1891146 2016-11-10 Andre Heinecke <aheinecke@intevation.de>
1901147
1911148 tests: Fix additional memleaks in thread tests.
1149 + commit d0030efb45ec8436dd84a9623d2f66b80c6b9e10
1921150 * tests/gpg/t-thread-keylist-verify.c (start_verify): Release
1931151 data.
1941152 (start_keylist): Unref keys.
1951153 * tests/gpg/t-thread-keylist.c (start_keylist): Unref keys.
1961154
1971155 tests: Improve new thread tests.
1156 + commit 4d5174e4a83dcd524f8085f6646145f81b50a02a
1981157 * tests/gpg/t-thread-keylist-verify.c (start_keylist): Mark
1991158 arg as unused. Release context.
2001159 (start_verify): Ditto.
2041163 (main): Mark args as unused.
2051164
2061165 core: Use gpgrt locking for thread safeness.
1166 + commit 09b64554328445e99a8cc78fc34ea49c2ea2e7f9
2071167 * configure.ac: Require libgpg-error 1.17. No longer
2081168 check for pthread.
2091169 * doc/gpgme.texi: Document removed neccessity for thread
2291189 2016-11-09 Justus Winter <justus@g10code.com>
2301190
2311191 python: Require at least GPGME 1.7 for out-of-tree builds.
1192 + commit f1f341062e24724e26928d893dd5769d3ccf5fa2
2321193 * lang/python/setup.py.in: Bump required version to 1.7.
2331194
2341195 2016-11-09 Werner Koch <wk@gnupg.org>
2351196
2361197 w32: Better protect the IO-system's fd_table.
1198 + commit 10f2e1c30be651e74a03f4563a9f212d7416adb3
2371199 * src/w32-io.c (fd_table_lock): New.
2381200 (new_fd): Lock allocation of a new slot.
2391201 (release_fd): Lock deallocation of a slot.
2411203 2016-11-04 Andre Heinecke <aheinecke@intevation.de>
2421204
2431205 cpp: Add API for swdb queries.
1206 + commit 3509cf2f9846360848b6c08d36cbca18373c935e
2441207 * lang/cpp/src/swdbresult.cpp,
2451208 lang/cpp/src/swdbresult.h (SwdbResult): New.
2461209 * lang/cpp/src/Makefile.am: Update accordingly.
2471210
2481211 cpp: Add more EngineInfo::Version ctors.
1212 + commit 512de91f9a8da8f491e09653eb4b5bdd0a027198
2491213 * lang/cpp/src/engineinfo.h
2501214 (EngineInfo::Version::Version(const char*)),
2511215 (EngineInfo::Version::Version()): New.
2521216
2531217 cpp: Don't include gpgme.h in tofuinfo header.
1218 + commit 4d3f33d0e9d960df2c34fb4d215987ab4d36111c
2541219 * lang/cpp/src/tofuinfo.h: Don't include gpgme.h
2551220
2561221 cpp: Extend gpgmefw for tofuinfo and swdb query.
1222 + commit 23979b9be5a6028e3e9cafc3aff632bc720b81f2
2571223 * lang/cpp/src/gpgmefw.h (gpgme_tofu_info_t)
2581224 (gpgme_query_swdb_result_t): New forwards.
2591225
2601226 2016-11-04 Werner Koch <wk@gnupg.org>
2611227
2621228 w32: Fix locating gpgconf on 64 bit systems.
1229 + commit df08a0ca3f029b06b7e3a6bd63330df5cb96585a
2631230 * src/w32-util.c (find_program_at_standard_place): Use access to check
2641231 whether the binary is at CSIDL_PROGRAM_FILES before testing
2651232 CSIDL_PROGRAM_FILESX86.
2671234 2016-11-03 Werner Koch <wk@gnupg.org>
2681235
2691236 core: Add gpgme_op_query_swdb and helper.
1237 + commit aad94cb7c313d4501bed748f48830cbb93c67e20
2701238 * src/gpgme.h.in (gpgme_query_swdb_result_t): New.
2711239 (gpgme_op_query_swdb): New.
2721240 (gpgme_op_query_swdb_result): New.
2901258 2016-11-03 Andre Heinecke <aheinecke@intevation.de>
2911259
2921260 qt: Change license of export / version header.
1261 + commit 34a4e8017be452e8ead6b9c2da84be1ec7929cae
2931262 * lang/qt/src/qgpgme_export.h,
2941263 lang/qt/src/qgpgme_version.h: Change license to GPLv2+
2951264
2961265 2016-11-03 Werner Koch <wk@gnupg.org>
2971266
2981267 core: Make use of --homedir in gpgconf.
1268 + commit 0c2038c0043c1e79547b55e79c3d3e267dae801c
2991269 * src/engine-gpgconf.c (struct engine_gpgconf): Add field 'version'.
3001270 (have_gpgconf_version): New.
3011271 (gpgconf_release): Free VERSION.
3051275 2016-11-02 Andras Mantia <andras@kdab.com>
3061276
3071277 qt: Fix build with g++ 4.8.x.
1278 + commit b4658f6a1110bb0b54bd5dfc9df8e8b390e38d61
3081279 * lang/qt/src/defaultkeygenerationjob.cpp
3091280 (DefaultKeyGenerationJob::start): Explicitly connect pointer
3101281 in the QPointer.
3121283 2016-11-02 Andre Heinecke <aheinecke@intevation.de>
3131284
3141285 qt, cpp: Fix versioning in cmake config and header.
1286 + commit bf9aa0ccf7b0165aa3a1af2bdb18daca7c02ce74
3151287 * configure.ac (VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO): New
3161288 subst variables for the version header.
3171289 * lang/cpp/src/GpgmeppConfigVersion.cmake.in,
3201292 lang/qt/src/qgpgme_version.h.in: Use new variables.
3211293
3221294 qt: Install cmake config into qgpgme subdir.
1295 + commit b5c4d56cfdcafade3467be100fca6f1c89ecab73
3231296 * lang/qt/src/Makefile.am: Install cmake config file in qgpgme subdir.
3241297
3251298 qt: Require gpgmepp from cmake config script.
1299 + commit 4149194d2e2f2f4d142926ba4d4efbd336b543f2
3261300 * lang/qt/src/QGpgmeConfig.cmake.in.in: Require cpp.
3271301
3281302 qt, cpp: Add all generated files to cleanfiles.
1303 + commit 8486f213423311174ebff5cba74127cbd9bb3c2a
3291304 * cpp/src/Makefile.am (CLEANFILES),
3301305 qt/src/Makefile.am (CLEANFILES): Add all generated files
3311306 to cleanfiles.
3331308 2016-11-01 Andre Heinecke <aheinecke@intevation.de>
3341309
3351310 qt: Add Distinguished Name parser from libkleo.
1311 + commit 627c5deed84b4481710b6c0de06b26e886679bbe
3361312 * lang/qt/src/dn.cpp (DN, DN::Attribute): New public API.
3371313 * lang/qt/src/dn.h: New.
3381314 * lang/qt/src/Makefile.am: Update accordingly.
3391315
3401316 qt, cpp: Install version headers in subdirs.
1317 + commit 567123de21247cab05762d799400739a12eb67ae
3411318 * lang/cpp/src/Makefile.am,
3421319 lang/qt/src/Makefile.am: Install version headers in include
3431320 subdirs.
3451322 2016-10-31 Justus Winter <justus@g10code.com>
3461323
3471324 python: Use vanity modules for constants in tests and examples.
1325 + commit 4b3264345084a0c9bf9f97fb233df700d7608e66
3481326 * lang/python/gpg/constants/sig/notation.py: New file.
3491327 * lang/python/gpg/constants/sig/__init__.py: Import new module.
3501328
3741352 * lang/python/tests/t-wait.py: Likewise.
3751353
3761354 python: Import the topmost module in tests and examples.
1355 + commit 20dc37a0e7e1531b0e568a6ec29b1c2d18de59c3
3771356 * examples/verifydetails.py: Only import the topmost module 'gpg' and
3781357 update the code accordingly.
3791358 * tests/support.py: Likewise.
3991378 * tests/t-wrapper.py: Likewise.
4001379
4011380 python: Improve constants module.
1381 + commit 70b7064e5c4f3eff9c296c00156724bc0cdaa64f
4021382 * lang/python/gpg/constants/__init__.py: Import all modules below
4031383 'constants/'. Interface hygiene: delete 'util'.
4041384 * lang/python/gpg/constants/data/encoding.py: Delete 'util'.
4161396 2016-10-31 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4171397
4181398 python: Rename Python module from PyME to gpg.
1399 + commit 2fac017618a76882605125b05ff1f7393fe99860
4191400 This follows weeks of discussion on the gnupg-devel mailing list.
4201401 Hopefully it will make it easier for people using Python to use GnuPG
4211402 in the future.
4231404 2016-10-25 Werner Koch <wk@gnupg.org>
4241405
4251406 core: New API functions gpgme_set_sender, gpgme_get_sender.
1407 + commit b8159eadb5636cd9d93ee60c41e75d5978927870
4261408 * src/context.h (struct gpgme_context): Add field 'sender'.
4271409 * src/gpgme.c: Include mbox-util.h.
4281410 (gpgme_release): Free SENDER.
4451427 2016-10-19 Andre Heinecke <aheinecke@intevation.de>
4461428
4471429 qt: Improve WKSPublishJob apidoc.
1430 + commit 26cbba3c9cb04a68b95f3a6000ac9bd93fe76dd7
4481431 * lang/qt/src/wkspublishjob.h: Improve doc.
4491432
4501433 2016-10-18 Werner Koch <wk@gnupg.org>
4511434
4521435 Release 1.7.1.
1436 + commit 2c490cdb3e50761c498357982445ebb01f18dc1e
4531437 * configure.ac: Set LT version to C27/A16/R0. Note that the LT
4541438 versions for cpp and Qt have already been updated.
4551439
4561440 2016-10-14 Werner Koch <wk@gnupg.org>
4571441
4581442 tests: Make t-cancel more portable.
1443 + commit 05e8e1260baa5cbc6f1d6e387e642c1f6c188d44
4591444 * tests/gpg/t-cancel.c: Include sys/time.h and protect sys/select.h.
4601445
4611446 python: Call ln(1) in a portable way.
1447 + commit c6cab5a2bd6e7ed226c6c3f0b78b3f48b47db74c
4621448 * lang/python/Makefile.am: Specify target dir for ln.
4631449
4641450 2016-10-14 Andre Heinecke <aheinecke@intevation.de>
4651451
4661452 cpp: Fix init of string from null.
1453 + commit 1e8c34a9192956bb2fe96a7a6a76ff59de8d1c0c
4671454 * lang/cpp/src/key.cpp (UserID::addrSpecFromString): Check return
4681455 value before creating the string.
4691456
4701457 2016-10-13 Justus Winter <justus@g10code.com>
4711458
4721459 python: Make 'get_key' more idiomatic.
1460 + commit f526d0e22e8b881ccbca66b46a0e1b68bbc4cd6b
4731461 * lang/python/pyme/core.py (Context.get_key): Raise errors.KeyNotFound
4741462 if the key is not found. This error is both a KeyError for idiomatic
4751463 error handling as well as a GPGMEError so we don't break existing
4791467 * lang/python/tests/t-keylist.py: Test the new behavior.
4801468
4811469 python: Return public keys by default.
1470 + commit 1e6073ffa98db2c265adbcf0dbbe70c067a910f0
4821471 * lang/python/pyme/core.py (Core.get_key): Return public keys by
4831472 default, improve docstring.
4841473 * lang/python/examples/testCMSgetkey.py: Update example.
4851474 * lang/python/examples/verifydetails.py: Likewise.
4861475
487 GnuPG-bug-id: 2751
488
4891476 python: Fix example.
1477 + commit cabd4c74e52c8983d624b6877cddc7f8912eff04
4901478 * lang/python/examples/inter-edit.py: Fix example.
4911479
492 Fixes-commit: a458e7fe
493
4941480 2016-10-13 Andre Heinecke <aheinecke@intevation.de>
4951481
4961482 cpp: Fix version number.
1483 + commit 56302e7bb6a694a7c570f389f9a7883efdfdaf42
4971484 * configure.ac (LIBGPGMEPP_LT_CURRENT): Bump.
4981485
4991486 qt, cpp: Fix permissions of Config files.
1487 + commit a274c7590aa0e38d682d5177904983632f471cb0
5001488 * lang/cpp/src/Makefile.am,
5011489 lang/qt/src/Makefile.am: Do not install config files as executable.
5021490
5031491 qt: Install SpecialJob.
1492 + commit 2538c12fa0728f4113f83f69f8c8ec9efb163872
5041493 * lang/qt/src/Makefile.am: Install SpecialJob
5051494 * NEWS: mention it.
5061495
5071496 qt, cpp: Fix expected targets in Config files.
1497 + commit a3cf30f89418c8a6bc9456533d95ba7fc2a33a4c
5081498 * lang/cpp/src/GpgmeppConfig.cmake.in.in,
5091499 lang/qt/src/QGpgmeConfig.cmake.in.in: Remove KF5 variants.
5101500
5111501 2016-10-11 Daniel Vrátil <dvratil@kde.org>
5121502
5131503 qt: Add missing implementation of MultiDeleteJob.
1504 + commit e5a35af5573651b96a90ef4a537b040333595472
5141505 * lang/qt/src/multideletejob.h: Fix include, cryptobackend.h is now
5151506 called protocol.h
5161507 * lang/qt/src/multideletejob.cpp: New file.
5171508 * lang/qt/src/Makefile.am: Add multideletejob.cpp.
5181509
5191510 qt: Install abstractimportjob.h.
1511 + commit ce7385caabb57e5435695cc912acffe2815770b7
5201512 * lang/cpp/src/Makefile.am: Install abstractimportjob.h since it's
5211513 included from importjob.h
5221514
5231515 2016-10-11 Andre Heinecke <aheinecke@intevation.de>
5241516
5251517 cpp: Add API for gpgme_addrspec_from_uid.
1518 + commit 54f94b14e2bb9b38ffd89f509406bfbd012da632
5261519 * lang/cpp/src/key.cpp (UserID::addrSpecFromString): New static
5271520 function to expose addrspec from uid.
5281521 (UserID::addrSpec): New. Get addrSpec from Userid.
5311524 2016-10-10 Andre Heinecke <aheinecke@intevation.de>
5321525
5331526 Add NEWS for cpp and qt, bump cpp version.
1527 + commit e7ceb83a5969581f5e1b0b6a69d18a93b594f6d4
5341528 * NEWS: Add entries for cpp and qt changes.
5351529 * configure.ac: Bump cpp version because of added API.
5361530
5371531 Add convenience function to get key from sig.
1532 + commit b6b820bff14a9aa8fa67755b246c90062ffdba14
5381533 * lang/cpp/src/verificationresult.cpp (Signature::key(bool, bool)):
5391534 New. Can be used to search / update the key associcated with this
5401535 signature.
5411536
5421537 cpp: Return null key if the signature had no key.
1538 + commit 34e9dfee81958160f6604849b63369ae4de67417
5431539 * lang/cpp/src/verificationresult.cpp (Private): Add null key
5441540 to list when there is no key associated with the signature.
5451541
5461542 qt: Add simple verify test.
1543 + commit f131a5e72b0881cafcc3b0a91da8f050af2684a6
5471544 * lang/qt/tests/t-verify.cpp: New. Small test if a signature
5481545 returns a key with fingerprint.
5491546 * lang/qt/tests/Makefile.am: Add new test.
5501547
5511548 core: Fix w32 crash in find_program_in_dir.
1549 + commit 098a2da15b1b46b145add623dec0488abd39bd74
5521550 * src/w32-util.c (find_program_in_dir): Fix call to _gpgme_strconcat.
5531551
5541552 2016-10-08 Werner Koch <wk@gnupg.org>
5551553
5561554 core: New helper function gpgme_addrspec_from_uid.
1555 + commit 0ea2ff67900c243fff9f689658dcb23d1c0961cd
5571556 * src/gpgme.h.in: Add gpgme_addrspec_from_uid.
5581557 * src/gpgme.def, src/libgpgme.vers: Ditto.
5591558 * src/mbox-util.c (gpgme_addrspec_from_uid): New.
5611560 2016-10-06 Justus Winter <justus@g10code.com>
5621561
5631562 Add missing includes.
1563 + commit 857592041b8355cd58a7068c9f2446cf8dc0968f
5641564 * lang/cpp/src/key.cpp: Include <strings.h> for 'strcasecmp'.
5651565 * tests/gpg/t-cancel.c: Include <sys/select.h> for 'fd_set' and
5661566 friends.
5681568 2016-10-05 Andre Heinecke <aheinecke@intevation.de>
5691569
5701570 cpp: Bump Revision.
1571 + commit 8033cff441e9ea185531290273ec343f3402703c
5711572 * configure.ac (LIBGPGMEPP_LT_REVISION): Bump revision.
5721573
5731574 qt: Fix spelling error in WKSPublishJob.
1575 + commit 88c7e84ede4b6017cac3a396e8c87c2bd3a2bf58
5741576 * src/qgpgmewkspublishjob.cpp,
5751577 src/qgpgmewkspublishjob.h,
5761578 src/wkspublishjob.h,
5791581 accordingly.
5801582
5811583 qt: Disable tests that require a password for 2.0.
1584 + commit 24779c9e2301bd17fd328d65b0383e1cbc944119
5821585 * lang/qt/tests/t-encrypt.cpp: Disable tests that require
5831586 a password for 2.0.
5841587
5851588 Add warning flags for c++ compiler, too.
1589 + commit 4984cc93db6b55f2420a9abd844c074a5fb4ed0c
5861590 * configure.ac (CXXFLAGS): Add Wall and Wextra.
5871591
5881592 qt: Fix unused variable warnings.
1593 + commit 9d1df990386010e0581b542a76a4f5d85d8d11b5
5891594 * qt/src/qgpgmenewcryptoconfig.cpp,
5901595 qt/src/threadedjobmixin.h,
5911596 qt/tests/t-encrypt.cpp,
5931598 qt/tests/t-wkspublish.cpp: Mark additional variables as unused.
5941599
5951600 cpp: Add support for URL Data encodings.
1601 + commit 370ee1aa802ec6a4030a39b2df7d24a0c47e5ac7
5961602 * lang/cpp/src/data.h (Data::Encoding): Extend enum.
5971603 * lang/cpp/src/data.cpp (Data::encoding),
5981604 Data::setEncoding): Support new values.
5991605
6001606 cpp: Fix gcc diagnostic push / pop.
1607 + commit 39dd7585f5a7d801942efcb375d6dd46d01d2968
6011608 * lang/cpp/src/context.cpp: Fix pragmas.
6021609
6031610 qt: Disable t-wkspublish test.
1611 + commit 52a91ccc6a25425d4374b77040e30efb6816940f
6041612 * lang/qt/tests/Makefile.am (TESTS): Remove t-wkspublish.
6051613
6061614 2016-09-30 Alon Bar-Lev <alon.barlev@gmail.com>
6071615
6081616 python: Link 'data.h' and 'config.h' into the builddir.
1617 + commit 453ab9d24ca48c9e01d21e1454d6b08de1938b76
6091618 * lang/python/Makefile.am: Link to the files.
6101619 * lang/python/gpgme.i: Update path.
6111620 * lang/python/setup.py.in: Do not add the top builddir to the include
6121621 path.
6131622
6141623 python: Add 'prepare' target.
1624 + commit 68fb8371a1dd5f4e05e50b1733f9996d139cbf38
6151625 * lang/python/Makefile.am: Add 'prepare' target.
6161626
6171627 2016-09-29 Andre Heinecke <aheinecke@intevation.de>
6181628
6191629 cpp, qt: Handle modified includedir installation.
1630 + commit 7302791c0d308c3284ac24a743035d27a0c0b6ba
6201631 * lang/cpp/src/Makefile.am,
6211632 lang/qt/src/Makefile.am: Replace resolved_includedir.
6221633 * lang/cpp/src/GpgmeppConfig.cmake.in.in,
6261637 2016-09-27 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
6271638
6281639 Clarify licensing.
1640 + commit 145392f07f42ef23ebcb83a917b4d8e2964e7aa8
6291641 * src/b64dec.c, src/mbox-util.c, src/mbox-util.h: These three files
6301642 are explicitly licensed under LGPL, but their comments suggest that
6311643 details about the warranty can be found in the GPL. Adjust comments
6341646 2016-09-27 Justus Winter <justus@g10code.com>
6351647
6361648 tests: Fix check for gpg versions not reporting the critical flag.
1649 + commit a423603f80d9eb653ce9c171662db2175d7456f5
6371650 * lang/python/tests/t-sig-notation.py: Also blacklist 2.0.x.
6381651 * tests/gpg/t-sig-notation.c: Likewise.
6391652
6401653 2016-09-26 Justus Winter <justus@g10code.com>
6411654
6421655 python: Correctly translate to size_t.
1656 + commit c38fabfea0601ed5f61e27e0bf43f8e74c67ce2a
6431657 * lang/python/gpgme.i: Correctly translate Python number to size_t.
6441658
6451659 python: Correctly translate off_t.
1660 + commit 1d80e7374aa3150306c86afe7acdc8e8eb05143f
6461661 * lang/python/gpgme.i: Improve int/long translations, correctly handle
6471662 off_t with large file support.
6481663
6491664 python: Include 'config.h'.
1665 + commit 3703a4723899d7563937b4b99f5bbe4dd8d3dfed
6501666 * lang/python/Makefile.am: Pass 'top_builddir' to 'setup.py'.
6511667 * lang/python/gpgme.i: Include 'config.h'.
6521668 * lang/python/helpers.c: Likewise.
6561672 2016-09-23 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
6571673
6581674 Fix spelling.
1675 + commit 95f38652f696476b38a040644eac40b4511d2b32
6591676 * lang/cpp/src/context.h, lang/qt/src/protocol.h,
6601677 lang/qt/src/wkspublishjob.h, src/data-identify.c, src/engine-gpg.c:
6611678 minor spelling cleanup.
6621679
6631680 move some file encodings to UTF-8.
1681 + commit a11450eb048df79a3f2b00ebef6d7cab07ad5054
6641682 * THANKS, doc/ChangeLog-2011, tests/ChangeLog-2011,
6651683 tests/gpg/geheim.txt: convert from iso 8859-1 to utf-8.
6661684 * lang/qt/src/dataprovider.cpp, lang/qt/src/qgpgmerefreshkeysjob.cpp,
6701688 2016-09-23 Andre Heinecke <aheinecke@intevation.de>
6711689
6721690 tests: Check data after decryption.
1691 + commit 9b38817968b90caf73f123255fe427691e82fec4
6731692 * tests/gpgsm/t-decrypt.c (main): Check data matches expected.
6741693 Only print result if it does not.
6751694
6761695 cpp, qt: Include config.h.
1696 + commit a142f187b7ddb2728ec3e1743da4a0c4538ab40a
6771697 lang/cpp/src/callbacks.cpp,
6781698 lang/cpp/src/configuration.cpp,
6791699 lang/cpp/src/context.cpp,
7471767 2016-09-22 Werner Koch <wk@gnupg.org>
7481768
7491769 w32: Silence some warnings about unused parameters.
1770 + commit 583aafdd6870a7fb12a34d90993fd0f46928592c
7501771 * src/assuan-support.c (my_recvmsg, my_sendmsg, my_waitpid)
7511772 (my_socketpair) [W32]: Mark unused parameters.
7521773
7531774 core: Fix error checking in _gpgme_mkstemp.
1775 + commit c447b64d5989845a2ae2cf8fb30a92d2a0bd05af
7541776 * src/w32-util.c (_gpgme_mkstemp): Fix error checking.
7551777 (dlopen): Mark FLAGS as unused.
7561778
7571779 core: New helper function _gpgme_strconcat.
1780 + commit dc39552d01094eff2bef5f9fcd1c16928909d20e
7581781 * src/conversion.c: Include stdarg.h.
7591782 (do_strconcat): New.
7601783 (_gpgme_strconcat): New.
7721795 2016-09-22 Daiki Ueno <ueno@gnu.org>
7731796
7741797 tests: Add test for cancellation.
1798 + commit 7a6543c2dfeef874a34086c8f3eeb1dbdf1ce822
7751799 * tests/gpg/t-cancel.c: New file.
7761800 * tests/gpg/Makefile.am (tests_skipped): New variable, default to
7771801 t-genkey and t-cancel.
7791803 * tests/gpg/.gitignore: Add t-cancel.
7801804
7811805 gpg: Add option --exit-on-status-write-error.
1806 + commit dee56820cabde60c43c9bf8281b8d411cb2ad644
7821807 * src/engine-gpg.c (gpg_new): Add --exit-on-status-write-error if the
7831808 engine version is latest enough to expect progress output from gpg.
7841809
7851810 tests: Fix select usage in t-eventloop.
1811 + commit d0cf6b15121c9b42dbcef243e5ce30c9996a449c
7861812 * tests/gpg/t-eventloop.c (do_select): Supply timeout value to select.
7871813
7881814 doc: Fix minor errors in I/O callback example.
1815 + commit 0aaf1dedd629446ab991fff76581b4b58e4872a0
7891816 * gpgme.texi (I/O Callback Example): Fix typos, add timeout to select,
7901817 and initialize mutex as recursive.
7911818
7921819 2016-09-21 Andreas Stieger <astieger@suse.com>
7931820
7941821 cpp: Avoid missing returns in non-void functions.
1822 + commit ae324b51ffa338b891387bff2657d60c1fd3ae40
7951823 * lang/cpp/src/context.cpp
7961824 (Context::signaturePolicyURL): return nullptr on default
7971825 (to_tofu_policy_t): add default case for unknown
8031831 2016-09-21 Werner Koch <wk@gnupg.org>
8041832
8051833 Release 1.7.0.
1834 + commit e7ab75379feadcc2894d9d4cde0f16ad0044780d
8061835 * configure.ac: Bump LT vesion to C26/A15/R0.
8071836
8081837 python: Create install dir.
1838 + commit 936928632b02d7cc2ac645543bb03e4c94285f05
8091839 * lang/python/Makefile.am (install-exec-local): Create dir.
8101840
8111841 2016-09-20 Werner Koch <wk@gnupg.org>
8121842
8131843 tests: Make "make -j distcheck" work in Python.
1844 + commit 0763357e39d140b068ee9838a5da08be75426d9f
8141845 * lang/python/Makefile.am (SUBDIRS): Make current dir fist.
8151846 * lang/python/tests/Makefile.am (xcheck): Depend on pubring-stamp.
8161847 (CLEANFILES): Remove private-keys-v1.d/gpg-sample.stamp.
8211852 basename.
8221853
8231854 tests: Use --batch for gpg import.
1855 + commit bfb6890ded99f040fe8ecf910f927a136e4acfda
8241856 * lang/python/tests/Makefile.am (./pubring-stamp): Use --batch with
8251857 GPG to avoid Pinentries during import when using GnuPG >= 2.1.
8261858 Replace touch by echo.
8271859 * tests/gpg/Makefile.am (./pubring-stamp): Ditto.
8281860
8291861 tests: Improve portability.
1862 + commit 29207bcd3bf4de7264197db6758130375b16d9bb
8301863 * lang/qt/tests/Makefile.am (clean-local): Avoid non-portable "--"
8311864 * lang/python/Makefile.am (copystamp): Use well defined cp -R instead
8321865 of cp -r.
8331866
8341867 build: Create swdb file.
1868 + commit df7e92b4d585b7dce919c5a3aab9524f6e183cbe
8351869 * Makefile.am (distcheck-hook): New.
8361870 (dist-hook): s/VERSION/PACKAGE_VERSION/ for future compatibility.
8371871
8381872 2016-09-20 Justus Winter <justus@g10code.com>
8391873
8401874 python: Fix detection of Python available versions.
1875 + commit ef99b74eb12463db7da5806a316e3b55f8097c5c
8411876 * configure.ac: Test for 'PYTHON_VERSION' as 'AX_PYTHON_DEVEL' sets
8421877 'PYTHON' but clears the former.
8431878
844 Fixes-commit: 99db3512
845
8461879 2016-09-19 Andre Heinecke <aheinecke@intevation.de>
8471880
8481881 core: Remove moc artifact.
1882 + commit e3c35147d6adb754d4eb0781a54af2a8f0803663
8491883 * src/moc_kdpipeiodevice.cpp: Removed.
8501884 * src/Makefile.am (EXTRA_DIST): Remove moc_kdpipeiodevice.cpp.
8511885
8521886 qt: Improve README.
1887 + commit 3f92253e0e476d77aa11463bc51ade367985855f
8531888 * lang/qt/README: Add more content. Clearly note license difference.
8541889
8551890 cpp: Improve README.
1891 + commit 66febf9942c321d30b8770f6aa6cd6ce2315d34f
8561892 * lang/cpp/README: Add more content, move license to bottom.
8571893
8581894 qt: Add debug output for testTofuPolicy.
1895 + commit d438cb59a068b6f076e6bd70d3a2c46bc05ccb5c
8591896 * lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): Add
8601897 debug output.
8611898
8621899 2016-09-19 Ben Kibbey <bjk@luxsci.net>
8631900
8641901 core: Check for GPG_TTY as well as DISPLAY.
1902 + commit 9d62bacac7826cb73bb18fac7268f3d2df662d7b
8651903 * src/engine-assuan.c (llass_new): Update --ttyname from GPG_TTY.
8661904 * src/engine-g13.c (g13_new): Ditto.
8671905 * src/engine-gpg.c (gpg_new): Ditto.
8711909 2016-09-16 Andre Heinecke <aheinecke@intevation.de>
8721910
8731911 qt: Add test for setting tofu policy.
1912 + commit a8ff34fc3025af4079cede7f8f9fdf40189b8638
8741913 * lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): New.
8751914
8761915 qt: Add job for tofupolicy.
1916 + commit 77aecfb5c97cea1a99f1ff627748cf71767bac5c
8771917 * lang/qt/src/job.cpp, lang/qt/src/protocol.h,
8781918 lang/qt/src/protocol_p.h: Register job.
8791919 * lang/qt/src/qgpgmetofupolicyjob.cpp,
8821922 * lang/qt/src/Makefile.am: Update accordingly.
8831923
8841924 cpp: Add support for gpgme_op_tofu_policy.
1925 + commit 4d384d7bfef044094695271576ca233625bb520a
8851926 * src/context.cpp, src/context.h (setTofuPolicy, setTofuPolicyStart):
8861927 New.
8871928
8881929 cpp: Declare sizes of tofu-info enums.
1930 + commit 32baac8cdec6fee51bdfc3c55cb2ee141e086df4
8891931 * lang/cpp/src/tofuinfo.h (Policy, Validity): Declare sizes.
8901932
8911933 2016-09-16 Werner Koch <wk@gnupg.org>
8921934
8931935 cpp: Silence use of deprecated function warning.
1936 + commit bd24db313d860ae46d37776dcf1067455d1b9880
8941937 * lang/cpp/src/context.cpp (GpgME): Use pragma to silence wardning.
8951938
8961939 core: Document the version a function has been deprecated.
1940 + commit b615316168f4d33311909d4056b236d13c69488f
8971941 * src/gpgme.h.in (_GPGME_DEPRECATED): Change to take versio numbers
8981942 for documentation. Change all places.
8991943 (_GPGME_DEPRECATED_OUTSIDE_GPGME): Ditto.
9001944 * lang/python/gpgme-h-clean.py: Adjust RE.
9011945
9021946 core: Map GPGME_STATUS_EOF to the empty string.
1947 + commit 3d6340e8c59ee11a95e03fb213ad9b228be47833
9031948 * src/status-table.c (_gpgme_status_to_string): Return "" for EOF.
9041949 * src/engine-gpg.c (read_status): Ditto. The old code accidently used
9051950 GPGME_STATUS_EOF which is the integer 0 and neiteyr NULL nor a string.
9081953 Kai Michaelis <kai@gnupg.org>
9091954
9101955 python: Release the GIL during calls into GPGME.
1956 + commit 6af7bee076bacbc0cdfe7de342bce43ca5671b3b
9111957 * lang/python/helpers.c (pyme_raise_callback_exception): Re-acquire
9121958 the Global Interpreter Lock.
9131959 (pyPassphraseCb, pyme_set_passphrase_cb, pyProgressCb,
9211967 2016-09-16 Justus Winter <justus@g10code.com>
9221968
9231969 python: Adapt to 'gpgme_op_interact'.
1970 + commit a458e7fe2006d92bd5a838e2747fb66bbac4b1b8
9241971 * lang/python/examples/inter-edit.py: Update example.
9251972 * lang/python/gpgme.i (gpgme_edit_cb_t): Turn into
9261973 'gpgme_interact_cb_t'.
9381985 2016-09-16 Werner Koch <wk@gnupg.org>
9391986
9401987 core: Remove stub to try implementing gpg < 2.1 support for createkey.
1988 + commit 268e251b802cc7c19831722d7e3a52777a0f412f
9411989 * src/engine-gpg.c (gpg_createkey_legacy): Remove.
9421990 (gpg_genkey): Remove call.
9431991
9441992 core: Fix setting og the verification result.
1993 + commit 1f9641dd0fb08e4a3df3b507b974a3f78887920f
9451994 * src/verify.c (parse_new_sig): Proberly handle the RC in an ERRSIG
9461995 status.
9471996
9481997 2016-09-15 Werner Koch <wk@gnupg.org>
9491998
9501999 core: New function gpgme_op_interact, deprecate gpgme_op_edit.
2000 + commit ed1f2700a73060e2615697491ea9e49ded4293e6
9512001 * src/gpgme.h.in (gpgme_interact_cb_t): New.
9522002 (GPGME_INTERACT_CARD): New.
9532003 (gpgme_op_interact_start, gpgme_op_interact): New.
9652015 (main): s/gpgme_op_edit/gpgme_op_interact/.
9662016
9672017 core: Minor change of the gpgme_op_edit semantics.
2018 + commit d2b72d3cc19fe2a7d548dac38d55e069e0c9a904
9682019 * src/edit.c (command_handler): Handle special error code.
9692020 * src/engine-gpg.c (read_status): Ditto.
9702021 * src/engine-gpgsm.c (status_handler): Ditto.
9742025 2016-09-14 Werner Koch <wk@gnupg.org>
9752026
9762027 core: New function gpgme_op_tofu_policy.
2028 + commit 7c37719d79345a665ec2f4570e3f257033b58c62
9772029 * src/gpgme.h.in (gpgme_op_tofu_policy_start): New function.
9782030 (gpgme_op_tofu_policy): New function.
9792031 * src/libgpgme.vers, src/gpgme.def: Add new functions.
9902042 * tests/Makefile.am (noinst_PROGRAMS): Add it.
9912043
9922044 core: Defer implementation of gpgme_op_createkey with gpg < 2.1.
2045 + commit d79dcb78d867aaf55b85aea117c4ae6035a1531a
9932046 * src/engine-gpg.c (gpg_createkey_legacy): Mark unused variables.
9942047
9952048 core: New function gpgme_op_keysign.
2049 + commit bfd2bd0ccc9fed8284ef932ac788d4ca0dba0336
9962050 * src/gpgme.h.in (gpgme_op_keysign_start, gpgme_op_keysign): New.
9972051 (GPGME_KEYSIGN_LOCAL): New.
9982052 (GPGME_KEYSIGN_LFSEP): New.
10162070 2016-09-14 Justus Winter <justus@g10code.com>
10172071
10182072 python: Clarify that we support Python 2.7 too.
2073 + commit 594c3b8b052e60b6be77ed532fe46549133a9726
10192074 * lang/python/README: Use 'Python' instead of 'Python 3'.
10202075 * lang/python/pyme/version.py.in: Likewise.
10212076 * lang/python/setup.py.in: Add classifier for 2.7, drop 3 only.
10222077
10232078 python: Trim imports.
2079 + commit 4011b2b2a1050f0837e989da3db9b5459e71ccd6
10242080 * lang/python/examples/encrypt-to-all.py: Drop unused import of 'os'.
10252081 * lang/python/examples/signverify.py: Likewise.
10262082 * lang/python/examples/simple.py: Likewise.
10272083 * lang/python/examples/verifydetails.py: Likewise.
10282084
10292085 python: Improve error handling.
2086 + commit 44d18200d5ffe8691e18d93ce6c534660702b982
10302087 * lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling.
10312088
10322089 python: Adapt to TOFU changes.
2090 + commit f6cd560ca74248dd719a37cfb34386148727a92d
10332091 * lang/python/pyme/results.py (TofuInfo): Drop.
10342092 (Signature): The TOFU information moved to the key.
10352093
10362094 python: Improve build system integration.
2095 + commit 99db351288d5bb075f124ef10e540e25bc36b70a
10372096 * configure.ac: Try to compile a Python module for each version.
10382097 * m4/m4_ax_swig_python.m4: Drop unused file.
10392098
10402099 2016-09-14 Werner Koch <wk@gnupg.org>
10412100
10422101 core: New function gpgme_op_revuid.
2102 + commit c943380b7a2cc9b32f81c22224fc6f92e8ea8469
10432103 * src/engine.h (GENKEY_EXTRAFLAG_REVOKE): New.
10442104 * src/genkey.c (adduid_start): Rename to addrevuid_start. Add arg
10452105 REVOKE and pass it as extraflags. Remove useless ARMOR extraflag.
10502110 * tests/run-genkey.c: Add option --revuid.
10512111
10522112 core: Change a parameter for the engine's genkey function.
2113 + commit c22f5884c50557f54704f4becc5a8c1ee0749547
10532114 * src/engine.h (GENKEY_EXTRAFLAG_ARMOR): New.
10542115 * src/engine-backend.h (engine_ops): Rename USE_ARMOR in genkey to
10552116 EXTRAFLAGS.
10642125 2016-09-14 Justus Winter <justus@g10code.com>
10652126
10662127 python: Build for both Python2 and Python3.
2128 + commit 24b4162d908b48a92660020be0b776c2874fb05a
10672129 * NEWS: Update.
10682130 * configure.ac: Check for multiple Python versions.
10692131 * lang/python/Makefile.am: Build and install for both Python versions.
10732135 2016-09-14 Werner Koch <wk@gnupg.org>
10742136
10752137 core: New function gpgme_op_adduid.
2138 + commit 3210f3e4725afc5ee2810b9a1361918ec9c42ca4
10762139 * src/genkey.c: Replace most error codes GPG_ERR_INV_VALUE by
10772140 GPG_ERR_INV_ARG.
10782141 (struct op_data_t): Add field UIDMODE.
10832146 * tests/run-genkey.c: Add option --adduid.
10842147
10852148 core: New function gpgme_op_createsubkey.
2149 + commit cc353701b0fde4c811ddc1e9a91b852dfe9f4e06
10862150 * src/genkey.c (createsubkey_start): New.
10872151 (gpgme_op_createsubkey_start, gpgme_op_createsubkey): New.
10882152 * src/gpgme.def, src/libgpgme.vers: Add them.
10942158 2016-09-13 Werner Koch <wk@gnupg.org>
10952159
10962160 core: Use const char * where appropriate.
2161 + commit 51f9acbca935c5287d9a28205037b0923e9a65f5
2162
10972163
10982164 core: Cast away the common const problem with spawn and argv.
2165 + commit 686a065f639ef006e33c164e282d787bcd169754
10992166 * src/dirinfo.c (read_gpgconf_dirs): Use a cast to assignd to ARGV.
11002167
11012168 core: Fix condition-always-true warning in trace macro.
2169 + commit 3009e6162eaa39adaaf45f06fc4f88c7153360ee
11022170 * src/data-compat.c (old_user_read): Cast AMT.
11032171
11042172 core: Mark unused function args.
2173 + commit 4a200146b602349eebb4eac2e102357748d7ba5b
2174
11052175
11062176 tests: Mark lots of unused vars and fix const mismatches.
2177 + commit 9064eebdc05e7149c2c8cc899fbd7874622fb769
2178
11072179
11082180 tests: Use gpgme_io_write in passhrase callbacks.
2181 + commit 4491ef0a9a15d3b307d1ade37ff620ef9fcb2478
11092182 * tests/gpg/t-support.h (passphrase_cb): Use gpgme_io_write.
11102183 * tests/gpgsm/t-support.h (passphrase_cb): Ditto.
11112184 * tests/run-support.h (passphrase_cb): Ditto.
11122185
11132186 core: Do not pass const char* to functions taking a char*.
2187 + commit 3972f476e00f27d41a0aeabcb66600905b6737bd
2188
11142189
11152190 build: Use more compiler warnings.
2191 + commit 0510591c36591816a6ff3f87a04451001b7ed46f
11162192 * configure.ac: Add useful compiler warnings.
11172193
11182194 core: New function gpgme_op_create_key.
2195 + commit 00c501d296da287bec2fd6a0e3912abfbde90a98
11192196 * src/engine-backend.h (engine_ops): Change prototype of genkey.
11202197 * src/engine-gpgsm.c (gpgsm_genkey): Change accordingly.
11212198 * src/engine-gpg.c (gpg_genkey): Change it to a dispatcher.
11522229 2016-09-13 Justus Winter <justus@g10code.com>
11532230
11542231 python: Handle slight differences between Python 2 and 3.
2232 + commit 70a3be27a509a1b5ea7372bee93d83c5019427ff
11552233 * lang/python/helpers.c (pyDataWriteCb): Handle Python integers being
11562234 returned on Python 2.
11572235 (pyDataSeekCb): Likewise.
11682246 using bytestrings in Python 3 would be very inconvenient.
11692247
11702248 python: Fix types and error handling.
2249 + commit 4abff7d750a1abf5b388a4c87ec321fc3e4aed10
11712250 * lang/python/helpers.c (_pyme_edit_cb): Drop the const.
11722251 (_pyme_assuan_{data,inquire,status}_cb): Fix error handling.
11732252
11742253 2016-09-12 Justus Winter <justus@g10code.com>
11752254
11762255 python: Avoid Python3-only form of super().
2256 + commit c0c50318bd8ef6c8119ad9fdc53ad9087ded4c32
11772257 * lang/python/pyme/core.py (GpgmeWrapper.__repr__): Use more
11782258 compatible form of super.
11792259 (GpgmeWrapper.__setattr__): Likewise.
11812261 (Data.__init__): Likewise.
11822262
11832263 python: Make type translation compatible with Python 2.7.
2264 + commit 1d5bbbf1185a0d1f82750f10b69dad3999f7ef4c
11842265 * lang/python/gpgme.i: Avoid functions not available in Python 2.7.
11852266 * lang/python/helpers.c: Likewise.
11862267
11872268 python: Avoid hardcoding the interpreter.
2269 + commit 70999d81618b3d3ae6b61a43be2ce703ad284275
11882270 * lang/python/setup.py.in: Avoid hardcoding the interpreter.
11892271
11902272 python: Do not rely on subprocess.DEVNULL.
2273 + commit b48b852a846129914d6c63ec7b47388cdcf6acca
11912274 * lang/python/setup.py.in: Do not rely on subprocess.DEVNULL.
11922275
11932276 tests: Fix version comparison.
2277 + commit dfd99ab50c3bc1d6745b6f682791e4885e8d8a9a
11942278 * tests/gpg/t-sig-notation.c: Fix version comparison.
11952279
1196 Fixes-commit: a0263ad2
1197
11982280 tests: Make signature notation test compatible with older GnuPGs.
2281 + commit a0263ad282d350b548cbbc27e96f196d9217d040
11992282 * lang/python/tests/t-sig-notation.py: Only check the critical flag
12002283 when GnuPG >= 2.1.13 is used.
12012284 * tests/gpg/t-sig-notation.c: Likewise.
12022285
1203 Fixes-commit: c88c9ef3
1204
12052286 2016-09-12 Andre Heinecke <aheinecke@intevation.de>
12062287
12072288 qt: Fix some includes.
2289 + commit d480f6b701894f78f3f4016d69c0e3b87939930b
12082290 * lang/qt/src/qgpgmekeyformailboxjob.cpp: Explicitly include
12092291 QStringList.
12102292 * lang/qt/tests/t-support.h, lang/qt/tests/t-support.cpp: Move
12132295 2016-09-12 Justus Winter <justus@g10code.com>
12142296
12152297 qt: Fix tofu test.
2298 + commit 7b9e6ea376d04fb4694ed22369abaae92ce3ec86
12162299 * lang/qt/tests/t-tofuinfo.cpp: Adjust member names.
12172300
1218 Fixes-commit: 120b1478
1219
12202301 2016-09-07 Werner Koch <wk@gnupg.org>
12212302
12222303 core,cpp: Extend the TOFU information.
2304 + commit 120b14783c0312d782dc08ce4949a6209d5ccc7b
12232305 * src/gpgme.h.in (struct _gpeme_tofu_info): Rename FIRSTSEEN to
12242306 SIGNFIRST and LASTSEEN to SIGNLAST. Add ENCRFIST and ENCRLAST.
12252307 * src/keylist.c (parse_tfs_record): Parse to ENCRFIRST and ENCRLAST.
12342316 2016-09-06 Andre Heinecke <aheinecke@intevation.de>
12352317
12362318 tests: Set passphrase cb in t-encrypt-mixed.
2319 + commit 151da95470f174dc770b2111890ad650a1697276
12372320 * tests/gpg/t-encrypt-mixed.c (main): Set passphrase cb.
12382321
12392322 core: Check for gpg version for loopback mode.
2323 + commit e8cb143c8337b122a6790f769ddb0a97c4baccd3
12402324 * src/engine-gpg.c (build_argv): Check for version 2.1.0
12412325 before adding pinentry-mode.
12422326
12432327 core: Fix passphrase cb for mixed sym encrypt.
2328 + commit efe7e11dfa2ff911b477ce748292e53e7a50347e
12442329 * src/encrypt.c (encrypt_start): Handle SYMMETRIC flag.
12452330 * src/encrypt-sign.c (encrypt_sign_start): Ditto.
12462331
12472332 2016-09-05 Andre Heinecke <aheinecke@intevation.de>
12482333
12492334 qt: Clarify comment and strings in tofuinfo test.
2335 + commit ab3fbdbd05cfd1b039bb5b1eb3941fbb4bcf6307
12502336 * lang/qt/tests/t-tofuinfo.cpp (testTofuSignCount)
12512337 (testTofuKeyList): Ensure distinct messages. Clarify comment.
12522338
12532339 qt: Enable signcount checks in tofuinfo test.
2340 + commit 965b842fad6ec6fbd8902f3a32119abcd0728fe4
12542341 * lang/qt/tests/t-tofuinfo.cpp: Enable checks for signcount.
12552342
12562343 cpp: Add convenience update function to a key.
2344 + commit 79439e76cc5b302222874a1f9e93665cb12801ac
12572345 * lang/cpp/src/key.cpp (Key::update): New.
12582346 * lang/cpp/src/key.h: Update accordingly.
12592347
12602348 cpp: Add ostream operators for key and uid.
2349 + commit 444d85ace0dddff5c511961927052d9946035b00
12612350 * lang/cpp/src/key.cpp (Key, UserID): Add ostream operator.
12622351 * lang/cpp/src/key.h: Update accordingly.
12632352
12642353 qt: Add missing header redirection.
2354 + commit 8a39a595eb802b80a6ad756b0ee8939e9733e86f
12652355 * lang/qt/src/keyformailboxjob.h,
12662356 lang/qt/src/qgpgmekeyformailboxjob.h: Fix includes.
12672357
12682358 qt: Include cpp before core directory.
2359 + commit e3a4697894cc5a93c295e84bb10c743bc7fdc87e
12692360 * lang/qt/src/Makefile.am (AM_CPPFLAGS): Include cpp before core.
12702361
12712362 2016-08-25 Andre Heinecke <aheinecke@intevation.de>
12722363
12732364 qt: Fix 2.1 t-support copy.
2365 + commit 05570bd3d05fb3d7934c1122f0d5ef5fdbaa7974
12742366 * lang/qt/src/t-support.cpp (copyKeyring): Fix seckey copy.
12752367
12762368 qt: Fix and extend TofuInfo test.
2369 + commit 9fc72e928bf2cf239bd3b0facdf33ceb1acc975b
12772370 * lang/qt/tests/t-tofuinfo.cpp: Delete executed jobs.
12782371 (testTofuKeyList): New.
12792372 (testSupported): Activate for 2.1.16
12802373 (signAndVerify): Disable sigcount tests.
12812374
12822375 qt: Fix keyring copy in tests.
2376 + commit c875f07e559a7c53fc173b4c3f9f5715f3fbb8f8
12832377 * lang/qt/test/t-encrypt.cpp,
12842378 lang/qt/test/t-tofuinfo.cpp: Assert on copy failure.
12852379 * lang/qt/test/t-support.cpp (copyKeyrings): Fix path.
12862380
12872381 qt: Add generic flag support for keylistjobs.
2382 + commit 4e37d0bb1255558ce20e1a5ac83a2d06a37f8b0b
12882383 * lang/qt/src/keylistjob.h (addMode): New.
12892384 * lang/qt/src/qgpgmekeylistjob.h (addMode): New.
12902385 * lang/qt/src/qgpgmekeylistjob.cpp (addMode: New.
12912386
12922387 qt: Ensure that current src dir is included first.
2388 + commit 5a92cc96da183ebb19867a2a910f53ba41e76ae9
12932389 * lang/qt/src/Makefile.am: Reorder include directives.
12942390
12952391 cpp: Add WithTofu Keylist Mode.
2392 + commit f311b92ceaedb12c9e00a722b6b47bbe6b50871e
12962393 * lang/cpp/src/context.cpp: Handle WithTofu.
12972394 * lang/cpp/src/global.h (KeyListMode): Add WithTofu.
12982395 * lang/cpp/src/util.h (add_to_gpgme_keylist_mode_t): Handle WithTofu.
12992396
13002397 qt: Fix tofuinfo test when gpg is gpg2.
2398 + commit 053e6e0a7b8ea38ad9d4160c84814867bbb9fcf6
13012399 * lang/qt/tests/t-support.cpp (QGpgMETest::copyKeyrings): New helper.
13022400 * lang/qt/tests/t-support.h: Declare.
13032401 * lang/qt/tests/t-encrypt.cpp: use it
13042402 * lang/qt/tests/t-tofuinbo.cpp: ditto.
13052403
13062404 qt: Remove unused variable in test.
2405 + commit f08904b810d77d87c66d9c7875c4e7f2bde5dd92
13072406 * t-wkspublish.cpp (testWKSPublishCreate): Remove context.
13082407
13092408 qt: Add test for wkspublishjob.
2409 + commit df04b232b8897f030534f8c3fbc87064edf8ae7d
13102410 * lang/qt/tests/t-wkspublish.cpp: New.
13112411 * lang/qt/tests/Makefile.am: Update accordingly.
13122412
13132413 qt: Add WKSPublishJob.
2414 + commit 94420b05775122b25885c66ac67f77c59d01644d
13142415 * lang/qt/src/Makefile.am: Add new files.
13152416 * lang/qt/src/job.cpp: Include moc / subclass stub.
13162417 * lang/qt/src/protocol.h: Add virtual for new job.
13202421 lang/qt/src/qgpgmewkspublishjob.h: New.
13212422
13222423 Cpp: Change firstSeen / lastSeen return values.
2424 + commit de7b67f9b2e6bd43a036fa0bcc6a8ca4f5b10986
13232425 * lang/cpp/src/tofuinfo.cpp,
13242426 lang/cpp/src/tofuinfo.h (TofuInfo::firstSeen, TofuInfo::lastSeen):
13252427 Change return values to unsigned long and update doc.
13262428
13272429 Cpp: Add wrapper for gpgme_get_dirinfo.
2430 + commit abcd9a283ee8f81870622c8e1dbdc7aad38c0358
13282431 * lang/cpp/src/context.cpp (dirInfo): New.
13292432 * lang/cpp/src/global.h (dirInfo): New.
13302433
13312434 Cpp: Add support for spawn engine.
2435 + commit ece8b02a839d6fc566fea7b6e59fabff164f6cf5
13322436 * lang/cpp/src/context.cpp (Context::spawn, Context::spawnAsync): New.
13332437 * lang/cpp/src/context.h: Add prototypes.
13342438 (SpawnFlags): New.
13372441 2016-08-25 Werner Koch <wk@gnupg.org>
13382442
13392443 core: Add GPGME_KEYLIST_MODE_WITH_TOFU.
2444 + commit 9ee103957e4136337b92d238283f8ef30fd4a7c5
13402445 * src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_TOFU): New.
13412446 * src/engine-gpg.c (gpg_keylist_build_options): Use that.
13422447 * src/keylist.c: Include limits.h.
13522457 2016-08-24 Werner Koch <wk@gnupg.org>
13532458
13542459 core: Adjust for TOFU_STATS change in gnupg 2.1.16.
2460 + commit 38798fee5b539d6153a8a7856152959412ee59b5
13552461 * src/gpgme.h.in (_gpgme_tofu_info): Change 'firstseen' and 'lastseen'
13562462 to a timestamp value.
13572463 * src/verify.c (parse_tofu_stats): Do not cap these values at UINT_MAX.
13582464
13592465 core: Set the 'encrcount' field in gpgme_tofu_info_t.
2466 + commit 1eefc2d43c0adb2ce516f8e3509ace2fb562e401
13602467 * src/verify.c (parse_tofu_stats): Set ENCRCOUNT field.
13612468
13622469 cpp: Get rid of AssuanResult due to its deprecation.
2470 + commit e20b0f0201543834f15c5d50cd3b2ece69a35d70
13632471 * lang/cpp/src/assuanresult.cpp: Remove.
13642472 * lang/cpp/src/assuanresult.h: Remove.
13652473 * lang/cpp/src/Makefile.am: Remove these files.
13732481 2016-08-24 Andre Heinecke <aheinecke@intevation.de>
13742482
13752483 Qt: Adapt (disabled) tofuinfo test to new API.
2484 + commit d2e40fb7adf667f3e2d2457ee4c646ea4d4d88b3
13762485 * lang/qt/tests/t-tofuinfo.cpp: Switch to UID based API.
13772486
13782487 Cpp: Add Key to signature.
2488 + commit 7c5a4974b71c30e824cbfcb3a0a70064e5ed5adb
13792489 * lang/cpp/src/verificationresult.cpp,
13802490 lang/cpp/src/verificationresult.h (Signature::key): New.
13812491
13822492 Cpp: Use fpr field for primaryFingerprint.
2493 + commit 40ea1c85773cbe324557c34b3a4282f609fcdaf6
13832494 * lang/cpp/src/key.cpp (Key::primaryFingerprint): Return
13842495 fpr value if available.
13852496
13862497 2016-08-23 Andre Heinecke <aheinecke@intevation.de>
13872498
13882499 Cpp: Move tofuinfo from signature to userid.
2500 + commit 799b168243e6499ac01bf59e0656547f353a2589
13892501 * lang/cpp/src/key.cpp (UserID::tofuInfo): New.
13902502 * lang/cpp/src/key.h: Update accordingly.
13912503 * lang/cpp/src/tofuinfo.cpp: Remove dropped fields.
13972509 2016-08-23 Werner Koch <wk@gnupg.org>
13982510
13992511 core: Put the protocol into a TOFU created key object.
2512 + commit 2972c44bd7e97b2169dea9c4a49d9754afdae3f0
14002513 * src/verify.c (parse_tofu_user): Add arg 'protocol' and store it in
14012514 the KEY.
14022515 (_gpgme_verify_status_handler): Pass protocol.
14032516
14042517 core: Change the way TOFU information are represented.
2518 + commit be4ff75d7d5ac6ed15feb245ef3cec59b4bad561
14052519 * src/gpgme.h.in (struct _gpgme_signature): Remove field 'tofu'. Add
14062520 field 'key'.
14072521 (struct _gpgme_key): Add field 'fpr'.
14192533 * tests/run-keylist.c (main): Print more fields.
14202534
14212535 core: Extend gpgme_user_id_t with 'address'.
2536 + commit 3955dce06e9d056599e5ec7d40301e66b9305195
14222537 * src/mbox-util.c, src/mbox-util.h: Adjust for use in gpgme.
14232538 * src/Makefile.am (main_sources): Add mbox-util.
14242539 * src/key.c (_gpgme_key_append_name): Set 'address' field of uid.
14272542 2016-08-22 Werner Koch <wk@gnupg.org>
14282543
14292544 core: New code for parsing mail addresses.
2545 + commit 26c5ba528ce1411d96655952ec48359105695c0f
14302546 * src/mbox-util.c: New.
14312547 * src/mbox-util.h: New.
14322548
14332549 core: Add new items for gpgme_get_dirinfo.
2550 + commit 24e61984c9532924135c57b8ff98489a2d3bd4a3
14342551 * src/dirinfo.c (WANT_SYSCONFDIR, WANT_LIBEXECDIR, WANT_LIBDIR): New.
14352552 (WANT_DATADIR, WANT_LCOALEDIR, WANT_AGENT_SSH_SOCKET): New
14362553 (WANT_DIRMNGR_SOCKET): New.
14412558 (gpgme_get_dirinfo): Likewise.
14422559
14432560 core: Base gpgme_get_dirinfo(uiserver-socket) on the socket dir.
2561 + commit c9e7dcb100d807583d8e312da459561138231376
14442562 * src/dirinfo.c (dirname_len): New.
14452563 (parse_output): Change computation of UISRV_SOCKET.
14462564
14472565 2016-08-21 Werner Koch <wk@gnupg.org>
14482566
14492567 core: New commands --lang and --have-lang for gpgme-config.
2568 + commit 3e60788810f93cfcd7f08e5882aff32ed7b6f831
14502569 * configure.ac (GPGME_CONFIG_AVAIL_LANG): New ac_subst.
14512570 * src/gpgme-config.in (avail_lang): Add commands --lang and
14522571 --have-lang.
14542573 2016-08-18 Andre Heinecke <aheinecke@intevation.de>
14552574
14562575 core: Remove (now) useless diagnostic.
2576 + commit 30f156280f18500ee522db58aecd40711c8af685
14572577 * src/w32-io.c(_gpgme_io_spawn): Remove spawnhelper not found
14582578 diagnostic.
14592579
14602580 core: Fail loudly in case w32 spawner not found.
2581 + commit 9cf983b0199950c8f8cccee2cb8e45aafcba9fd1
14612582 * src/w32-io.c (_gpgme_io_spawn): Show a message box in
14622583 case gpgme-w32spawn.exe not found.
14632584
14642585 2016-08-17 Andre Heinecke <aheinecke@intevation.de>
14652586
14662587 Cpp: Fix some pedantic warnings.
2588 + commit 64194b0f8df1afe6135cd119fd3216fc8db68033
14672589 * lang/cpp/src/context.cpp,
14682590 lang/cpp/src/context.h (Context::getKeysFromRecipients): Remove
14692591 ignored / invalid const qualifier.
14722594 2016-08-16 Werner Koch <wk@gnupg.org>
14732595
14742596 core: New global flag "require-gnupg".
2597 + commit 8c09dd9989bcd434a8cb5997770cb8414b96bd5c
14752598 * src/gpgme.c (gpgme_set_global_flag): Add flag.
14762599 * src/engine.c (engine_minimal_version): New variable.
14772600 (_gpgme_set_engine_minimal_version): New function.
14802603 * tests/run-keylist.c (main): New option --require-gnupg.
14812604
14822605 core: Simplify setting of dummy versions.
2606 + commit b7b0e7b5bfefd51c8092ea54f262b18aebf78128
14832607 * src/engine.c (_gpgme_engine_info_release): Do not assert but free
14842608 FILE_NAME.
14852609 (gpgme_get_engine_info): Provide default for VERSION and REQ_VERSION.
14952619 2016-08-12 Andre Heinecke <aheinecke@intevation.de>
14962620
14972621 Qt: Add test for progress signal of encryptjob.
2622 + commit 391e55411cda11446ca9de4dd0dc2b54d3e6fff5
14982623 * lang/qt/tests/t-encrypt.cpp (testProgress): New.
14992624
15002625 Cpp: Provide size-hint for seekable and mem data.
2626 + commit df7bbf5a66576a5a320b54c8f6ad52bc84f0e833
15012627 * lang/cpp/src/data.cpp (GpgME::Data::Data): Set size-hint for
15022628 mem and DataProvider based Data.
15032629
15042630 2016-08-12 Werner Koch <wk@gnupg.org>
15052631
15062632 core: Make use of the "size-hint" in engine-gpg.
2633 + commit fe1e8e71aa18b4ac6471292b2894b8859f42f7c8
15072634 * src/engine-gpg.c: Include data.h.
15082635 (add_input_size_hint): New.
15092636 (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign)
15152642 size for the input data.
15162643
15172644 core: Add gpgme_data_set_flag to add more meta data to data objects.
2645 + commit 293d1736911fd5e77b8cec305168b35b2420c612
15182646 * src/gpgme.h.in (gpgme_data_set_flag): New public function.
15192647 * src/data.c (gpgme_data_set_flag): New.
15202648 (_gpgme_data_get_size_hint): New.
15252653 2016-08-12 Andre Heinecke <aheinecke@intevation.de>
15262654
15272655 Qt: Fix defaultkeygenerationjob build.
2656 + commit 75c974c4e0a31981325f7d151bd13f2523f5df20
15282657 * lang/qt/src/defaultkeygenerationjob.cpp: Include moc.
15292658
15302659 2016-08-11 Andre Heinecke <aheinecke@intevation.de>
15312660
15322661 Qt: Add DefaultKeyGenerationJob.
2662 + commit 105f5446e69db00291164397cf0d8e68374cf420
15332663 * lang/qt/src/defaultkeygenerationjob.cpp,
15342664 lang/qt/src/defaultkeygenerationjob.h: New.
15352665 * lang/qt/src/Makefile.am: Update accordingly.
15362666
15372667 Qt: Ensure all public classes are exported.
2668 + commit 59e2251a083b0ed61b3ab6d47015cef7cc6ceb05
15382669 * src/abstractimportjob.h,
15392670 src/cryptoconfig.h,
15402671 src/deletejob.h,
15502681 src/verifydetachedjob.h: Export classes.
15512682
15522683 Qt: Add KeyForMailboxJob.
2684 + commit 8c5abc8d932affab4bc79a85e3f98f6f6b982ae8
15532685 * lang/qt/src/job.cpp: Include moc and make subclass.
15542686 * lang/qt/src/keyformailboxjob.h,
15552687 lang/qt/src/qgpgmekeyformailboxjob.cpp,
15632695 2016-08-10 Werner Koch <wk@gnupg.org>
15642696
15652697 doc: Get rid of version.texi.
2698 + commit b7d99e02188b7907b09fec3032fc1fd82fc2668a
15662699 * configure.ac (CC_FOR_BUILD): New.
15672700 * doc/mkdefsinc.c: New. Taken from GnuPG and modified for gpgme.
15682701 * doc/Makefile.am (EXTRA_DIST): Add defsincdate and mkdefsinc.c
15732706 * doc/gpgme.texi: Include defs.inc. Remove version.texi.
15742707
15752708 build: Declare all languages for make dist.
2709 + commit 48691db97b759d67aa7b49c36bb704b5806ade2e
15762710 * lang/Makefile.am (DIST_SUBDIRS): New.
15772711
15782712 core: Do not identify PNG files as PGP signatures.
2713 + commit a9168185ba97aa1d827315cd8017899bf904aded
15792714 * src/data-identify.c (next_openpgp_packet): Blacklist PNG files.
15802715
15812716 2016-08-10 Andre Heinecke <aheinecke@intevation.de>
15822717
15832718 Cpp: Handle empty recipients consistently.
2719 + commit 09667a6006986a782af98ca1de4d6521e1b8f353
15842720 * lang/cpp/src/context.cpp (Context::getKeysFromRecipients):
15852721 New helper.
15862722 (Context::encrypt, Context::startEncryption, Context::signAndEncrypt)
15892725 as private helper.
15902726
15912727 core: Handle ENCRYPT_SYMMETRIC also for sig & enc.
2728 + commit b602d8bc7bd726afb52dc60cc07e4609e88d4511
15922729 * src/engine-gpg.c (gpg_encrypt_sign): Handle ENCRYPT_SYMMETRIC
15932730 flag.
15942731
15952732 Qt: Remove unused variable.
2733 + commit d467018ce36f5be36751267c3b6079e8c1ee5d8a
15962734 * lang/qt/src/qgpgmerefreshkeysjob.cpp (slotStatus): Remove
15972735 unused variable typ.
15982736
15992737 Qt: Create TestPassphraseProvider on stack.
2738 + commit a27d7755d071aad42efc2aa4ea3899ba7b17f8bf
16002739 * lang/qt/tests/t-encrypt.cpp, lang/qt/tests/t-tofuinfo.cpp: Create
16012740 TestPassphraseProvider on stack.
16022741
16032742 Cpp: Clarify ownership of provider classes.
2743 + commit 21d5e71d486da8e37cf53f2b968646b39a6daa72
16042744 * lang/cpp/src/context.h: Note that the context does not take
16052745 ownership of providers.
16062746
16072747 2016-08-10 Justus Winter <justus@g10code.com>
16082748
16092749 tests: Fix memory leak.
2750 + commit 04f994d5db6db0575dc73c2356c7d51424e2d9fe
16102751 * tests/gpg/t-encrypt-mixed.c (main): Free 'text2'.
16112752
16122753 2016-08-10 Andre Heinecke <aheinecke@intevation.de>
16132754
16142755 core: Ensure err is initalized in gpg_encrypt.
2756 + commit 270887309f4b673b13e58c29ea3989c56989590e
16152757 * src/engine-gpg.c (gpg_encrypt): Initialize err.
16162758
16172759 Qt: Fix t-keylist moc include.
2760 + commit 0c222e1b3cabe1a8b84a2877420cdd5df56171b5
16182761 * lang/qt/tests/t-keylist.cpp: Don't include t-support.moc
16192762
16202763 2016-08-09 Andre Heinecke <aheinecke@intevation.de>
16212764
16222765 Qt: Clean up debug output in tests.
2766 + commit 969f223d8de21d7c8b0f7646bbf8dbb5864e8d03
16232767 * lang/qt/tests/t-support.cpp: Remove accidentally commited
16242768 debug output.
16252769
16262770 Qt: Add encryption test and refactor testsuite.
2771 + commit f209ec8f581ae597b37f2e3a5e452e4b53b2d4c7
16272772 * lang/qt/tests/Makefile.am: Add t-encrypt and t-support.
16282773 * lang/qt/tests/t-support.cpp, lang/qt/tests/t-support.c (QGpgMETest):
16292774 New. Class to handle common cleanup / init.
16352780 encryption. Mixed encryption test is disabled.
16362781
16372782 Qt: Add support for EncryptJobs with generic flags.
2783 + commit 34b456c3fb9e59788b07a75441da482bb28bda87
16382784 * lang/qt/src/encryptjob.h, lang/qt/src/signencryptjob.h,
16392785 lang/qt/src/qgpgmeencryptjob.h, lang/qt/src/qgpgmeencryptjob.cpp,
16402786 lang/qt/src/qgpgmesignencryptjob.cpp,
16422788 that accept generic EncryptFlags.
16432789
16442790 Cpp: Add support for all EncryptionFlags.
2791 + commit 17372393798ea5e2d6838f3dd1e001dd4a66c941
16452792 * lang/cpp/src/context.h (EncryptionFlags): Extend.
16462793 * lang/cpp/src/context.cpp (encryptflags2encryptflags): Ditto.
16472794
16482795 Cpp: Fix simple symmetric encryption.
2796 + commit bf776ce94cf454f1b3f1645b1cde09cd1c54324b
16492797 * lang/cpp/src/context.cpp (Context::encrypt): If no recipients
16502798 are provided encrypt with NULL and not an empty array.
16512799
16522800 core: Add support for mixed symmetric and asym enc.
2801 + commit 3d2f027d0f40e7ec4ab48cee89ff0ee10b423566
16532802 * src/gpgme.h.in (gpgme_encrypt_flags_t): New flag
16542803 GPGME_ENCRYPT_SYMMETRIC.
16552804 * src/engine-gpg.c (gpg_encrypt): Also add --symmetric if the flag
16662815 2016-08-08 Werner Koch <wk@gnupg.org>
16672816
16682817 core: Let GPGME_PROTOCOL_ASSUAN pass Assuan comments through.
2818 + commit b5e16b036f0045524a583d8a366d8a3366fc0005
16692819 * src/engine-assuan.c (llass_new): Set ASSUAN_CONVEY_COMMENTS,
16702820
16712821 2016-08-08 Andre Heinecke <aheinecke@intevation.de>
16722822
16732823 Prepend LD_LIBRARY_PATH for python tests.
2824 + commit ab6f66d676581cb497e581e4af40e2fe5bff507b
16742825 * lang/python/tests/Makefile.am (TESTS_ENVIRONMENT): Prepend path
16752826 instead of setting the value.
16762827
16772828 2016-08-05 Justus Winter <justus@g10code.com>
16782829
16792830 python: Clean up and modernize examples.
2831 + commit 2a613e87156b23c4aa6aa5ce38505cb285de6a18
16802832 * lang/python/examples/Examples.rst: Delete file.
16812833 * lang/python/examples/t-edit.py: Likewise. This is actually a test
16822834 case and has been moved to 'tests'.
16962848 2016-08-04 Werner Koch <wk@gnupg.org>
16972849
16982850 core: Extend gpgme_subkey_t to carry the keygrip.
2851 + commit 6f3dc66634e30d86aa6250c4ac22f9b8f7ec1be9
16992852 * src/gpgme.h.in (struct _gpgme_subkey): Add file 'keygrip'.
17002853 * src/key.c (gpgme_key_unref): Free KEYGRIP.
17012854 * src/keylist.c (keylist_colon_handler): Parse GRP records.
17072860 2016-08-03 Justus Winter <justus@g10code.com>
17082861
17092862 python: Add a nicer interface to list keys.
2863 + commit 56e26b54da9f16961209275d7a61883d3ea898ca
17102864 * lang/python/pyme/core.py (Context.keylist): New method.
17112865 * lang/python/tests/t-keylist.py: Test new method.
17122866
17132867 2016-08-02 Justus Winter <justus@g10code.com>
17142868
17152869 python: Add a flag identifying in-tree builds.
2870 + commit 4c8265d32ddff5960a464b8d4e8d7d2258495b2e
17162871 * lang/python/helpers.c (pyme_in_tree_build): New variable.
17172872 * lang/python/helpers.h (pyme_in_tree_build): New declaration.
17182873 * lang/python/pyme/version.py.in (in_tree_build): New variable.
17202875 as appropriate.
17212876
17222877 python: Fix build system integration.
2878 + commit 0bd7d8c1977183abc414e11aafa26a4f834ca2a5
17232879 * lang/python/Makefile.am: Be more careful when cleaning the build
17242880 directory, we must not delete the generated file 'pyme/version.py'.
17252881
17262882 doc: Document the Assuan protocol.
2883 + commit 135185b7ef2225aa5e8c54a6cf1265d3e6cbbe48
17272884 * doc/gpgme.texi: Document the Assuan protocol.
17282885
1729 GnuPG-bug-id: 2407
1730
17312886 2016-07-28 Justus Winter <justus@g10code.com>
17322887
17332888 python: Fix out-of-tree build.
2889 + commit 4e728de8421e2ade2061786aaebcdae3f60da3b8
17342890 * lang/python/MANIFEST.in: Add 'private.h'.
17352891
1736 Fixes-commit: 3d4dc3f0
1737
17382892 python: Improve error handling.
2893 + commit 5a7c7a86f7e8eaf10e37138617a2d838f9d4466f
17392894 * lang/python/pyme/core.py (Context.protocol): Check that the engine
17402895 is usable before setting the protocol.
17412896 (Context._errorcheck): Add missing functions.
17422897
17432898 src: Fix dummy engine versions.
2899 + commit b9e6eacd06ffeb36854c208aa4325cff3e3dfbbe
17442900 Previously, 'gpgme_engine_check_version' failed for these protocols
17452901 because the version parser failed to parse the dummy versions.
17462902
17532909 (uiserver_get_req_version): Likewise.
17542910
17552911 python: Drop superfluous imports and trim public interface.
2912 + commit 2ff58fcbd5c060dac3a7feec478819d2c5a164ec
17562913 * lang/python/pyme/__init__.py: Avoid leaking low-level 'gpgme', make
17572914 sure the main module looks nice and tidy, appease pyflakes.
17582915 * lang/python/pyme/errors.py: Appease pyflakes.
17652922 * lang/python/tests/t-signers.py: Likewise.
17662923
17672924 python: Rename compiled SWIG module.
2925 + commit 2f754440f28e8f81babdf7efa6186edbc8ad99fd
17682926 Avoid the name pygpgme, as this is the name of another popular Python
17692927 binding for GPGME.
17702928
17792937 * lang/python/setup.py.in: Likewise.
17802938
17812939 python: Rename exported functions.
2940 + commit b5aa05c3b261c3846ebbcf76e7505cff5459f918
17822941 Avoid the name pygpgme, as this is the name of another popular Python
17832942 binding for GPGME.
17842943
17902949 * lang/python/pyme/core.py: Likewise.
17912950
17922951 python: Rename private functions.
2952 + commit 1d2f22aae668ce136cacd254875e118dc1faa6a2
17932953 Avoid the name pygpgme, as this is the name of another popular Python
17942954 binding for GPGME.
17952955
18032963 prototypes here.
18042964
18052965 python: Support the Assuan engine.
2966 + commit de69fa496c09386d5e99747670d6887cf52dd09e
18062967 * lang/python/gpgme.i: Add typemaps for the Assuan protocol callbacks.
18072968 * lang/python/helpers.c (_pyme_assuan_{data,inquire,status}_cb): New
18082969 functions.
18142975 * lang/python/tests/t-protocol-assuan.py: New file.
18152976
18162977 python: Improve engine information handling.
2978 + commit 355d7072863ac1f0f725e77141a59f3ed8a5e4af
18172979 * lang/python/gpgme.i (gpgme_engine_info_t): Wrap engine infos.
18182980 * lang/python/pyme/core.py (Context.engine_info): New property.
18192981 (Context.{g,s}et_engine_info): Improve docstrings.
18202982 * lang/python/pyme/results.py (EngineInfo): New class.
18212983
18222984 python: Add accessors for the protocol.
2985 + commit 78f7bf4dcf75206faae5776c2ee4166628313532
18232986 * lang/python/pyme/core.py (Context.__init__): Add 'protocol'
18242987 parameter.
18252988 (Context.protocol): New accessors.
18262989
18272990 python: Expose less functions to the Python world.
2991 + commit 3d4dc3f0218234a27103bdb6f93b17c0703b71a2
18282992 * lang/python/Makefile.am (EXTRA_DIST, COPY_FILES): Add new file.
18292993 * lang/python/gpgme.i: Include new file and add comments.
18302994 * lang/python/helpers.c: Include new file.
18342998 2016-07-19 Ben Kibbey <bjk@luxsci.net>
18352999
18363000 Fix including nil bytes in keylist output.
3001 + commit 6a7ee33abd5059f5ae2f70a7dd9f610c16552f8e
18373002 * src/gpgme-tool.c (cmd_keylist,gt_result): use strlen().
18383003
18393004 2016-07-15 Justus Winter <justus@g10code.com>
18403005
18413006 python: Make GPGME's version easily accessible.
3007 + commit e545ca3f682b615ce447c186a2c73489a32b0592
18423008 * lang/python/pyme/version.py.in (gpgme_versionstr): New variable.
18433009
18443010 python: Add an idiomatic interface.
3011 + commit 1f318b7aaaa77672fab117d54fe75221780df83c
18453012 * configure.ac: Bump required Python version.
18463013 * lang/python/pyme/__init__.py: Update docstring. Import Context and
18473014 Data.
18763043 2016-07-14 Andre Heinecke <aheinecke@intevation.de>
18773044
18783045 Qt: Disable keylocate test for gnupg < 2.0.10.
3046 + commit d2f2cbd297c4d2f2c3264ecc3ffb7a2b3a70bd55
18793047 * lang/qt/tests/t-keylocate.cpp: Disable test for gnupg < 2.0.10
18803048
18813049 Cpp: Add EngineInfo::Version class.
3050 + commit 41de1ab904eaddffb2de17b1de8ef41e462daabe
18823051 * lang/cpp/src/engineinfo.cpp (EngineInfo::engineVersion): New.
18833052 * lang/cpp/src/engineinfo.h (EngineInfo::engineVersion): Declare.
18843053 (EngineInfo::Version): Small helper to work with versions.
18853054
18863055 Qt: Fix usage of ignore-invalid-option in tests.
3056 + commit e7f4c364732660c6cda25720b7dbc5b1c917e368
18873057 * Makefile.am (pubring-stamp): Fix config.
18883058
18893059 Qt: Fix tests if gpg2 is gpg.
3060 + commit e4c0645c1eea9380d80a20895eb83c9dd7228776
18903061 * lang/qt/tests/Makefile.am (pubring-stamp): Loopback and provide
18913062 passphrase on command line when importing.
18923063
18933064 2016-07-14 Justus Winter <justus@g10code.com>
18943065
18953066 python: Fix test.
3067 + commit fddcc62abd57cb04e84861abd3991c7d529c2464
18963068 * lang/python/tests/t-keylist.py: Do not assume key alpha is trusted
18973069 yet.
18983070
18993071 2016-07-13 Werner Koch <wk@gnupg.org>
19003072
19013073 build: Update config.{guess,sub} to {2016-05-15,2016-06-20}.
3074 + commit a9670d152a4598aef1ae0960a79fb6f5d8db55ad
19023075 * build-aux/config.guess: Update.
19033076 * build-aux/config.sub: Update.
19043077
19053078 core: New GPGME_DATA_ENCODING_MIME.
3079 + commit d8d5f5a16712244fe6eff860b6ac5f007b1bf870
19063080 * src/gpgme.h.in (GPGME_DATA_ENCODING_MIME): New.
19073081 * src/data.c (gpgme_data_set_encoding): Adjust check.
19083082 * src/engine-gpg.c (have_gpg_version): New.
19153089 * src/gpgme-tool.c (server_data_encoding): Add flag --mime.
19163090
19173091 core: Pass the engine's version string to the engine's new function.
3092 + commit 2095b1573a8196ba3efdf817324d1b3ee05cbb93
19183093 * src/engine-backend.h (engine_ops): Add arg 'version' to NEW.
19193094 * src/engine-assuan.c (llass_new): Add dummy arg 'version'.
19203095 * src/engine-g13.c (g13_new): Ditto.
19313106 2016-07-13 Andre Heinecke <aheinecke@intevation.de>
19323107
19333108 Cpp: Add feature enum for new identify.
3109 + commit 537cb871fd59f3a20c697a046715e6339ff6633b
19343110 * lang/cpp/src/context.cpp (supported_features2): Add
19353111 BinaryAndFineGrainedIdentify
19363112 * lang/cpp/src/global.h (Feature2): ditto.
19383114 2016-07-12 Justus Winter <justus@g10code.com>
19393115
19403116 python: Port more tests.
3117 + commit 1bff47ee58bcf9d0016fb7ac7e37cbf075abd059
19413118 * lang/python/pyme/core.py (Context.op_keylist_all): Add missing
19423119 'op_keylist_end'.
19433120 (Context.op_trustlist_all): Fix function. Add missing
19483125 * lang/python/tests/t-trustlist.py: Check alternate interface.
19493126
19503127 python: Improve python packaging.
3128 + commit 57b51685528153f5a50ab0999feec25c83190501
19513129 * lang/python/Makefile.am: Sign source releases, and upload them.
19523130 * lang/python/setup.py.in: Add categories.
19533131
19543132 2016-07-12 Andre Heinecke <aheinecke@intevation.de>
19553133
19563134 m4: Don't set fpic for qt on windows.
3135 + commit 938f7e9c8b466594d05c0347fe627b225263a6a6
19573136 * m4/qt.m4 (FIND_QT): Do not set fpic for windows.
19583137
19593138 m4: Use LIBS instead of LDFLAGS for Qt libs.
3139 + commit 744978cce8f9dfb2363b9d274ee99f25cfcf0e40
19603140 * m4/qt.m4: Modify LIBS instead of LDFLAGS for link test.
19613141
19623142 Bump version to 1.7.0.
3143 + commit bf742fb88545689addfca18192baf2f56a1895e1
19633144 * configure.ac(mym4_version_minor),
19643145 (mym4_version_micro): Next release will be 1.7.0
19653146
19663147 Qt: Install CamelCase forward includes.
3148 + commit fd87c4679c4bfe19390fa2047dff23bb213a4b18
19673149 * lang/qt/src/Makefile.am (camelcase_headers): New. Create and install
19683150 CamelCase headers.
19693151
19703152 Qt: Export VerifyDetachedJob.
3153 + commit 86ab2ee2d603111d24500b8d64a9a1dd82f8bdc0
19713154 * lang/qt/src/verifydetachedjob.h (VerifyDetachedJob): Export it.
19723155
19733156 Qt/Cpp: Add version headers.
3157 + commit b03c48cfb06faae7d7033a0532f319cbcf13f18a
19743158 * lang/cpp/src/gpgmepp_version.h.in,
19753159 lang/qt/src/qgpgme_version.h.in: New. Version information.
19763160 * lang/qt/src/Makefile.am, lang/cpp/src/Makefile.am: Add them.
19773161 * configure.ac: Configure them.
19783162
19793163 Qt/Cpp: Add license blurb to export headers.
3164 + commit 362b8cdf4e0d5cd54ec2b325508dcdefac686f2c
19803165 * lang/cpp/src/gpgmepp_export.h,
19813166 lang/qt/src/qgpgme_export.h: Add license blurb.
19823167
19833168 2016-07-11 Justus Winter <justus@g10code.com>
19843169
19853170 python: Fix distcheck.
3171 + commit ce662891373eba6cce1cf8df516cb2370970737e
19863172 * lang/python/Makefile.am (EXTRA_DIST): Add missing files.
19873173
19883174 2016-07-11 Andre Heinecke <aheinecke@intevation.de>
19893175
19903176 m4: Add compile / link check for qt.
3177 + commit ed070313155a1c79a57ba69f4299f2aefc65fad7
19913178 * m4/qt.m4 (FIND_QT): Check if a qt application can be compiled and
19923179 linked.
19933180
19943181 2016-07-11 Justus Winter <justus@g10code.com>
19953182
19963183 python: Enable out-of-tree build of pyme bindings.
3184 + commit 007382ce94a6318557370c440f7d609a030a119e
19973185 * lang/python/MANIFEST.in: Update manifest template.
19983186 * lang/python/Makefile.am: Copy more files, move generation of files
19993187 to Python build script, add 'sdist' target to build a Python source
20023190 * lang/python/setup.py.in: Generate files, enable out-of-tree builds.
20033191
20043192 python: Do not depend on access to internal data structures.
3193 + commit 98cba522c906115efcba1f8cc0bec7e5edb51ecd
20053194 * lang/python/gpgme.i (gpgme_data_t): Rework so that it works without
20063195 access to the definition of 'struct gpgme_data'.
20073196 * lang/python/helpers.c (object_to_gpgme_data_t): Add assertion.
20083197
20093198 python: Make result wrapping backwards compatible.
3199 + commit c53f87c5f9ca63119152f41dcebfb175d4df2cef
20103200 * lang/python/pyme/results.py (Result.__init__): Skip missing fields.
20113201
20123202 2016-07-11 Andre Heinecke <aheinecke@intevation.de>
20133203
20143204 Qt: Fix memleaks in tests.
3205 + commit bfa8ac7e02c16790ee5bd3b42c26699f4821d72e
20153206 * lang/qt/tests/t-keylist.cpp(cleanupTestCase): Ensure that
20163207 posted events are handled for autodeletion.
20173208 (testSingleKeylistSync): delete job.
20213212 * lang/qt/tests/t-keylocate.cpp(cleanupTestCase): Ditto
20223213
20233214 Qt: Add some general Protocol documentation.
3215 + commit b1f42e8f25ada220ec8e4762cfebc3a49b1f7d56
20243216 * lang/qt/src/protocol.h (Protocol): Add doc.
20253217
20263218 Qt: Disable t-tofuinfo tests.
3219 + commit 02babb29612d554c37b63a49f78acc45653b557e
20273220 * lang/qt/tests/t-tofuinfo.cpp: Disable tests.
20283221
20293222 2016-07-08 Justus Winter <justus@g10code.com>
20303223
20313224 src: Fix error handling.
3225 + commit de74fe59feef9adc858ac04004880bfd44315d0d
20323226 * src/encrypt.c (encrypt_status_handler): Fix error handling, ||
20333227 conflates errors.
20343228
20353229 python: Fix raising stashed exceptions.
3230 + commit 8a93f345b701332270c9829a4d0a93537f98a8d8
20363231 Fixes an issue with newer versions of Python.
20373232
20383233 * lang/python/helpers.c (pygpgme_raise_callback_exception): Be more
20413236 2016-07-07 Justus Winter <justus@g10code.com>
20423237
20433238 python: Fix distcheck.
3239 + commit 52efcf1ee9fc8ba4c6bd23d8fe4f5f7993ba9fb1
20443240 * lang/python/INSTALL: Drop obsolete file.
20453241 * lang/python/Makefile.am (EXTRA_DIST): Add missing files.
20463242 (CLEANFILES): Remove generated files.
20523248 * lang/python/tests/initial.py: Likewise.
20533249
20543250 qt: Fix distcheck.
3251 + commit 38c408560c6ebc3ea5eeeade01d38750bf5799e5
20553252 * lang/qt/src/Makefile.am (qgpgme_headers): Add missing file.
20563253 (CLEANFILES): Add generated file.
20573254 * lang/qt/tests/Makefile.am (clean-local): Remove private keys.
20583255
20593256 cpp: Fix distcheck.
3257 + commit 49286ac1c82c480e2c718f828c57da9778ccd0b9
20603258 * lang/cpp/src/Makefile.am (CLEANFILES): Remove generated file.
20613259
20623260 2016-07-06 Andre Heinecke <aheinecke@intevation.de>
20633261
20643262 Qt: Add test for publicKeyAlgorithmAsString.
3263 + commit fc0267233239b42e9fb74a8acd7511503e287a9e
20653264 * lang/qt/tests/t-keylist.cpp (testPubkeyAlgoAsString): New.
20663265
20673266 Cpp: Expose gpgme_pubkey_algo_name.
3267 + commit e41ae4db9e70d9aebf80ebbd4ce03977435c2ccf
20683268 * lang/cpp/src/key.cpp (Subkey::publicKeyAlgorithmAsString): New
20693269 static variant.
20703270 * lang/cpp/src/key.h: Declare function. Clarify comment about name
20713271 mismatch.
20723272
20733273 Qt: Add check for pubkeyAlgo in t-keylist.
3274 + commit 9f93346d21271b916f15d80420669f5d659a40de
20743275 * lang/qt/tests/t-keylist.cpp (testSingleKeyListSync): Check
20753276 pubkeyAlgo.
20763277
20773278 Cpp: Add PubkeyAlgo enum.
3279 + commit c28007d0407bcc3621b8266d6d77eb0d069aec35
20783280 * lang/cpp/src/key.h (Subkey::PubkeyAlgo): New enum.
20793281 (Subkey::publicKeyAlgorithm): Change return type.
20803282 * lang/cpp/src/key.cpp (Subkey::publicKeyAlgorithm): Use enum.
20813283
20823284 Qt: Fix include order when buildin test.
3285 + commit 4934893e27a50f5715dcd4d2907ecbe629921b32
20833286 * lang/qt/tests/Makefile.am (AM_CPPFLAGS): Include cpp before
20843287 gpgme src directory.
20853288
20863289 Revert "Qt: More robust lookup of Cpp's context.h"
3290 + commit 7a8c04f66d382dc49d962ad18c46d7ad332ccc0f
20873291 * lang/qt/src/threadedjobmixin.h: Revert using full path
20883292 for context.h
20893293
20903294 2016-07-05 Andre Heinecke <aheinecke@intevation.de>
20913295
20923296 Qt: Fix test build with Qt < 5.4.0.
3297 + commit 49a6ee50587c9d4b6f07e60ce1a939c863e7f15c
20933298 * lang/qt/tests/t-keylist.cpp,
20943299 lang/qt/tests/t-keylocate.cpp,
20953300 lang/qt/tests/t-ownertrust.cpp: Use old style SIGNAl syntax for
20963301 QSignalSpy
20973302
20983303 Qt: More robust lookup of Cpp's context.h.
3304 + commit 47bfbc9026b49b9918359af5fcc1621aab0d1065
20993305 * lang/qt/src/threadedjobmixin.h: When building qgpgme look for
21003306 context.h in the full cpp subdirectory.
21013307
21023308 w32: Fallback to 2.1 reg key for gpgconf search.
3309 + commit 72b83ffc4d7581f4efef3bd7c261d7d7424bcf0e
21033310 * src/w32-util.c (_gpgme_get_gpgconf_path): Fallback to 2.1 installer
21043311 registry key.
21053312
21063313 2016-07-04 Andre Heinecke <aheinecke@intevation.de>
21073314
21083315 Doc: Document pinentry mode.
3316 + commit 329ab93f7ed862d7f4c0501fca5355936a74ac52
21093317 * doc/gpgme.texi (Passphrase Callback): Document as context
21103318 attribute.
21113319 (gpgme_set_passphrase_cb): Note that this requires LOOPBACK mode
21123320 with GnuPG 2.1.
21133321
21143322 Qt: Add testTofuSignCount.
3323 + commit 8fa9b5696ca9f8386971e6f36646536f9579ceaa
21153324 * src/lang/qt/tests/t-tofuinfo.cpp(testTofuSignCount): New.
21163325 (initTestCase): Set gpg-agent loopback pinentry config.
21173326 (signAndVerify): Helper for tofuTestSignCount.
21183327
21193328 Qt: Add test passphrase provider.
3329 + commit efb5059b9b6e81db7b0c016aa9fb70abe98308ea
21203330 * lang/qt/tests/t-support.h (TestPassphraseProvider): New.
21213331 * lang/qt/tests/Makefile.am (t_tofuinfo_SOURCES): Add t-support.h
21223332
21233333 Cpp: Add support for TOFU_CONFLICT sigsum.
3334 + commit 80498ab662238a31325e78c0037ea6752f680a37
21243335 * lang/cpp/src/verificationresult.cpp (GpgME::Signature::Summary):
21253336 Handle TOFU_CONFLICT.
21263337 * lang/cpp/src/verificationresult.h (Summary): Add TofuConflict.
21273338
21283339 Cpp: Add support for pinentry_mode.
3340 + commit d75c118aae18e20f08dbbb69c7998e1f3694ccd0
21293341 * lang/cpp/src/context.cpp (Context::pinentryMode): Return mode.
21303342 (Context::setPinentryMode): Set mode.
21313343 * lang/cpp/src/context.h (PinentryMode): Add enum.
21333345 2016-07-01 Andre Heinecke <aheinecke@intevation.de>
21343346
21353347 Qt: Add test for TofuInfo.
3348 + commit fbd6ac4655ebf56d91ebd9a4ff499c8319fcd087
21363349 * lang/qt/tests/t-tofuinfo.cpp: New.
21373350 * lang/qt/tests/Makefile.am: Update accordingly.
21383351
21393352 Cpp: Add TofuInfo to signatures.
3353 + commit 93c5d420fcfe275aeff2b3d5ce99629edbe6625d
21403354 * lang/cpp/src/tofuinfo.cpp, lang/cpp/src/tofuinfo.h: New class.
21413355 * lang/cpp/src/verificationresult.cpp (Signature::tofuInfo): New.
21423356 (VerificationResult::Private): Handle tofu info.
21483362 * configure.ac (LIBGPGMEPP_LT_REVISION): Bump for new API.
21493363
21503364 core: Clarify documentation of tofu_stats address.
3365 + commit 948ce7d1edf12ecb5080a4816ca15f495d6393f5
21513366 * src/gpgme.h.in: Mention that Address is not always in addr-spec.
21523367
21533368 core: Fix identify for armored detached sigs.
3369 + commit 570bf2a648f14b34c4c45d3890b7300529a82d37
21543370 * src/data-identify.c (basic_detection): Return signature for
21553371 signature.
21563372
21573373 2016-06-27 Andre Heinecke <aheinecke@intevation.de>
21583374
21593375 Cpp: Expose new data_identify values.
3376 + commit 15fc5c34c88ecbb61272705af60f7054b41c57f7
21603377 * lang/cpp/src/data.cpp (GpgME::Data::type): Handle PGP Encrypted
21613378 and Signature.
21623379 * lang/cpp/src/data.h: Add values accordingly.
21633380
21643381 Cpp: Do not treat KEYEXPIRED as error.
3382 + commit 82d484c852d07958ac93efb3d2d7b7726fbb5231
21653383 * lang/cpp/src/editinteractor.cpp (status_to_error): No error
21663384 for KEYEXPIRED.
21673385
21683386 2016-06-24 Andre Heinecke <aheinecke@intevation.de>
21693387
21703388 tests: Add new test tool run-decrypt.
3389 + commit 3364549c19682f56d4d9c52ab7f76862c5a456cf
21713390 * tests/run-decrypt.c: New.
21723391 * tests/Makefile.am (noinst_PROGRAMS): Add run-decrypt.
21733392
21743393 2016-06-23 Werner Koch <wk@gnupg.org>
21753394
21763395 core: Add closer inspection of "PGP MESSAGE".
3396 + commit cf37a57d28c43ec36277e84ca44458b7287b940b
21773397 * src/data-identify.c (inspect_pgp_message): New.
21783398 (basic_detection): Un-const arg DATA. Call inspect_pgp_message.
21793399
21803400 core: Add a base 64 decoder.
3401 + commit f8b8027ae63c957557ed6bdc7e5a30ef1bdd8e77
21813402 * src/b64dec.c: New. Taken from gnupg. Prefix function names with
21823403 _gpgme_ and change to use standard C malloc functions.
21833404 * src/util.h.h (struct b64state): New.
21863407 2016-06-22 Werner Koch <wk@gnupg.org>
21873408
21883409 core: Detect compressed signed OpenPGP data.
3410 + commit bb8cf6236582fc9eb6564046599989af52779a26
21893411 * src/data-identify.c (next_openpgp_packet): Allow partial encoding.
21903412 (pgp_binary_detection): Handle compressed packets.
21913413
21923414 2016-06-21 Werner Koch <wk@gnupg.org>
21933415
21943416 tests: Add new test tool run-identify.
3417 + commit 5905e8bbd809c1408edad4fa4eb0527fa51cbea3
21953418 * src/gpgme-tool.c (gt_identify): Add new strings.
21963419 * tests/run-identify.c: New.
21973420 * tests/Makefile.am (noinst_PROGRAMS): Add run-identify.
21983421
21993422 core: Enhance gpgme_data_identify to detect binary PGP messages.
3423 + commit 32d4bbf5e3e5f88e4a6852d72a35ee30df9d5279
22003424 * src/gpgme.h.in (GPGME_DATA_TYPE_PGP_ENCRYPTED): New.
22013425 (GPGME_DATA_TYPE_PGP_SIGNATURE): New.
22023426 * src/data-identify.c: Add enum for OpenPGP packet types.
22103434 2016-06-16 Justus Winter <justus@g10code.com>
22113435
22123436 python: Improve autmatically generated docstrings.
3437 + commit 8997d88bf97d1784706becbf8e9dc74e4656e311
22133438 * lang/python/gpgme.i: Add comment.
22143439 * lang/python/pyme/core.py (__getattr__): Rewrite automatically
22153440 generated doctrings for the wrapper methods.
22163441
22173442 python: Make result objects more robust.
3443 + commit a324d0cffe93cab955698c2c065b2f2227e379e4
22183444 Results returned by the GPGME are fragile, i.e. they are only valid
22193445 until the next operation is performed in the context.
22203446
22283454 * lang/python/pyme/results.py: New file.
22293455
22303456 python: Avoid creating SWIG proxy classes.
3457 + commit 856bcfe2934237011984fab0bc69800a7c25c34b
22313458 * lang/python/Makefile.am (gpgme_wrap.c): Use '-builtin' to make SWIG
22323459 generate builtin types for c types.
22333460 * lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Adapt slightly.
22343461
22353462 python: Simplify wrapping glue.
3463 + commit 6641c7814b30e3e8f18105b2636545cc1bd07552
22363464 * lang/python/pyme/core.py: Rename '_getctype' to '_ctype' and turn it
22373465 into a string. Likewise rename '_getnameprepend' to '_cprefix'.
22383466 * lang/python/helpers.c: Adapt accordingly.
22393467
22403468 python: Rework callbacks.
3469 + commit f3618bc615e3eff1f52fb5849cbf0f0b95515a61
22413470 Simplify how the lifetime of callback arguments is managed.
22423471
22433472 * lang/python/gpgme.i (gpgme_edit_cb_t): Check arguments.
22613490 * lang/python/pyme/core.py (Context, Data): Update callsites.
22623491
22633492 python: Wrap objects implementing the buffer protocol.
3493 + commit 616929b6edf00b4a774b727385d39b785a112b90
22643494 * lang/python/Makefile.am: Add the toplevel source directory to CFLAGS
22653495 when compiling the bindings so that we can use private header files.
22663496 * lang/python/gpgme.i (gpgme_data_t): Rework the object wrapping. Do
22753505 * lang/python/tests/t-idiomatic.py: Demonstrate this.
22763506
22773507 python: Add properties to wrapped object.
3508 + commit 5464060baef2da8f5ea377118758e451c55e3787
22783509 * lang/python/pyme/core.py (GpgmeWrapper.__repr__): Saner
22793510 representation.
22803511 (GpgmeWrapper.__str__): Construct a nicer human readable string.
22893520 them.
22903521
22913522 python: Improve the documentation.
3523 + commit 5492853d7b84b4e1d0b11b234e32252ba8d1608d
22923524 * lang/python/Makefile.am: Copy the README file.
22933525 * lang/python/README: Rename, convert to org, and update.
22943526 * lang/python/pyme/__init__.py: Move license out of the docstring,
22963528 * lang/python/pyme/core.py: Add and update docstrings.
22973529
22983530 python: Get version information from the build system.
3531 + commit 7eef399d89d4c3877cb795ed5ba45ecb241e67be
22993532 * configure.ac: Generate 'setup.py' and 'version.py'.
23003533 * lang/python/Makefile.am: Use generated setup script.
23013534 * lang/python/pyme/version.py: Turn it into a template, and get
23043537 version module, which is frowned upon and actually caused a problem.
23053538
23063539 python: Fix exception leak.
3540 + commit a852f99a0ac9dc7f7493b403f811f5f7518fae40
23073541 * lang/python/helpers.c (pygpgme_stash_callback_exception): Fix leak.
23083542
23093543 python: Fix license.
3544 + commit 3bacce03e60dc45cc2da99a2f5c504612202e802
23103545 Other parts of the build system are also LGPLed.
23113546
23123547 * lang/python/Makefile.am: Fix license.
23143549 2016-06-14 Werner Koch <wk@gnupg.org>
23153550
23163551 core: Make sure FD_SET is not used with an out of range fd.
3552 + commit 8173c4f1f8a145c4b1d454f6f05e26950e23d675
23173553 * src/posix-io.c (_gpgme_io_select): Check for FD out of range.
23183554
23193555 2016-06-08 Justus Winter <justus@g10code.com>
23203556
23213557 python: Improve error handling.
3558 + commit 77d149e8614c381458e07808a7930ce3fb92cdc3
23223559 * lang/python/helpers.c (pyPassphraseCb): Handle write errors.
23233560 (pyEditCb): Likewise.
23243561
23253562 python: Add function to raise exceptions from c.
3563 + commit 5ebc205439cac266685d2532466df8b3457dea23
23263564 * lang/python/helpers.c (pygpgme_raise_exception): New function.
23273565
23283566 python: Fix stripping deprecated functionality.
3567 + commit 8426304b67a0b0a5630db500abf740b0e0b9e43c
23293568 * lang/python/Makefile.am (gpgme.h): Add script as input.
23303569 * lang/python/gpgme-h-clean.py (deprec_func): Also match struct
23313570 members.
23323571 (line_break): Fix matching on struct members.
23333572
23343573 python: Fix type.
3574 + commit 990492ea4f7dafbb75de15ea91c30cbf090034b5
23353575 * lang/python/gpgme.i: Use correct Python type for size.
23363576
23373577 python: Implement the context manager protocol.
3578 + commit e3c5913a33edcbd7329b8d154c669f95ce782038
23383579 * lang/python/pyme/core.py (Context.__del__): Make function
23393580 idemptotent.
23403581 (Context.{__enter__,__exit__}): Implement the context manager
23473588 2016-06-07 Justus Winter <justus@g10code.com>
23483589
23493590 python: Fix error handling.
3591 + commit f8f9bf06bc3190968ba6613032d60a3bf2c8a6d9
23503592 * lang/python/gpgme.i: Fix freeing an uninitialized pointer in the
23513593 error handling of generated wrapper functions by explicitly storing
23523594 the pointer in a local variable which can be initialized.
23543596 2016-06-06 Justus Winter <justus@g10code.com>
23553597
23563598 python: Wrap file-like objects on demand.
3599 + commit 8196edf9ca5c8f2f02553e7f22d9c79dbd229882
23573600 * lang/python/gpgme.i (gpgme_data_t): Use new function to create
23583601 wrapper objects if necessary, and deallocate them after the function
23593602 call.
23633606 * lang/python/tests/t-idiomatic.py: New file.
23643607
23653608 python: Move helper function.
3609 + commit 26c3accc95ab77ddbe60db822e2938ad5f480d41
23663610 * lang/python/gpgme.i (object_to_gpgme_t): Move...
23673611 * lang/python/helpers.c: ... here.
23683612 * lang/python/helpers.h (object_to_gpgme_t): New prototype.
23693613
23703614 python: Fix error handling.
3615 + commit 89eb0cd4d65bc033ed6342810b26232797482d64
23713616 * lang/python/gpgme.i (object_to_gpgme_t): Properly propagate
23723617 exceptions.
23733618
23743619 python: Initialize GPGME for the user.
3620 + commit ae06f7c2fe0e49baeab5a827dc38ba8c57a6404c
23753621 * lang/python/pyme/core.py: Call 'check_version' and explain why.
23763622 * lang/python/tests/support.py (init_gpgme): Drop call here.
23773623
23783624 2016-06-01 Justus Winter <justus@g10code.com>
23793625
23803626 python: Fix test suite with GnuPG prior to 2.1.12.
3627 + commit bbf19124bbec9eb6298cef2914baae7ac74382fe
23813628 * lang/python/tests/Makefile.am (gpg-agent.conf): Use
23823629 'allow-loopback-pinentry'.
23833630
23843631 python: Make Python detection more robust.
3632 + commit 1607aa7fe5dd686ba3bfb6de4a2b602d6a458c86
23853633 Previously, missing Python development packages made configure fail
23863634 instead of merely disabling the bindings.
23873635
23893637 * m4/ax_python_devel.m4: Make test non-fatal.
23903638
23913639 python: Improve build system integration, fix warnings.
3640 + commit 73c47535b631a55687ecc5eff1d1d9a9fd71021e
23923641 * lang/python/Makefile.am: Pass CFLAGS to python build system.
23933642 * lang/python/helpers.c (pyPassphraseCb): Use correct type for length.
23943643 (pygpgme_data_new_from_cbs): Drop unused variable.
23963645 2016-06-01 Andre Heinecke <aheinecke@intevation.de>
23973646
23983647 Cpp: Use whitelist for status messages.
3648 + commit 54314a9c7d7ad52981c836ca742644a1fa69b518
23993649 * lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
24003650 Use whitelist instead of blacklist.
24013651
24023652 Qt: Fix debug output in t-ownertrust.
3653 + commit 9d6f85bd25e51445f1776b498875e77b529311b1
24033654 * lang/qt/tests/t-ownertrust.cpp (testChangeOwnerTrust): Remove
24043655 general debug of trust level. Add debug output for error.
24053656
24063657 2016-06-01 Justus Winter <justus@gnupg.org>
24073658
24083659 tests: Fix notation tests.
3660 + commit c88c9ef384b6f7bda9a61b58f26c2f89ae25f684
24093661 * lang/python/tests/t-sig-notation.py (check_result): Check critical
24103662 flag.
24113663 * tests/gpg/t-sig-notation.c (check_result): Likewise.
24123664
2413 Fixes-commit: 1cacd7d0
2414
24153665 2016-06-01 Werner Koch <wk@gnupg.org>
24163666
24173667 core: Set notation flags for verify.
3668 + commit 1cacd7d00a7b3de4a5e11ccce5ee6c50e0a5516d
24183669 * src/gpgme.h.in (GPGME_STATUS_NOTATION_FLAGS): New.
24193670 * src/status-table.c (status_table): Add new status.
24203671 * src/verify.c (parse_notation): Handle flags. Also fix NOTATION_DATA
24253676 2016-05-31 Tobias Mueller <muelli@cryptobitch.de>
24263677
24273678 python: use GPG_ERROR_CONFIG variable.
3679 + commit 8ad17f402f6420880dcf06a13a54feadb52c0208
24283680 instead of calling gpg-error-config.
24293681 This is useful when configuring with --with-gpgerror-prefix
24303682 because then GPG_ERROR_CONFIG contains the correct
24353687 2016-05-31 Justus Winter <justus@gnupg.org>
24363688
24373689 python: Port more tests.
3690 + commit afa0dd56e1cce64fe08bff3c64b12aecce54fd2d
24383691 * lang/python/gpgme.i: Hide length fields of notations.
24393692 * lang/python/tests/Makefile.am (pytests): Add new tests.
24403693 * lang/python/tests/t-decrypt-verify.py: New file.
24443697 2016-05-27 Werner Koch <wk@gnupg.org>
24453698
24463699 Speedup closing of fds before exec.
3700 + commit 89d22f9229f2ecd559ac6ea91dae60eeff940fa5
24473701 * src/posix-io.c [__linux__]: Include dirent.h.
24483702 (get_max_fds) [__linux__]: Try to figure out the highest used fd.
24493703
24503704 2016-05-27 Justus Winter <justus@gnupg.org>
24513705
24523706 python: Port more tests.
3707 + commit 3915842657f0849a038752fd7445f96081a89dd9
24533708 * lang/python/pyme/core.py (Data._error_check): Add
24543709 'gpgme_data_get_file_name' to the list of functions not returning an
24553710 error code.
24613716 * lang/python/tests/t-trustlist.py: Likewise.
24623717
24633718 python: Implement data callbacks.
3719 + commit 2ae847c02731994d99e69d3d025ff01f41406452
24643720 * lang/python/gpgme.i (object_to_gpgme_t): Set exception on error.
24653721 * lang/python/helpers.c (pyDataReadCb): New function.
24663722 (pyDataWriteCb): Likewise.
24803736 * lang/python/tests/t-data.py: Likewise.
24813737
24823738 python: Fix object deallocation.
3739 + commit ebfe2300c33a3bad311e9ac1530e6c92636a08a4
24833740 Handing a reference to the wrapper object created a non-trivial
24843741 circular reference that Pythons garbage collector is unable to break.
24853742 Explicitly break it by using a weak reference.
24933750 (Context.op_edit): Likewise.
24943751
24953752 Improve comments.
3753 + commit e74cd9fb80f12b764d5e4561e73d55644147e9e7
24963754 * src/gpgme.h.in (gpgme_data_seek_cb_t, gpgme_data_seek): Clarify that
24973755 these functions return the new offset.
24983756 (gpgme_data_release_cb_t): Fix name of parameter.
24993757
25003758 python: Fix reading data from existing files.
3759 + commit bf188e280b8b4fc775f33c47e2e1e275ed044004
25013760 * lang/python/pyme/core.py (Data.__init__): Add 'copy' kwargument, and
25023761 pass it to functions supporting it. PEP8 fix.
25033762 (Data.new_from_fd): PEP8 fix.
25103769 2016-05-25 Justus Winter <justus@gnupg.org>
25113770
25123771 src: Fix trace string.
3772 + commit ce73ae9d0cbf782cd3a1949fc4f568f0d1da60d9
25133773 * src/data-compat.c (gpgme_data_new_from_file): Fix trace string.
25143774
25153775 2016-05-24 Justus Winter <justus@gnupg.org>
25163776
25173777 python: Improve and test Context.wait.
3778 + commit 00ff6d07330028da370c869e3ec442eb76f8cbb8
25183779 * lang/python/pyme/core.py (Context.wait): Improve docstring. As the
25193780 context passed to 'gpgme_wait' is never NULL, it is pointless to look
25203781 at the returned context. Always raise exceptions.
25223783 * lang/python/tests/t-wait.py: New file.
25233784
25243785 python: Make all GnuPG errors available.
3786 + commit 7bc9cc717e428f48d4b27016f44c9f3900b1fba6
25253787 * lang/python/Makefile.am (errors.i): Generate file.
25263788 * lang/python/gpgme.i: Include generated file.
25273789 * lang/python/pyme/errors.py: Pull in all errors and error sources.
25283790
25293791 python: Move the base wrapper class.
3792 + commit 0ebd6a1b43a96bffa78da89dc8629edac0a74d35
25303793 * python/lang/pyme/util.py (GpgmeWrapper): Move...
25313794 * python/lang/pyme/core.py: ... here.
25323795
25333796 python: Support status callbacks.
3797 + commit 8b57f06e0c04f5c9b87a3c76618230d757412076
25343798 * lang/python/helpers.c (pyStatusCb): New function.
25353799 (pygpgme_set_status_cb): Likewise.
25363800 * lang/python/helpers.h (pygpgme_set_status_cb): New prototype.
25413805 * lang/python/tests/t-callbacks.py: Test status callbacks.
25423806
25433807 python: Improve docstring.
3808 + commit 72afb68f8c2f0cb326f20b289215402fd849339d
25443809 * lang/python/pyme/core.py (Context.set_progress_cb): Improve
25453810 docstring.
25463811
25473812 2016-05-24 Andre Heinecke <aheinecke@intevation.de>
25483813
25493814 Qt: Fix test build with clang.
3815 + commit 00e93b2cae0585ff10425421d9097a846943b21c
25503816 * lang/qt/tests/Makefile.am (LDADD): Explicitly add -lstdc++
25513817
25523818 Cpp: Set -std=c++11 also if CXXCPP is already set.
3819 + commit b107fc8a92bd16bc0d868c771b6334d6594e6395
25533820 * m4/ax_cxx_compile_stdxx.m4 (AX_CXX_COMPILE_STDCXX): Set CXXCPP if
25543821 neccessary.
25553822
25563823 2016-05-24 Justus Winter <justus@gnupg.org>
25573824
25583825 python: Improve support for edit callbacks.
3826 + commit 09803c4a81b9431fd4c8f30abb1c60c4c735f0cb
25593827 * lang/python/helpers.c (pyEditCb): Stash exceptions.
25603828 * lang/python/pyme/core.py (Context.op_edit): Hand in 'self'.
25613829 * lang/python/tests/Makefile.am (py_tests): Add new test.
25653833 2016-05-23 Justus Winter <justus@gnupg.org>
25663834
25673835 python: Fix hook.
3836 + commit 283f0bdc3d32624dac93d02ba3df516e69d8d4ba
25683837 * lang/python/helpers.c (pyProgressCb): Fix getting hook data.
25693838 * lang/python/tests/t-callbacks.py: Show that this works.
25703839
25713840 python: Move edit callback function.
3841 + commit 5476ca6813fc9d8833d5224f19d4bb7515380ab5
25723842 * lang/python/gpgme.i (pyEditCb): Move...
25733843 * lang/python/helpers.c: ... here.
25743844 * lang/python/helpers.h (pyEditCb): New prototype.
25753845
25763846 python: Port more tests.
3847 + commit a42d814a65fdc29a3be6efa97433997495696a88
25773848 * lang/python/tests/Makefile.am (TESTS_ENVIRONMENT): Set
25783849 LD_LIBRARY_PATH.
25793850 (pytests): Add new tests.
25833854 * lang/python/tests/t-signers.py: Likewise.
25843855
25853856 python: Translate list of strings.
3857 + commit c9cc0412e940c78c3e9bacb6ff1459b5bb5bb9ad
25863858 * lang/python/gpgme.i: Add typemap translating list of strings.
25873859
25883860 2016-05-21 Werner Koch <wk@gnupg.org>
25893861
25903862 api: Return Tofu info for signatures.
3863 + commit 10df06ee8f9192309bf124872438f7c32457e1c6
25913864 * src/gpgme.h.in (gpgme_tofu_policy_t): New.
25923865 (gpgme_status_code_t): Add status codes for TOFU.
25933866 (struct _gpgme_tofu_info, gpgme_tofu_info_t): New.
26053878 (print_result): print tofu info.
26063879
26073880 api: Add new context flag "raw-description".
3881 + commit dac2c5441d418536632f014c8b0e1359580279d1
26083882 * src/context.h (struct gpgme_context): Add field raw_description.
26093883 * src/gpgme.c (gpgme_set_ctx_flag): New flag.
26103884
26113885 core: New functions to help parsing of status lines.
3886 + commit a92946a8cacc44f655249d84b316deae59e62671
26123887 * src/conversion.c (_gpgme_split_fields): New.
26133888 (_gpgme_strtoul_field): New.
26143889
26153890 2016-05-20 Andre Heinecke <aheinecke@intevation.de>
26163891
26173892 Qt: Add test for changeownertrust.
3893 + commit eaf2d018e63c15cd9a81e5c1fd2fedbf8829f7b9
26183894 * lang/qt/tests/t-ownertrust.cpp: New test.
26193895 * lang/qt/tests/Makefile.am: Add test.
26203896
26213897 Cpp: Ignore STATUS_KEY_CONSIDERED when editing.
3898 + commit 5df858cbf196b2a53d600b7f45655f7b35c1fe93
26223899 * lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
26233900 Handle GPGME_STATUS_KEY_CONSIDERED.
26243901
26253902 2016-05-19 Werner Koch <wk@gnupg.org>
26263903
26273904 api: Add new function gpgme_set_ctx_flag.
3905 + commit 88f2c1c0d16eee6bb36a901623ea65ac69499f03
26283906 * src/gpgme.h.in (gpgme_set_ctx_flag): New prototype.
26293907 * src/gpgme.c (gpgme_set_ctx_flag): New.
26303908 * src/gpgme.def, src/libgpgme.vers: Add new function.
26633941 (main): Add option --status.
26643942
26653943 api: Remove arbitrary restriction from gpgme_op_verify.
3944 + commit 5aa8e588e166abeef2e3d677ab6830f2d7af1b5d
26663945 * src/verify.c (verify_start): Do not return GPG_ERR_INV_VALUES when
26673946 when SIGNED_TEXT is not given.
26683947
26693948 2016-05-19 Justus Winter <justus@gnupg.org>
26703949
26713950 python: Improve progress callbacks.
3951 + commit 0d4e95621e05d50cd454049a424bb9ee098a5db6
26723952 * lang/python/helpers.c (pyProgressCb): Stash python errors, convert
26733953 'what' to Unicode object.
26743954 * lang/python/pyme/core.py (Context.set_progress_cb): Hand in 'self'.
26753955 * lang/python/tests/t-callbacks.py: Test progress callbacks.
26763956
26773957 python: Robust exception handling in callbacks.
3958 + commit d90857a08c4fe5b73b6d6d46fd6200efdd72db44
26783959 * lang/python/helpers.c (pygpgme_stash_callback_exception): New
26793960 function.
26803961 (pygpgme_raise_callback_exception): Likewise.
26923973 2016-05-19 Andre Heinecke <aheinecke@intevation.de>
26933974
26943975 Qt: Check for graphviz and set HAVE_DOT correctly.
3976 + commit 2f748b5a2d162be4f23b18782219771ead54cb51
26953977 * configure.ac: Check for graphviz and define HAVE_DOT.
26963978 * lang/qt/doc/Doxyfile.in (HAVE_DOT): Use variable.
26973979
26983980 2016-05-19 Justus Winter <justus@gnupg.org>
26993981
27003982 python: Add more tests.
3983 + commit 464d404c8816fc93baf945816c93e86bdeb0ea39
27013984 * lang/python/tests/Makefile.am (py_tests): Add new tests.
27023985 * lang/python/tests/support.py (print_data): New function.
27033986 * lang/python/tests/t-decrypt.py: Use new function.
27063989 * lang/python/tests/t-encrypt-sym.py: Likewise.
27073990
27083991 python: More type conversion fixes.
3992 + commit c1c893e3384a07ff864507902fbac4a7fee4d6f1
27093993 * lang/python/helpers.c (pyPassphraseCb): Cope with 'uid_hint' being
27103994 NULL, convert it to an Unicode object, and cope with the callback
27113995 returning both Unicode and bytes objects.
27123996
27133997 python: Fix import.
3998 + commit 07f71cd17706093ca6b1507c41609356d479ae9f
27143999 * lang/python/helpers.c (pygpgme_exception_init): Make module import
27154000 relative.
27164001
27174002 2016-05-19 Andre Heinecke <aheinecke@intevation.de>
27184003
27194004 Qt: Fix compilation of unit tests.
4005 + commit 375523ead3a749d77d286c56f10d403c07f2b014
27204006 * lang/qt/tests/Makefile.am (AM_CPPFLAGS): Add -DBUILDING_QGPGME.
27214007
27224008 2016-05-18 Justus Winter <justus@gnupg.org>
27234009
27244010 python: Various fixes.
4011 + commit 2c3a5d93e78cfca22785e51c5a65184a47da4bff
27254012 * configure.ac: Fix SWIG detection, bump required Python version.
27264013 * lang/python/Makefile.am: Portability fix.
27274014
27284015 2016-05-18 Andre Heinecke <aheinecke@intevation.de>
27294016
27304017 Fix typo in compatibility declaration.
4018 + commit f0dca0ab92ed18d80e30d7d39db1596b4112794f
27314019 * src/op-support.c (GPG_ERR_SUBKEYS_EXP_REV): Change to
27324020 GPG_ERR_SUBKEYS_EXP_OR_REV.
27334021
27344022 2016-05-17 Werner Koch <wk@gnupg.org>
27354023
27364024 tests: New maintenance helper run-encrypt.
4025 + commit 30b447fcfe0e4f362c2575e1b9388e8144b5b2fd
27374026 * tests/run-encrypt.c: New.
27384027
27394028 Return dedicated error code for all subkeys expired or revoked.
4029 + commit 315fb73d4a774e2c699ac1804f5377559b4d0027
27404030 * src/gpgme.h.in (GPGME_STATUS_KEY_CONSIDERED): New.
27414031 (GPGME_SIGSUM_TOFU_CONFLICT): New.
27424032 * src/status-table.c (KEY_CONSIDERED): New.
27534043 2016-05-17 Andre Heinecke <aheinecke@intevation.de>
27544044
27554045 Qt / Cpp: Port auto_ptr to unique_ptr.
4046 + commit 9b36ebf37a3b889c955ba68038bd5b3d9c5cde4e
27564047 * lang/cpp/src/context.cpp,
27574048 lang/cpp/src/context.h,
27584049 lang/cpp/src/context_p.h (Context::createForEngine),
27704061 2016-05-17 Justus Winter <justus@gnupg.org>
27714062
27724063 build: Add python autoconf macro.
4064 + commit 4711a1e181153a2395e5f523047595abd47965db
27734065 * m4/ax_python_devel.m4: New file.
27744066
27754067 python: Clean up examples.
4068 + commit 10328324c8fc9725cd0c885eaebfc80dc32c1ff6
27764069 * lang/python/examples/delkey.py: Clean up example.
27774070 * lang/python/examples/encrypt-to-all.py: Likewise.
27784071 * lang/python/examples/genkey.py: Likewise.
27854078 * lang/python/pyme/__init__.py: Likewise.
27864079
27874080 python: Import GPGMEError.
4081 + commit 64e5fe767f45e9ccb0fb3fe919171c222132a54c
27884082 * pyme/core.py: Import GPGMEError.
27894083
27904084 Fixes c5d118b2.
27914085
27924086 python: Port more tests.
4087 + commit 9ceaec25918c6c5f2dfafe4e20181b83ce78f6ce
27934088 * lang/python/Makefile.am: Add bits from the c test suite.
27944089 * lang/python/support.py: New file.
27954090 * lang/python/t-decrypt.py: Likewise.
27984093 2016-05-13 Andre Heinecke <aheinecke@intevation.de>
27994094
28004095 Qt: Add keyLocateJob and test for it.
4096 + commit 52f2295d528029a36a3e0a89c777297762b3fc9b
28014097 * configure.ac (LIBQGPGME_LT_REVISION): Bump.
28024098 * lang/qt/src/protocol.h (locateKeysJob): Add Job.
28034099 * lang/qt/src/protocol_p.h (locateKeysJob): Implement.
28054101 * lang/qt/tests/t-keylocate.cpp: New.
28064102
28074103 Qt: Add missing copyright header in test.
4104 + commit 66ded1a5ce7236254f8541addecd4c3bc7b2878e
28084105 * lang/qt/tests/t-keylist.cpp: Add copyright header.
28094106
28104107 2016-05-12 Justus Winter <justus@gnupg.org>
28114108
28124109 python: Share generated methods between objects.
4110 + commit 11314f0db6e57597e3f56351a86fdb36a7a17dd7
28134111 * lang/python/pyme/util.py (GpgmeWrapper.__getattr__): Monkey-patch
28144112 the class.
28154113 * lang/python/tests/t-wrapper.py: Demonstrate the sharing.
28164114
28174115 python: Raise exceptions on write errors.
4116 + commit c5d118b2a76e9528df780d11da9566ff7c22e4f5
28184117 * lang/python/pyme/core.py (Data.write): Handle errors.
28194118 * lang/python/pyme/errors.py (GPGMEError.fromSyserror): New function.
28204119
28214120 python: Fix writing to data buffers.
4121 + commit f7094d8358e933f3ce074eade7a40b2a7d291180
28224122 * lang/python/gpgme.i: Add typemap for buffers.
28234123 * lang/python/pyme/core.py (Data.write): Fix function.
28244124 * lang/python/tests/Makefile.am: Add new test.
28254125 * lang/python/tests/t-data.py: New file.
28264126
28274127 python: Add a test suite.
4128 + commit e64bffe0307d14204b00a177a472cd4f99c07561
28284129 * configure.ac: Add new Makefile.
28294130 * lang/python/Makefile.am: Add subdirectory.
28304131 * lang/python/tests/Makefile.am: New file.
28314132 * lang/python/tests/t-wrapper.py: Likewise.
28324133
28334134 python: Cache generated wrapper functions.
4135 + commit ed0ce84fbd2904bf59ac66ae7422716db3624efa
28344136 * lang/python/util.py (GpgmeWrap.__getattr__): Cache generated wrapper
28354137 functions.
28364138
28374139 python: Fix function invocation.
4140 + commit e3d3d366bd1a1aea8a38ae5dcbf71ea3c784e920
28384141 * lang/python/pyme/core.py (Data.new_from_fd): Fix function
28394142 invocation.
28404143
28414144 python: Fix name of exception, make slot methods explicit.
4145 + commit af9371eb63664c92fb67e8e7e03cc984e7d38a7f
28424146 * lang/python/pyme/util.py (GpgmeWrapper._getctype): Fix exception,
28434147 add docstring.
28444148 (GpgmeWrapper._getnameprepend): New function.
28454149 (GpgmeWrapper._errorcheck): Likewise.
28464150
28474151 python: Handle interpreter shutdown.
4152 + commit ce5121ad53b0e17fbf9150b354c80da73f7fe190
28484153 * lang/python/pyme/core.py: Avoid races at interpreter shutdown. This
28494154 silences the most annoying occurrences, however this problem also
28504155 affects the SWIG generated code, which might indicate that the real
28514156 problem is somewhere else. If so, this change can be easily reverted.
28524157
28534158 python: Make test case more robust.
4159 + commit c89d3a71ad20ff02755539a44f254b1e59054c4a
28544160 * lang/python/examples/t-edit.py: Check if key is found.
28554161
28564162 python: Fix type translation.
4163 + commit d60deb8a127fb35c01acc729f33b014840af0e7b
28574164 * lang/python/gpgme.i: Adjust to Python3's string type being
28584165 'Unicode', not 'bytes'. Fix type checking.
28594166 * lang/python/core.py (Data.write): Add docstring mentioning the
28654172 2016-05-11 Andre Heinecke <aheinecke@intevation.de>
28664173
28674174 Cpp: Ensure gpgme.h is taken from current build.
4175 + commit b8de79160b2e05ac84d8feb61ff7ed1f7015a623
28684176 * lang/cpp/src/Makefile.am (AM_CPPFLAGS): Add gpgme.h location.
28694177
28704178 2016-05-11 Justus Winter <justus@gnupg.org>
28714179
28724180 python: Fix simple example.
4181 + commit bbeee5e1a060f2d1e37a08220eb552cf4673a058
28734182 * lang/python/examples/simple.py: Flush stdout, encode name as
28744183 UTF-8 before passing it to GPGME.
28754184
28764185 python: Integrate into the build system.
4186 + commit a29babd07cf9f9625d2b5aa2eb6b7bc9d1828359
28774187 * configure.ac: Make Python bindings configurable, add new Makefile.
28784188 * lang/python/Makefile.am: New file.
28794189 * lang/python/setup.py: Integrate into the build system.
28834193 2016-05-10 Andre Heinecke <aheinecke@intevation.de>
28844194
28854195 Qt / Cpp: Fix make dist.
4196 + commit c303292aca26c43b6efe98719edb3ff7b2d6665d
28864197 * lang/cpp/src/Makefile.am (EXTRA_DIST): Fix typo.
28874198 (private_gpgmepp_headers): New. Private headers.
28884199 (libgpgmepp_la_SOURCES): Add private headers.
28924203 2016-05-10 Justus Winter <justus@gnupg.org>
28934204
28944205 python: PEP8 fixes.
4206 + commit 11392a80d9a85bcd8718b105e6d58038e61beaac
28954207 Cherry picked from 0267c151.
28964208
28974209 2016-05-10 Andre Heinecke <aheinecke@intevation.de>
28984210
28994211 Qt: Make Protocol class public API.
4212 + commit 56c4d9ea9520c95612e525b2fa1359db6fa88f4a
29004213 * lang/qt/src/Makefile.am (qgpgme_headers): Add protocol.h
29014214 (private_qgpgme_headers): Add protocol_p.h
29024215 * lang/qt/src/protocol.h: New. From QGpgMEBackend.
29054218 lang/qt/src/qgpgmebackend.cpp (Protocol): Removed.
29064219
29074220 Qt: Make doxygen quieter.
4221 + commit 97225bb01cd2ffa1d84c7fedbc577275de4a4893
29084222 * lang/qt/doc/Doxyfile.in: Quiet and no undocumented warnings.
29094223
29104224 Qt: Only install public headers.
4225 + commit 740f92a7b83389ee9bde98b7bd25556793500b8b
29114226 * lang/qt/src/Makefile.am: Do not install all headers.
29124227
29134228 Qt: Add test for async keylisting.
4229 + commit 0e3195948ddaba3af07d2415bb496491076edc17
29144230 * src/lang/qt/tests/t-keylist.cpp(KeyListTest::testKeyListAsync): New.
29154231
29164232 2016-05-10 Werner Koch <wk@gnupg.org>
29174233
29184234 Allow cc to detect missing cases in a switch.
4235 + commit fc38c15136c87ce971a8381fa87399088dd5a3cc
29194236 * src/delete.c (delete_status_handler): Remove default case from a
29204237 switch so that cc can check the use of all enum values.
29214238
29224239 2016-05-06 Andre Heinecke <aheinecke@intevation.de>
29234240
29244241 Use common error message style for qt lang checks.
4242 + commit a579be82c84f0b9732ee3d52ff2142a3decf95d7
29254243 * configure.ac: Use common error highliting for qt lang options.
29264244
29274245 Qt: Fix license mentioned in README.
4246 + commit 11ff8d5964bf66f905818514f6a51fc881ea1a56
29284247 * lang/qt/README: License is GPLv2+ and not LGPL.
29294248
29304249 Add maybe mode for langs and default to it.
4250 + commit cd267791e9bd73505a2a1ea90c85df988e153c19
29314251 * configure.ac (languages): Warn and disable langs for which
29324252 requirements are not met.
29334253
29344254 Cpp: Handle PINENTRY_LAUNCHED status line.
4255 + commit 3fad1216770f446a89801d842aa8667356a5ec95
29354256 * lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
29364257 Add GPGME_STATUS_PINENTRY_LAUNCHED.
29374258
29384259 2016-04-12 Andre Heinecke <aheinecke@intevation.de>
29394260
29404261 Cpp: Add support for pubkey_algo_name.
4262 + commit 5489532ad6ccf3a9b59405686b8a17352f1ecf06
29414263 * lang/cpp/src/key.cpp (Subkey::algoName): New.
29424264 * lang/cpp/src/key.h: Declare.
29434265
29444266 Cpp: Add support for gpgme_data_identify.
4267 + commit d949d711dc1d944a9d627d39a89af74943a5a8c1
29454268 * lang/cpp/src/data.cpp (Data::type): New.
29464269 * lang/cpp/src/data.h (Data::Type): New enum mapping.
29474270
29484271 Fix configuration without Qt language.
4272 + commit 6dba47c3a2c32d7c1e1d91a96030f99f606433ea
29494273 * configure.ac: Define HAVE_DOXYGEN also if qt should not be built.
29504274
29514275 2016-04-11 Andre Heinecke <aheinecke@intevation.de>
29524276
29534277 Qt/Cpp: Bump so version to 6.
4278 + commit 8e7074dbb8093cc342e330bcd6b172b4f769a0c6
29544279 * configure.ac (LIBGPGMEPP_LT_CURRENT, LIBQGPGME_LT_CURRENT): Bump.
29554280
29564281 Qt / Cpp: Mention coding style in READMES.
4282 + commit d2b55101195efe9702e855a48fc6e21839fb98cc
29574283 * src/lang/cpp/README, src/lang/qt/README: Add hacking note.
29584284
29594285 Qt: Add doc generation with doxygen.
4286 + commit a1e95f36ce1895cd9894f6d3ca76640c42c2f9fc
29604287 * configure.ac: Look for doxygen if qt is built.
29614288 Configure new files.
29624289 * lang/qt/doc/Doxyfile.in: New.
29644291 * lang/qt/README: Update.
29654292
29664293 Qt: Fix unit test by adding initial.test dep.
4294 + commit d9f7a18ed88127e7f05d770d55118d1e928f3b3f
29674295 * lang/qt/tests/t-keylist.cpp: Verify that GNUPGHOME is set.
29684296 * lang/qt/tests/initial.test: New dummy test.
29694297 * lang/qt/tests/Makefile.am: Add dependency to initial.test
29704298
29714299 Qt: Remove remaining boost usage.
4300 + commit afd8fad6e275e2f74b2ad045dce05d826986e2ec
29724301 * lang/qt/src/dataprovider.h,
29734302 lang/qt/src/decryptjob.h,
29744303 lang/qt/src/decryptverifyjob.h,
30024331 lang/qt/src/verifyopaquejob.h: Remove boost usage.
30034332
30044333 Qt: Remove predicates.h and stl_util.h.
4334 + commit e18256fc5f613da9406da60c3ef2f84f2be04ef0
30054335 * src/lang/qt/predicates.h, src/lang/qt/stl_util.h: Removed.
30064336
30074337 Qt: Remove usage of stl_util.h and predicates.h.
4338 + commit d293bd32293929eeb3f6ec35f916a4678fb51729
30084339 * src/lang/qt/qgpgmelistallkeysjob.cpp: Use comperators from
30094340 gpgmepp instead of detail. Remove boost usage.
30104341
30114342 Cpp: Add string comparators for keys.
4343 + commit 1bb162a54ba480413c4da07f2578efe6860494c0
30124344 * lang/cpp/src/global.h (GPGMEPP_MAKE_STRCMP): New.
30134345 (_gpgmepp_strcmp): NULL save wrapper around std::strcmp.
30144346 * lang/cpp/src/key.h: Add comparators for various attributes.
30154347
30164348 Cpp: Remove last usages of boost.
4349 + commit 691950e18cf08a3f9bbc2004501834cd47bea579
30174350 * lang/cpp/src/configuration.cpp: Use std::remove_pointer.
30184351 (Configuration::operator<<): std::for_each.
30194352 * lang/cpp/src/context.cpp: Delete manually instead of scoped ptr.
30234356 2016-04-04 Andre Heinecke <aheinecke@intevation.de>
30244357
30254358 Add pthread in gpgmepp config.
4359 + commit cc68ff5f7210ac879fbdf719fcd5944f9ae5602b
30264360 * lang/cpp/src/GpgmeppConfig.cmake.in.in: Add pthread.
30274361
30284362 2016-04-03 Andre Heinecke <aheinecke@intevation.de>
30294363
30304364 Cpp / Qt: Reduce boost usage (memory and tuple)
4365 + commit f98898ab1a6952e0c3a5d235963a27eba2e19e46
30314366 * cpp/src/assuanresult.h,
30324367 cpp/src/configuration.cpp,
30334368 cpp/src/configuration.h,
30994434 qt/src/verifyopaquejob.h: Reduce boost usage.
31004435
31014436 Cpp: Require c++ 11 if cpp binding requested.
4437 + commit c07aaef6eb8a9b5e623479f27d562fd1570bf4bb
31024438 * configure.ac: Call ax_cxx_compile_stdcxx
31034439 * m4/ax_cxx_compile_stdcxx.m4
31044440
31054441 Qt: Add static factor methods for protocol.
4442 + commit 0991485170ca4ef90fd566540522027d0fc59a72
31064443 * lang/qt/src/qgpgmebackend.cpp (QGpgME::openpgp, QGpgME::smime): New.
31074444 * lang/qt/src/qgpgmebackend.h: Declare.
31084445 * lang/qt/tests/t-keylist.cpp (KeyListTest::testSingleKeyListSync):
31094446 Use new functions.
31104447
31114448 Qt: Add a unit test for qgpgme.
4449 + commit faf987dd62893955251378a2a715edd2892a540c
31124450 * configure.ac: Configure test Makefile.
31134451 * m4/qt.m4: Look up Qt5Test flags.
31144452 * lang/qt/tests/t-keylist.cpp: New. Simple keylist check.
31154453 * lang/qt/tests/Makefile.am: New. General test framework.
31164454
31174455 Qt: Add missing MOC includes.
4456 + commit b7b9e38399a572cb61a297db552026eac5b2a5e1
31184457 * qgpgmeadduseridjob.cpp,
31194458 qgpgmechangeexpiryjob.cpp,
31204459 qgpgmechangeownertrustjob.cpp,
31394478 qgpgmeverifyopaquejob.cpp: Add missing MOC includes.
31404479
31414480 Qt: Declare pure virtuals as such.
4481 + commit 0cc9006dbc59d87c6bcda88b36d59dcb69ac35cb
31424482 * lang/qt/src/qgpgmebackend.h (Protocol): Make all functions
31434483 pure virtual.
31444484
31454485 Qt: Don't declare showErrorDialog anymore.
4486 + commit 3e38cc6fc67c420dec3e9e8afd072b4c8a157c85
31464487 * cpp/qt/src/job.h: Remove showErrorDialog.
31474488
31484489 Qt: Only use GpgME based config class.
4490 + commit 7071b2a9c00b85d434d01b6166269ebf48b01b81
31494491 * lang/qt/src/qgpgmecryptoconfig.cpp,
31504492 lang/qt/src/qgpgmecryptoconfig.h: Removed.
31514493 * lang/qt/src/qgpgmebackend.cpp: Return newcryptoconfig.
31534495 2016-04-02 Andre Heinecke <aheinecke@intevation.de>
31544496
31554497 Add additional include path in config files.
4498 + commit 63c115b067400e1b02c7d849c99f54dc9f394d68
31564499 * lang/cpp/src/GpgmeppConfig.cmake.in.in
31574500 lang/qt/src/QGpgmeConfig.cmake.in.in: Include directory above headers.
31584501
31594502 Qt: Fix library name in nodist variable.
4503 + commit 576be46f34b42e896a5e3be65560a4b518a758be
31604504 * lang/qt/Makefile.am (nodist_qgpgme_SOURCES): Change to real name.
31614505
31624506 Add missing files to QGpgME.
4507 + commit a440050fc2c11e4867da9d4707616fa23ac52141
31634508 * lang/qt/src/gpgme_backend_debug.cpp,
31644509 lang/qt/src/gpgme_backend_debug.h,
31654510 lang/qt/src/predicates.h,
31664511 lang/qt/src/stl_util.h: New.
31674512
31684513 Add QGpgME code from libkleo.
4514 + commit 226e51052ae73efa8d9f30729b28de68d35231af
31694515 * lang/qt/src/Makefile.am,
31704516 lang/qt/src/abstractimportjob.h,
31714517 lang/qt/src/adduseridjob.h,
32524598 2016-03-08 Andre Heinecke <aheinecke@intevation.de>
32534599
32544600 Add qgpgme as qt language binding.
4601 + commit 8347f3d5fc3e476aa767fbbaf09a1310a6154280
32554602 * configure.ac: Add version defines. Check for qt if neccessary.
32564603 * lang/README: Mention qt
32574604 * lang/cpp/src/GpgmeppConfig.cmake.in.in: Remove comment. Find qgpgme.
32684615 lang/cpp/src/Makefile.am: Fix generated config file.
32694616
32704617 Remove obsolete w32-qt code.
4618 + commit 58ed9c17f00f420035ecc6973a6c6ed948757a9a
32714619 * configure.ac (w32-qt): Remove option and Qt checks.
32724620 * src/Makefile.am: Remove BUILD_W32_QT handling.
32734621 * src/kdpipeiodevice.cpp,
32784626 2016-03-02 Andre Heinecke <aheinecke@intevation.de>
32794627
32804628 Add version info for gpgmepp.
4629 + commit a06603d75e80aba58df58f9a41770c56b6a1f0b8
32814630 * lang/cpp/src/Makefile.am (libgpgmepp_la_LDFLAGS): Add version info.
32824631
32834632 Add cmake configuration files.
4633 + commit 77c3fb450c7adf36804a55d76ff49a06a71d22a0
32844634 * configure.ac: Add libgpgmepp version. Configure cmake files.
32854635 * lang/cpp/src/Makefile.am: Add targets for cmake files.
32864636 (EXTRA_DIST): Add cmake files.
32874637
32884638 Fix export header and windows export macros.
4639 + commit 98e5b672422ca1e38ca38ff0357cee6cc936aee0
32894640 * lang/cpp/src/gpgme_export.h: Fix variable name. Add Windows ifdefs.
32904641
32914642 Add header installation.
4643 + commit c5291a88913ace8f2115021b69c7aeb59b4f79d4
32924644 * lang/cpp/src/Makefile.am: Add headers as deps and install them.
32934645 (AM_CPPFLAGS): Add BUILDING_GPGMEPP to be used in export macros.
32944646
32954647 Add enable-languages build option.
4648 + commit a313b3e28cc42785365822519b25d6a87dfdf0c9
32964649 * acinclude.m4 (LIST_MEMBER): New macro.
32974650 * configure.ac (enable-languages): New option. Add info output.
32984651 * lang/Makefile.am: Only add enabled language subdirs.
33004653 2016-02-22 Andre Heinecke <aheinecke@intevation.de>
33014654
33024655 Add README for gpgmepp.
4656 + commit 7286fc7f3d51d475f82c7c9821d031290f5b0066
33034657 * lang/README: Note down cpp.
33044658 * cpp/README: Add README based on original repo version.
33054659
33064660 Add buildsystem for Gpgmepp.
4661 + commit f5fd787b5b45cb14d539b5c26f44066eb9ac0f75
33074662 * configure.ac: Configure Makefiles.
33084663 * lang/Makefile.am: Add cpp subdir
33094664 * lang/cpp/Makefile.am: New. Add src subdir.
33104665 * lang/cpp/src/Makefile.am: New. Basic buildsystem.
33114666
33124667 Remove feature check ifdefs.
4668 + commit 433bb8e84b2d1e50b5c5b9f7f2006b60cd7d7785
33134669 * lang/cpp/src/assuanresult.cpp,
33144670 lang/cpp/src/callbacks.cpp,
33154671 lang/cpp/src/configuration.cpp,
33394695 lang/cpp/src/vfsmountresult.cpp: Remove feature checks.
33404696
33414697 Initial checkin of gpgmepp sources.
4698 + commit 0855a1296a1908016f011eb5e6552854ac53e63a
33424699 Based on git.kde.org/pim/gpgmepp rev. 0e3ebc02
33434700
33444701 * lang/cpp/src/assuanresult.cpp,
34144771 2016-01-15 Werner Koch <wk@gnupg.org>
34154772
34164773 Fix possible _SC_OPEN_MAX max problem on AIX.
4774 + commit e79199468ac54ce4fe919603ff7bada97267174f
34174775 * src/posix-io.c [HAVE_STDINT_H]: Include stdint.h.
34184776 (get_max_fds): Limit returned value for too high values.
34194777
34204778 2015-12-09 Werner Koch <wk@gnupg.org>
34214779
34224780 w32: Avoid conflict with Mingw-w64 version 4.0.4-1.
4781 + commit 83415dffaea53611dbce77b50d8ddfb2a50aed2e
34234782 * src/w32-util.c (mkstemp): Rename to my_mkstemp. Change caller.
34244783
34254784 2015-12-04 Daiki Ueno <ueno@gnu.org>
34264785
34274786 Return on user cancellation of delete operation.
4787 + commit 67d7f7a9383763b01daf877c846bf3e32f647fa5
34284788 * src/delete.c (delete_status_handler): Return on ERROR status, if the
34294789 error location is set to "delete_key.secret" and the code is either
34304790 CANCELED or FULLY_CANCELED, which indicates a situation that the user
34314791 selected "No" on the confirmation dialog.
34324792
34334793 doc: Fix minor errors.
4794 + commit 3b6e9a3d0afcdd3c2f1de19f15924c3404c7140a
34344795 * doc/gpgme.texi: Fix errors and typos in the cancellation and
34354796 gpgme_import_result_t documentation.
34364797
34374798 2015-10-29 Ben Kibbey <bjk@luxsci.net>
34384799
34394800 Make use of user passphrase handler during passwd.
4801 + commit dfa79f9300b837b0f7f2ea44afa589bfcda1dbd9
34404802 * src/passwd.c (passwd_start): set engine passphrase command handler.
34414803
34424804 2015-10-28 Werner Koch <wk@gnupg.org>
34434805
34444806 w32: Add extra diagnostic about possible missing gpgme-w32spawn.exe.
4807 + commit bb2d11c1eebd4bcfb0f2cfce728026a7420dca47
34454808 * src/w32-io.c (_gpgme_io_spawn): Add a new diagnostic.
34464809
34474810 w32: Improve locating gpgconf on 64 bit systems.
4811 + commit a82e9b182f62966207cad0972be6fa284329a5a1
34484812 * src/w32-util.c (find_program_at_standard_place): Fallback to
34494813 CSIDL_PROGRAM_FILESX86.
34504814
34514815 w32: Add new global flag "w32-inst-dir".
4816 + commit bb600aa8fd2f9575ee7afc64c978e3e7523b1173
34524817 * src/gpgme.c (gpgme_set_global_flag): Add flag "w32-inst-dir";
34534818 * src/posix-util.c (_gpgme_set_override_inst_dir): New stub.
34544819 * src/w32-util.c (override_inst_dir): New var.
34584823 2015-10-16 NIIBE Yutaka <gniibe@fsij.org>
34594824
34604825 cleanup: Fix type mismatch around gpgme_error_t.
4826 + commit 0d9d0a6b5b0c6f474a079bbaef11078c5df5f3b5
34614827 * src/data-compat.c (gpgme_error_to_errno): Use gpg_err_code
34624828 to get error code from gpgme_error_t.
34634829 * src/gpgme.c (gpgme_new): Don't use gpgme_error.
34654831 2015-08-31 Werner Koch <wk@gnupg.org>
34664832
34674833 gpgme-tool: Switch to argparse.c for option parsing.
4834 + commit f0ccce855bd99fca7cfbbcafe3544e3113fedc67
34684835 * src/argparse.c, src/argparse.h: New. Taken from current gnupg.
34694836 * src/Makefile.am (gpgme_tool_SOURCES): New.
34704837 * src/gpgme-tool.c: Remove all argp.h stuff.
34744841 2015-08-30 Werner Koch <wk@gnupg.org>
34754842
34764843 Add gpgme_pubkey_algo_string.
4844 + commit c4b6b35bfa98e478f1d13f4ce3e664771f2604c2
34774845 * src/gpgme.h.in (GPGME_PK_EDDSA): New.
34784846 (gpgme_pubkey_algo_string): New.
34794847 * src/conversion.c (_gpgme_map_pk_algo): Add new algo.
34834851 2015-08-26 Werner Koch <wk@gnupg.org>
34844852
34854853 Release 1.6.0.
4854 + commit 107bff70edb611309f627058dd4777a5da084b1a
34864855 * configure.ac: Set LT version to C25/A14/R0.
34874856
34884857 Make use of GPGRT macros is available.
4858 + commit c4f4b5c0a6fc172f7ceedc1a0021169e7f31b941
34894859 * src/gpgme.h.in (_GPGME_INLINE): Define using GPGRT_INLINE if
34904860 possible. Fix problem with -Wundef by adding an extra "defined()".
34914861 (_GPGME_GCC_VERSION): Define using GPGRT_ macro if possible.
34934863 2015-08-25 Werner Koch <wk@gnupg.org>
34944864
34954865 Avoid -Wundef warnings if gpgme.h is used by g++.
4866 + commit 3f53d3d5d9e73a053b1e89073ef8f7cf01bfc8e6
34964867 * src/gpgme.h.in (_GPGME_INLINE): Move definition into the
34974868 extern-C-scope.
34984869
34994870 Add configure option --enable-build-timestamp.
4871 + commit ff91e699f7c14ea6cbc27b487cb40e9f6bd58901
35004872 * configure.ac (BUILD_TIMESTAMP): Set to "<none>" by default.
35014873
35024874 2015-08-25 Daiki Ueno <ueno@gnu.org>
35034875
35044876 Relax ttyname_r error checks.
4877 + commit 028a0ef3336c5180797fb247448683195376c007
35054878 * src/engine-assuan.c (llass_new): Don't treat ttyname_r error as
35064879 fatal.
35074880 * src/engine-g13.c (g13_new): Likewise.
35124885 2015-08-25 Werner Koch <wk@gnupg.org>
35134886
35144887 Cleanup layout of gpgme.h.
4888 + commit 97f1f3e883808743da5ee144abab25de062f34ac
35154889 * src/gpgme.h.in: Reorder prototypes. Chnage some comments.
35164890
35174891 Improve error return by checking the FAILURE status.
4892 + commit 8ddc5801ade02297924447df5745c8877a96e5e3
35184893 * src/gpgme.h.in (GPGME_STATUS_FAILURE): New.
35194894 * src/status-table.c (FAILURE): New.
35204895 * src/op-support.c (_gpgme_parse_failure): New.
35354910 (_gpgme_verify_status_handler): Parse that code and act upon it on EOF.
35364911
35374912 tests: Allow using run-sign to test loopback pinentry problems.
4913 + commit 491fcd91b84564232d5d061942baa50b99e166c0
35384914 * tests/run-sign.c: Add options --status and --loopback.
35394915
35404916 2015-08-24 Werner Koch <wk@gnupg.org>
35414917
35424918 Call status_cb for an ERROR status seen in the passphrase handler.
4919 + commit ad46f4f655e653580343c15f1b0b365b7d307d1b
35434920 * src/passphrase.c (_gpgme_passphrase_status_handler): Call status_cb.
35444921
35454922 w32: Look for gpgconf in the new GnuPG 2.1 install dir.
4923 + commit a7dbab23ea4976d106d649aa515ffb2968a085ed
35464924 * src/w32-util.c (_gpgme_get_gpgconf_path): Try another location of
35474925 gpgconf.exe.
35484926
35494927 w32: Expect gpgme-w32spawn.exe only in the gpgme installation dir.
4928 + commit 06d6fd8ca01354c8f7cfc847c4ac1b868268cbaa
35504929 * src/w32-util.c (find_program_at_standard_place): Remove.
35514930 (_gpgme_get_gpg_path): Make the search order more explicit.
35524931 (_gpgme_get_gpgconf_path): Ditto.
35534932 (_gpgme_get_w32spawn_path): Search only in the inst_dir.
35544933
35554934 w32: Print the installation directory in debug mode.
4935 + commit df098d6a437109c57516db75addf3764a6dfda81
35564936 * src/debug.c (debug_init) [W32]: Show libgpgme installation dir.
35574937
35584938 Add an export secret key feature.
4939 + commit 2b632bbb78eee2b94c122f66d171a7c80e9c4fb0
35594940 * src/gpgme.h.in (GPGME_EXPORT_MODE_SECRET): New.
35604941 (GPGME_EXPORT_MODE_RAW): New.
35614942 (GPGME_EXPORT_MODE_PKCS12): New.
35704951 2015-08-16 Ben Kibbey <bjk@luxsci.net>
35714952
35724953 Parse INQUIRE_MAXLEN in the passphrase callback.
4954 + commit ccbaccbf2e0ba582d181b9ee4d8543d7c1248b2c
35734955 * src/passphrase.c (_gpgme_passphrase_status_handler): Parse
35744956 GPGME_STATUS_INQUIRE_MAXLEN.
35754957 * src/passphrase.c (_gpgme_passphrase_command_handler): Send the
35764958 INQUIRE_MAXLEN status message.
35774959
35784960 Fix gpgme_{get,set}_status_cb to match documentation.
4961 + commit 70b3e5964ea0592bd09d1877d720b2c63f501970
35794962 * doc/gpgme.texi: Minor fixes.
35804963 * src/gpgme.c (gpgme_get_status_cb): Set return variables to NULL and
35814964 check for a valid ctx pointer.
35824965
35834966 Parse the INQUIRE_MAXLEN status message.
4967 + commit 6dd24c3c6133ec54f75abd056191a8027fe01de0
35844968 * src/gpgme.h.in: (gpgme_status_code_t): Add INQUIRE_MAXLEN.
35854969 * src/status-table.c (status_table_s): Ditto.
35864970 * src/genkey.c (genkey_status_handler): Parse INQUIRE_MAXLEN.
35924976 gpgme_status_cb_t.
35934977
35944978 Add gpgme_set/get_status_cb().
4979 + commit 4fadcf06ec8b0ebfb05c7622dbc3b73fd3c1bad9
35954980 * src/gpgme.h.in (gpgme_set_status_cb): New.
35964981 (gpgme_get_status_cb): New.
35974982 (gpgme_status_cb_t): New.
36044989 * doc/gpgme.texi: Document these new functions.
36054990
36064991 Make use of user passphrase handler during genkey.
4992 + commit 2b6ae3dadf4432f7a72fd119144b835f7b1adcc4
36074993 * src/genkey.c (genkey_start): set engine passphrase command handler.
36084994
36094995 2015-08-12 Ben Kibbey <bjk@luxsci.net>
36104996
36114997 Also check the return code in gpg_sign().
4998 + commit e07d38f5f9f3b94e403f1265ff7fd3d7009dd557
36124999 * src/engine-gpg.c (gpg_sign): Check return value from start().
36135000
36145001 2015-08-11 Ben Kibbey <bjk@luxsci.net>
36155002
36165003 Check the return value when starting gpg.
5004 + commit 8f28e3caf95d7bc99e9271bfc2b44080166af31f
36175005 * src/engine-gpg.c (gpg_decrypt, gpg_delete, gpg_passwd): Check return
36185006 value of start().
36195007
36205008 2015-08-02 Ben McGinnes <ben@adversary.org>
36215009
36225010 More GTK2 removal.
5011 + commit a7fbd5293ed0ba2c179837a4a2b859376d30e35e
36235012 * Missed a couple of files, these 2 go for the same reason as the
36245013 previous 3.
36255014
36265015 Removed GUI examples.
5016 + commit 1cd0aef0afb196094d90673002d4c210a04911c9
36275017 * GUI examples written with pygtk, which has not been ported to Python
36285018 3 and won't be as it is for GTK2 and GNOME is moving to GTK3.
36295019 * New GUI examples may be required in future using any of several GUI
36325022 2015-07-31 Andre Heinecke <aheinecke@intevation.de>
36335023
36345024 Add offline mode support for CMS keylisting.
5025 + commit 08086dd6901740e155e4361212b4e9cff8a47296
36355026 * doc/gpgme.texi: Document offline mode.
36365027 * src/context.h (gpgme_context): Add offline.
36375028 * src/engine-backend.h (keylist, keylist_ext): Add engine_flags.
36525043 2015-07-23 Peter Wu <peter@lekensteyn.nl>
36535044
36545045 build: ignore scissor line for the commit-msg hook.
5046 + commit 157c8be183153ff588f98874a3205aa483d0fd23
36555047 * build-aux/git-hooks/commit-msg: Stop processing more lines when the
36565048 scissor line is encountered.
36575049
36585050 2015-07-23 Werner Koch <wk@gnupg.org>
36595051
36605052 Add option --lib-version to gpgme-tool.
5053 + commit c23f8897105ce2bb6e62d9c44ca0779fcc08a919
36615054 * src/gpgme-tool.c (options, parse_options): Add --lib-version
36625055 (CMD_LIBVERSION): New.
36635056 (main): Implement.
36655058 2015-06-08 Werner Koch <wk@gnupg.org>
36665059
36675060 Release 1.5.5.
5061 + commit 052a9e3c5671d1ab69551f7b0abd0bbf859d4aba
5062
36685063
36695064 Fix regression with gpgsm 2.0 due to "OPTION with-secret".
5065 + commit ddbd54ef881bd2c3481d62b89bef7241667b64ee
36705066 * src/engine-gpgsm.c (gpgsm_assuan_simple_command): Do not terminate
36715067 on a status lines.
36725068
36735069 tests: Add option --secret to run-keylist.
5070 + commit 7addffc0826e7f36afcc7f66268e9ee2a37e2042
5071
36745072
36755073 Fix compiler warnings about unused value in TRACE macros.
5074 + commit 8b9f84828cd04a7dab37e219123edc1905da8e6b
36765075 * src/debug.h: Change macros to not have a literal 0 as last
36775076 expression of the comma operator.
36785077 * src/debug.c (_gpgme_debug_frame_end): Return 0.
36795078 (_gpgme_debug): Return 0.
36805079
36815080 Fix test suite for GnuPG 2.1 which uses pubring.kbx.
5081 + commit a5b040cc57c65b3d105666b90c7eb59ee6ff3882
36825082 * tests/gpgsm/final.test: New.
36835083 * tests/gpgsm/initial.test: New.
36845084 * tests/gpg/start-stop-agent: Move to ../.
36965096 2015-06-05 Matthew Barnes <mbarnes@redhat.com>
36975097
36985098 Set GPGME_SIGSUM_KEY_REVOKED also for gpg.
5099 + commit 87d713ff41454bd08a345c63605f6fc7ac854dd4
36995100 * src/verify.c (calc_sig_summary): Handle GPG_ERR_CERT_REVOKED.
37005101
37015102 2015-06-05 Werner Koch <wk@gnupg.org>
37025103
37035104 Fix segv for userids with a backslash.
5105 + commit 0d28a696163677d6b34a802b6beddecd805d0fc7
37045106 * src/engine-gpg.c (gpg_keylist_preprocess): Increment SRC for a
37055107 backslash.
37065108
37075109 2015-05-16 Ben McGinnes <ben@adversary.org>
37085110
37095111 Python 3 port of PyME.
5112 + commit 90405ac84b78ba7e5458ea09986749594a01195a
37105113 * Port of PyME 0.9.0 for Python 2 to Python 3 along with most of the
37115114 example scripts.
37125115 * Intended to be developed in parallel with the original Python 2
37195122 reference with git commit signatures.
37205123
37215124 Explaining why not all scripts work.
5125 + commit 29887c9b28c0db14bf75e227a8082d23a2c151d2
37225126 * Some of them cannot be properly tested on OS X, especially with GTK in
37235127 the mix (it works on OS X, but is unlikely to be as easily accessible
37245128 as Cocoa or Qt).
37265130 false positives of error messages, at least on OS X.
37275131
37285132 Byte encoding.
5133 + commit c39cea7a07cec9ab34cd2026f47b6fba80fea3c8
37295134 * More string updates.
37305135 * verifydetails.py still fails, but as Bernhard is still contactable, it
37315136 might be worth him checking on it instead.
37325137
37335138 No change, note added to explain why.
5139 + commit 0e6e6689ef1aea36c1cb3cb47e94f1f2ebbd97cb
5140
37345141
37355142 Strings vs. Bytes.
5143 + commit 40290507bcdc63ab9023393d071167d455d70737
37365144 * CLI input must be byte encoded.
37375145
37385146 More byte changes and passphrase changes.
5147 + commit 325b0ca341ae3ac8c3232f557ea2c381b4843969
37395148 * exportimport works, but will still segfault for an as yet unknown
37405149 reason.
37415150 * genkey produces a traceback error, but does create the key as
37435152 * matched passphrase in signverify.
37445153
37455154 More bytes good.
5155 + commit ba3c9f2617955dc828309a4800e4f5b3f1c3a949
37465156 * Another string to byte change.
37475157
37485158 Updated encrypt-to-all.
5159 + commit 1c87ecb86ae364b18f69bca726021271fefaa1c1
37495160 * Changed plaintext string to byte literal.
37505161 * Nested key selection in a try/except statement in case of
37515162 UnicodeEncodeError instances.
37525163 * Tested successfully on over 9,000 keys.
37535164
37545165 Passphrase update.
5166 + commit 24c738f5bb5c253a17962c62867d6c847250b41e
37555167 * Changed example passphrase to something that meets the current minimum
37565168 requirements.
37575169
37585170 example email.
5171 + commit 8345bf6f43c4f671124eaa1b713a7f5ac5780cbd
37595172 * changed joe@foo.bar to joe@example.org as it is only a matter of time
37605173 before ICANN actually creates bar as a gTLD, if they haven't already.
37615174
37625175 Updated string and key data.
5176 + commit 4fc123981514c7087114e08ee8ca63de1a1db59f
37635177 * Text changed to byte literals.
37645178 * Changed key type to RSA/RSA.
37655179 * Changed expiry to the future (2020).
37675181 2015-05-08 Ben McGinnes <ben@adversary.org>
37685182
37695183 String type.
5184 + commit 90079786c5cde4dd8ceb2e0fcda7605b08ccd021
37705185 * the plain text string must be bytes and not unicode.
37715186 * Expect most of the example code to have similar issues at present.
37725187
37735188 2015-05-05 Ben McGinnes <ben@adversary.org>
37745189
37755190 Python 3 port of PyME.
5191 + commit ebd8734ad705afa4edc409787a00d4968d25e018
37765192 * The entirety of the Python 3 port of PyME up to commit
37775193 2145348ec54c6027f2ea20f695de0277e2871405
37785194 * The old commit log has been saved as
37865202 2015-04-13 Werner Koch <wk@gnupg.org>
37875203
37885204 Release 1.5.4.
5205 + commit d2712d9f6f086911184453219a096c61f6829d3b
5206
37895207
37905208 w32: Use -static-libgcc to avoid linking to libgcc_s_sjlj-1.dll.
5209 + commit 524dacfbb6bb131f05a4ecab3d7bcd91c1b43d33
37915210 * src/Makefile.am (extra_ltoptions): New.
37925211 (libgpgme_la_LDFLAGS): Use it.
37935212 (libgpgme_pthread_la_LDFLAGS): Ditto.
37965215 2015-03-16 Werner Koch <wk@gnupg.org>
37975216
37985217 Fix potential crash in trace macro.
5218 + commit 8cfcdfe5564f87362e5ec1bfdca5c14aed9c45f0
37995219 * src/signers.c (gpgme_signers_add): Avoid deref of a NULL KEY in the
38005220 trace macro.
38015221 * src/engine-spawn.c (engspawn_release): Remove always true condition.
38025222 * src/engine-gpg.c (gpg_release): Ditto.
38035223
38045224 Fix one byte too short malloc.
5225 + commit 119f27032b822ace8c012b96f9e41bcf23251a54
38055226 * src/engine-spawn.c (add_data): Fix malloc
38065227
38075228 2015-01-30 Werner Koch <wk@gnupg.org>
38085229
38095230 Switch to automake 1.14 and update build-aux files.
5231 + commit 428ea7696585bc24d127b903840554ca659069b6
5232
38105233
38115234 2014-12-11 Werner Koch <wk@gnupg.org>
38125235
38135236 Release 1.5.3.
5237 + commit 37d927a9706fff6d8ef8d45073984ea2f92afb31
38145238 * configure.ac: Set LT version to C24/A13/R2.
38155239
38165240 2014-12-08 Werner Koch <wk@gnupg.org>
38175241
38185242 Return an error for some export key operations.
5243 + commit 05258d427513a933f01d4df13aca834d797f91e7
38195244 * src/context.h (OPDATA_EXPORT): New.
38205245 * src/export.c (op_data_t): New.
38215246 (release_op_data): New.
38285253 2014-11-21 Werner Koch <wk@gnupg.org>
38295254
38305255 Release 1.5.2.
5256 + commit c62ce32b9c01ee9ceb1d69e7344fb79a9162d232
38315257 * configure.ac: Set LT version to C24/A13/R1.
38325258
38335259 Update the previous commit.
5260 + commit 81ce87111f5a3f966188629abb07a4d0702e6db0
38345261 * src/sign.c (gpgme_op_sign_result): Reformat and take care of failed
38355262 malloc.
38365263
38375264 2014-11-21 Ben Kibbey <bjk@luxsci.net>
38385265
38395266 Fix returning new signatures when there are none.
5267 + commit 5942b0c7e0593b82b4c4a142c214d7a2649de104
38405268 * src/sign.c (gpgme_op_sign_result): Test that invalid and valid
38415269 signatures add up to gpgme_signers_count().
38425270
38435271 2014-11-06 Werner Koch <wk@gnupg.org>
38445272
38455273 Improve the debug output a bit.
5274 + commit 8031341283f4fcb1f226aa6f66bc5a6042586815
38465275 * src/debug.h (TRACE_ERR): Include the line number in the output.
38475276
38485277 2014-10-02 Werner Koch <wk@gnupg.org>
38495278
38505279 build: Implement SYSROOT feature.
5280 + commit 4027a0a89724df3aeef8a964c529548d724b6a5a
38515281 * configure.ac: Document SYSROOT.
38525282 * m4/gpg-error.m4: Update from libgpg-error master.
38535283 * src/gpgme.m4: Implement SYSROOT stuff.
38555285 2014-09-24 Werner Koch <wk@gnupg.org>
38565286
38575287 tests: Delay some test file extraction until "make check".
5288 + commit 2e8ecc24cf74f918c303c315da3bb18636a5e288
38585289 * tests/gpg/Makefile.am (all-local): Change to check-local.
38595290 * tests/gpgsm/Makefile.am (all-local): Ditto.
38605291
38615292 2014-09-24 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
38625293
38635294 Clean up gpgme's tests/gpg when gpg2.1 is available.
5295 + commit 36997e0f746ce2d38de997055141542583cc0f52
38645296 * tests/gpg/Makefile.am: Clean up .gpg-v21-migrated
38655297
38665298 2014-08-12 Werner Koch <wk@gnupg.org>
38675299
38685300 gpgme-tool: Print fingerprint and keyid with keyservers.
5301 + commit 4160ef90a1b1b778c735f31f98a6966ba3b3ea90
38695302 * src/gpgme-tool.c (cmd_keylist): Print keyid. Print FPR only if
38705303 available.
38715304
38725305 Handle modern keyserver output which may emit the fingerprint.
5306 + commit 3450bff52baef2c14118958cf79ead46940d58f0
38735307 * src/engine-gpg.c (read_colon_line): Split preprocessed lines.
38745308 (gpg_keylist_preprocess): Limit keyid field and print fingerprint.
38755309
38765310 gpgme-tool: Install gpgme-tool.
5311 + commit 488e44cdb531035fa8813b95b212f9728abc7e62
38775312 * src/Makefile.am (bin_PROGRAMS): New. Add gpgme-tools.
38785313 (noinst_PROGRAMS): Remove.
38795314
38805315 gpgme-tool: Fix segv for external key listing.
5316 + commit e5ab11607281b9838da2728268a8f9f0daa2b04d
38815317 * src/gpgme-tool.c (result_xml_escape): Allow for DATA being NULL.
38825318
38835319 2014-07-30 Werner Koch <wk@gnupg.org>
38845320
38855321 Release 1.5.1.
5322 + commit 16835c3b5d1cea18512b2c93e884d8ca513a2ee7
38865323 * configure.ac: Change LT version to C24/A13/R0.
38875324
38885325 Fix possible realloc overflow for gpgsm and uiserver engines.
5326 + commit 2cbd76f7911fc215845e89b50d6af5ff4a83dd77
38895327 * src/engine-gpgsm.c (status_handler):
38905328 * src/engine-uiserver.c (status_handler):
38915329
38925330 2014-06-26 Werner Koch <wk@gnupg.org>
38935331
38945332 w32: Get IOSPAWN flag back in sync with spawn helper.
5333 + commit 68116fa5f67238a60bb8be375cc959262fa021d3
38955334 * src/gpgme-w32spawn.c: Include priv-io.h.
38965335
38975336 2014-06-10 Werner Koch <wk@gnupg.org>
38985337
38995338 Add new reason codes to the INV_RECP status code.
5339 + commit 86260b47c9e306e325103d1af767842357647e60
39005340 * src/op-support.c (_gpgme_parse_inv_recp): Add codes 13 and 14.
39015341
39025342 2014-06-04 Werner Koch <wk@gnupg.org>
39035343
39045344 Add new keylist mode GPGME_KEYLIST_MODE_WITH_SECRET.
5345 + commit 4dc9af24156b4fd52c7b76e7522b9b7a64e5386a
39055346 * src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_SECRET): New.
39065347 * src/engine-gpg.c (gpg_keylist_build_options): Handle new mode.
39075348 * src/engine-gpgsm.c (gpgsm_keylist, gpgsm_keylist_ext): Ditto.
39145355 2014-05-21 Werner Koch <wk@gnupg.org>
39155356
39165357 Release 1.5.0.
5358 + commit 0eca21113c1d1ab2aea58e1ea21075f472f99c23
39175359 * configure.ac: Change LT version to C22/A11/R0.
39185360
39195361 2014-05-13 Werner Koch <wk@gnupg.org>
39205362
39215363 Add 6 new GPGME_STATUS_ codes.
5364 + commit de6caeed6d6432101c673c35717f152d5facf823
39225365 * src/status-table.c: Also add missing DECRYPTION_INFO entry.
39235366
39245367 2014-05-08 Werner Koch <wk@gnupg.org>
39255368
39265369 Add field CURVE to the key info.
5370 + commit 88f15336ec0eadde68ff2618349efb9006b8e801
39275371 * src/gpgme.h.in (struct _gpgme_subkey): Add field CURVE.
39285372 * src/key.c (gpgme_key_unref): Free CURVE.
39295373 * src/keylist.c (keylist_colon_handler): Set CURVE.
39325376 engine info after freeing.
39335377
39345378 Fix a memory access and a double slash bug.
5379 + commit de4a1ea684e1591975feb801e7651309e1ee2c49
39355380 * src/engine-spawn.c (engspawn_start): Allocate space for list
39365381 terminator.
39375382 * src/posix-util.c (walk_path): Fix trailing slash detection.
39385383
39395384 Map public key algos returned by gpg to gpgme values.
5385 + commit d5fb92cdaed21eea2f1a921e4f11df72635a8462
39405386 * src/conversion.c (_gpgme_map_pk_algo): New.
39415387 * src/decrypt.c (parse_enc_to): Add arg PROTOCOL and map pubkey algo.
39425388 (_gpgme_decrypt_status_handler): Map pubkey algo.
39525398 (gpgme_hash_algo_name): Add GPGME_MD_SHA224.
39535399
39545400 Add GPGME_ENCRYPT_NO_COMPRESS flag.
5401 + commit 991cde9e79fec70aad093ded383c5574d30f9388
39555402 * src/gpgme.h.in (GPGME_ENCRYPT_NO_COMPRESS): New.
39565403 * src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Implement it.
39575404 * src/gpgme-tool.c (_cmd_sign_encrypt): Add option --no-compress.
39595406 2014-04-16 Werner Koch <wk@gnupg.org>
39605407
39615408 w32: Fix another memleak on error.
5409 + commit 62711e5614e44e65a7c7bb7d21493d09d3081271
39625410 * src/w32-io.c (create_reader): free CTX.
39635411
39645412 2014-04-15 Werner Koch <wk@gnupg.org>
39655413
39665414 w32: Fix memleak in an error code paths.
5415 + commit 85a07ca7e3dffdefc8ae74beebb59e47a6e6bd1b
39675416 * src/w32-io.c (create_writer): Free CTX in cased of bad FD.
39685417 * src/w32-util.c (_gpgme_mkstemp): Free TMPNAME in case of a failed
39695418 mkstemp.
39705419
39715420 Fix possible zombie processes.
5421 + commit 2bb26185e3b9a048033c559517d6ba7d2eb47066
39725422 * src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR.
39735423 (_gpgme_io_dup): Likewise.
39745424 (_gpgme_io_connect): Likewise.
39765426 2014-04-10 Werner Koch <wk@gnupg.org>
39775427
39785428 Actually implement flags for gpgme_op_spawn.
5429 + commit d3bd8fff863f62b6d0e228aea754efbbde861e9a
39795430 * src/spawn.c (gpgme_op_spawn_start, gpgme_op_spawn): Pass FLAGS dow
39805431 to spawn_start and add FLAGS args along the call path.
39815432 * src/engine-spawn.c (engspawn_start): Hack to automagically provide
39825433 argv[0].
39835434
39845435 Add GPGME_PROTOCOL_SPAWN and gpgme_op_spawn.
5436 + commit 4f2d652e60700e03809307a10015ff9003ac3579
39855437 * src/gpgme.h.in (GPGME_PROTOCOL_SPAWN): New.
39865438 (GPGME_SPAWN_DETACHED, GPGME_SPAWN_ALLOW_SET_FG): New.
39875439 * src/gpgme.c (gpgme_set_protocol): Add new protocol.
39995451 (gt_spawn, cmd_spawn): New.
40005452
40015453 Add gpgme_get_dirinfo.
5454 + commit 77931a9a1468b0cfbaafd4153867d90764a6d258
40025455 * src/dirinfo.c (gpgme_get_dirinfo): New.
40035456 * tests/t-engine-info.c (main): Print results from that function.
40045457
40055458 Make use of internal iospawn flags more flexible.
5459 + commit 443f6b76a964b77e2e61c03592a83ffa0a6da4b1
40065460 * src/priv-io.h (IOSPAWN_FLAG_DETACHED): New. Renumber the others.
40075461 * src/w32-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS process only if
40085462 IOSPAWN_FLAG_DETACHED is given.
40155469 * src/version.c (_gpgme_get_program_version): Ditto.
40165470
40175471 Make sure a spawned process has all standard fds connected.
5472 + commit 617d3be629229cbebfdc2d26a4e854bc4fe38a68
40185473 * src/posix-io.c (_gpgme_io_spawn): dup /dev/null also to unsued
40195474 stdout.
40205475
40215476 2014-03-13 Werner Koch <wk@gnupg.org>
40225477
40235478 Add configure option --enable-fixed-path.
5479 + commit 766355b5d4f63261c428531fdbdafb8b67de9369
40245480 * configure.ac: Add option --enable-fixed-path.
40255481 (FIXED_SEARCH_PATH): New ac_define.
40265482 * src/posix-util.c (walk_path): Make use of the option. Remove
40295485 2014-03-11 Werner Koch <wk@gnupg.org>
40305486
40315487 Avoid pointer arithmetic on void pointer.
5488 + commit dd9c8c56719db093b8daa23aa40b2be71bbd1526
40325489 * src/gpgme.c (gpgme_io_writen): Use new var buffer.
40335490
40345491 Change implementation return type to match the definition.
5492 + commit 75a6255935f450d56f3637cbb2b6c8161ace57ab
40355493 * src/gpgme.c (gpgme_get_sub_protocol): Change return type to
40365494 gpgme_protocol_t.
40375495
40385496 2014-03-05 Daiki Ueno <ueno@gnu.org>
40395497
40405498 doc: Fix documentation of struct data types.
5499 + commit 40938feb3f3393b0cdc6ec61ca2e77ff0b82c69a
40415500 * gpgme.texi (Key Management): Document is_cardkey and card_number
40425501 members of gpgme_subkey_t.
40435502 (Decrypt): Remove description of the non-existent wrong_key_usage
40505509 2014-02-21 Werner Koch <wk@gnupg.org>
40515510
40525511 Always pass correct name to argv[0]. Ignore GPG_AGENT_INFO for gpg2.
5512 + commit 651d9e1c6bc1cab248024c3850ef64698247588f
40535513 * src/dirinfo.c (WANT_GPG_ONE_MODE): New.
40545514 (struct dirinfo): Add field "gpg_one_mode".
40555515 (get_gpgconf_item): Set that field and return it if requested.
40665526 2014-02-12 Werner Koch <wk@gnupg.org>
40675527
40685528 Fix type inconsistency between gpgme.h and gpgme.c.
5529 + commit f916ab753b7d17210cd455666870038949f72851
40695530 * src/gpgme.c (gpgme_set_pinentry_mode): Fix type of MODE.
40705531
40715532 2014-01-10 Werner Koch <wk@gnupg.org>
40725533
40735534 Use the generic autogen.sh script.
5535 + commit 1a504aab384947c1a6e949affd14bc696297fc8d
40745536 * autogen.rc: New.
40755537 * Makefile.am (EXTRA_DIST): Add it.
40765538 * autogen.sh: Update from GnuPG.
40805542 2014-01-07 Werner Koch <wk@gnupg.org>
40815543
40825544 Make gpgconf engine work again - fixes 02ba35c1.
5545 + commit ab6e718327451e418782990c5a0a4e72588e3f0b
40835546 * src/gpgconf.c: Remove ENABLE_GPGCONF and move prototypes to ...
40845547 * src/engine-backend.h: ... here.
40855548
40865549 Make gpgme_new return a proper error if no engines are installed.
5550 + commit 121efcc5618374a1b4450b1d6a18bb3c35edb1fd
40875551 * src/engine.c (gpgme_get_engine_info): Improve error handling.
40885552 (_gpgme_engine_info_copy): Ditto.
40895553 * src/gpgme.c (gpgme_new): Return error GPG_ERR_NO_ENGINE.
40905554
40915555 Print the full PATH in the log if gpg was not found.
5556 + commit d63058b852b83515e7715103c04a684ecf59838a
40925557 * src/posix-util.c (walk_path): Keep a copy of PATH.
40935558
40945559 2014-01-06 Werner Koch <wk@gnupg.org>
40955560
40965561 Add global flags disable-gpgconf, gpgconf-name, and gpg-name.
5562 + commit 6564e5e78e8c6e5a120675a5699b5b75248cfbc7
40975563 * src/gpgme.c (gpgme_set_global_flag): Add names "disable-gpgconf",
40985564 "gpgconf-name", and "gpg-name".
40995565 * src/dirinfo.c (_gpgme_dirinfo_disable_gpgconf): New.
41165582 2013-12-27 Werner Koch <wk@gnupg.org>
41175583
41185584 Locate engine names only at runtime and prefer GnuPG-2.
5585 + commit 02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b
41195586 * configure.ac (NEED_GPG_VERSION, NEED_GPGSM_VERSION)
41205587 (NEED_G13_VERSION, NEED_GPGCONF_VERSION): Remove vars and all related
41215588 checks. Do not check for any engine version.
41505617 2013-08-19 Werner Koch <wk@gnupg.org>
41515618
41525619 Document API change for GPGME_EVENT_DONE from 2009.
5620 + commit b0aaa3f9aef36634b5c391812362f016114f02ba
41535621 * doc/gpgme.texi (I/O Callback Interface): Fix description for the
41545622 event arg.
41555623
41565624 Fix possible segv in the gpgme_op_card_edit.
5625 + commit 372bd439834c69d502668007c8c683233d676bd5
41575626 * src/edit.c (gpgme_op_edit_start, gpgme_op_card_edit_start): Do not
41585627 deref a NULL KEY in TRACE_BEG.
41595628
41605629 tests: Fix NULL ptr deref in gpgsm/t-verify.
5630 + commit eae9c32bd9c80ca4a4ecf794808211808f2ebbdd
41615631 * tests/gpgsm/t-verify.c (check_result): Do not dereference a sig or
41625632 sig->fpr if NULL.
41635633
41645634 2013-08-12 Werner Koch <wk@gnupg.org>
41655635
41665636 Release 1.4.3.
5637 + commit d788c35e19df9eade8eb0b880ca1dc47ae7928ad
41675638 * configure.ac: Change LT version to C22/A11/R0.
41685639
41695640 Make test suite workable with GnuPG 2.1.
5641 + commit 3ca7e96e384d5872c71ceb3b2e2a05b0c1b7e1a0
41705642 * tests/gpg/start-stop-agent: New.
41715643 * tests/gpg/initial.test: New.
41725644 * tests/gpg/final.test: New.
41855657 * tests/gpg/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New.
41865658
41875659 Improve detection of default gpg by configure.
5660 + commit 069ac580373923f5635b7172ecff79eb189f6944
41885661 * configure.ac: Move test for gpgconf before test for gpg.
41895662 (GPG, GPGSM, G13): Use gpgconf instead of AC_PATH_PROG if possible.
41905663
41915664 2013-08-09 Werner Koch <wk@gnupg.org>
41925665
41935666 Add function gpgme_data_identify.
5667 + commit 8579091c4f6a36e6bb06fcfbd147a776166fd3ea
41945668 * src/gpgme.h.in (gpgme_data_type_t): New.
41955669 (gpgme_data_identify): New prototype.
41965670 * src/data-identify.c: New.
42055679 2013-08-02 Werner Koch <wk@gnupg.org>
42065680
42075681 Prefer GnuPG-2 engines over GnuPG-1.
5682 + commit a4c80126ae4754c8478c69a8a24a6ffd975485fc
42085683 * src/util.h: Move some prototypes to ...
42095684 * src/sys-util.h: New.
42105685 * src/Makefile.am (main_sources): Add sys-util.h.
42315706 (_gpgme_get_uiserver_socket_path): Remove.
42325707
42335708 w32: Try to locate gpg in the gpgme installation dir.
5709 + commit 3881ea4e83d1533ef497b7332398fc1850e29205
42345710 * src/w32-util.c (my_hmodule): New.
42355711 (wchar_to_utf8): New.
42365712 (DllMain): New.
42455721 2013-07-31 Werner Koch <wk@gnupg.org>
42465722
42475723 doc: Add --binary option for the OUTPUT command of an uiserver.
5724 + commit 393a9471f2f3ac0a5b14f3534a5bfc7ffe948567
5725
42485726
42495727 2013-06-18 Werner Koch <wk@gnupg.org>
42505728
42515729 Add function gpgme_signers_count.
5730 + commit f2eeccbdfaf855a81abb92abe5ab4c702712bac7
42525731 * src/signers.c (gpgme_signers_count): New.
42535732 * src/libgpgme.vers, src/gpgme.def: Add as external symbol.
42545733 * src/gpgme.h.in: Add prototype.
42565735 2013-05-28 Werner Koch <wk@gnupg.org>
42575736
42585737 Release 1.4.2.
5738 + commit 009e26a989f8a251563303f155c51fe012af52a4
42595739 * configure.ac: Set LT version to C21/A10/R0.
42605740
42615741 Add convenience macro GPGME_PROTOCOL_OPENPGP.
5742 + commit 2e8feb6016dede400053f76fc3a418e1dd567bef
42625743 * src/gpgme.h.in (GPGME_PROTOCOL_OPENPGP): New.
42635744
42645745 2013-05-23 Werner Koch <wk@gnupg.org>
42655746
42665747 w32: Fix installing of .def file.
5748 + commit c29dad2315406bed75b9547103650bef642e6aa7
42675749 * src/Makefile.am (install-def-file): Create libdir first.
42685750
42695751 Fix libtool 2.4.2 to correctly detect .def files.
5752 + commit d739d4d8cf9c873b0f3bb7836aaf3d0ba31a7b7f
42705753 * build-aux/ltmain.sh (sed_uncomment_deffile): New.
42715754 (orig_export_symbols): Uncomment def file before testing for EXPORTS.
42725755 * m4/libtool.m4: Do the same for the generated code.
42745757 2013-05-22 Werner Koch <wk@gnupg.org>
42755758
42765759 Support --no-encrypt-to also with gpgme_op_encrypt_sign.
5760 + commit d4371ed30da2e8b3d9f440613af299a952bde2b1
42775761 * src/engine-gpg.c (gpg_encrypt_sign): Support the
42785762 GPGME_ENCRYPT_NO_ENCRYPT_TO flag.
42795763
42815765 Kyle L. Huff <g10bts@curetheitch.com>
42825766
42835767 Allow symmetric encryption with gpgme_op_encrypt_sign.
5768 + commit 567e6481d767af60390d649897b897a8b0e7e9a5
42845769 * src/encrypt-sign.c (encrypt_sym_status_handler): New.
42855770 (encrypt_sign_start): Handle recp == NULL case.
42865771 * src/engine-gpg.c (gpg_encrypt_sign): Implement symmetric encryption.
42895774 2013-05-22 Werner Koch <wk@gnupg.org>
42905775
42915776 gpgme-tool: Allow for symmetric encryption.
5777 + commit 0c1de7abd57b677998792e6cd5df5ddfb6e451b7
42925778 * src/gpgme-tool.c (gt_sign_encrypt): Pass NULL for recp if no
42935779 recipients are given.
42945780
42955781 tests: Print auditlog in plain text format.
5782 + commit 18254f88f82da7542a986dca60917fb48d5bccd3
42965783 * tests/gpgsm/t-verify.c (show_auditlog): Use plain text format.
42975784
42985785 2013-05-18 Werner Koch <wk@gnupg.org>
42995786
43005787 Improve C++ compatibility of previous patch.
5788 + commit e99356306d7bda61802530ebeb07d9ba73c4dec0
43015789 * src/gpgme.h.in: Move gpgme_sssize_t and gpgme_off_t typedefs into
43025790 the extern "C" scope.
43035791
43045792 2013-05-16 Werner Koch <wk@gnupg.org>
43055793
43065794 Make definition of off_t robust against misbehaving w32 toolchains.
5795 + commit 6d0d8e7ba0bb989c251545fa8af35b97d1a703ba
43075796 * configure.ac (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
43085797 and gpgme_ssize_t.
43095798 (API__OFF_T, API__SSIZE_T): New ac_subst.
43185807 2013-05-11 Werner Koch <wk@gnupg.org>
43195808
43205809 w32: Change the way the I/O threads are cleaned up.
5810 + commit 9e7df9aa6d81f0abbabb03a2346d80eb5d375f81
43215811 * src/w32-io.c (reader_context_s, create_reader)
43225812 (writer_context_s, create_writer): Rename STOPPED to CLOSE_EV.
43235813 (reader, writer): Remove setting of STOPPED. Wait for CLOSE_EV and
43295819 2013-05-08 Werner Koch <wk@gnupg.org>
43305820
43315821 Fix hang in socket closing.
5822 + commit 9f330be8210d2498fe93d4166b6f6c02fca76475
43325823 * src/w32-io.c (destroy_reader): Call shutdown.
43335824 (reader): Do not print an error in the shutdown case.
43345825
43355826 Improve debug output of the I/O reader and writer.
5827 + commit 2118f497010a9a41c29d062a7605ff2e136f8f4e
43365828 * src/w32-io.c (reader, writer): Also print file_sock.
43375829
43385830 2013-05-06 Werner Koch <wk@gnupg.org>
43395831
43405832 Simplify a debug code function.
5833 + commit a7e5f1096f02af7bfb678b0bea8da6ccfc28cc79
43415834 * src/debug.c (_gpgme_debug): Remove static space string.
43425835
43435836 2013-05-01 Werner Koch <wk@gnupg.org>
43445837
43455838 Release 1.4.1.
5839 + commit 5075c0da7c464af2a45cd36db134ed7e88f155af
43465840 * configure.ac: Bump LT version to C20/A9/R1.
43475841
43485842 Disable fd-passing for Apple.
5843 + commit ef5b4ae37d13142e89a051908dc080cda3d24baa
43495844 * configure.ac: Disable fd-passing by default for Apple.
43505845
43515846 2013-04-30 Werner Koch <wk@gnupg.org>
43525847
43535848 Allow reading of long gpgconf output lines.
5849 + commit f623a6b94c527795d0b6f7e66a3966e5d9e1c454
43545850 * src/engine-gpgconf.c (gpgconf_read): Rewrite to allow for line
43555851 lengths up to 64k.
43565852
43575853 2013-04-29 Werner Koch <wk@gnupg.org>
43585854
43595855 Fix for i686-w64-mingw32.
5856 + commit 867b950b9306904a0ff522d0ef4a43789393cfc4
43605857 * configure.ac (NEED__FILE_OFFSET_BITS): Do not define under Windows.
43615858
43625859 2013-02-26 Werner Koch <wk@gnupg.org>
43635860
43645861 Release 1.4.0.
5862 + commit ef5cd38123dfbef7843f374ee697b0b5e8730c46
43655863 * configure.ac: Bump LT version to C20/A9/R0.
43665864
43675865 Enable FD passing and thus building of the UI-server.
5866 + commit 5090f6f246bfad2eb80f3cc222963f73996d8028
43685867 * configure.ac: Make --enable-fd-passing the default.
43695868 * src/engine-uiserver.c (_gpgme_engine_ops_uiserver): Syntax fix.
43705869
43715870 w32: Hacks for building with 32 bit mingw64.
5871 + commit cdae524b282ef0ea67c3880b3e0f852c84c351ce
43725872 * configure.ac (INSERT__TYPEDEFS_FOR_GPGME_H): Add hacks for 32 bit
43735873 mingw64.
43745874 * src/util.h [W32]: Include winsock2.h before windows to make mingw64
43765876 * src/w32-util.c (_WIN32_IE): Need to use 5.1 for mingw64.
43775877
43785878 Improve missing libgpg-error reporting in configure.
5879 + commit 787b5f14b933e5cee2624f79a23a60947f8134c8
43795880 * configure.ac (NEED_GPG_ERROR_VERSION): New. Improve reporting for
43805881 missing libgpg-error.
43815882
43825883 Change the various version numbers to the new scheme.
5884 + commit d8b46c919f45666af0d541e00dcedf57e6c4b66f
43835885 * configure.ac: Rename my_foo variables to mym4_foo variables to make
43845886 clear that they are processed by m4.
43855887 (VERSION_NUMBER): New ac_subst.
43945896 * tests/t-version.c (main): Add option --verbose.
43955897
43965898 Update GnuPG related m4 files.
5899 + commit 863c0f2a3eaf2a5d46c5518e5ac3486cc1a49bd3
43975900 * m4/gpg-error.m4: Update from libgpg-error.
43985901 * m4/libassuan.m4: Update from libassuan.
43995902
44005903 Update helper scripts.
5904 + commit fdcd5736e610cd64e47da73dcafe8bc4a6a67666
44015905 * configure.ac: Use AC_CONFIG_AUX_DIR. Remove args from
44025906 AM_INIT_AUTOMAKE. Replace AM_CONFIG_HEADER by AC_CONFIG_HEADER.
44035907 * compile, config.guess, config.sub, depcomp, install-sh, ltmain.sh
44115915 2013-02-25 Werner Koch <wk@gnupg.org>
44125916
44135917 Remove included gitlog-to-changelog.
5918 + commit 967e043ac42330ee692f23d05ce3a0dd457f2119
44145919 * build-aux/gitlog-to-changelog: Remove.
44155920 * configure.ac (GITLOG_TO_CHANGELOG): Default to just
44165921 gitlog-to-changelog.
44185923 2013-02-12 Werner Koch <wk@gnupg.org>
44195924
44205925 Add macro GPGME_VERSION_NUMBER.
5926 + commit f48f75b1e812d33b76e439412efffa8277ab9abe
44215927 * src/gpgme.h.in (GPGME_VERSION_NUMBER): New.
44225928 * configure.ac (my_version_major, my_version_minor)
44235929 (my_version_micro): New m4 macros.
44255931 (VERSION_NUMBER): New ac_subst.
44265932
44275933 Add public function gpgme_get_pinentry_mode.
5934 + commit 4f381554411ef019d79492f1751543f145604bcf
44285935 * src/gpgme.c (gpgme_get_pinentry_mode): New.
44295936
44305937 2013-02-07 Werner Koch <wk@gnupg.org>
44315938
44325939 gpgme_tool: Support GPG's new pinentry-mode.
5940 + commit 02a2cf0ccb4d01700adf6d18316d7705d519a048
44335941 * src/gpgme-tool.c (log_error): Do not always print the error source.
44345942 (gt_set_pinentry_mode): New.
44355943 (server_passphrase_cb): New.
44405948 (parse_options, main): Implement that option.
44415949
44425950 Add public function gpgme_set_pinentry_mode.
5951 + commit 61a0d92b679f248505f1bf16386bc41a5bf2ba1d
44435952 * src/gpgme.c (gpgme_set_pinentry_mode): New.
44445953 * src/gpgme.h.in (gpgme_pinentry_t): New.
44455954 (gpgme_set_pinentry_mode): New.
44525961 (_gpgme_engine_ops_gpg): Register gpg_set_pinentry_mode.
44535962
44545963 Add public function gpgme_io_writen.
5964 + commit 29eced50687dd8a39dafe704102ae09ea8e8533a
44555965 * src/gpgme.c (gpgme_io_read): New.
44565966
44575967 2012-11-16 Werner Koch <wk@gnupg.org>
44585968
44595969 Improve parsing of the GIT revision number.
5970 + commit 322552a88db47896881e55c00ca301137cd160c6
44605971 * configure.ac (git_revision): Use git rev-parse.
44615972
44625973 Fix non-portable use of chmod in autogen.sh.
5974 + commit cd6de92f42cb6e5b85bc376d5544496cb4d6a88a
44635975 * autogen.sh: Remove option -c from chmod.
44645976
44655977 2012-11-15 Werner Koch <wk@gnupg.org>
44665978
44675979 Make _gpgme_encode_percent_string work for memory buffers.
5980 + commit 1a17acd8e9b7c0ef924f98bfb1502fe12e83c363
44685981 * src/conversion.c (D_gpgme_encode_percent_string): Remove stray
44695982 semicolon. Reported by Xi Wang.
44705983
44715984 2012-10-24 Werner Koch <wk@gnupg.org>
44725985
44735986 Make local variables configure hack more robust.
5987 + commit c97d067f27899d890a99036fcbed9263f4f68875
44745988 * configure.ac (emacs_local_vars_begin): Use extra m4 quoting so that
44755989 newer Emscasen won't take it up as Local Variables for this file.
44765990
44775991 Fix ttyname problem on Android.
5992 + commit 12a0c93433a0b1d7e8019fc35a63476db39327fa
44785993 * configure.ac: Define macro and conditional HAVE_ANDROID_SYSTEM.
44795994 * m4/gnupg-ttyname.m4: Force use of replacement on Android.
44805995 * src/ttyname_r.c: Ditto.
44815996
44825997 tests: Adhere to the docs and call gpgme_check_version.
5998 + commit cc59b75b21516198b39a56950afbcec140d8ba48
44835999 * tests/t-engine-info.c: Call gpgme_check_version.
44846000
44856001 2012-10-19 Werner Koch <wk@gnupg.org>
44866002
44876003 Trace the use of GPG_ERR_INV_ENGINE.
6004 + commit bd24feaa86f8154e550107990392ac9ac05e60d4
44886005 * src/debug.h: Include "gpgme.h"
44896006 (_gpgme_trace_gpgme_error): New.
44906007 (trace_gpg_error): New macro. Use it in all files where we return
44916008 GPG_ERR_INV_ENGINE; also "include debug.h" as needed.
44926009
44936010 Avoid warning about initialized but not used variable.
6011 + commit 14a8fd4eec126cad282a85c5aa336a6b55229b52
44946012 * src/engine-gpgsm.c (gpgsm_set_fd): Do not set DIR if not needed.
44956013
44966014 2012-10-11 Werner Koch <wk@gnupg.org>
44976015
44986016 gpgme-tool: Use membuf functions to build up strings.
6017 + commit e11e7fc5586613525035c3358e15ae24accb96ea
44996018 * src/gpgme-tool.c (clear_membuf, init_membuf, put_membuf)
45006019 (put_membuf_str, get_membuf, peek_membuf): Add membuf functions.
45016020 Take from GnuPG master's common/membuf.[ch] and patch for our use.
45026021 (result_xml_escape): Rewrite using new functions.
45036022
45046023 gpgme-tool: Change license from LPGLv2+ to GPLv3+
6024 + commit aa30b47aa010bf46876f2335e288f8bd8718e396
45056025 * src/gpgme-tool.c: Change license notice.
45066026
45076027 2012-10-11 W. Trevor King <wking@tremily.us>
45086028
45096029 gpgme-tool: escape special characters in output XML data (<, >, and &).
6030 + commit 3f1329e1c9b99b1632cc4c4eec2e4399676fd93d
45106031
45116032 src/gpgme-tool.c (result_xml_escape_replacement, result_xml_escape):
45126033 New.
45146035 (result_add_error): Use unescaped < and >.
45156036
45166037 gpgme-tool: Fix chain_id -> chain-id in KEYLIST XML.
6038 + commit c28ebca9f2e21344d68e9fdcec60553f225c2e54
45176039
45186040 src/gpgme-tool.c (cmd_keylist): Use <chain-id> instead of <chain_id>.
45196041
45206042 2012-09-28 W. Trevor King <wking@tremily.us>
45216043
45226044 gpgme-tool: Return more detailed XML from KEYLIST.
6045 + commit 3d69b51f7f083193db28f364da4590c33b5e44e6
45236046 src/gpgme-tool.c (cmd_keylist): Convert output from a list of
45246047 to more detailed XML.
45256048 (xml_preamble1, xml_preamble2, xml_end): Make global.
45306053 value returned by gpgme_get_protocol_name directly.
45316054
45326055 gpgme-tool: Initialize input_fd and output_fd.
6056 + commit dda3702a9024a08da7bb949e15b63a47d23d59f5
45336057 * src/gpgme-tool.c (gpgme_server): Initialize input_fd and output_fd.
45346058
45356059 2012-09-26 Werner Koch <wk@gnupg.org>
45366060
45376061 gpgme-tool: Fix handling of file descriptors.
6062 + commit 193eb62538b9413e0dfbd04c075f871d5aa9130b
45386063 * src/gpgme-tool.c (server_reset_fds): Use close/CloseHandle instead
45396064 of the assuan close functions.
45406065 (_cmd_decrypt_verify, _cmd_sign_encrypt, cmd_verify, cmd_import)
45446069 2012-09-25 Werner Koch <wk@gnupg.org>
45456070
45466071 Document contribution rules.
6072 + commit db33945ab3b8c173a3fc2dd1a0d22d7fc15d8730
45476073 * doc/HACKING (License policy): New.
45486074 * doc/DCO: New.
45496075 * AUTHORS: Change maintainer address.
45506076
45516077 Add gpgme_set_global_flag to help debugging.
6078 + commit c62b79a1d6e576d94e08cb81c2f5dbcb42ecf8cf
45526079 * src/gpgme.c (gpgme_set_global_flag): New.
45536080 * src/gpgme.h.in (gpgme_set_global_flag): New.
45546081 * src/gpgme.def, src/libgpgme.vers: Add new public function.
45596086 2012-07-28 Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>
45606087
45616088 Add two recent contributors.
6089 + commit 83e74202cd7c4c975d149c49e2507fdb0e60ef32
6090
45626091
45636092 Fix sign error in position calculation for mem_seek.
6093 + commit 8384ccbd1a51447dccbd608fc5df3c24cb8999b1
45646094 * data-mem.c (mem_seek): Fix sign error in position calculation.
45656095
45666096 Allow null context on gpgme_set_locale.
6097 + commit 434735f71e6969248651ac01c6bd6f6789a6305d
45676098 * gpgme.c (gpgme_set_locale): Allow CTX to be a null pointer.
45686099
45696100 2012-07-13 Werner Koch <wk@gnupg.org>
45706101
45716102 Do not include the removed file status-table.h.
6103 + commit e7aeaebb01395b170c91f290bf3ff5021023420f
45726104 * src/engine-uiserver.c: Remove status-table.h which is not anymore
45736105 built. Fixes bug#1412.
45746106
45756107 Make handling of new conf values more robust (bug#1413).
6108 + commit 9f081da7356288a96e8ea4d81a74ff706c00b0cd
45766109 * src/engine-gpgconf.c (arg_to_data): Allow for NULL as value.string.
45776110
45786111 2012-05-02 Werner Koch <wk@gnupg.org>
45796112
45806113 Release 1.3.2.
6114 + commit 9c8608f702ec0f44ae55cd7f33bd8df0a2d48508
45816115 * configure.ac: Bump LT version to C19/A8/R1.
45826116
45836117 * configure.ac (GITLOG_TO_CHANGELOG): Define.
45846118 * Makefile.am (gen-ChangeLog): Use it.
45856119
45866120 Remove unused pth stuff from gpgme-config.
6121 + commit 295dd3f238fa656493d34e8a718958d62226b56c
45876122 * src/gpgme-config.in: Remove unused pth stuff.
45886123
45896124 Update signature summary for the case of missing X.509 keys.
6125 + commit d6402b888fd00b883bbfc00c91a2aa9706e4377e
45906126 * src/verify.c (gpgme_op_verify_result): Update summary field.
45916127
45926128 2012-04-30 Werner Koch <wk@gnupg.org>
45936129
45946130 Fix timestamp parsing for y2038 hack.
6131 + commit 1a21574b48ee91eedbf95251ee600648b377d1e7
45956132 * src/conversion.c (_gpgme_parse_timestamp): Set ENDP before year 2038
45966133 check.
45976134
45986135 2012-04-20 W. Trevor King <wking@drexel.edu>
45996136
46006137 .gitignore: flesh out rules and add subdirectory-.gitignores.
6138 + commit 4cb408d33efe80e7d102049dea244d22907d8395
6139
46016140
46026141 2012-04-13 W. Trevor King <wking@drexel.edu>
46036142
46046143 status-table.c: include string.h for strcmp.
6144 + commit 62bbe58280737d73badbe518f140e40480205176
46056145 * status-table.c: include string.h to avoid `warning: implicit
46066146 declaration of function 'strcmp'`.
46076147
46086148 2012-04-03 W. Trevor King <wking@drexel.edu>
46096149
46106150 gpgme-tool: add help messages for a number of commands.
6151 + commit c318e69d8fa5f9e92d4aac3dd44fae5adcaade72
46116152 * src/gpgme-tool.c (hlp_engine, hlp_sub_protocol, hlp_armor, hlp_textmode,
46126153 hlp_include_certs, hlp_keylist_mode, hlp_input, hlp_output, hlp_message,
46136154 hlp_recipient, hlp_signer, hlp_signers_clear, hlp_decrypt, hlp_decrypt_verify,
46176158 (doc): Mention Assuan.
46186159
46196160 uiserver.texi: fix decryption -> encryption typo in PREP_ENCRYPT discussion.
6161 + commit bb62104adf78e8416b3c56b8b2621edd723b56cd
46206162 * doc/uiserver.texi (PREP_ENCRYPT): Fix documentation.
46216163
46226164 Update Werner Koch's distribution signing key in the README.
6165 + commit 6ec9e21dd1ea2f8509700bce018aef6ad7e9a927
46236166 * README: Update signing key.
46246167
46256168 2012-03-12 Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>
46266169
46276170 Do not rely on glibc name of syscall.
6171 + commit ff0a640a18e7b7457e6c2edfdc8307bf44628b60
46286172 * src/ath.c (ath_self): Use __NR_gettid, not SYS_gettid.
46296173
46306174 Update config.guess and config.sub to latest version.
6175 + commit ced1ad01aed32d1e4c5000f3b901db018ef7bf1e
46316176 * config.guess, config.sub: Update to latest version.
46326177
46336178 2012-02-14 Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>
46346179
46356180 Rework status table to be less dynamically generated.
6181 + commit 885243e05467e79e2375b3febe7904053ab45dfc
46366182 * src/Makefile.am (EXTRA_DIST): Remove mkstatus.
46376183 (BUILT_SOURCE, MOSTLYCLEANFILES): Remove.
46386184 (main_sources): Remove status-table.h, extra-stati.h.
46596205 2012-02-08 Marcus Brinkmann <mb@g10code.com>
46606206
46616207 Use gpgme interface for error handling to avoid linking with gpg-error.
6208 + commit dae3073aaa8b7feb1c844fdaf711f79141b9cc65
46626209 * tests/t-data.c, tests/run-export.c, tests/run-keylist.c,
46636210 tests/run-support.h, tests/run-verify.c, tests/gpg/t-decrypt-verify.c,
46646211 tests/gpg/t-edit.c, tests/gpg/t-eventloop.c, tests/gpg/t-keylist-sig.c,
46696216 tests/opassuan/t-command.c: Use gpgme interface for gpg-error functions.
46706217
46716218 Link the thread test to pthread.
6219 + commit 0052a72f89c6830818e354358fdd84702d3494c8
46726220 * tests/gpg/Makefile.am (t_thread1_LDADD): Add -lpthread.
46736221
46746222 Link gpgme-tool directly to libassuan, as it uses its interface.
6223 + commit 3f03897cbd223d4a75eb62c3b7bdfeb800661641
46756224 * src/Makefile.am (gpgme_tool_LDADD): Add @LIBASSUAN_LIBS@.
46766225
46776226 2012-01-19 Werner Koch <wk@gnupg.org>
46786227
46796228 Support the mingw-w64 toolchain.
6229 + commit 24a10a4af948ebb1c767b69a92fa5bbe933a417c
46806230 * autogen.sh (build-w32): Add i686-w64-mingw32 to the toolprefix.
46816231
46826232 Fix Solaris problems with ttyname_r.
6233 + commit 2f304957f5122a5d9da643dc9951ee67ece06eaf
46836234 * m4/gnupg-ttyname.m4: New. Based on ttyname_r from gnulib.
46846235 * src/ttyname_r.c (_gpgme_ttyname_r): Rename from ttyname_r.
46856236 Implement hacks required for Solaris and possible other non-fully
46886239 REPLACE_TTYNAME_R and put it into the gpgme name space.
46896240
46906241 Try to make configure.ac a bit smaller.
6242 + commit c96778297f5477448a676fcf0c61044bdbccc86d
46916243 * configure.ac: Move header checks.
46926244
46936245 For W32 use a build number instead of abbreviated commit id.
6246 + commit 574b087e84f5652cf9d8eba8aa16b8d6bb988035
46946247 We would need to use a shortened commit id so that it fits into an 16
46956248 bit Windows variable. Further it is a random number and not something
46966249 increasing. Thus a build number made up from the day of the year and
47006253 * src/versioninfo.rc.in: Ditto.
47016254
47026255 Adjust configure.ac for modern autoconf.
6256 + commit a0149630ce6d3e17a7475e20e8b2e31ed5ba57fd
47036257 * configure.ac: Minor cleanups.
47046258
47056259 Update to libtool 2.4.2.
6260 + commit 4cfddadcd0a569f0b204dccea3c975ce0bdfb232
47066261 * ltmain.sh, m4/libtool.m4, m4/ltoptions.m4, m4/ltversion.m4,
47076262 * m4/lt~obsolete.m4: Update.
47086263
47096264 Add ttyname_r check macro from gnulib.
6265 + commit 3ef528b63679df912551d5d21fc36e465cf50c40
47106266 * m4/gnupg-ttyname.m4: New. Taken from current gnulib.
47116267
47126268 2011-12-02 Werner Koch <wk@gnupg.org>
47136269
47146270 Generate the ChangeLog from commit logs.
6271 + commit a4c4ee1aaea4359432bdf60dd572f549ef8dee83
47156272 * build-aux/gitlog-to-changelog: New script. Taken from gnulib.
47166273 * build-aux/git-log-fix: New file.
47176274 * build-aux/git-log-footer: New file.
0 Noteworthy changes in version 1.9.0 (2017-03-28)
1 ------------------------------------------------
2
3 * Clarified meaning of the 'expire' parameter of gpgme_op_createkey
4 and gpgme_op_createsubkey. New flag to force a key without an
5 expiration date.
6
7 * New function gpgme_op_keylist_from_data_start to list keys from
8 data objects without importing them.
9
10 * New function gpgme_op_set_uid_flag to flag a key as primary.
11
12 * New function gpgme_op_decrypt_ext to run decryption with special
13 flags. This can for example be used to unwrap keys (remove only
14 the encryption layer).
15
16 * New encryption flags to wrap a key (adding an encryption layer to
17 an OpenPGP message) or to create anonymously encrypted messages.
18
19 * Support for adduid and revuid operations in the C++ bindings.
20
21 * Support for smartcard key generation in the C++ bindings.
22
23 * Several new functions for the Python binding.
24
25 * Many smaller bug fixes.
26
27
28 * Interface changes relative to the 1.8.0 release:
29 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 gpgme_op_createkey CHANGED: Meaning of 'expire' parameter.
31 gpgme_op_createsubkey CHANGED: Meaning of 'expire' parameter.
32 GPGME_CREATE_NOEXPIRE NEW.
33 gpgme_key_t EXTENDED: New field 'origin'.
34 gpgme_key_t EXTENDED: New field 'last_update'.
35 gpgme_subkey_t EXTENDED: New field 'is_de_vs'.
36 gpgme_user_id_t EXTENDED: New field 'origin'.
37 gpgme_user_id_t EXTENDED: New field 'last_update'.
38 gpgme_op_keylist_from_data_start NEW.
39 gpgme_op_set_uid_flag_start NEW.
40 gpgme_op_set_uid_flag NEW.
41 gpgme_op_decrypt_ext_start NEW.
42 gpgme_op_decrypt_ext NEW.
43 GPGME_ENCRYPT_THROW_KEYIDS NEW.
44 GPGME_ENCRYPT_WRAP NEW.
45 GPGME_DECRYPT_VERIFY NEW.
46 GPGME_DECRYPT_UNWRAP NEW.
47 gpgme_data_rewind UN-DEPRECATE.
48 cpp: Context::revUid(const Key&, const char*) NEW.
49 cpp: Context::startRevUid(const Key&, const char*) NEW.
50 cpp: Context::addUid(const Key&, const char*) NEW.
51 cpp: Context::startAddUid(const Key&, const char*) NEW.
52 cpp: Key::UserID::revoke() NEW.
53 cpp: Key::addUid() NEW.
54 cpp: Key::isDeVs NEW.
55 cpp: GpgGenCardKeyInteractor NEW.
56 cpp: Subkey::keyGrip NEW.
57 cpp: Subkey::isDeVs NEW.
58 cpp: Data::toKeys NEW.
59 cpp: Context::setDecryptFlags NEW.
60 cpp: Context::decrypt EXTENDED: Flags added.
61 cpp: Context::startDecrypt EXTENDED: Flags added.
62 cpp: Context::decryptAndVerify EXTENDED: Flags added.
63 cpp: Context::startCombinedDecryptionAndVerification EXTENDED: Flags.
64 cpp: Context::encryptFlags EXTENDED: New flags.
65 qt: CryptoConfig::stringValueList() NEW.
66 py: Context.__init__ EXTENDED: New keyword arg home_dir.
67 py: Context.home_dir NEW.
68 py: Context.keylist EXTENDED: New keyword arg mode.
69 py: Context.keylist EXTENDED: New keyword arg source.
70 py: Context.create_key NEW.
71 py: Context.create_subkey NEW.
72 py: Context.key_add_uid NEW.
73 py: Context.key_revoke_uid NEW.
74 py: Context.key_sign NEW.
75 py: Context.key_tofu_policy NEW.
76 py: core.pubkey_algo_string NEW.
77 py: core.addrspec_from_uid NEW.
78
79 [c=C29/A18/R0 cpp=C10/A4/R0 qt=C9/A2/R0]
80
81
082 Noteworthy changes in version 1.8.0 (2016-11-16)
183 ------------------------------------------------
284
00 GPGME - GnuPG Made Easy
11 ---------------------------
22
3 Copyright 2001-2016 g10 Code GmbH
3 Copyright 2001-2017 g10 Code GmbH
44
55 This file is free software; as a special exception the author gives
66 unlimited permission to copy and/or distribute it, with or without
6969 indeed a a signature of gpgme-x.y.z.tar.gz. The key used to create
7070 this signature is either of:
7171
72 2048R/4F25E3B6 2011-01-12 [expires: 2019-12-31]
72 rsa2048/4F25E3B6 2011-01-12 [expires: 2019-12-31]
7373 Key fingerprint = D869 2123 C406 5DEA 5E0F 3AB5 249B 39D2 4F25 E3B6
7474 Werner Koch (dist sig)
7575
8585 Key fingerprint = D238 EA65 D64C 67ED 4C30 73F2 8A86 1B1C 7EFD 60D9
8686 Werner Koch (Release Signing Key)
8787
88 rsa3072/4B092E28 2017-03-17 [expires: 2027-03-15]
89 Key fingerprint = 5B80 C575 4298 F0CB 55D8 ED6A BCEF 7E29 4B09 2E28
90 Andre Heinecke (Release Signing Key)
91
8892 You may retrieve these files from the keyservers using this command
8993
9094 gpg --recv-keys 249B39D24F25E3B6 04376F3EE0856959 \
91 2071B08A33BD3F06 8A861B1C7EFD60D9
95 2071B08A33BD3F06 8A861B1C7EFD60D9 BCEF7E294B092E28
9296
9397 The keys are also available at https://gnupg.org/signature_key.html
9498 and in released GnuPG tarballs in the file g10/distsigkey.gpg .
0 1.8.0
0 1.9.0
2727 # commit and push so that the git magic is able to work. See below
2828 # for the LT versions.
2929 m4_define(mym4_version_major, [1])
30 m4_define(mym4_version_minor, [8])
30 m4_define(mym4_version_minor, [9])
3131 m4_define(mym4_version_micro, [0])
3232
3333 # Below is m4 magic to extract and compute the revision number, the
5454 # (Interfaces added: AGE++)
5555 # (Interfaces removed/changed: AGE=0)
5656 #
57 LIBGPGME_LT_CURRENT=28
58 LIBGPGME_LT_AGE=17
57 LIBGPGME_LT_CURRENT=29
58 LIBGPGME_LT_AGE=18
5959 LIBGPGME_LT_REVISION=0
6060
6161 # If there is an ABI break in gpgmepp or qgpgme also bump the
6262 # version in IMPORTED_LOCATION in the GpgmeppConfig-w32.cmake.in.in
6363
64 LIBGPGMEPP_LT_CURRENT=9
65 LIBGPGMEPP_LT_AGE=3
64 LIBGPGMEPP_LT_CURRENT=10
65 LIBGPGMEPP_LT_AGE=4
6666 LIBGPGMEPP_LT_REVISION=0
6767
68 LIBQGPGME_LT_CURRENT=8
69 LIBQGPGME_LT_AGE=1
68 LIBQGPGME_LT_CURRENT=9
69 LIBQGPGME_LT_AGE=2
7070 LIBQGPGME_LT_REVISION=0
7171
7272 # If the API is changed in an incompatible way: increment the next counter.
166166 have_ld_version_script=yes
167167 ;;
168168 *-apple-darwin*)
169 AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
170 Expose all libc features (__DARWIN_C_FULL).)
169171 AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X)
170172 ;;
171173 esac
181183 have_android_system=no
182184 have_w32_system=no
183185 have_w64_system=no
186 have_macos_system=no
184187 build_w32_glib=no
185188 build_w32_qt=no
186189 available_languages="cl cpp python python2 python3 qt"
195198 *-linux-androideabi)
196199 have_android_system=yes
197200 ;;
201 *-apple-darwin*)
202 have_macos_system=yes
203 ;;
198204 esac
199205 case "${host}" in
200206 *-mingw32ce*|*-mingw32*)
251257 AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
252258 fi
253259 AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
260
261 if test "$have_macos_system" = yes; then
262 AC_DEFINE(HAVE_MACOS_SYSTEM,1,
263 [Defined if we build for an MacOS system])
264 fi
265 AM_CONDITIONAL(HAVE_MACOS_SYSTEM, test "$have_macos_system" = yes)
254266
255267 AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes)
256268
405417 unset am_cv_python_pyexecdir
406418
407419 if test "$found_py" = "1" -o "$found_py2" = "1"; then
408 AM_PATH_PYTHON([2.7])
409 AX_PYTHON_DEVEL
410 if test "$PYTHON_VERSION"; then
411 PYTHONS="$(echo $PYTHONS $PYTHON)"
412 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
413 fi
420 AM_PATH_PYTHON([2.7], [
421 AX_PYTHON_DEVEL
422 if test "$PYTHON_VERSION"; then
423 PYTHONS="$(echo $PYTHONS $PYTHON)"
424 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
425 fi
426 ], :)
414427 fi
415428
416429 if test "$found_py" = "1" -o "$found_py3" = "1"; then
428441 unset am_cv_python_platform
429442 unset am_cv_python_pythondir
430443 unset am_cv_python_pyexecdir
431 AM_PATH_PYTHON([3.4])
432 AX_PYTHON_DEVEL
433 if test "$PYTHON_VERSION"; then
434 PYTHONS="$(echo $PYTHONS $PYTHON)"
435 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
436 fi
444 AM_PATH_PYTHON([3.4], [
445 AX_PYTHON_DEVEL
446 if test "$PYTHON_VERSION"; then
447 PYTHONS="$(echo $PYTHONS $PYTHON)"
448 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
449 fi
450 ], :)
437451 fi
438452
453 # Recover some values lost in the second attempt to find Python.
454 PYTHON="$(echo $PYTHONS | cut -d ' ' -f 1)"
455 PYTHON_VERSION="$(echo $PYTHON_VERSIONS | cut -d ' ' -f 1)"
456
457 # Remove duplicates.
458 PYTHONS="$(echo $PYTHONS | tr '[[:space:]]' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/ $//')"
459 PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS | tr '[[:space:]]' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/ $//')"
460
439461 if test "$PYTHON_VERSIONS"; then
440 enabled_languages_v=$(echo $enabled_languages | sed "s/python\([[23]]\)\?/python ($PYTHON_VERSIONS)/")
441 enabled_languages=$(echo $enabled_languages | sed "s/python\([[23]]\)\?/python/")
462 enabled_languages_v=$(echo $enabled_languages | sed -Ee "s/python[[23]]?/python ($PYTHON_VERSIONS)/")
463 enabled_languages=$(echo $enabled_languages | sed -Ee "s/python[[23]]?/python/")
442464 else
443465 if test "$explicit_languages" = "1"; then
444466 AC_MSG_ERROR([[
621643
622644 AC_FUNC_FSEEKO
623645
624 AC_REPLACE_FUNCS(vasprintf)
625 if test "$ac_cv_func_vasprintf" != yes; then
626 GNUPG_CHECK_VA_COPY
627 fi
628
629646 # Try to find a thread-safe version of ttyname().
630647 gnupg_REPLACE_TTYNAME_R
631648 if test "$ac_cv_func_ttyname_r" != yes; then
687704 # Other checks
688705 #
689706
690 # Check for funopen
691 AC_CHECK_FUNCS(funopen)
692 if test $ac_cv_func_funopen != yes; then
693 # No funopen but we can implement that in terms of fopencookie.
694 AC_CHECK_FUNCS(fopencookie)
695 if test $ac_cv_func_fopencookie = yes; then
696 AC_REPLACE_FUNCS(funopen)
697 else
698 AC_MSG_WARN([
699 ***
700 *** No implementation of fopencookie or funopen available
701 ***])
702 fi
703 fi
704
705707 # Check for getgid etc
706 AC_CHECK_FUNCS(getgid getegid)
708 AC_CHECK_FUNCS(getgid getegid closefrom)
707709
708710
709711 # Replacement functions.
731733 #include <unistd.h>
732734 ])
733735
734
735 dnl There seems to be a problem with Apple and decriptor passing.
736 dnl Until we found a solution we change the default to no.
737 dnl See bug 1483.
738 case "${host}" in
739 *-apple-darwin*)
740 use_descriptor_passing=no
741 ;;
742 *)
743 use_descriptor_passing=yes
744 ;;
745 esac
736 use_descriptor_passing=yes
746737 AC_ARG_ENABLE(fd-passing,
747738 AC_HELP_STRING([--disable-fd-passing], [do not use FD passing]),
748739 use_descriptor_passing=$enableval)
797788 #define GPG_ERR_ENABLE_ERRNO_MACROS 1
798789
799790 #define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \
800 "Copyright (C) 2001--2016 g10 Code GmbH\n"
791 "Copyright (C) 2001--2017 g10 Code GmbH\n"
801792 ])
802793
803794
1313 @syncodeindex pg fn
1414
1515 @copying
16 Copyright @copyright{} 2002--2008, 2010, 2012--2016 g10 Code GmbH.
16 Copyright @copyright{} 2002--2008, 2010, 2012--2017 g10 Code GmbH.
1717
1818 @quotation
1919 Permission is granted to copy, distribute and/or modify this document
977977
978978 @item g13-name
979979 Return the name of the file container encryption engine.
980
981 @item gpg-wks-client-name
982 Return the name of the Web Key Service tool.
980983
981984 @end table
982985
28872890 values for @var{name}:
28882891
28892892 @table @code
2893 @item "redraw"
2894 This flag is normally not changed by the caller because GPGME sets and
2895 clears it automatically: The flag is cleared before an operation and
2896 set if an operation noticed that the engine has launched a Pinentry.
2897 A Curses based application may use this information to redraw the
2898 screen; for example:
2899
2900 @example
2901 err = gpgme_op_keylist_start (ctx, "foo@@example.org", 0);
2902 while (!err)
2903 @{
2904 err = gpgme_op_keylist_next (ctx, &key);
2905 if (err)
2906 break;
2907 show_key (key);
2908 gpgme_key_release (key);
2909 @}
2910 if ((s = gpgme_get_ctx_flag (ctx, "redraw")) && *s)
2911 redraw_screen ();
2912 gpgme_release (ctx);
2913 @end example
2914
2915
28902916 @item "full-status"
28912917 Using a @var{value} of "1" the status callback set by
28922918 gpgme_set_status_cb returns all status lines with the exception of
30513077 (offline/stub keys). This is only set if a listing of secret keys has
30523078 been requested or if @code{GPGME_KEYLIST_MODE_WITH_SECRET} is active.
30533079
3080 @item unsigned int origin : 5
3081 Reserved for the origin of this key.
3082
30543083 @item gpgme_protocol_t protocol
30553084 This is the protocol supported by this key.
30563085
30833112 this is a copy of the fingerprint of the first subkey. For an
30843113 incomplete key (for example from a verification result) a subkey may
30853114 be missing but this field may be set nevertheless.
3115
3116 @item unsigned long last_update
3117 Reserved for the time of the last update of this key.
30863118
30873119 @end table
30883120 @end deftp
31323164 This is true if the subkey can be used for qualified signatures
31333165 according to local government regulations.
31343166
3167 @item unsigned int is_de_vs : 1
3168 This is true if the subkey complies with the rules for classified
3169 information in Germany at the restricted level (VS-NfD). This are
3170 currently RSA keys of at least 2048 bits or ECDH/ECDSA keys using a
3171 Brainpool curve.
3172
31353173 @item unsigned int secret : 1
31363174 This is true if the subkey is a secret key. Note that it will be
31373175 false if the key is actually a stub key; i.e. a secret key operation
32223260
32233261 @item gpgme_key_sig_t signatures
32243262 This is a linked list with the signatures on this user ID.
3263
3264 @item unsigned int origin : 5
3265 Reserved for the origin of this user ID.
3266
3267 @item unsigned long last_update
3268 Reserved for the time of the last update of this user ID.
3269
32253270 @end table
32263271 @end deftp
32273272
33123357 @cindex key ring, search
33133358
33143359 @deftypefun gpgme_error_t gpgme_op_keylist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{secret_only}})
3360
33153361 The function @code{gpgme_op_keylist_start} initiates a key listing
33163362 operation inside the context @var{ctx}. It sets everything up so that
33173363 subsequent invocations of @code{gpgme_op_keylist_next} return the keys
33393385 @end deftypefun
33403386
33413387 @deftypefun gpgme_error_t gpgme_op_keylist_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{int @var{secret_only}}, @w{int @var{reserved}})
3388
33423389 The function @code{gpgme_op_keylist_ext_start} initiates an extended
33433390 key listing operation inside the context @var{ctx}. It sets
33443391 everything up so that subsequent invocations of
33693416 are reported by the crypto engine support routines.
33703417 @end deftypefun
33713418
3419 @deftypefun gpgme_error_t gpgme_op_keylist_from_data @
3420 (@w{gpgme_ctx_t @var{ctx}}, @
3421 @w{gpgme_data_t @var{data}}, @
3422 @w{int @var{reserved}})
3423
3424 The function @code{gpgme_op_keylist_from_data_start} initiates a key
3425 listing operation inside the context @var{ctx}. In contrast to the
3426 other key listing operation the keys are read from the supplied
3427 @var{data} and not from the local key database. The keys are also not
3428 imported into the local key database. The function sets everything up
3429 so that subsequent invocations of @code{gpgme_op_keylist_next} return
3430 the keys from @var{data}.
3431
3432 The value of @var{reserved} must be @code{0}.
3433
3434 This function requires at least GnuPG version 2.1.14 and currently
3435 works only with OpenPGP keys.
3436
3437 The context will be busy until either all keys are received (and
3438 @code{gpgme_op_keylist_next} returns @code{GPG_ERR_EOF}), or
3439 @code{gpgme_op_keylist_end} is called to finish the operation.
3440 While the context is busy @var{data} may not be released.
3441
3442 The function returns the error code @code{GPG_ERR_INV_VALUE} if
3443 @var{ctx} is not a valid pointer, and passes through any errors that
3444 are reported by the crypto engine support routines.
3445 @end deftypefun
3446
33723447 @deftypefun gpgme_error_t gpgme_op_keylist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t *@var{r_key}})
3448
33733449 The function @code{gpgme_op_keylist_next} returns the next key in the
33743450 list created by a previous @code{gpgme_op_keylist_start} operation in
33753451 the context @var{ctx}. The key will have one reference for the user.
33873463 @end deftypefun
33883464
33893465 @deftypefun gpgme_error_t gpgme_op_keylist_end (@w{gpgme_ctx_t @var{ctx}})
3466
33903467 The function @code{gpgme_op_keylist_end} ends a pending key list
33913468 operation in the context @var{ctx}.
33923469
34013478
34023479 The following example illustrates how all keys containing a certain
34033480 string (@code{g10code}) can be listed with their key ID and the name
3404 and e-mail address of the main user ID:
3481 and email address of the main user ID:
34053482
34063483 @example
34073484 gpgme_ctx_t ctx;
35883665
35893666 @var{reserved} must be set to zero.
35903667
3591 @var{expires} can be set to the number of seconds since Epoch of the
3592 desired expiration date in UTC for the new key. Using 0 does not
3593 set an expiration date. Note that this parameter takes an unsigned long
3594 value and not a @code{time_t} to avoid problems on systems which use a
3595 signed 32 bit @code{time_t}. Note further that the OpenPGP protocol
3596 uses 32 bit values for timestamps and thus can only encode dates up to
3597 the year 2106.
3668 @var{expires} specifies the expiration time in seconds. If you supply
3669 0, a reasonable expiration time is chosen. Use the flag
3670 @code{GPGME_CREATE_NOEXPIRE} to create keys that do not expire. Note
3671 that this parameter takes an unsigned long value and not a
3672 @code{time_t} to avoid problems on systems which use a signed 32 bit
3673 @code{time_t}. Note further that the OpenPGP protocol uses 32 bit
3674 values for timestamps and thus can only encode dates up to the year
3675 2106.
35983676
35993677 @var{extrakey} is currently not used and must be set to @code{NULL}.
36003678 A future version of GPGME may use this parameter to create X.509 keys.
36353713 The engine does not allow the creation of a key with a user ID
36363714 already existing in the local key database. This flag can be used to
36373715 override this check.
3716
3717 @item GPGME_CREATE_NOEXPIRE
3718 Request generation of keys that do not expire.
36383719
36393720 @end table
36403721
36953776
36963777 @var{reserved} must be set to zero.
36973778
3698 @var{expires} can be set to the number of seconds since Epoch of the
3699 desired expiration date in UTC for the new subkey. Using 0 does not
3700 set an expiration date. Note that this parameter takes an unsigned long
3701 value and not a @code{time_t} to avoid problems on systems which use a
3702 signed 32 bit @code{time_t}. Note further that the OpenPGP protocol
3703 uses 32 bit values for timestamps and thus can only encode dates up to
3704 the year 2106.
3779 @var{expires} specifies the expiration time in seconds. If you supply
3780 0, a reasonable expiration time is chosen. Use the flag
3781 @code{GPGME_CREATE_NOEXPIRE} to create keys that do not expire. Note
3782 that this parameter takes an unsigned long value and not a
3783 @code{time_t} to avoid problems on systems which use a signed 32 bit
3784 @code{time_t}. Note further that the OpenPGP protocol uses 32 bit
3785 values for timestamps and thus can only encode dates up to the year
3786 2106.
37053787
37063788 @var{flags} takes the same values as described above for
37073789 @code{gpgme_op_createkey}.
38273909
38283910
38293911 @c
3912 @c gpgme_op_set_uid_flag
3913 @c
3914 @deftypefun gpgme_error_t gpgme_op_set_ui_flag @
3915 (@w{gpgme_ctx_t @var{ctx}}, @
3916 @w{gpgme_key_t @var{key}}, @
3917 @w{const char *@var{userid}}, @
3918 @w{cons char * @var{name}}, @
3919 @w{cons char * @var{value}});
3920
3921 The function @code{gpgme_op_set_uid_flag} is used to set flags on a
3922 user ID from the OpenPGP key given by @var{KEY}. Setting flags on
3923 user IDs after key creation is a feature of the OpenPGP protocol and
3924 thus the protocol for the context @var{ctx} must be set to OpenPGP.
3925
3926 @var{key} specifies the key to operate on. This parameters is required.
3927
3928 @var{userid} is the user ID of the key to be manipulated. This user ID
3929 must be given verbatim because the engine does an exact and case
3930 sensitive match. Thus the @code{uid} field from the user ID object
3931 (@code{gpgme_user_id_t}) is to be used. This is a required parameter.
3932
3933 @var{name} names the flag which is to be changed. The only currently
3934 supported flag is:
3935
3936 @table @code
3937 @item primary
3938 This sets the primary key flag on the given user ID. All other
3939 primary key flag on other user IDs are removed. @var{value} must be
3940 given as NULL. For technical reasons this functions bumps the
3941 creation timestamp of all affected self-signatures up by one second.
3942 At least GnuPG version 2.1.20 is required.
3943
3944 @end table
3945
3946 The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if
3947 the engine does not support the command, or a bunch of other error
3948 codes.
3949
3950 @end deftypefun
3951
3952 @deftypefun gpgme_error_t gpgme_op_set_uid_flag_start @
3953 (@w{gpgme_ctx_t @var{ctx}}, @
3954 @w{gpgme_key_t @var{key}}, @
3955 @w{const char *@var{userid}}, @
3956 @w{cons char * @var{name}}, @
3957 @w{cons char * @var{value}});
3958
3959 The function @code{gpgme_op_set_uid_flag_start} initiates a
3960 @code{gpgme_op_set_uid_flag} operation; see there for details. It must
3961 be completed by calling @code{gpgme_wait} on the context.
3962 @xref{Waiting For Completion}.
3963
3964 @end deftypefun
3965
3966 @c
38303967 @c gpgme_op_genkey
38313968 @c
38323969 @deftypefun gpgme_error_t gpgme_op_genkey @
38503987 be signed by the certification authority and imported before it can be
38513988 used. GpgSM does not make the fingerprint available.
38523989
3853 The argument @var{parms} specifies parameters for the key in an XML
3854 string. The details about the format of @var{parms} are specific to
3855 the crypto engine used by @var{ctx}. Here is an example for GnuPG as
3856 the crypto engine (all parameters of OpenPGP key generation are
3857 documented in the GPG manual):
3990 The argument @var{parms} specifies parameters for the key in an string
3991 that looks something like XML. The details about the format of
3992 @var{parms} are specific to the crypto engine used by @var{ctx}. The
3993 first line of the parameters must be @code{<GnupgKeyParams
3994 format="internal">} and the last line must be
3995 @code{</GnupgKeyParams>}. Every line in between the first and last
3996 lines is treated as a Header: Value pair. In particular, no XML
3997 escaping is necessary if you need to include the characters @code{<},
3998 @code{>}, or @code{&}.
3999
4000 Here is an example for GnuPG as the crypto engine (all parameters of
4001 OpenPGP key generation are documented in the GPG manual):
38584002
38594003 @example
38604004 <GnupgKeyParms format="internal">
38904034
38914035 The function returns the error code @code{GPG_ERR_NO_ERROR} if the
38924036 operation could be started successfully, @code{GPG_ERR_INV_VALUE} if
3893 @var{parms} is not a valid XML string, @code{GPG_ERR_NOT_SUPPORTED} if
3894 @var{public} or @var{secret} is not valid, and @code{GPG_ERR_GENERAL}
3895 if no key was created by the backend.
4037 @var{parms} is not a well-formed string (e.g. does not have the
4038 expected tag-like headers and footers), @code{GPG_ERR_NOT_SUPPORTED}
4039 if @var{public} or @var{secret} is not valid, and
4040 @code{GPG_ERR_GENERAL} if no key was created by the backend.
38964041 @end deftypefun
38974042
38984043 @deftypefun gpgme_error_t gpgme_op_genkey_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{parms}}, @w{gpgme_data_t @var{public}}, @w{gpgme_data_t @var{secret}})
40074152 one user ID put them all into one string separated by linefeeds
40084153 characters (@code{\n}) and set the flag @code{GPGME_KEYSIGN_LFSEP}.
40094154
4010 @var{expires} can be set to the number of seconds since Epoch of the
4011 desired expiration date in UTC for the new signature. The common case
4012 is to use 0 to not set an expiration date. However, if the
4013 configuration of the engine defines a default expiration for key
4014 signatures, that is still used unless the flag
4155 @var{expires} specifies the expiration time of the new signature in
4156 seconds. The common case is to use 0 to not set an expiration date.
4157 However, if the configuration of the engine defines a default
4158 expiration for key signatures, that is still used unless the flag
40154159 @code{GPGME_KEYSIGN_NOEXPIRE} is used. Note that this parameter takes
40164160 an unsigned long value and not a @code{time_t} to avoid problems on
40174161 systems which use a signed 32 bit @code{time_t}. Note further that
44534597 @cindex validity, TOFU
44544598
44554599 The OpenPGP engine features a Trust-On-First-Use (TOFU) key validation
4456 model. For resolving clonflics it is necessary to declare the policy
4600 model. For resolving conflicts it is necessary to declare the policy
44574601 for a key. See the GnuPG manual for details on the TOFU
44584602 implementation.
44594603
44664610 @item GPGME_TOFU_POLICY_AUTO
44674611 Set the policy to ``auto''.
44684612 @item GPGME_TOFU_POLICY_GOOD
4469 Set the policy to ``goog''.
4613 Set the policy to ``good''.
44704614 @item GPGME_TOFU_POLICY_BAD
44714615 Set the policy to ``bad''.
44724616 @item GPGME_TOFU_POLICY_ASK
47584902 if @var{cipher} or @var{plain} is not a valid pointer.
47594903 @end deftypefun
47604904
4905
4906 @deftypefun gpgme_error_t gpgme_op_decrypt_ext ( @
4907 @w{gpgme_ctx_t @var{ctx}}, @
4908 @w{gpgme_decrypt_flags_t @var{flags}}, @
4909 @w{gpgme_data_t @var{cipher}}, @
4910 @w{gpgme_data_t @var{plain}})
4911
4912 The function @code{gpgme_op_decrypt_ext} is the same as
4913 @code{gpgme_op_decrypt_ext} but has an additional argument
4914 @var{flags}. If @var{flags} is 0 both function behave identically.
4915
4916 The value in @var{flags} is a bitwise-or combination of one or
4917 multiple of the following bit values:
4918
4919 @table @code
4920 @item GPGME_DECRYPT_VERIFY
4921 The @code{GPGME_DECRYPT_VERIFY} symbol specifies that this function
4922 shall exacty act as @code{gpgme_op_decrypt_verify}.
4923
4924 @item GPGME_DECRYPT_UNWRAP
4925 The @code{GPGME_DECRYPT_UNWRAP} symbol specifies that the output shall
4926 be an OpenPGP message with only the encryption layer removed. This
4927 requires GnuPG 2.1.12 and works only for OpenPGP. This is the
4928 counterpart to @code{GPGME_ENCRYPT_WRAP}.
4929
4930 @end table
4931
4932 The function returns the error codes as descriped for
4933 @code{gpgme_op_decrypt} respective @code{gpgme_op_encrypt}.
4934 @end deftypefun
4935
4936 @deftypefun gpgme_error_t gpgme_op_decrypt_ext_start ( @
4937 @w{gpgme_ctx_t @var{ctx}}, @
4938 @w{gpgme_decrypt_flags_t @var{flags}}, @
4939 @w{gpgme_data_t @var{cipher}}, @
4940 @w{gpgme_data_t @var{plain}})
4941
4942 The function @code{gpgme_op_decrypt_ext_start} initiates a
4943 @code{gpgme_op_decrypt_ext} operation. It can be completed by calling
4944 @code{gpgme_wait} on the context. @xref{Waiting For Completion}.
4945
4946 The function returns the error code @code{GPG_ERR_NO_ERROR} if the
4947 operation could be started successfully, and @code{GPG_ERR_INV_VALUE}
4948 if @var{cipher} or @var{plain} is not a valid pointer.
4949 @end deftypefun
4950
4951
47614952 @deftp {Data type} {gpgme_recipient_t}
47624953 This is a pointer to a structure used to store information about the
47634954 recipient of an encrypted text which is decrypted in a
49475138 This is a bit vector giving a summary of the signature status. It
49485139 provides an easy interface to a defined semantic of the signature
49495140 status. Checking just one bit is sufficient to see whether a
4950 signature is valid without any restrictions.
5141 signature is valid without any restrictions. This means that
5142 you can check for GPGME_SIGSUM_VALID like this:
5143
5144 @example
5145 if ((sig.summary & GPGME_SIGSUM_VALID))
5146 @{
5147 ..do stuff if valid..
5148 @}
5149 else
5150 @{
5151 ..do stuff if not fully valid..
5152 @}
5153 @end example
49515154
49525155 The defined bits are:
49535156 @table @code
54795682
54805683 @item GPGME_ENCRYPT_SYMMETRIC
54815684 The @code{GPGME_ENCRYPT_SYMMETRIC} symbol specifies that the
5482 output should be additionally encrypted symmetically even
5685 output should be additionally encrypted symmetrically even
54835686 if recipients are provided. This feature is only supported for
54845687 for the OpenPGP crypto engine.
5688
5689 @item GPGME_ENCRYPT_THROW_KEYIDS
5690 The @code{GPGME_ENCRYPT_THROW_KEYIDS} symbols requests that the
5691 identifiers for the decrption keys are not included in the ciphertext.
5692 On the receiving side, the use of this flag may slow down the
5693 decryption process because all available secret keys must be tried.
5694 This flag is only honored for OpenPGP encryption.
5695
5696 @item GPGME_ENCRYPT_WRAP
5697 The @code{GPGME_ENCRYPT_WRAP} symbol specifies that the input is an
5698 OpenPGP message and not a plain data. This is the counterpart to
5699 @code{GPGME_DECRYPT_UNWRAP}.
54855700
54865701 @end table
54875702
55615776 for the OpenPGP crypto engine.
55625777 @end deftypefun
55635778
5564 @deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
5779 @deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
55655780 The function @code{gpgme_op_encrypt_sign_start} initiates a
55665781 @code{gpgme_op_encrypt_sign} operation. It can be completed by
55675782 calling @code{gpgme_wait} on the context. @xref{Waiting For
00 # This is a template. The dist target uses it to create the real file.
11 Summary: GPGME - GnuPG Made Easy
22 Name: gpgme
3 Version: 1.8.0
3 Version: 1.9.0
44 Release: 1
55 URL: https://gnupg.org/gpgme.html
66 Source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/%{name}-%{version}.tar.gz
6262
6363 set_target_properties(Gpgmepp PROPERTIES
6464 INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/gpgme++;@resolved_includedir@"
65 INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme@libsuffix@;@LIBASSUAN_LIBS@"
66 IMPORTED_LOCATION "@resolved_libdir@/libgpgmepp.so"
65 INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme.so;@LIBASSUAN_LIBS@"
66 IMPORTED_LOCATION "@resolved_libdir@/libgpgmepp@libsuffix@"
6767 )
6868
6969 if(CMAKE_VERSION VERSION_LESS 2.8.12)
3030 signingresult.cpp encryptionresult.cpp \
3131 engineinfo.cpp gpgsetexpirytimeeditinteractor.cpp \
3232 gpgsetownertrusteditinteractor.cpp gpgsignkeyeditinteractor.cpp \
33 gpgadduserideditinteractor.cpp defaultassuantransaction.cpp \
33 gpgadduserideditinteractor.cpp gpggencardkeyinteractor.cpp \
34 defaultassuantransaction.cpp \
3435 scdgetinfoassuantransaction.cpp gpgagentgetinfoassuantransaction.cpp \
3536 vfsmountresult.cpp configuration.cpp tofuinfo.cpp swdbresult.cpp
3637
4142 gpgadduserideditinteractor.h gpgagentgetinfoassuantransaction.h \
4243 gpgmefw.h gpgsetexpirytimeeditinteractor.h \
4344 gpgsetownertrusteditinteractor.h gpgsignkeyeditinteractor.h \
45 gpggencardkeyinteractor.h \
4446 importresult.h keygenerationresult.h key.h keylistresult.h \
4547 notation.h result.h scdgetinfoassuantransaction.h signingresult.h \
4648 trustitem.h verificationresult.h vfsmountresult.h gpgmepp_export.h \
6870 libgpgmepp_la_LDFLAGS = -no-undefined -version-info \
6971 @LIBGPGMEPP_LT_CURRENT@:@LIBGPGMEPP_LT_REVISION@:@LIBGPGMEPP_LT_AGE@
7072
73 if HAVE_MACOS_SYSTEM
74 libsuffix=.dylib
75 else
76 libsuffix=.so
77 endif
78
7179 if HAVE_W32_SYSTEM
7280 GpgmeppConfig.cmake: GpgmeppConfig-w32.cmake.in
7381 sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \
7684 else
7785 GpgmeppConfig.cmake: GpgmeppConfig.cmake.in
7886 sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \
87 sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \
7988 sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@
8089 endif
8190 install-cmake-files: GpgmeppConfig.cmake GpgmeppConfigVersion.cmake
279279 return std::unique_ptr<Context>(new Context(ctx));
280280 }
281281
282 void Context::setDecryptionFlags(DecryptionFlags flags)
283 {
284 d->decryptFlags = flags;
285 }
286
282287 //
283288 //
284289 // Context::Private
293298 lastAssuanInquireData(Data::null),
294299 lastAssuanTransaction(),
295300 lastEditInteractor(),
296 lastCardEditInteractor()
301 lastCardEditInteractor(),
302 decryptFlags(DecryptNone)
297303 {
298304
299305 }
903909 return std::move(d->lastAssuanTransaction);
904910 }
905911
906 DecryptionResult Context::decrypt(const Data &cipherText, Data &plainText)
912 DecryptionResult Context::decrypt(const Data &cipherText, Data &plainText, const DecryptionFlags flags)
907913 {
908914 d->lastop = Private::Decrypt;
909915 const Data::Private *const cdp = cipherText.impl();
910916 Data::Private *const pdp = plainText.impl();
911 d->lasterr = gpgme_op_decrypt(d->ctx, cdp ? cdp->data : 0, pdp ? pdp->data : 0);
917 d->lasterr = gpgme_op_decrypt_ext(d->ctx, static_cast<gpgme_decrypt_flags_t> (d->decryptFlags | flags), cdp ? cdp->data : 0, pdp ? pdp->data : 0);
912918 return DecryptionResult(d->ctx, Error(d->lasterr));
913919 }
914920
915 Error Context::startDecryption(const Data &cipherText, Data &plainText)
921 DecryptionResult Context::decrypt(const Data &cipherText, Data &plainText)
922 {
923 return decrypt(cipherText, plainText, DecryptNone);
924 }
925
926 Error Context::startDecryption(const Data &cipherText, Data &plainText, const DecryptionFlags flags)
916927 {
917928 d->lastop = Private::Decrypt;
918929 const Data::Private *const cdp = cipherText.impl();
919930 Data::Private *const pdp = plainText.impl();
920 return Error(d->lasterr = gpgme_op_decrypt_start(d->ctx, cdp ? cdp->data : 0, pdp ? pdp->data : 0));
931 return Error(d->lasterr = gpgme_op_decrypt_ext_start(d->ctx, static_cast<gpgme_decrypt_flags_t> (d->decryptFlags | flags),
932 cdp ? cdp->data : 0, pdp ? pdp->data : 0));
933 }
934
935 Error Context::startDecryption(const Data &cipherText, Data &plainText)
936 {
937 return startDecryption(cipherText, plainText, DecryptNone);
921938 }
922939
923940 DecryptionResult Context::decryptionResult() const
972989 }
973990 }
974991
975 std::pair<DecryptionResult, VerificationResult> Context::decryptAndVerify(const Data &cipherText, Data &plainText)
992 std::pair<DecryptionResult, VerificationResult> Context::decryptAndVerify(const Data &cipherText, Data &plainText, DecryptionFlags flags)
976993 {
977994 d->lastop = Private::DecryptAndVerify;
978995 const Data::Private *const cdp = cipherText.impl();
979996 Data::Private *const pdp = plainText.impl();
980 d->lasterr = gpgme_op_decrypt_verify(d->ctx, cdp ? cdp->data : 0, pdp ? pdp->data : 0);
997 d->lasterr = gpgme_op_decrypt_ext(d->ctx, static_cast<gpgme_decrypt_flags_t> (d->decryptFlags | flags | DecryptVerify),
998 cdp ? cdp->data : 0, pdp ? pdp->data : 0);
981999 return std::make_pair(DecryptionResult(d->ctx, Error(d->lasterr)),
9821000 VerificationResult(d->ctx, Error(d->lasterr)));
9831001 }
9841002
985 Error Context::startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText)
1003 std::pair<DecryptionResult, VerificationResult> Context::decryptAndVerify(const Data &cipherText, Data &plainText)
1004 {
1005 return decryptAndVerify(cipherText, plainText, DecryptNone);
1006 }
1007
1008 Error Context::startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText, DecryptionFlags flags)
9861009 {
9871010 d->lastop = Private::DecryptAndVerify;
9881011 const Data::Private *const cdp = cipherText.impl();
9891012 Data::Private *const pdp = plainText.impl();
990 return Error(d->lasterr = gpgme_op_decrypt_verify_start(d->ctx, cdp ? cdp->data : 0, pdp ? pdp->data : 0));
1013 return Error(d->lasterr = gpgme_op_decrypt_ext_start(d->ctx, static_cast<gpgme_decrypt_flags_t> (d->decryptFlags | flags | DecryptVerify), cdp ? cdp->data : 0, pdp ? pdp->data : 0));
1014 }
1015
1016 Error Context::startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText)
1017 {
1018 return startCombinedDecryptionAndVerification(cipherText, plainText, DecryptNone);
9911019 }
9921020
9931021 unsigned int to_auditlog_flags(unsigned int flags)
13731401 {
13741402 return Error(d->lasterr = gpgme_op_tofu_policy_start(d->ctx,
13751403 k.impl(), to_tofu_policy_t(policy)));
1404 }
1405
1406 Error Context::addUid(const Key &k, const char *userid)
1407 {
1408 return Error(d->lasterr = gpgme_op_adduid(d->ctx,
1409 k.impl(), userid, 0));
1410 }
1411
1412 Error Context::startAddUid(const Key &k, const char *userid)
1413 {
1414 return Error(d->lasterr = gpgme_op_adduid_start(d->ctx,
1415 k.impl(), userid, 0));
1416 }
1417
1418 Error Context::revUid(const Key &k, const char *userid)
1419 {
1420 return Error(d->lasterr = gpgme_op_revuid(d->ctx,
1421 k.impl(), userid, 0));
1422 }
1423
1424 Error Context::startRevUid(const Key &k, const char *userid)
1425 {
1426 return Error(d->lasterr = gpgme_op_revuid_start(d->ctx,
1427 k.impl(), userid, 0));
13761428 }
13771429
13781430 // Engine Spawn stuff
213213 GpgME::Error edit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
214214 GpgME::Error startEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
215215
216 Error addUid(const Key &key, const char *userid);
217 Error startAddUid(const Key &key, const char *userid);
218
219 Error revUid(const Key &key, const char *userid);
220 Error startRevUid(const Key &key, const char *userid);
221
216222 // using TofuInfo::Policy
217223 Error setTofuPolicy(const Key &k, unsigned int policy);
218224 Error setTofuPolicyStart(const Key &k, unsigned int policy);
254260 //
255261 // Crypto Operations
256262 //
257 //
263
264 enum DecryptionFlags {
265 // Keep in line with core's flags
266 DecryptNone = 0,
267 DecryptVerify = 1,
268 DecryptUnwrap = 128,
269 DecryptMaxValue = 0x80000000
270 };
258271
259272 //
260273 // Decryption
261274 //
275
276 // Alternative way to set decryption flags as they were added only in
277 // 1.9.0 and so other API can still be used but with 1.9.0 additionally
278 // flags can be set.
279 void setDecryptionFlags (const DecryptionFlags flags);
262280
263281 DecryptionResult decrypt(const Data &cipherText, Data &plainText);
264282 GpgME::Error startDecryption(const Data &cipherText, Data &plainText);
283 DecryptionResult decrypt(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
284 GpgME::Error startDecryption(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
265285 DecryptionResult decryptionResult() const;
266286
267287 //
279299 //
280300
281301 std::pair<DecryptionResult, VerificationResult> decryptAndVerify(const Data &cipherText, Data &plainText);
302 std::pair<DecryptionResult, VerificationResult> decryptAndVerify(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
282303 GpgME::Error startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText);
304 GpgME::Error startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
283305 // use verificationResult() and decryptionResult() to retrieve the result objects...
284306
285307 //
318340 Prepare = 4,
319341 ExpectSign = 8,
320342 NoCompress = 16,
321 Symmetric = 32
343 Symmetric = 32,
344 ThrowKeyIds = 64,
345 EncryptWrap = 128
322346 };
323347 EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
324348 GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText);
7676 Data lastAssuanInquireData;
7777 std::unique_ptr<AssuanTransaction> lastAssuanTransaction;
7878 std::unique_ptr<EditInteractor> lastEditInteractor, lastCardEditInteractor;
79 DecryptionFlags decryptFlags;
7980 };
8081
8182 } // namespace GpgME
2424 #endif
2525
2626 #include "data_p.h"
27 #include "context_p.h"
2728 #include <error.h>
2829 #include <interfaces/dataprovider.h>
2930
229230 {
230231 return gpgme_data_seek(d->data, offset, whence);
231232 }
233
234 std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
235 {
236 std::vector<GpgME::Key> ret;
237 if (isNull()) {
238 return ret;
239 }
240 auto ctx = GpgME::Context::createForProtocol(proto);
241 if (!ctx) {
242 return ret;
243 }
244
245 if (gpgme_op_keylist_from_data_start (ctx->impl()->ctx, d->data, 0)) {
246 return ret;
247 }
248
249 gpgme_key_t key;
250 while (!gpgme_op_keylist_next (ctx->impl()->ctx, &key)) {
251 ret.push_back(GpgME::Key(key, false));
252 }
253 delete ctx;
254 return ret;
255 }
2323 #define __GPGMEPP_DATA_H__
2424
2525 #include "global.h"
26 #include "key.h"
2627
2728 #include <sys/types.h> // for size_t, off_t
2829 #include <cstdio> // FILE
108109 ssize_t write(const void *buffer, size_t length);
109110 off_t seek(off_t offset, int whence);
110111
112 /** Try to parse the data to a key object using the
113 * Protocol proto. Returns an empty list on error.*/
114 std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
115
111116 class Private;
112117 Private *impl()
113118 {
211211 case GPGME_STATUS_KEY_CREATED:
212212 case GPGME_STATUS_NEED_PASSPHRASE_SYM:
213213 case GPGME_STATUS_SC_OP_FAILURE:
214 case GPGME_STATUS_CARDCTRL:
215 case GPGME_STATUS_BACKUP_KEY_CREATED:
214216 return false;
215217 default:
216218 return true;
0 /*
1 gpggencardkeyinteractor.cpp - Edit Interactor to generate a key on a card
2 Copyright (C) 2017 Intevation GmbH
3
4 This file is part of GPGME++.
5
6 GPGME++ is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 GPGME++ is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with GPGME++; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "gpggencardkeyinteractor.h"
27
28 #include "error.h"
29
30 #include <gpgme.h>
31
32 using namespace GpgME;
33
34 class GpgGenCardKeyInteractor::Private
35 {
36 public:
37 Private() : keysize(2048), backup(false)
38 {
39
40 }
41 std::string name, email, backupFileName, expiry, serial;
42 int keysize;
43 bool backup;
44 };
45
46 GpgGenCardKeyInteractor::~GpgGenCardKeyInteractor() {}
47
48 GpgGenCardKeyInteractor::GpgGenCardKeyInteractor(const std::string &serial):
49 d(new Private)
50 {
51 d->serial = serial;
52 }
53
54 void GpgGenCardKeyInteractor::setNameUtf8(const std::string &name)
55 {
56 d->name = name;
57 }
58
59 void GpgGenCardKeyInteractor::setEmailUtf8(const std::string &email)
60 {
61 d->email = email;
62 }
63
64 void GpgGenCardKeyInteractor::setDoBackup(bool value)
65 {
66 d->backup = value;
67 }
68
69 void GpgGenCardKeyInteractor::setKeySize(int value)
70 {
71 d->keysize = value;
72 }
73
74 void GpgGenCardKeyInteractor::setExpiry(const std::string &timeStr)
75 {
76 d->expiry = timeStr;
77 }
78
79 std::string GpgGenCardKeyInteractor::backupFileName() const
80 {
81 return d->backupFileName;
82 }
83
84 namespace GpgGenCardKeyInteractor_Private
85 {
86 enum {
87 START = EditInteractor::StartState,
88 DO_ADMIN,
89 EXPIRE,
90
91 GOT_SERIAL,
92 COMMAND,
93 NAME,
94 EMAIL,
95 COMMENT,
96 BACKUP,
97 REPLACE,
98 SIZE,
99 SIZE2,
100 SIZE3,
101 BACKUP_KEY_CREATED,
102 KEY_CREATED,
103 QUIT,
104 SAVE,
105
106 ERROR = EditInteractor::ErrorState
107 };
108 }
109
110 const char *GpgGenCardKeyInteractor::action(Error &err) const
111 {
112
113 using namespace GpgGenCardKeyInteractor_Private;
114
115 switch (state()) {
116 case DO_ADMIN:
117 return "admin";
118 case COMMAND:
119 return "generate";
120 case NAME:
121 return d->name.c_str();
122 case EMAIL:
123 return d->email.c_str();
124 case EXPIRE:
125 return d->expiry.c_str();
126 case BACKUP:
127 return d->backup ? "Y" : "N";
128 case REPLACE:
129 return "Y";
130 case SIZE:
131 case SIZE2:
132 case SIZE3:
133 return std::to_string(d->keysize).c_str();
134 case COMMENT:
135 return "";
136 case SAVE:
137 return "Y";
138 case QUIT:
139 return "quit";
140 case KEY_CREATED:
141 case START:
142 case GOT_SERIAL:
143 case BACKUP_KEY_CREATED:
144 case ERROR:
145 return 0;
146 default:
147 err = Error::fromCode(GPG_ERR_GENERAL);
148 return 0;
149 }
150 }
151
152 unsigned int GpgGenCardKeyInteractor::nextState(unsigned int status, const char *args, Error &err) const
153 {
154
155 static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
156 static const Error INV_NAME_ERROR = Error::fromCode(GPG_ERR_INV_NAME);
157 static const Error INV_EMAIL_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
158 static const Error INV_COMMENT_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
159
160 if (needsNoResponse(status)) {
161 return state();
162 }
163
164 using namespace GpgGenCardKeyInteractor_Private;
165
166 switch (state()) {
167 case START:
168 if (status == GPGME_STATUS_CARDCTRL &&
169 !d->serial.empty()) {
170 const std::string sArgs = args;
171 if (sArgs.find(d->serial) == std::string::npos) {
172 // Wrong smartcard
173 err = Error::fromCode(GPG_ERR_WRONG_CARD);
174 return ERROR;
175 } else {
176 printf("EditInteractor: Confirmed S/N: %s %s\n",
177 d->serial.c_str(), sArgs.c_str());
178 }
179 return GOT_SERIAL;
180 } else if (d->serial.empty()) {
181 return GOT_SERIAL;
182 }
183 err = GENERAL_ERROR;
184 return ERROR;
185 case GOT_SERIAL:
186 if (status == GPGME_STATUS_GET_LINE &&
187 strcmp(args, "cardedit.prompt") == 0) {
188 return DO_ADMIN;
189 }
190 err = GENERAL_ERROR;
191 return ERROR;
192 case DO_ADMIN:
193 if (status == GPGME_STATUS_GET_LINE &&
194 strcmp(args, "cardedit.prompt") == 0) {
195 return COMMAND;
196 }
197 err = GENERAL_ERROR;
198 return ERROR;
199 case COMMAND:
200 if (status == GPGME_STATUS_GET_LINE &&
201 strcmp(args, "cardedit.genkeys.backup_enc") == 0) {
202 return BACKUP;
203 }
204 err = GENERAL_ERROR;
205 return ERROR;
206 case BACKUP:
207 if (status == GPGME_STATUS_GET_BOOL &&
208 strcmp(args, "cardedit.genkeys.replace_keys") == 0) {
209 return REPLACE;
210 }
211 if (status == GPGME_STATUS_GET_LINE &&
212 strcmp(args, "cardedit.genkeys.size") == 0) {
213 return SIZE;
214 }
215 err = GENERAL_ERROR;
216 return ERROR;
217 case REPLACE:
218 if (status == GPGME_STATUS_GET_LINE &&
219 strcmp(args, "cardedit.genkeys.size") == 0) {
220 printf("Moving to SIZE\n");
221 return SIZE;
222 }
223 err = GENERAL_ERROR;
224 return ERROR;
225 case SIZE:
226 if (status == GPGME_STATUS_GET_LINE &&
227 strcmp(args, "cardedit.genkeys.size") == 0) {
228 return SIZE2;
229 }
230 if (status == GPGME_STATUS_GET_LINE &&
231 strcmp(args, "keygen.valid") == 0) {
232 return EXPIRE;
233 }
234 err = GENERAL_ERROR;
235 return ERROR;
236 case SIZE2:
237 if (status == GPGME_STATUS_GET_LINE &&
238 strcmp(args, "cardedit.genkeys.size") == 0) {
239 return SIZE3;
240 }
241 if (status == GPGME_STATUS_GET_LINE &&
242 strcmp(args, "keygen.valid") == 0) {
243 return EXPIRE;
244 }
245 err = GENERAL_ERROR;
246 return ERROR;
247 case SIZE3:
248 if (status == GPGME_STATUS_GET_LINE &&
249 strcmp(args, "keygen.valid") == 0) {
250 return EXPIRE;
251 }
252 err = GENERAL_ERROR;
253 return ERROR;
254 case EXPIRE:
255 if (status == GPGME_STATUS_GET_LINE &&
256 strcmp(args, "keygen.name") == 0) {
257 return NAME;
258 }
259 err = GENERAL_ERROR;
260 return ERROR;
261 case NAME:
262 if (status == GPGME_STATUS_GET_LINE &&
263 strcmp(args, "keygen.email") == 0) {
264 return EMAIL;
265 }
266 err = GENERAL_ERROR;
267 if (status == GPGME_STATUS_GET_LINE &&
268 strcmp(args, "keygen.name") == 0) {
269 err = INV_NAME_ERROR;
270 }
271 return ERROR;
272 case EMAIL:
273 if (status == GPGME_STATUS_GET_LINE &&
274 strcmp(args, "keygen.comment") == 0) {
275 return COMMENT;
276 }
277 err = GENERAL_ERROR;
278 if (status == GPGME_STATUS_GET_LINE &&
279 strcmp(args, "keygen.email") == 0) {
280 err = INV_EMAIL_ERROR;
281 }
282 return ERROR;
283 case COMMENT:
284 if (status == GPGME_STATUS_BACKUP_KEY_CREATED) {
285 std::string sArgs = args;
286 const auto pos = sArgs.rfind(" ");
287 if (pos != std::string::npos) {
288 d->backupFileName = sArgs.substr(pos + 1);
289 return BACKUP_KEY_CREATED;
290 }
291 }
292 if (status == GPGME_STATUS_KEY_CREATED) {
293 return KEY_CREATED;
294 }
295 if (status == GPGME_STATUS_GET_LINE &&
296 strcmp(args, "keyedit.prompt") == 0) {
297 return QUIT;
298 }
299 err = GENERAL_ERROR;
300 if (status == GPGME_STATUS_GET_LINE &&
301 strcmp(args, "keygen.comment") == 0) {
302 err = INV_COMMENT_ERROR;
303 }
304 return ERROR;
305 case BACKUP_KEY_CREATED:
306 if (status == GPGME_STATUS_KEY_CREATED) {
307 return KEY_CREATED;
308 }
309 err = GENERAL_ERROR;
310 return ERROR;
311 case KEY_CREATED:
312 return QUIT;
313 case QUIT:
314 if (status == GPGME_STATUS_GET_LINE &&
315 strcmp(args, "cardedit.prompt") == 0) {
316 return QUIT;
317 }
318 err = GENERAL_ERROR;
319 return ERROR;
320 case ERROR:
321 if (status == GPGME_STATUS_GET_LINE &&
322 strcmp(args, "keyedit.prompt") == 0) {
323 return QUIT;
324 }
325 err = lastError();
326 return ERROR;
327 default:
328 err = GENERAL_ERROR;
329 return ERROR;
330 }
331 }
0 /*
1 gpggencardkeyinteractor.h - Edit Interactor to generate a key on a card
2 Copyright (C) 2017 Intevation GmbH
3
4 This file is part of GPGME++.
5
6 GPGME++ is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 GPGME++ is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with GPGME++; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20 */
21
22 #ifndef __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
23 #define __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
24
25 #include <editinteractor.h>
26
27 #include <string>
28 #include <memory>
29
30 namespace GpgME
31 {
32
33 class GPGMEPP_EXPORT GpgGenCardKeyInteractor: public EditInteractor
34 {
35 public:
36 /** Edit interactor to generate a key on a smartcard.
37 *
38 * The \a serialnumber argument is intended to safeguard
39 * against accidentally working on the wrong smartcard.
40 *
41 * The edit interactor will fail if the card did not match.
42 *
43 * @param serialnumber: Serialnumber of the intended card.
44 **/
45 explicit GpgGenCardKeyInteractor(const std::string &serialnumber);
46 ~GpgGenCardKeyInteractor();
47
48 /** Set the key sizes for the subkeys (default 2048) */
49 void setKeySize(int size);
50
51 void setNameUtf8(const std::string &name);
52 void setEmailUtf8(const std::string &email);
53
54 void setDoBackup(bool value);
55 void setExpiry(const std::string &timeString);
56
57 std::string backupFileName() const;
58
59 private:
60 /* reimp */ const char *action(Error &err) const;
61 /* reimp */ unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const;
62
63 private:
64 class Private;
65 std::shared_ptr<Private> d;
66 };
67
68 } // namespace GpgME
69
70 #endif // __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
231231 bool Key::isQualified() const
232232 {
233233 return key && key->is_qualified;
234 }
235
236 bool Key::isDeVs() const
237 {
238 return key && key->subkeys && key->subkeys->is_de_vs;
234239 }
235240
236241 const char *Key::issuerSerial() const
340345 KeyListMode::Validate |
341346 KeyListMode::WithTofu);
342347 Error err;
343 auto newKey = ctx->key(primaryFingerprint(), err, hasSecret());
348 auto newKey = ctx->key(primaryFingerprint(), err, true);
349 // Not secret so we get the information from the pubring.
350 if (newKey.isNull())
351 {
352 newKey = ctx->key(primaryFingerprint(), err, false);
353 }
344354 delete ctx;
345355 if (err) {
346356 return;
463473 return subkey && subkey->is_qualified;
464474 }
465475
476 bool Subkey::isDeVs() const
477 {
478 return subkey && subkey->is_de_vs;
479 }
480
466481 bool Subkey::isCardKey() const
467482 {
468483 return subkey && subkey->is_cardkey;
470485
471486 const char *Subkey::cardSerialNumber() const
472487 {
473 return subkey ? subkey->card_number : 0 ;
488 return subkey ? subkey->card_number : nullptr;
489 }
490
491 const char *Subkey::keyGrip() const
492 {
493 return subkey ? subkey->keygrip : nullptr;
474494 }
475495
476496 bool Subkey::isSecret() const
893913
894914 std::string UserID::addrSpec() const
895915 {
896 return addrSpecFromString(email());
916 if (!uid || !uid->address) {
917 return std::string();
918 }
919
920 return uid->address;
921 }
922
923 Error UserID::revoke()
924 {
925 if (isNull()) {
926 return Error::fromCode(GPG_ERR_GENERAL);
927 }
928 auto ctx = Context::createForProtocol(parent().protocol());
929 if (!ctx) {
930 return Error::fromCode(GPG_ERR_INV_ENGINE);
931 }
932 Error ret = ctx->revUid(key, id());
933 delete ctx;
934 return ret;
935 }
936
937 Error Key::addUid(const char *uid)
938 {
939 if (isNull()) {
940 return Error::fromCode(GPG_ERR_GENERAL);
941 }
942 auto ctx = Context::createForProtocol(protocol());
943 if (!ctx) {
944 return Error::fromCode(GPG_ERR_INV_ENGINE);
945 }
946 Error ret = ctx->addUid(key, uid);
947 delete ctx;
948 return ret;
897949 }
898950
899951 std::ostream &operator<<(std::ostream &os, const UserID &uid)
902954 if (!uid.isNull()) {
903955 os << "\n name: " << protect(uid.name())
904956 << "\n email: " << protect(uid.email())
957 << "\n mbox: " << uid.addrSpec()
905958 << "\n comment: " << protect(uid.comment())
906959 << "\n validity: " << uid.validityAsString()
907960 << "\n revoked: " << uid.isRevoked()
111111 bool canCertify() const;
112112 bool canAuthenticate() const;
113113 bool isQualified() const;
114 bool isDeVs() const;
114115
115116 bool hasSecret() const;
116117 GPGMEPP_DEPRECATED bool isSecret() const
151152 * how long the keylisting takes.*/
152153 void update();
153154
155 /**
156 * @brief Add a user id to this key.
157 *
158 * Needs gnupg 2.1.13 and the key needs to be updated
159 * afterwards to see the new uid.
160 *
161 * @param uid should be fully formated and UTF-8 encoded.
162 *
163 * @returns a possible error.
164 **/
165 Error addUid(const char *uid);
154166 private:
155167 gpgme_key_t impl() const
156168 {
207219 bool canCertify() const;
208220 bool canAuthenticate() const;
209221 bool isQualified() const;
222 bool isDeVs() const;
210223 bool isCardKey() const;
211224
212225 bool isSecret() const;
258271
259272 const char *cardSerialNumber() const;
260273
274 const char *keyGrip() const;
275
261276 private:
262277 shared_gpgme_key_t key;
263278 gpgme_sub_key_t subkey;
334349 * @returns a normalized mail address for this userid
335350 * or an empty string. */
336351 std::string addrSpec() const;
352
353 /*! Revoke the user id.
354 *
355 * Key needs update afterwards.
356 *
357 * @returns an error on error.*/
358 Error revoke();
337359 private:
338360 shared_gpgme_key_t key;
339361 gpgme_user_id_t uid;
412412 }
413413 }
414414 if (update) {
415 ret.update();
415 d->keys[idx].update();
416 ret = d->keys[idx];
416417 }
417418 return ret;
418419 }
4545
4646 # For VPATH builds we need to copy some files because Python's
4747 # distutils are not VPATH-aware.
48 copystamp: $(COPY_FILES) $(COPY_FILES_GPG) data.h config.h
49 if test "$(srcdir)" != "$(builddir)" ; then \
50 cp -R $(COPY_FILES) . ; \
51 cp -R $(COPY_FILES_GPG) gpg ; \
52 fi
48 copystamp: $(COPY_FILES) $(COPY_FILES_GPG)
49 set -e ; for VERSION in $(PYTHON_VERSIONS); do \
50 $(MKDIR_P) python$${VERSION}-gpg/gpg ; \
51 cp -R $(COPY_FILES) python$${VERSION}-gpg ; \
52 cp setup.py python$${VERSION}-gpg ; \
53 cp gpg/version.py python$${VERSION}-gpg/gpg ; \
54 ln -sf "$(abs_top_srcdir)/src/data.h" python$${VERSION}-gpg ; \
55 ln -sf "$(abs_top_builddir)/config.h" python$${VERSION}-gpg ; \
56 cp -R $(COPY_FILES_GPG) python$${VERSION}-gpg/gpg ; \
57 done
5358 touch $@
5459
55 data.h:
56 ln -s "$(top_srcdir)/src/data.h" .
57
58 config.h:
59 ln -s "$(top_builddir)/config.h" .
60
6160 all-local: copystamp
62 for PYTHON in $(PYTHONS); do \
61 set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
62 PYTHON="$$1" ; shift ; \
63 cd python$${VERSION}-gpg && \
6364 CFLAGS="$(CFLAGS)" \
6465 $$PYTHON setup.py build --verbose ; \
66 cd .. ; \
6567 done
6668
67 dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc: copystamp
69 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
70 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
71 cd python$(PYTHON_VERSION)-gpg && \
6872 CFLAGS="$(CFLAGS)" \
6973 $(PYTHON) setup.py sdist --verbose
70 gpg2 --detach-sign --armor dist/gpg-$(VERSION).tar.gz
74 gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz
7175
7276 .PHONY: prepare
7377 prepare: copystamp
7478
7579 .PHONY: sdist
76 sdist: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
80 sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
81 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
7782
7883 .PHONY: upload
79 upload: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
84 upload: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
85 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
8086 twine upload $^
8187
82 CLEANFILES = gpgme.h errors.i gpgme_wrap.c gpg/gpgme.py \
83 data.h config.h copystamp
88 CLEANFILES = copystamp
8489
8590 # Remove the rest.
8691 #
8893 # permissions.
8994 clean-local:
9095 rm -rf -- build
91 if test "$(srcdir)" != "$(builddir)" ; then \
92 find . -type d ! -perm -200 -exec chmod u+w {} ';' ; \
93 for F in $(COPY_FILES); do rm -rf -- `basename $$F` ; done ; \
94 for F in $(COPY_FILES_GPG); do \
95 rm -rf -- gpg/`basename $$F` ; \
96 done ; \
97 fi
96 for VERSION in $(PYTHON_VERSIONS); do \
97 find python$${VERSION}-gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
98 rm -rf -- python$${VERSION}-gpg ; \
99 done
98100
99101 install-exec-local:
100102 rm -f install_files.txt
101 for PYTHON in $(PYTHONS); do \
103 set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
104 PYTHON="$$1" ; shift ; \
105 cd python$${VERSION}-gpg ; \
102106 $$PYTHON setup.py install \
103107 --prefix $(DESTDIR)$(prefix) \
104108 --record files.txt \
105109 --verbose ; \
106 cat files.txt >> install_files.txt ; \
110 cat files.txt >> ../install_files.txt ; \
107111 rm files.txt ; \
112 cd .. ; \
108113 done
109114 $(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
110115 mv install_files.txt $(DESTDIR)$(pythondir)/gpg
2424 del util
2525
2626 # For convenience, we import the modules here.
27 from . import data, event, keylist, md, pk
28 from . import protocol, sig, sigsum, status, validity
27 from . import data, keylist, sig, tofu # The subdirs.
28 from . import create, event, keysign, md, pk, protocol, sigsum, status, validity
2929
3030 # A complication arises because 'import' is a reserved keyword.
3131 # Import it as 'Import' instead.
3232 globals()['Import'] = getattr(__import__('', globals(), locals(),
3333 [str('import')], 1), "import")
3434
35 __all__ = ['data', 'event', 'import', 'keylist', 'md', 'pk',
36 'protocol', 'sig', 'sigsum', 'status', 'validity']
35 __all__ = ['data', 'event', 'import', 'keysign', 'keylist', 'md', 'pk',
36 'protocol', 'sig', 'sigsum', 'status', 'tofu', 'validity', 'create']
3737
3838 # GPGME 1.7 replaced gpgme_op_edit with gpgme_op_interact. We
3939 # implement gpg.Context.op_edit using gpgme_op_interact, so the
0 # Flags for key creation
1 #
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 from gpg import util
23 util.process_constants('GPGME_CREATE_', globals())
24 del util
0 # Flags for key signing
1 #
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 from gpg import util
23 util.process_constants('GPGME_KEYSIGN_', globals())
24 del util
0 # TOFU
1 #
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 from . import policy
23 __all__ = ['policy']
0 # TOFU policies
1 #
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 from gpg import util
23 util.process_constants('GPGME_TOFU_POLICY_', globals())
24 del util
0 # Copyright (C) 2016 g10 Code GmbH
0 # Copyright (C) 2016-2017 g10 Code GmbH
11 # Copyright (C) 2004,2008 Igor Belyi <belyi@users.sourceforge.net>
22 # Copyright (C) 2002 John Goerzen <jgoerzen@complete.org>
33 #
175175 def __init__(self, armor=False, textmode=False, offline=False,
176176 signers=[], pinentry_mode=constants.PINENTRY_MODE_DEFAULT,
177177 protocol=constants.PROTOCOL_OpenPGP,
178 wrapped=None):
178 wrapped=None, home_dir=None):
179179 """Construct a context object
180180
181181 Keyword arguments:
185185 signers -- list of keys used for signing (default [])
186186 pinentry_mode -- pinentry mode (default PINENTRY_MODE_DEFAULT)
187187 protocol -- protocol to use (default PROTOCOL_OpenPGP)
188 home_dir -- state directory (default is the engine default)
188189
189190 """
190191 if wrapped:
202203 self.signers = signers
203204 self.pinentry_mode = pinentry_mode
204205 self.protocol = protocol
206 self.home_dir = home_dir
207
208 def __repr__(self):
209 return (
210 "Context(armor={0.armor}, "
211 "textmode={0.textmode}, offline={0.offline}, "
212 "signers={0.signers}, pinentry_mode={0.pinentry_mode}, "
213 "protocol={0.protocol}, home_dir={0.home_dir}"
214 ")").format(self)
205215
206216 def encrypt(self, plaintext, recipients=[], sign=True, sink=None,
207217 passphrase=None, always_trust=False, add_encrypt_to=False,
472482 plainbytes = data.read()
473483 return plainbytes, result
474484
475 def keylist(self, pattern=None, secret=False):
485 def keylist(self, pattern=None, secret=False,
486 mode=constants.keylist.mode.LOCAL,
487 source=None):
476488 """List keys
477489
478490 Keyword arguments:
479491 pattern -- return keys matching pattern (default: all keys)
480 secret -- return only secret keys
492 secret -- return only secret keys (default: False)
493 mode -- keylist mode (default: list local keys)
494 source -- read keys from source instead from the keyring
495 (all other options are ignored in this case)
481496
482497 Returns:
483498 -- an iterator returning key objects
485500 Raises:
486501 GPGMEError -- as signaled by the underlying library
487502 """
488 return self.op_keylist_all(pattern, secret)
503 if not source:
504 self.set_keylist_mode(mode)
505 self.op_keylist_start(pattern, secret)
506 else:
507 # Automatic wrapping of SOURCE is not possible here,
508 # because the object must not be deallocated until the
509 # iteration over the results ends.
510 if not isinstance(source, Data):
511 source = Data(file=source)
512 self.op_keylist_from_data_start(source, 0)
513
514 key = self.op_keylist_next()
515 while key:
516 yield key
517 key = self.op_keylist_next()
518 self.op_keylist_end()
519
520 def create_key(self, userid, algorithm=None, expires_in=0, expires=True,
521 sign=False, encrypt=False, certify=False, authenticate=False,
522 passphrase=None, force=False):
523 """Create a primary key
524
525 Create a primary key for the user id USERID.
526
527 ALGORITHM may be used to specify the public key encryption
528 algorithm for the new key. By default, a reasonable default
529 is chosen. You may use "future-default" to select an
530 algorithm that will be the default in a future implementation
531 of the engine. ALGORITHM may be a string like "rsa", or
532 "rsa2048" to explicitly request an algorithm and a key size.
533
534 EXPIRES_IN specifies the expiration time of the key in number
535 of seconds since the keys creation. By default, a reasonable
536 expiration time is chosen. If you want to create a key that
537 does not expire, use the keyword argument EXPIRES.
538
539 SIGN, ENCRYPT, CERTIFY, and AUTHENTICATE can be used to
540 request the capabilities of the new key. If you don't request
541 any, a reasonable set of capabilities is selected, and in case
542 of OpenPGP, a subkey with a reasonable set of capabilities is
543 created.
544
545 If PASSPHRASE is None (the default), then the key will not be
546 protected with a passphrase. If PASSPHRASE is a string, it
547 will be used to protect the key. If PASSPHRASE is True, the
548 passphrase must be supplied using a passphrase callback or
549 out-of-band with a pinentry.
550
551 Keyword arguments:
552 algorithm -- public key algorithm, see above (default: reasonable)
553 expires_in -- expiration time in seconds (default: reasonable)
554 expires -- whether or not the key should expire (default: True)
555 sign -- request the signing capability (see above)
556 encrypt -- request the encryption capability (see above)
557 certify -- request the certification capability (see above)
558 authenticate -- request the authentication capability (see above)
559 passphrase -- protect the key with a passphrase (default: no passphrase)
560 force -- force key creation even if a key with the same userid exists
561 (default: False)
562
563 Returns:
564 -- an object describing the result of the key creation
565
566 Raises:
567 GPGMEError -- as signaled by the underlying library
568
569 """
570 if util.is_a_string(passphrase):
571 old_pinentry_mode = self.pinentry_mode
572 old_passphrase_cb = getattr(self, '_passphrase_cb', None)
573 self.pinentry_mode = constants.PINENTRY_MODE_LOOPBACK
574 def passphrase_cb(hint, desc, prev_bad, hook=None):
575 return passphrase
576 self.set_passphrase_cb(passphrase_cb)
577
578 try:
579 self.op_createkey(userid, algorithm,
580 0, # reserved
581 expires_in,
582 None, # extrakey
583 ((constants.create.SIGN if sign else 0)
584 | (constants.create.ENCR if encrypt else 0)
585 | (constants.create.CERT if certify else 0)
586 | (constants.create.AUTH if authenticate else 0)
587 | (constants.create.NOPASSWD if passphrase == None else 0)
588 | (0 if expires else constants.create.NOEXPIRE)
589 | (constants.create.FORCE if force else 0)))
590 finally:
591 if util.is_a_string(passphrase):
592 self.pinentry_mode = old_pinentry_mode
593 if old_passphrase_cb:
594 self.set_passphrase_cb(*old_passphrase_cb[1:])
595
596 return self.op_genkey_result()
597
598 def create_subkey(self, key, algorithm=None, expires_in=0, expires=True,
599 sign=False, encrypt=False, authenticate=False, passphrase=None):
600 """Create a subkey
601
602 Create a subkey for the given KEY. As subkeys are a concept
603 of OpenPGP, calling this is only valid for the OpenPGP
604 protocol.
605
606 ALGORITHM may be used to specify the public key encryption
607 algorithm for the new subkey. By default, a reasonable
608 default is chosen. You may use "future-default" to select an
609 algorithm that will be the default in a future implementation
610 of the engine. ALGORITHM may be a string like "rsa", or
611 "rsa2048" to explicitly request an algorithm and a key size.
612
613 EXPIRES_IN specifies the expiration time of the subkey in
614 number of seconds since the subkeys creation. By default, a
615 reasonable expiration time is chosen. If you want to create a
616 subkey that does not expire, use the keyword argument EXPIRES.
617
618 SIGN, ENCRYPT, and AUTHENTICATE can be used to request the
619 capabilities of the new subkey. If you don't request any, an
620 encryption subkey is generated.
621
622 If PASSPHRASE is None (the default), then the subkey will not
623 be protected with a passphrase. If PASSPHRASE is a string, it
624 will be used to protect the subkey. If PASSPHRASE is True,
625 the passphrase must be supplied using a passphrase callback or
626 out-of-band with a pinentry.
627
628 Keyword arguments:
629 algorithm -- public key algorithm, see above (default: reasonable)
630 expires_in -- expiration time in seconds (default: reasonable)
631 expires -- whether or not the subkey should expire (default: True)
632 sign -- request the signing capability (see above)
633 encrypt -- request the encryption capability (see above)
634 authenticate -- request the authentication capability (see above)
635 passphrase -- protect the subkey with a passphrase (default: no passphrase)
636
637 Returns:
638 -- an object describing the result of the subkey creation
639
640 Raises:
641 GPGMEError -- as signaled by the underlying library
642
643 """
644 if util.is_a_string(passphrase):
645 old_pinentry_mode = self.pinentry_mode
646 old_passphrase_cb = getattr(self, '_passphrase_cb', None)
647 self.pinentry_mode = constants.PINENTRY_MODE_LOOPBACK
648 def passphrase_cb(hint, desc, prev_bad, hook=None):
649 return passphrase
650 self.set_passphrase_cb(passphrase_cb)
651
652 try:
653 self.op_createsubkey(key, algorithm,
654 0, # reserved
655 expires_in,
656 ((constants.create.SIGN if sign else 0)
657 | (constants.create.ENCR if encrypt else 0)
658 | (constants.create.AUTH if authenticate else 0)
659 | (constants.create.NOPASSWD
660 if passphrase == None else 0)
661 | (0 if expires else constants.create.NOEXPIRE)))
662 finally:
663 if util.is_a_string(passphrase):
664 self.pinentry_mode = old_pinentry_mode
665 if old_passphrase_cb:
666 self.set_passphrase_cb(*old_passphrase_cb[1:])
667
668 return self.op_genkey_result()
669
670 def key_add_uid(self, key, uid):
671 """Add a UID
672
673 Add the uid UID to the given KEY. Calling this function is
674 only valid for the OpenPGP protocol.
675
676 Raises:
677 GPGMEError -- as signaled by the underlying library
678
679 """
680 self.op_adduid(key, uid, 0)
681
682 def key_revoke_uid(self, key, uid):
683 """Revoke a UID
684
685 Revoke the uid UID from the given KEY. Calling this function
686 is only valid for the OpenPGP protocol.
687
688 Raises:
689 GPGMEError -- as signaled by the underlying library
690
691 """
692 self.op_revuid(key, uid, 0)
693
694 def key_sign(self, key, uids=None, expires_in=False, local=False):
695 """Sign a key
696
697 Sign a key with the current set of signing keys. Calling this
698 function is only valid for the OpenPGP protocol.
699
700 If UIDS is None (the default), then all UIDs are signed. If
701 it is a string, then only the matching UID is signed. If it
702 is a list of strings, then all matching UIDs are signed. Note
703 that a case-sensitive exact string comparison is done.
704
705 EXPIRES_IN specifies the expiration time of the signature in
706 seconds. If EXPIRES_IN is False, the signature does not
707 expire.
708
709 Keyword arguments:
710 uids -- user ids to sign, see above (default: sign all)
711 expires_in -- validity period of the signature in seconds
712 (default: do not expire)
713 local -- create a local, non-exportable signature
714 (default: False)
715
716 Raises:
717 GPGMEError -- as signaled by the underlying library
718
719 """
720 flags = 0
721 if uids == None or util.is_a_string(uids):
722 pass#through unchanged
723 else:
724 flags |= constants.keysign.LFSEP
725 uids = "\n".join(uids)
726
727 if not expires_in:
728 flags |= constants.keysign.NOEXPIRE
729
730 if local:
731 flags |= constants.keysign.LOCAL
732
733 self.op_keysign(key, uids, expires_in, flags)
734
735 def key_tofu_policy(self, key, policy):
736 """Set a keys' TOFU policy
737
738 Set the TOFU policy associated with KEY to POLICY. Calling
739 this function is only valid for the OpenPGP protocol.
740
741 Raises:
742 GPGMEError -- as signaled by the underlying library
743
744 """
745 self.op_tofu_policy(key, policy)
489746
490747 def assuan_transact(self, command,
491748 data_cb=None, inquire_cb=None, status_cb=None):
511768
512769 """
513770
514 if isinstance(command, (str, bytes)):
771 if util.is_a_string(command) or isinstance(command, bytes):
515772 cmd = command
516773 else:
517774 cmd = " ".join(util.percent_escape(f) for f in command)
601858 errorcheck(gpgme.gpgme_engine_check_version(value))
602859 self.set_protocol(value)
603860
861 @property
862 def home_dir(self):
863 """Engine's home directory"""
864 return self.engine_info.home_dir
865 @home_dir.setter
866 def home_dir(self, value):
867 self.set_engine_info(self.protocol, home_dir=value)
868
604869 _ctype = 'gpgme_ctx_t'
605870 _cprefix = 'gpgme_'
606871
607872 def _errorcheck(self, name):
608873 """This function should list all functions returning gpgme_error_t"""
874 # The list of functions is created using:
875 #
876 # $ grep '^gpgme_error_t ' obj/lang/python/python3.5-gpg/gpgme.h \
877 # | grep -v _op_ | awk "/\(gpgme_ctx/ { printf (\"'%s',\\n\", \$2) } "
609878 return ((name.startswith('gpgme_op_')
610879 and not name.endswith('_result'))
611880 or name in {
881 'gpgme_new',
612882 'gpgme_set_ctx_flag',
613883 'gpgme_set_protocol',
614884 'gpgme_set_sub_protocol',
615885 'gpgme_set_keylist_mode',
616886 'gpgme_set_pinentry_mode',
617887 'gpgme_set_locale',
618 'gpgme_set_engine_info',
888 'gpgme_ctx_set_engine_info',
619889 'gpgme_signers_add',
620 'gpgme_get_sig_key',
621890 'gpgme_sig_notation_add',
891 'gpgme_set_sender',
622892 'gpgme_cancel',
623893 'gpgme_cancel_async',
624 'gpgme_cancel_get_key',
894 'gpgme_get_key',
625895 })
626896
627897 _boolean_properties = {'armor', 'textmode', 'offline'}
8281098 home_dir -- configuration directory (unchanged if None)
8291099
8301100 """
831 errorcheck(gpgme.gpgme_ctx_set_engine_info(
832 self.wrapped, proto, file_name, home_dir))
1101 self.ctx_set_engine_info(proto, file_name, home_dir)
8331102
8341103 def wait(self, hang):
8351104 """Wait for asynchronous call to finish. Wait forever if hang is True.
8831152
8841153 def _errorcheck(self, name):
8851154 """This function should list all functions returning gpgme_error_t"""
1155 # This list is compiled using
1156 #
1157 # $ grep -v '^gpgme_error_t ' obj/lang/python/python3.5-gpg/gpgme.h \
1158 # | awk "/\(gpgme_data_t/ { printf (\"'%s',\\n\", \$2) } " | sed "s/'\\*/'/"
8861159 return name not in {
1160 'gpgme_data_read',
1161 'gpgme_data_write',
1162 'gpgme_data_seek',
1163 'gpgme_data_release',
8871164 'gpgme_data_release_and_get_mem',
8881165 'gpgme_data_get_encoding',
889 'gpgme_data_seek',
8901166 'gpgme_data_get_file_name',
1167 'gpgme_data_identify',
8911168 }
8921169
8931170 def __init__(self, string=None, file=None, offset=None,
10961373 chunks.append(result)
10971374 return b''.join(chunks)
10981375
1376 def pubkey_algo_string(subkey):
1377 """Return short algorithm string
1378
1379 Return a public key algorithm string (e.g. "rsa2048") for a given
1380 SUBKEY.
1381
1382 Returns:
1383 algo - a string
1384
1385 """
1386 return gpgme.gpgme_pubkey_algo_string(subkey)
1387
10991388 def pubkey_algo_name(algo):
1389 """Return name of public key algorithm
1390
1391 Return the name of the public key algorithm for a given numeric
1392 algorithm id ALGO (cf. RFC4880).
1393
1394 Returns:
1395 algo - a string
1396
1397 """
11001398 return gpgme.gpgme_pubkey_algo_name(algo)
11011399
11021400 def hash_algo_name(algo):
1401 """Return name of hash algorithm
1402
1403 Return the name of the hash algorithm for a given numeric
1404 algorithm id ALGO (cf. RFC4880).
1405
1406 Returns:
1407 algo - a string
1408
1409 """
11031410 return gpgme.gpgme_hash_algo_name(algo)
11041411
11051412 def get_protocol_name(proto):
1413 """Get protocol description
1414
1415 Get the string describing protocol PROTO.
1416
1417 Returns:
1418 proto - a string
1419
1420 """
11061421 return gpgme.gpgme_get_protocol_name(proto)
1422
1423 def addrspec_from_uid(uid):
1424 """Return the address spec
1425
1426 Return the addr-spec (cf. RFC2822 section 4.3) from a user id UID.
1427
1428 Returns:
1429 addr_spec - a string
1430
1431 """
1432 return gpgme.gpgme_addrspec_from_uid(uid)
11071433
11081434 def check_version(version=None):
11091435 return gpgme.gpgme_check_version(version)
6363
6464 setattr(self, key, getattr(fragile, key))
6565
66 def __str__(self):
67 return '<{} {}>'.format(
66 def __repr__(self):
67 return '{}({})'.format(
6868 self.__class__.__name__,
69 ', '.join('{}: {}'.format(k, getattr(self, k))
69 ', '.join('{}={!r}'.format(k, getattr(self, k))
7070 for k in dir(self) if not k.startswith('_')))
7171
7272 class InvalidKey(Result):
110110 }
111111
112112 /* Release returned buffers as necessary. */
113 %typemap(newfree) char * "free($1);";
113 %typemap(newfree) char * "gpgme_free($1);";
114114 %newobject gpgme_data_release_and_get_mem;
115 %newobject gpgme_pubkey_algo_string;
116 %newobject gpgme_addrspec_from_uid;
115117
116118 %typemap(arginit) gpgme_key_t [] {
117119 $1 = NULL;
134136
135137 /* Following code is from swig's python.swg. */
136138 if ((SWIG_ConvertPtr(pypointer,(void **) &$1[i], $*1_descriptor,SWIG_POINTER_EXCEPTION | $disown )) == -1) {
137 Py_DECREF(pypointer);
139 Py_DECREF(pypointer);
140 PyErr_Format(PyExc_TypeError,
141 "arg %d: list must contain only gpgme_key_ts, got %s "
142 "at position %d",
143 $argnum, pypointer->ob_type->tp_name, i);
144 free($1);
138145 return NULL;
139146 }
140147 Py_DECREF(pypointer);
286293 gpgme_data_t sig, gpgme_data_t signed_text,
287294 gpgme_data_t plaintext, gpgme_data_t keydata,
288295 gpgme_data_t pubkey, gpgme_data_t seckey,
289 gpgme_data_t out};
296 gpgme_data_t out, gpgme_data_t data};
290297
291298 /* SWIG has problems interpreting ssize_t, off_t or gpgme_error_t in
292299 gpgme.h. */
423430
424431
425432 /* Wrap the fragile result objects into robust Python ones. */
426 %typemap(out) gpgme_encrypt_result_t {
433 %define wrapresult(cls, name)
434 %typemap(out) cls {
427435 PyObject *fragile;
428436 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
429437 %newpointer_flags);
430 $result = _gpg_wrap_result(fragile, "EncryptResult");
438 $result = _gpg_wrap_result(fragile, name);
431439 Py_DECREF(fragile);
432440 }
433
434 %typemap(out) gpgme_decrypt_result_t {
435 PyObject *fragile;
436 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
437 %newpointer_flags);
438 $result = _gpg_wrap_result(fragile, "DecryptResult");
439 Py_DECREF(fragile);
440 }
441
442 %typemap(out) gpgme_sign_result_t {
443 PyObject *fragile;
444 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
445 %newpointer_flags);
446 $result = _gpg_wrap_result(fragile, "SignResult");
447 Py_DECREF(fragile);
448 }
449
450 %typemap(out) gpgme_verify_result_t {
451 PyObject *fragile;
452 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
453 %newpointer_flags);
454 $result = _gpg_wrap_result(fragile, "VerifyResult");
455 Py_DECREF(fragile);
456 }
457
458 %typemap(out) gpgme_import_result_t {
459 PyObject *fragile;
460 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
461 %newpointer_flags);
462 $result = _gpg_wrap_result(fragile, "ImportResult");
463 Py_DECREF(fragile);
464 }
465
466 %typemap(out) gpgme_genkey_result_t {
467 PyObject *fragile;
468 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
469 %newpointer_flags);
470 $result = _gpg_wrap_result(fragile, "GenkeyResult");
471 Py_DECREF(fragile);
472 }
473
474 %typemap(out) gpgme_keylist_result_t {
475 PyObject *fragile;
476 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
477 %newpointer_flags);
478 $result = _gpg_wrap_result(fragile, "KeylistResult");
479 Py_DECREF(fragile);
480 }
481
482 %typemap(out) gpgme_vfs_mount_result_t {
483 PyObject *fragile;
484 fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
485 %newpointer_flags);
486 $result = _gpg_wrap_result(fragile, "VFSMountResult");
487 Py_DECREF(fragile);
488 }
441 %enddef
442
443 wrapresult(gpgme_encrypt_result_t, "EncryptResult")
444 wrapresult(gpgme_decrypt_result_t, "DecryptResult")
445 wrapresult(gpgme_sign_result_t, "SignResult")
446 wrapresult(gpgme_verify_result_t, "VerifyResult")
447 wrapresult(gpgme_import_result_t, "ImportResult")
448 wrapresult(gpgme_genkey_result_t, "GenkeyResult")
449 wrapresult(gpgme_keylist_result_t, "KeylistResult")
450 wrapresult(gpgme_vfs_mount_result_t, "VFSMountResult")
489451
490452 %typemap(out) gpgme_engine_info_t {
491453 int i;
585547 }
586548 }
587549
550
551 /* With SWIG, you can define default arguments for parameters.
552 * While it's legal in C++ it is not in C, so we cannot change the
553 * already existing gpgme.h. We need, however, to declare the function
554 * *before* SWIG loads it from gpgme.h. Hence, we define it here. */
555 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx,
556 const char *pattern="",
557 int secret_only=0);
558
588559 /* Include the unmodified <gpgme.h> for cc, and the cleaned-up local
589560 version for SWIG. We do, however, want to hide certain fields on
590561 some structs, which we provide prior to including the version for
655626 PyObject *
656627 _gpg_wrap_gpgme_data_t(gpgme_data_t data)
657628 {
658 return SWIG_Python_NewPointerObj(NULL, data, SWIGTYPE_p_gpgme_data, 0);
629 /*
630 * If SWIG is invoked without -builtin, the macro SWIG_NewPointerObj
631 * expects a variable named "self".
632 *
633 * XXX: It is not quite clear why passing NULL as self is okay, but
634 * it works with -builtin, and it seems to work just fine without
635 * it too.
636 */
637 PyObject* self = NULL;
638 (void) self;
639 return SWIG_NewPointerObj(data, SWIGTYPE_p_gpgme_data, 0);
659640 }
660641
661642 gpgme_ctx_t
674655 /* ... but only the public definitions here. They will be exposed to
675656 the Python world, so let's be careful. */
676657 %include "helpers.h"
658
659
660 %define genericrepr(cls)
661 %pythoncode %{
662 def __repr__(self):
663 names = [name for name in dir(self)
664 if not name.startswith("_") and name != "this"]
665 props = ", ".join(("{}={!r}".format(name, getattr(self, name))
666 for name in names)
667 )
668 return "cls({})".format(props)
669 %}
670
671 %enddef
672
673 %extend _gpgme_key {
674 genericrepr(Key)
675 };
676
677
678 %extend _gpgme_subkey {
679 genericrepr(SubKey)
680 };
681
682 %extend _gpgme_key_sig {
683 genericrepr(KeySig)
684 };
685
686 %extend _gpgme_user_id {
687 genericrepr(UID)
688 };
689
690 %extend _gpgme_tofu_info {
691 genericrepr(TofuInfo)
692 };
292292 return _gpg_obj2gpgme_t(data, "gpgme_data_t", argnum);
293293
294294 return PyErr_Format(PyExc_TypeError,
295 "arg %d: expected gpg.Data, file, or an object "
296 "implementing the buffer protocol, got %s",
295 "arg %d: expected gpg.Data, file, "
296 "bytes (not string!), or an object "
297 "implementing the buffer protocol. Got: %s. "
298 "If you provided a string, try to encode() it.",
297299 argnum, data->ob_type->tp_name);
298300 }
299301
374376 goto leave;
375377 }
376378
377 PyTuple_SetItem(args, 1, PyBytes_FromString(passphrase_info));
379 if (passphrase_info == NULL)
380 {
381 Py_INCREF(Py_None);
382 PyTuple_SetItem(args, 1, Py_None);
383 }
384 else
385 PyTuple_SetItem(args, 1, PyUnicode_DecodeUTF8(passphrase_info,
386 strlen (passphrase_info),
387 "strict"));
388 if (PyErr_Occurred()) {
389 Py_DECREF(args);
390 err_status = gpg_error(GPG_ERR_GENERAL);
391 goto leave;
392 }
393
378394 PyTuple_SetItem(args, 2, PyBool_FromLong((long)prev_was_bad));
379395 if (dataarg) {
380396 Py_INCREF(dataarg); /* Because GetItem doesn't give a ref but SetItem taketh away */
3333 extra_swig_opts = []
3434 extra_macros = dict()
3535
36 if os.path.exists("../../src/gpgme-config"):
36 if os.path.exists("../../../src/gpgme-config"):
3737 # In-tree build.
3838 in_tree = True
39 gpgme_config = ["../../src/gpgme-config"] + gpgme_config_flags
40 gpgme_h = "../../src/gpgme.h"
41 library_dirs = ["../../src/.libs"] # XXX uses libtool internals
39 gpgme_config = ["../../../src/gpgme-config"] + gpgme_config_flags
40 gpgme_h = "../../../src/gpgme.h"
41 library_dirs = ["../../../src/.libs"] # XXX uses libtool internals
4242 extra_macros.update(
4343 HAVE_CONFIG_H=1,
4444 HAVE_DATA_H=1,
151151 self.run_command('build_ext')
152152 build.run(self)
153153
154 py3 = [] if sys.version_info.major < 3 else ['-py3']
154155 swige = Extension("gpg._gpgme", ["gpgme.i", "helpers.c"],
155 swig_opts = ['-py3', '-builtin', '-threads',
156 '-outdir', 'gpg'] + extra_swig_opts,
156 swig_opts = ['-threads',
157 '-outdir', 'gpg'] + py3 + extra_swig_opts,
157158 include_dirs = include_dirs,
158159 define_macros = define_macros,
159160 library_dirs = library_dirs,
170171 url='https://www.gnupg.org',
171172 ext_modules=[swige],
172173 packages = ['gpg', 'gpg.constants', 'gpg.constants.data',
173 'gpg.constants.keylist', 'gpg.constants.sig'],
174 'gpg.constants.keylist', 'gpg.constants.sig',
175 'gpg.constants.tofu'],
174176 license="LGPL2.1+ (the library), GPL2+ (tests and examples)",
175177 classifiers=[
176178 'Development Status :: 4 - Beta',
4545 t-trustlist.py \
4646 t-edit.py \
4747 t-keylist.py \
48 t-keylist-from-data.py \
4849 t-wait.py \
4950 t-encrypt-large.py \
5051 t-file-name.py \
5152 t-idiomatic.py \
52 t-protocol-assuan.py
53 t-protocol-assuan.py \
54 t-quick-key-creation.py \
55 t-quick-subkey-creation.py \
56 t-quick-key-manipulation.py \
57 t-quick-key-signing.py
5358
5459 XTESTS = initial.py $(py_tests) final.py
5560 EXTRA_DIST = support.py $(XTESTS) encrypt-only.asc sign-only.asc \
7277
7378 CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \
7479 gpg-agent.conf pubring.kbx~ gpg.conf pubring.gpg~ \
75 random_seed .gpg-v21-migrated \
80 random_seed .gpg-v21-migrated tofu.db \
7681 pubring-stamp private-keys-v1.d/gpg-sample.stamp
7782
7883 private_keys = \
106111 ./gpg.conf:
107112 # This is required for t-sig-notations.
108113 echo no-force-v3-sigs > ./gpg.conf
114 echo ignore-invalid-option agent-program >> ./gpg.conf
115 echo "agent-program `which $(GPG_AGENT)`|--debug-quick-random" >> ./gpg.conf
109116
110117 ./gpg-agent.conf:
111118 # This is required for gpg2, which does not support command fd.
112119 echo pinentry-program $(abs_top_srcdir)/tests/gpg/pinentry >$@
113 echo allow-loopback-pinentry >>$@
2323 import subprocess
2424 import gpg
2525 import support
26 support.init_gpgme(gpg.constants.protocol.OpenPGP)
26
27 print("Using gpg module from {0!r}.".format(os.path.dirname(gpg.__file__)))
2728
2829 subprocess.check_call([os.path.join(os.getenv('top_srcdir'),
2930 "tests", "start-stop-agent"), "--start"])
3838 help='A test to run')
3939 parser.add_argument('-v', '--verbose', action="store_true", default=False,
4040 help='Be verbose.')
41 parser.add_argument('-q', '--quiet', action="store_true", default=False,
42 help='Be quiet.')
4143 parser.add_argument('--interpreters', metavar='PYTHON', type=str,
4244 default=[], action=SplitAndAccumulate,
4345 help='Use these interpreters to run the tests, ' +
4850 parser.add_argument('--builddir', type=str,
4951 default=os.environ.get("abs_builddir", ""),
5052 help='Location of the tests.')
53 parser.add_argument('--parallel', action="store_true", default=False,
54 help='Ignored. For compatibility with run-tests.scm.')
5155
5256 args = parser.parse_args()
5357 if not args.interpreters:
6468 version = subprocess.check_output(
6569 [interpreter, "-c", "import sys; print('{0}.{1}'.format(sys.version_info[0], sys.version_info[1]))"]).strip().decode()
6670
67 builddirs = glob.glob(os.path.join(args.builddir, "..", "build",
68 "lib*"+version))
69 assert len(builddirs) == 1, \
70 "Expected one build directory, got {0}".format(builddirs)
71 pattern = os.path.join(args.builddir, "..",
72 "python{0}-gpg".format(version),
73 "build",
74 "lib*"+version)
75 builddirs = glob.glob(pattern)
76 if len(builddirs) == 0:
77 sys.exit("Build directory matching {0!r} not found.".format(pattern))
78 elif len(builddirs) > 1:
79 sys.exit("Multiple build directories matching {0!r} found: {1}".format(
80 pattern, builddirs))
81
7182 env = dict(os.environ)
7283 env["PYTHONPATH"] = builddirs[0]
7384
74 print("Running tests using {0} ({1})...".format(interpreter, version))
85 if not args.quiet:
86 print("Running tests using {0} ({1})...".format(interpreter, version))
87
7588 for test in args.tests:
7689 status = subprocess.call(
7790 [interpreter, os.path.join(args.srcdir, test)],
7891 env=env, stdout=out, stderr=err)
79 print("{0}: {1}".format(status_to_str(status), test))
92 if not args.quiet:
93 print("{0}: {1}".format(status_to_str(status), test))
8094 results.append(status)
8195
8296 def count(status):
8498 def failed():
8599 return len(list(filter(lambda x: x not in (0, 77, 99), results)))
86100
87 print("{0} tests run, {1} succeeded, {2} failed, {3} skipped.".format(
88 len(results), count(0), failed(), count(77)))
89 sys.exit(len(results) - count(0))
101 if not args.quiet:
102 print("{0} tests run, {1} succeeded, {2} failed, {3} skipped.".format(
103 len(results), count(0), failed(), count(77)))
104 sys.exit(len(results) - count(0))
105 sys.exit(results[0])
1717 from __future__ import absolute_import, print_function, unicode_literals
1818 del absolute_import, print_function, unicode_literals
1919
20 import contextlib
21 import shutil
2022 import sys
2123 import os
24 import re
25 import tempfile
26 import time
2227 import gpg
28
29 def assert_gpg_version(version=(2, 1, 0)):
30 with gpg.Context() as c:
31 clean_version = re.match(r'\d+\.\d+\.\d+', c.engine_info.version).group(0)
32 if tuple(map(int, clean_version.split('.'))) < version:
33 print("GnuPG too old: have {0}, need {1}.".format(
34 c.engine_info.version, '.'.join(map(str, version))))
35 sys.exit(77)
36
37 # Skip the Python tests for GnuPG < 2.1.12. Prior versions do not
38 # understand the command line flags that we assume exist. C.f. issue
39 # 3008.
40 assert_gpg_version((2, 1, 12))
2341
2442 # known keys
2543 alpha = "A0FF4590BB6122EDEF6E3C542D727CC768697734"
3452 def in_srcdir(name):
3553 return os.path.join(os.environ['srcdir'], name)
3654
37 def init_gpgme(proto):
38 gpg.core.engine_check_version(proto)
39
4055 verbose = int(os.environ.get('verbose', 0)) > 1
4156 def print_data(data):
4257 if verbose:
4762 except:
4863 # Hope for the best.
4964 pass
50 sys.stdout.buffer.write(data)
65
66 if hasattr(sys.stdout, "buffer"):
67 sys.stdout.buffer.write(data)
68 else:
69 sys.stdout.write(data)
5170
5271 def mark_key_trusted(ctx, key):
5372 class Editor(object):
6786 return result
6887 with gpg.Data() as sink:
6988 ctx.op_edit(key, Editor().edit, sink, sink)
89
90
91 # Python3.2 and up has tempfile.TemporaryDirectory, but we cannot use
92 # that, because there shutil.rmtree is used without
93 # ignore_errors=True, and that races against gpg-agent deleting its
94 # sockets.
95 class TemporaryDirectory(object):
96 def __enter__(self):
97 self.path = tempfile.mkdtemp()
98 return self.path
99 def __exit__(self, *args):
100 shutil.rmtree(self.path, ignore_errors=True)
101
102 @contextlib.contextmanager
103 def EphemeralContext():
104 with TemporaryDirectory() as tmp:
105 home = os.environ['GNUPGHOME']
106 shutil.copy(os.path.join(home, "gpg.conf"), tmp)
107 shutil.copy(os.path.join(home, "gpg-agent.conf"), tmp)
108
109 with gpg.Context(home_dir=tmp) as ctx:
110 yield ctx
111
112 # Ask the agent to quit.
113 agent_socket = os.path.join(tmp, "S.gpg-agent")
114 ctx.protocol = gpg.constants.protocol.ASSUAN
115 ctx.set_engine_info(ctx.protocol, file_name=agent_socket)
116 try:
117 ctx.assuan_transact(["KILLAGENT"])
118 except gpg.errors.GPGMEError as e:
119 if e.getcode() == gpg.errors.ASS_CONNECT_FAILED:
120 pass # the agent was not running
121 else:
122 raise
123
124 # Block until it is really gone.
125 while os.path.exists(agent_socket):
126 time.sleep(.01)
2323 import gpg
2424 import support
2525
26 support.init_gpgme(gpg.constants.protocol.OpenPGP)
26 support.assert_gpg_version()
2727
2828 c = gpg.Context()
2929 c.set_pinentry_mode(gpg.constants.PINENTRY_MODE_LOOPBACK)
3333 assert sig.validity == gpg.constants.validity.FULL
3434 assert gpg.errors.GPGMEError(sig.validity_reason).getcode() == gpg.errors.NO_ERROR
3535
36 support.init_gpgme(gpg.constants.protocol.OpenPGP)
3736 c = gpg.Context()
3837
3938 source = gpg.Data(file=support.make_filename("cipher-2.asc"))
2222 import gpg
2323 import support
2424
25 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2625 c = gpg.Context()
2726
2827 source = gpg.Data(file=support.make_filename("cipher-1.asc"))
2525 import gpg
2626 import support
2727
28 support.assert_gpg_version()
29
2830 class KeyEditor(object):
2931 def __init__(self):
3032 self.steps = ["fpr", "expire", "1", "primary", "quit"]
5052
5153 return result
5254
53 support.init_gpgme(gpg.constants.protocol.OpenPGP)
54
5555 c = gpg.Context()
5656 c.set_pinentry_mode(gpg.constants.PINENTRY_MODE_LOOPBACK)
5757 c.set_passphrase_cb(lambda *args: "abc")
2929 else:
3030 nbytes = 100000
3131
32 support.init_gpgme(gpg.constants.protocol.OpenPGP)
3332 c = gpg.Context()
3433
3534 ntoread = nbytes
2323 import gpg
2424 import support
2525
26 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2726 c = gpg.Context()
2827 c.set_armor(True)
2928
2323 import gpg
2424 import support
2525
26 support.init_gpgme(gpg.constants.protocol.OpenPGP)
26 support.assert_gpg_version()
2727
2828 for passphrase in ("abc", b"abc"):
2929 c = gpg.Context()
2222 import gpg
2323 import support
2424
25 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2625 c = gpg.Context()
2726 c.set_armor(True)
2827
6160 assert support.sign_only.endswith(e.recipients[0].fpr)
6261 else:
6362 assert False, "Expected an InvalidRecipients error, got none"
63
64
65
66 try:
67 # People might be tempted to provide strings.
68 # We should raise something useful.
69 ciphertext, _, _ = c.encrypt("Hallo Leute\n",
70 recipients=keys,
71 sign=False,
72 always_trust=True)
73 except TypeError as e:
74 # This test is a bit fragile, because the message
75 # may very well change. So if the behaviour will change
76 # this test can easily be deleted.
77 assert "encode" in str(e)
2222 import gpg
2323 import support
2424
25 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2625 c = gpg.Context()
2726 c.set_armor(True)
2827
2525
2626 testname = "abcde12345"
2727
28 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2928 c = gpg.Context()
3029 c.set_armor(True)
3130
2525 import tempfile
2626 import gpg
2727 import support
28
29 support.init_gpgme(gpg.constants.protocol.OpenPGP)
3028
3129 # Both Context and Data can be used as context manager:
3230 with gpg.Context() as c, gpg.Data() as d:
6666 assert len(result.imports) == 1 or fpr == result.imports[1].fpr
6767 assert result.imports[0].result == 0
6868
69 support.init_gpgme(gpg.constants.protocol.OpenPGP)
7069 c = gpg.Context()
7170
7271 c.op_import(gpg.Data(file=support.make_filename("pubkey-1.asc")))
0 #!/usr/bin/env python
1
2 # Copyright (C) 2016 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 import os
23 import sys
24 import gpg
25 import support
26
27 support.assert_gpg_version((2, 1, 14))
28
29 # Check expration of keys. This test assumes three subkeys of which
30 # 2 are expired; it is used with the "Whisky" test key. It has
31 # already been checked that these 3 subkeys are available.
32 def check_whisky(name, key):
33 sub1 = key.subkeys[2]
34 sub2 = key.subkeys[3]
35
36 assert sub1.expired and sub2.expired, \
37 "Subkey of `{}' not flagged as expired".format(name)
38 assert sub1.expires == 1129636886 and sub2.expires == 1129636939, \
39 "Subkey of `{}' has wrong expiration date".format(name)
40
41 keys = [
42 [ "A0FF4590BB6122EDEF6E3C542D727CC768697734", "6AE6D7EE46A871F8",
43 [ [ "Alfa Test", "demo key", "alfa@example.net" ],
44 [ "Alpha Test", "demo key", "alpha@example.net" ],
45 [ "Alice", "demo key", "" ] ], 1 ],
46 [ "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", "5381EA4EE29BA37F",
47 [ [ "Bob", "demo key", "" ],
48 [ "Bravo Test", "demo key", "bravo@example.net" ] ], 1 ],
49 [ "61EE841A2A27EB983B3B3C26413F4AF31AFDAB6C", "E71E72ACBC43DA60",
50 [ [ "Charlie Test", "demo key", "charlie@example.net" ] ], 1 ],
51 [ "6560C59C43D031C54D7C588EEBA9F240EB9DC9E6", "06F22880B0C45424",
52 [ [ "Delta Test", "demo key", "delta@example.net" ] ], 1 ],
53 [ "3531152DE293E26A07F504BC318C1FAEFAEF6D1B", "B5C79E1A7272144D",
54 [ [ "Echelon", "demo key", "" ],
55 [ "Echo Test", "demo key", "echo@example.net" ],
56 [ "Eve", "demo key", "" ] ], 1 ],
57 [ "56D33268F7FE693FBB594762D4BF57F37372E243", "0A32EE79EE45198E",
58 [ [ "Foxtrot Test", "demo key", "foxtrot@example.net" ] ], 1 ],
59 [ "C9C07DCC6621B9FB8D071B1D168410A48FC282E6", "247491CC9DCAD354",
60 [ [ "Golf Test", "demo key", "golf@example.net" ] ], 1 ],
61 [ "9E91CBB11E4D4135583EF90513DB965534C6E3F1", "76E26537D622AD0A",
62 [ [ "Hotel Test", "demo key", "hotel@example.net" ] ], 1 ],
63 [ "CD538D6CC9FB3D745ECDA5201FE8FC6F04259677", "C1C8EFDE61F76C73",
64 [ [ "India Test", "demo key", "india@example.net" ] ], 1 ],
65 [ "F8F1EDC73995AB739AD54B380C820C71D2699313", "BD0B108735F8F136",
66 [ [ "Juliet Test", "demo key", "juliet@example.net" ] ], 1 ],
67 [ "3FD11083779196C2ECDD9594AD1B0FAD43C2D0C7", "86CBB34A9AF64D02",
68 [ [ "Kilo Test", "demo key", "kilo@example.net" ] ], 1 ],
69 [ "1DDD28CEF714F5B03B8C246937CAB51FB79103F8", "0363B449FE56350C",
70 [ [ "Lima Test", "demo key", "lima@example.net" ] ], 1 ],
71 [ "2686AA191A278013992C72EBBE794852BE5CF886", "5F600A834F31EAE8",
72 [ [ "Mallory", "demo key", "" ],
73 [ "Mike Test", "demo key", "mike@example.net" ] ], 1 ],
74 [ "5AB9D6D7BAA1C95B3BAA3D9425B00FD430CEC684", "4C1D63308B70E472",
75 [ [ "November Test", "demo key", "november@example.net" ] ], 1 ],
76 [ "43929E89F8F79381678CAE515F6356BA6D9732AC", "FF0785712681619F",
77 [ [ "Oscar Test", "demo key", "oscar@example.net" ] ], 1 ],
78 [ "6FAA9C201E5E26DCBAEC39FD5D15E01D3FF13206", "2764E18263330D9C",
79 [ [ "Papa test", "demo key", "papa@example.net" ] ], 1 ],
80 [ "A7969DA1C3297AA96D49843F1C67EC133C661C84", "6CDCFC44A029ACF4",
81 [ [ "Quebec Test", "demo key", "quebec@example.net" ] ], 1 ],
82 [ "38FBE1E4BF6A5E1242C8F6A13BDBEDB1777FBED3", "9FAB805A11D102EA",
83 [ [ "Romeo Test", "demo key", "romeo@example.net" ] ], 1 ],
84 [ "045B2334ADD69FC221076841A5E67F7FA3AE3EA1", "93B88B0F0F1B50B4",
85 [ [ "Sierra Test", "demo key", "sierra@example.net" ] ], 1 ],
86 [ "ECAC774F4EEEB0620767044A58CB9A4C85A81F38", "97B60E01101C0402",
87 [ [ "Tango Test", "demo key", "tango@example.net" ] ], 1 ],
88 [ "0DBCAD3F08843B9557C6C4D4A94C0F75653244D6", "93079B915522BDB9",
89 [ [ "Uniform Test", "demo key", "uniform@example.net" ] ], 1 ],
90 [ "E8143C489C8D41124DC40D0B47AF4B6961F04784", "04071FB807287134",
91 [ [ "Victor Test", "demo key", "victor@example.org" ] ], 1 ],
92 [ "E8D6C90B683B0982BD557A99DEF0F7B8EC67DBDE", "D7FBB421FD6E27F6",
93 [ [ "Whisky Test", "demo key", "whisky@example.net" ] ], 3,
94 check_whisky ],
95 [ "04C1DF62EFA0EBB00519B06A8979A6C5567FB34A", "5CC6F87F41E408BE",
96 [ [ "XRay Test", "demo key", "xray@example.net" ] ], 1 ],
97 [ "ED9B316F78644A58D042655A9EEF34CD4B11B25F", "5ADFD255F7B080AD",
98 [ [ "Yankee Test", "demo key", "yankee@example.net" ] ], 1 ],
99 [ "23FD347A419429BACCD5E72D6BC4778054ACD246", "EF9DC276A172C881",
100 [ [ "Zulu Test", "demo key", "zulu@example.net" ] ], 1 ],
101 ]
102
103 def check_global(key, uids, n_subkeys):
104 assert not key.revoked, "Key unexpectedly revoked"
105 assert not key.expired, "Key unexpectedly expired"
106 assert not key.disabled, "Key unexpectedly disabled"
107 assert not key.invalid, "Key unexpectedly invalid"
108 assert key.can_sign, "Key unexpectedly unusable for signing"
109 assert key.can_certify, "Key unexpectedly unusable for certifications"
110 assert not key.secret, "Key unexpectedly secret"
111 assert not key.protocol != gpg.constants.protocol.OpenPGP, \
112 "Key has unexpected protocol: {}".format(key.protocol)
113 assert not key.issuer_serial, \
114 "Key unexpectedly carries issuer serial: {}".format(key.issuer_serial)
115 assert not key.issuer_name, \
116 "Key unexpectedly carries issuer name: {}".format(key.issuer_name)
117 assert not key.chain_id, \
118 "Key unexpectedly carries chain ID: {}".format(key.chain_id)
119 assert key.owner_trust == gpg.constants.validity.UNKNOWN, \
120 "Key has unexpected owner trust: {}".format(key.owner_trust)
121 assert len(key.subkeys) - 1 == n_subkeys, \
122 "Key `{}' has unexpected number of subkeys".format(uids[0][0])
123
124
125 def check_subkey(fpr, which, subkey):
126 assert not subkey.revoked, which + " key unexpectedly revoked"
127 assert not subkey.expired, which + " key unexpectedly expired"
128 assert not subkey.disabled, which + " key unexpectedly disabled"
129 assert not subkey.invalid, which + " key unexpectedly invalid"
130
131 if which == "Primary":
132 assert not subkey.can_encrypt, \
133 which + " key unexpectedly usable for encryption"
134 assert subkey.can_sign, \
135 which + " key unexpectedly unusable for signing"
136 assert subkey.can_certify, \
137 which + " key unexpectedly unusable for certifications"
138 else:
139 assert subkey.can_encrypt, \
140 which + " key unexpectedly unusable for encryption"
141 assert not subkey.can_sign, \
142 which + " key unexpectedly usable for signing"
143 assert not subkey.can_certify, \
144 which + " key unexpectedly usable for certifications"
145
146 assert not subkey.secret, which + " key unexpectedly secret"
147 assert not subkey.is_cardkey, "Public key marked as card key"
148 assert not subkey.card_number, "Public key with card number set"
149 assert not subkey.pubkey_algo != (gpg.constants.pk.DSA if which == "Primary"
150 else gpg.constants.pk.ELG_E), \
151 which + " key has unexpected public key algo: {}".\
152 format(subkey.pubkey_algo)
153 assert subkey.length == 1024, \
154 which + " key has unexpected length: {}".format(subkey.length)
155 assert fpr.endswith(subkey.keyid), \
156 which + " key has unexpected key ID: {}".format(subkey.keyid)
157 assert which == "Secondary" or subkey.fpr == fpr, \
158 which + " key has unexpected fingerprint: {}".format(subkey.fpr)
159 assert not subkey.expires, \
160 which + " key unexpectedly expires: {}".format(subkey.expires)
161
162 def check_uid(which, ref, uid):
163 assert not uid.revoked, which + " user ID unexpectedly revoked"
164 assert not uid.invalid, which + " user ID unexpectedly invalid"
165 assert uid.validity == gpg.constants.validity.UNKNOWN, \
166 which + " user ID has unexpected validity: {}".format(uid.validity)
167 assert not uid.signatures, which + " user ID unexpectedly signed"
168 assert uid.name == ref[0], \
169 "Unexpected name in {} user ID: {!r}".format(which.lower(), uid.name)
170 assert uid.comment == ref[1], \
171 "Unexpected comment in {} user ID: {!r}".format(which.lower(),
172 uid.comment)
173 assert uid.email == ref[2], \
174 "Unexpected email in {} user ID: {!r}".format(which.lower(), uid.email)
175
176 # Export all the data from our keyring...
177 key_data = gpg.Data()
178 with gpg.Context() as c:
179 c.op_export_keys([c.get_key(k[0]) for k in keys], 0, key_data)
180
181 # ... rewind the tape...
182 key_data.rewind()
183
184 # ... and feed it into a keylist in an empty context.
185 with support.EphemeralContext() as c:
186 for i, key in enumerate(c.keylist(source=key_data)):
187 try:
188 if len(keys[i]) == 4:
189 fpr, sec_keyid, uids, n_subkeys = keys[i]
190 misc_check = None
191 else:
192 fpr, sec_keyid, uids, n_subkeys, misc_check = keys[i]
193 except IndexError:
194 # There are more keys. We don't check for that.
195 break
196
197 # Global key flags.
198 check_global(key, uids, n_subkeys)
199 check_subkey(fpr, "Primary", key.subkeys[0])
200 check_subkey(sec_keyid, "Secondary", key.subkeys[1])
201
202 assert len(key.uids) == len(uids)
203 check_uid("First", uids[0], key.uids[0])
204 if len(key.uids) > 1:
205 check_uid("Second", uids[1], key.uids[1])
206 if len(key.uids) > 2:
207 check_uid("Third", uids[2], key.uids[2])
208
209 if misc_check:
210 misc_check (uids[0][0], key)
211
212 assert len(list(c.keylist())) == 0, "Keys were imported"
2222 import gpg
2323 import support
2424
25 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2625 c = gpg.Context()
2726
2827 # Check expration of keys. This test assumes three subkeys of which
218217 assert not result.truncated, "Key listing unexpectedly truncated"
219218
220219
220 # We test for a parameter-less keylist
221 keyring_length = len(list(c.op_keylist_all()))
222 assert keyring_length > 1,\
223 "Expected to find some keys, but got %r" % keyring_length
224
225 # Then we do want to call with a pattern, only
226 # i.e. without giving secret=0
227 alpha_keys = list(c.op_keylist_all(b"Alpha"))
228 assert len(alpha_keys) == 1, "Expected only one key for 'Alpha', got %r" % len(alpha_keys)
229
230
231
221232 for i, key in enumerate(c.keylist()):
222233 try:
223234 if len(keys[i]) == 4:
2323
2424 with gpg.Context(protocol=gpg.constants.protocol.ASSUAN) as c:
2525 # Do nothing.
26 c.assuan_transact('nop')
27 c.assuan_transact('NOP')
28 c.assuan_transact(['NOP'])
26 err = c.assuan_transact('nop')
27 assert err == None
28 err = c.assuan_transact(b'NOP')
29 assert err == None
30 err = c.assuan_transact(['NOP'])
31 assert err == None
2932
3033 err = c.assuan_transact('idontexist')
3134 assert err.getsource() == gpg.errors.SOURCE_GPGAGENT
0 #!/usr/bin/env python
1
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 import gpg
23 import itertools
24 import time
25
26 import support
27 support.assert_gpg_version((2, 1, 2))
28
29 alpha = "Alpha <alpha@invalid.example.net>"
30
31 with support.EphemeralContext() as ctx:
32 res = ctx.create_key(alpha)
33
34 keys = list(ctx.keylist())
35 assert len(keys) == 1, "Weird number of keys created"
36
37 key = keys[0]
38 assert key.fpr == res.fpr
39 assert len(key.subkeys) == 2, "Expected one primary key and one subkey"
40 assert key.subkeys[0].expires > 0, "Expected primary key to expire"
41
42 # Try to create a key with the same UID
43 try:
44 ctx.create_key(alpha)
45 assert False, "Expected an error but got none"
46 except gpg.errors.GpgError as e:
47 pass
48
49 # Try to create a key with the same UID, now with force!
50 res2 = ctx.create_key(alpha, force=True)
51 assert res.fpr != res2.fpr
52
53
54 # From here on, we use one context, and create unique UIDs
55 uid_counter = 0
56 def make_uid():
57 global uid_counter
58 uid_counter += 1
59 return "user{0}@invalid.example.org".format(uid_counter)
60
61 with support.EphemeralContext() as ctx:
62 # Check gpg.constants.create.NOEXPIRE...
63 res = ctx.create_key(make_uid(), expires=False)
64 key = ctx.get_key(res.fpr, secret=True)
65 assert key.fpr == res.fpr
66 assert len(key.subkeys) == 2, "Expected one primary key and one subkey"
67 assert key.subkeys[0].expires == 0, "Expected primary key not to expire"
68
69 t = 2 * 24 * 60 * 60
70 slack = 5 * 60
71 res = ctx.create_key(make_uid(), expires_in=t)
72 key = ctx.get_key(res.fpr, secret=True)
73 assert key.fpr == res.fpr
74 assert len(key.subkeys) == 2, "Expected one primary key and one subkey"
75 assert abs(time.time() + t - key.subkeys[0].expires) < slack, \
76 "Primary keys expiration time is off"
77
78 # Check capabilities
79 for sign, encrypt, certify, authenticate in itertools.product([False, True],
80 [False, True],
81 [False, True],
82 [False, True]):
83 # Filter some out
84 if not (sign or encrypt or certify or authenticate):
85 # This triggers the default capabilities tested before.
86 continue
87 if (sign or encrypt or authenticate) and not certify:
88 # The primary key always certifies.
89 continue
90
91 res = ctx.create_key(make_uid(), algorithm="rsa",
92 sign=sign, encrypt=encrypt, certify=certify,
93 authenticate=authenticate)
94 key = ctx.get_key(res.fpr, secret=True)
95 assert key.fpr == res.fpr
96 assert len(key.subkeys) == 1, \
97 "Expected no subkey for non-default capabilities"
98
99 p = key.subkeys[0]
100 assert sign == p.can_sign
101 assert encrypt == p.can_encrypt
102 assert certify == p.can_certify
103 assert authenticate == p.can_authenticate
104
105 # Check algorithm
106 res = ctx.create_key(make_uid(), algorithm="rsa")
107 key = ctx.get_key(res.fpr, secret=True)
108 assert key.fpr == res.fpr
109 for k in key.subkeys:
110 assert k.pubkey_algo == 1
111
112 # Check algorithm with size
113 res = ctx.create_key(make_uid(), algorithm="rsa1024")
114 key = ctx.get_key(res.fpr, secret=True)
115 assert key.fpr == res.fpr
116 for k in key.subkeys:
117 assert k.pubkey_algo == 1
118 assert k.length == 1024
119
120 # Check algorithm future-default
121 ctx.create_key(make_uid(), algorithm="future-default")
122
123 # Check passphrase protection
124 recipient = make_uid()
125 passphrase = "streng geheim"
126 res = ctx.create_key(recipient, passphrase=passphrase)
127 ciphertext, _, _ = ctx.encrypt(b"hello there", recipients=[ctx.get_key(res.fpr)])
128
129 cb_called = False
130 def cb(*args):
131 global cb_called
132 cb_called = True
133 return passphrase
134 ctx.pinentry_mode = gpg.constants.PINENTRY_MODE_LOOPBACK
135 ctx.set_passphrase_cb(cb)
136
137 plaintext, _, _ = ctx.decrypt(ciphertext)
138 assert plaintext == b"hello there"
139 assert cb_called
0 #!/usr/bin/env python
1
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 import os
23 import gpg
24
25 import support
26 support.assert_gpg_version((2, 1, 14))
27
28 alpha = "Alpha <alpha@invalid.example.net>"
29 bravo = "Bravo <bravo@invalid.example.net>"
30
31 with support.EphemeralContext() as ctx:
32 res = ctx.create_key(alpha, certify=True)
33 key = ctx.get_key(res.fpr)
34 assert len(key.subkeys) == 1, "Expected one primary key and no subkeys"
35 assert len(key.uids) == 1, "Expected exactly one UID"
36
37 def get_uid(uid):
38 key = ctx.get_key(res.fpr)
39 for u in key.uids:
40 if u.uid == uid:
41 return u
42 return None
43
44 # sanity check
45 uid = get_uid(alpha)
46 assert uid, "UID alpha not found"
47 assert uid.revoked == 0
48
49 # add bravo
50 ctx.key_add_uid(key, bravo)
51 uid = get_uid(bravo)
52 assert uid, "UID bravo not found"
53 assert uid.revoked == 0
54
55 # revoke alpha
56 ctx.key_revoke_uid(key, alpha)
57 uid = get_uid(alpha)
58 assert uid, "UID alpha not found"
59 assert uid.revoked == 1
60 uid = get_uid(bravo)
61 assert uid, "UID bravo not found"
62 assert uid.revoked == 0
63
64 # try to revoke the last UID
65 try:
66 ctx.key_revoke_uid(key, alpha)
67 # IMHO this should fail. issue2961.
68 # assert False, "Expected an error but got none"
69 except gpg.errors.GpgError:
70 pass
71
72 # Everything should be the same
73 uid = get_uid(alpha)
74 assert uid, "UID alpha not found"
75 assert uid.revoked == 1
76 uid = get_uid(bravo)
77 assert uid, "UID bravo not found"
78 assert uid.revoked == 0
79
80 # try to revoke a non-existent UID
81 try:
82 ctx.key_revoke_uid(key, "i dont exist")
83 # IMHO this should fail. issue2963.
84 # assert False, "Expected an error but got none"
85 except gpg.errors.GpgError:
86 pass
87
88 # try to add an pre-existent UID
89 try:
90 ctx.key_add_uid(key, bravo)
91 assert False, "Expected an error but got none"
92 except gpg.errors.GpgError:
93 pass
94
95 # Check setting the TOFU policy.
96 with open(os.path.join(ctx.home_dir, "gpg.conf"), "a") as handle:
97 handle.write("trust-model tofu+pgp\n")
98
99 for name, policy in [(name, getattr(gpg.constants.tofu.policy, name))
100 for name in filter(lambda x: not x.startswith('__'),
101 dir(gpg.constants.tofu.policy))]:
102 if policy == gpg.constants.tofu.policy.NONE:
103 # We must not set the policy to NONE.
104 continue
105
106 ctx.key_tofu_policy(key, policy)
107
108 keys = list(ctx.keylist(key.uids[0].uid,
109 mode=(gpg.constants.keylist.mode.LOCAL
110 |gpg.constants.keylist.mode.WITH_TOFU)))
111 assert len(keys) == 1
112
113 if policy == gpg.constants.tofu.policy.AUTO:
114 # We cannot check that it is set to AUTO.
115 continue
116
117 for uid in keys[0].uids:
118 if uid.uid == alpha:
119 # TOFU information of revoked UIDs is not updated.
120 # XXX: Is that expected?
121 continue
122 assert uid.tofu[0].policy == policy, \
123 "Expected policy {0} ({1}), got {2}".format(policy, name,
124 uid.tofu[0].policy)
0 #!/usr/bin/env python
1
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 import gpg
23 import itertools
24 import time
25
26 import support
27 support.assert_gpg_version((2, 1, 1))
28
29 with support.EphemeralContext() as ctx:
30 uid_counter = 0
31 def make_uid():
32 global uid_counter
33 uid_counter += 1
34 return "user{0}@invalid.example.org".format(uid_counter)
35
36 def make_key():
37 uids = [make_uid() for i in range(3)]
38 res = ctx.create_key(uids[0], certify=True)
39 key = ctx.get_key(res.fpr)
40 for u in uids[1:]:
41 ctx.key_add_uid(key, u)
42 return key, uids
43
44 def check_sigs(key, expected_sigs):
45 keys = list(ctx.keylist(key.fpr, mode=(gpg.constants.keylist.mode.LOCAL
46 |gpg.constants.keylist.mode.SIGS)))
47 assert len(keys) == 1
48 key_uids = {uid.uid: [s for s in uid.signatures] for uid in keys[0].uids}
49 expected = list(expected_sigs)
50
51 while key_uids and expected:
52 uid, signing_key, func = expected[0]
53 match = False
54 for i, s in enumerate(key_uids[uid]):
55 if signing_key.fpr.endswith(s.keyid):
56 if func:
57 func(s)
58 match = True
59 break
60 if match:
61 expected.pop(0)
62 key_uids[uid].pop(i)
63 if not key_uids[uid]:
64 del key_uids[uid]
65
66 assert not key_uids, "Superfluous signatures: {0}".format(key_uids)
67 assert not expected, "Missing signatures: {0}".format(expected)
68
69 # Simplest case. Sign without any options.
70 key_a, uids_a = make_key()
71 key_b, uids_b = make_key()
72 ctx.signers = [key_a]
73
74 def exportable_non_expiring(s):
75 assert s.exportable
76 assert s.expires == 0
77
78 check_sigs(key_b, itertools.product(uids_b, [key_b], [exportable_non_expiring]))
79 ctx.key_sign(key_b)
80 check_sigs(key_b, itertools.product(uids_b, [key_b, key_a], [exportable_non_expiring]))
81
82 # Create a non-exportable signature, and explicitly name all uids.
83 key_c, uids_c = make_key()
84 ctx.signers = [key_a, key_b]
85
86 def non_exportable_non_expiring(s):
87 assert s.exportable == 0
88 assert s.expires == 0
89
90 ctx.key_sign(key_c, local=True, uids=uids_c)
91 check_sigs(key_c,
92 list(itertools.product(uids_c, [key_c],
93 [exportable_non_expiring]))
94 + list(itertools.product(uids_c, [key_b, key_a],
95 [non_exportable_non_expiring])))
96
97 # Create a non-exportable, expiring signature for a single uid.
98 key_d, uids_d = make_key()
99 ctx.signers = [key_c]
100 expires_in = 600
101 slack = 10
102
103 def non_exportable_expiring(s):
104 assert s.exportable == 0
105 assert abs(time.time() + expires_in - s.expires) < slack
106
107 ctx.key_sign(key_d, local=True, expires_in=expires_in, uids=uids_d[0])
108 check_sigs(key_d,
109 list(itertools.product(uids_d, [key_d],
110 [exportable_non_expiring]))
111 + list(itertools.product(uids_d[:1], [key_c],
112 [non_exportable_expiring])))
113
114 # Now sign the second in the same fashion, but use a singleton list.
115 ctx.key_sign(key_d, local=True, expires_in=expires_in, uids=uids_d[1:2])
116 check_sigs(key_d,
117 list(itertools.product(uids_d, [key_d],
118 [exportable_non_expiring]))
119 + list(itertools.product(uids_d[:2], [key_c],
120 [non_exportable_expiring])))
0 #!/usr/bin/env python
1
2 # Copyright (C) 2017 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 from __future__ import absolute_import, print_function, unicode_literals
20 del absolute_import, print_function, unicode_literals
21
22 import gpg
23 import itertools
24 import time
25
26 import support
27
28 alpha = "Alpha <alpha@invalid.example.net>"
29 bravo = "Bravo <bravo@invalid.example.net>"
30
31 with support.EphemeralContext() as ctx:
32 res = ctx.create_key(alpha, certify=True)
33 keys = list(ctx.keylist())
34 assert len(keys) == 1, "Weird number of keys created"
35 key = keys[0]
36 assert key.fpr == res.fpr
37 assert len(key.subkeys) == 1, "Expected one primary key and no subkeys"
38
39 def get_subkey(fpr):
40 k = ctx.get_key(fpr)
41 for sk in k.subkeys:
42 if sk.fpr == fpr:
43 return sk
44 return None
45
46 # Check gpg.constants.create.NOEXPIRE...
47 res = ctx.create_subkey(key, expires=False)
48 subkey = get_subkey(res.fpr)
49 assert subkey.expires == 0, "Expected subkey not to expire"
50 assert subkey.can_encrypt, \
51 "Default subkey capabilities do not include encryption"
52
53 t = 2 * 24 * 60 * 60
54 slack = 5 * 60
55 res = ctx.create_subkey(key, expires_in=t)
56 subkey = get_subkey(res.fpr)
57 assert abs(time.time() + t - subkey.expires) < slack, \
58 "subkeys expiration time is off"
59
60 # Check capabilities
61 for sign, encrypt, authenticate in itertools.product([False, True],
62 [False, True],
63 [False, True]):
64 # Filter some out
65 if not (sign or encrypt or authenticate):
66 # This triggers the default capabilities tested before.
67 continue
68
69 res = ctx.create_subkey(key, sign=sign, encrypt=encrypt,
70 authenticate=authenticate)
71 subkey = get_subkey(res.fpr)
72 assert sign == subkey.can_sign
73 assert encrypt == subkey.can_encrypt
74 assert authenticate == subkey.can_authenticate
75
76 # Check algorithm
77 res = ctx.create_subkey(key, algorithm="rsa")
78 subkey = get_subkey(res.fpr)
79 assert subkey.pubkey_algo == 1
80
81 # Check algorithm with size
82 res = ctx.create_subkey(key, algorithm="rsa1024")
83 subkey = get_subkey(res.fpr)
84 assert subkey.pubkey_algo == 1
85 assert subkey.length == 1024
86
87 # Check algorithm future-default
88 ctx.create_subkey(key, algorithm="future-default")
89
90 # Check passphrase protection. For this we create a new key
91 # so that we have a key with just one encryption subkey.
92 bravo_res = ctx.create_key(bravo, certify=True)
93 bravo_key = ctx.get_key(bravo_res.fpr)
94 assert len(bravo_key.subkeys) == 1, "Expected one primary key and no subkeys"
95
96 passphrase = "streng geheim"
97 res = ctx.create_subkey(bravo_key, passphrase=passphrase)
98 ciphertext, _, _ = ctx.encrypt(b"hello there",
99 recipients=[ctx.get_key(bravo_res.fpr)])
100
101 cb_called = False
102 def cb(*args):
103 global cb_called
104 cb_called = True
105 return passphrase
106 ctx.pinentry_mode = gpg.constants.PINENTRY_MODE_LOOPBACK
107 ctx.set_passphrase_cb(cb)
108
109 plaintext, _, _ = ctx.decrypt(ciphertext)
110 assert plaintext == b"hello there"
111 assert cb_called
6161
6262 assert len(expected_notations) == 0
6363
64 support.init_gpgme(gpg.constants.protocol.OpenPGP)
65
6664 source = gpg.Data("Hallo Leute\n")
6765 signed = gpg.Data()
6866
5252 if signature.fpr != "A0FF4590BB6122EDEF6E3C542D727CC768697734":
5353 fail("Wrong fingerprint reported: {}".format(signature.fpr))
5454
55
56 support.init_gpgme(gpg.constants.protocol.OpenPGP)
5755 c = gpg.Context()
5856 c.set_textmode(True)
5957 c.set_armor(True)
5252 "23FD347A419429BACCD5E72D6BC4778054ACD246"):
5353 fail("Wrong fingerprint reported: {}".format(signature.fpr))
5454
55
56 support.init_gpgme(gpg.constants.protocol.OpenPGP)
5755 c = gpg.Context()
5856 c.set_textmode(True)
5957 c.set_armor(True)
2222 import gpg
2323 import support
2424
25 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2625 c = gpg.Context()
2726
2827 def dump_item(item):
9696 sig.validity, validity)
9797 assert gpg.errors.GPGMEError(sig.validity_reason).getcode() == gpg.errors.NO_ERROR
9898
99
100 support.init_gpgme(gpg.constants.protocol.OpenPGP)
10199 c = gpg.Context()
102100 c.set_armor(True)
103101
2323 import gpg
2424 import support
2525
26 support.init_gpgme(gpg.constants.protocol.OpenPGP)
2726 c = gpg.Context()
2827 c.set_armor(True)
2928
3636 qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \
3737 qgpgmetofupolicyjob.cpp \
3838 defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \
39 dn.cpp
39 dn.cpp cryptoconfig.cpp
4040
4141 # If you add one here make sure that you also add one in camelcase
4242 qgpgme_headers= \
219219 libqgpgme_la_LDFLAGS = -no-undefined -version-info \
220220 @LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@
221221
222 if HAVE_MACOS_SYSTEM
223 libsuffix=.dylib
224 else
225 libsuffix=.so
226 endif
227
222228 if HAVE_W32_SYSTEM
223229 QGpgmeConfig.cmake: QGpgmeConfig-w32.cmake.in
224230 sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \
227233 else
228234 QGpgmeConfig.cmake: QGpgmeConfig.cmake.in
229235 sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \
236 sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \
230237 sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@
231238 endif
232239
6363 set_target_properties(QGpgme PROPERTIES
6464 INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@"
6565 INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt5::Core"
66 IMPORTED_LOCATION "@resolved_libdir@/libqgpgme.so"
66 IMPORTED_LOCATION "@resolved_libdir@/libqgpgme@libsuffix@"
6767 )
6868
6969 if(CMAKE_VERSION VERSION_LESS 2.8.12)
0 /*
1 cryptoconfig.cpp
2
3 This file is part of qgpgme, the Qt API binding for gpgme
4 Copyright (c) 2017 Intevation GmbH
5
6 QGpgME is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 QGpgME is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
30 */
31 #include "cryptoconfig.h"
32 #include "qgpgmenewcryptoconfig.h"
33
34 using namespace QGpgME;
35
36 QStringList CryptoConfigEntry::stringValueList() const
37 {
38 const QGpgMENewCryptoConfigEntry *entry = dynamic_cast <const QGpgMENewCryptoConfigEntry*> (this);
39 if (!entry) {
40 return QStringList();
41 }
42 return entry->stringValueList();
43 }
247247 * @return true if the value was changed
248248 */
249249 virtual bool isDirty() const = 0;
250
251 // Design change from here on we are closely bound to one implementation
252 // of cryptoconfig. To avoid ABI breaks with every new function we
253 // add real functions from now on.
254
255 /**
256 * @return a stringValueList.
257 */
258 QStringList stringValueList() const;
250259 };
251260
252261 /**
378387 /**
379388 * Write back changes
380389 *
381 * @param runtime If this option is set, the changes will take effect at run-time, as
382 * far as this is possible. Otherwise, they will take effect at the next
383 * start of the respective backend programs.
390 * @param runtime this parameter is ignored. Changes will always
391 * be made with --runtime set.
384392 */
385393 virtual void sync(bool runtime) = 0;
386394
9090
9191 GpgME::Error DefaultKeyGenerationJob::start(const QString &email, const QString &name)
9292 {
93 const QString namePart = name.isEmpty() ? QString() :
94 QStringLiteral("name-real: %1\n").arg(name);
95 const QString mailPart = email.isEmpty() ? QString() :
96 QStringLiteral("name-email: %1\n").arg(email);
97
9398 const QString args = QStringLiteral("<GnupgKeyParms format=\"internal\">\n"
9499 "%ask-passphrase\n"
95100 "key-type: RSA\n"
98103 "subkey-type: RSA\n"
99104 "subkey-length: 2048\n"
100105 "subkey-usage: encrypt\n"
101 "name-email: %1\n"
102 "name-real: %2\n"
103 "</GnupgKeyParms>").arg(email, name);
106 "%1"
107 "%2"
108 "</GnupgKeyParms>").arg(mailPart, namePart);
104109
105110 d->job = openpgp()->keyGenerationJob();
106111 d->job->installEventFilter(this);
3535 #endif
3636
3737 #include "dn.h"
38
39 #include <gpg-error.h>
3840
3941 static const struct {
4042 const char *name;
164166 for (unsigned int i = 0; i < numOidMaps; ++i)
165167 if (!strcasecmp((char *)p, oidmap[i].oid)) {
166168 free(p);
167 p = strdup(oidmap[i].name);
169 gpgrt_asprintf(&p, oidmap[i].name);
168170 break;
169171 }
170172 array->key = p;
4848 #include <sstream>
4949 #include <string>
5050 #include <cassert>
51 #include <functional>
5152
5253 using namespace QGpgME;
5354 using namespace GpgME;
215216
216217 void QGpgMENewCryptoConfigComponent::sync(bool runtime)
217218 {
218 Q_UNUSED(runtime)
219 // ### how to pass --runtime to gpgconf? -> marcus: not yet supported (2010-11-20)
219 Q_UNUSED(runtime) // runtime is always set by engine_gpgconf
220220 if (const Error err = m_component.save()) {
221 #if 0
222 TODO port
223 const QString wmsg = i18n("Error from gpgconf while saving configuration: %1", QString::fromLocal8Bit(err.asString()));
224 qCWarning(GPGPME_BACKEND_LOG) << ":" << wmsg;
225 KMessageBox::error(0, wmsg);
226 #endif
227 }
228 // ### unset dirty state again
221 qCWarning(GPGPME_BACKEND_LOG) << ":"
222 << "Error from gpgconf while saving configuration: %1"
223 << QString::fromLocal8Bit(err.asString());
224 }
229225 }
230226
231227 ////
550546 return m_option.currentValue().uintValues();
551547 }
552548
549 QStringList QGpgMENewCryptoConfigEntry::stringValueList() const
550 {
551 Q_ASSERT(isList());
552 const Argument arg = m_option.currentValue();
553 const std::vector<const char *> values = arg.stringValues();
554 QStringList ret;
555 for(const char *value: values) {
556 ret << QString::fromUtf8(value);
557 }
558 return ret;
559 }
560
553561 QList<QUrl> QGpgMENewCryptoConfigEntry::urlValueList() const
554562 {
555563 const Type type = m_option.type();
9292 void setURLValueList(const QList<QUrl> &) Q_DECL_OVERRIDE;
9393 bool isDirty() const Q_DECL_OVERRIDE;
9494
95 QStringList stringValueList() const;
96
9597 #if 0
9698 void setDirty(bool b);
9799 QString outputString() const;
5050 #include "job.h"
5151
5252 #include <cassert>
53 #include <functional>
5354
5455 namespace QGpgME
5556 {
2424 EXTRA_DIST = initial.test
2525
2626 TESTS = initial.test t-keylist t-keylocate t-ownertrust t-tofuinfo \
27 t-encrypt t-verify
27 t-encrypt t-verify t-various t-config
2828
2929 moc_files = t-keylist.moc t-keylocate.moc t-ownertrust.moc t-tofuinfo.moc \
30 t-encrypt.moc t-support.hmoc t-wkspublish.moc t-verify.moc
30 t-encrypt.moc t-support.hmoc t-wkspublish.moc t-verify.moc \
31 t-various.moc t-config.moc
3132
3233 AM_LDFLAGS = -no-install
3334
5657 t_encrypt_SOURCES = t-encrypt.cpp $(support_src)
5758 t_wkspublish_SOURCES = t-wkspublish.cpp $(support_src)
5859 t_verify_SOURCES = t-verify.cpp $(support_src)
60 t_various_SOURCES = t-various.cpp $(support_src)
61 t_config_SOURCES = t-config.cpp $(support_src)
5962 run_keyformailboxjob_SOURCES = run-keyformailboxjob.cpp
6063
6164 nodist_t_keylist_SOURCES = $(moc_files)
6366 BUILT_SOURCES = $(moc_files)
6467
6568 noinst_PROGRAMS = t-keylist t-keylocate t-ownertrust t-tofuinfo t-encrypt \
66 run-keyformailboxjob t-wkspublish t-verify
69 run-keyformailboxjob t-wkspublish t-verify t-various t-config
6770
6871 CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \
6972 gpg-agent.conf pubring.kbx~ S.gpg-agent gpg.conf pubring.gpg~ \
7073 random_seed S.gpg-agent .gpg-v21-migrated pubring-stamp $(moc_files) \
71 gpg.conf
74 gpg.conf tofu.db
7275
7376 clean-local:
7477 -rm -fR private-keys-v1.d crls.d
0 /* t-config.cpp
1
2 This file is part of qgpgme, the Qt API binding for gpgme
3 Copyright (c) 2016 Intevation GmbH
4
5 QGpgME is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 QGpgME is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of this program with any edition of
21 the Qt library by Trolltech AS, Norway (or with modified versions
22 of Qt that use the same license as Qt), and distribute linked
23 combinations including the two. You must obey the GNU General
24 Public License in all respects for all of the code used other than
25 Qt. If you modify this file, you may extend this exception to
26 your version of the file, but you are not obligated to do so. If
27 you do not wish to do so, delete this exception statement from
28 your version.
29 */
30 #ifdef HAVE_CONFIG_H
31 #include "config.h"
32 #endif
33
34 #include <QDebug>
35 #include <QTest>
36 #include <QTemporaryDir>
37 #include "t-support.h"
38 #include "protocol.h"
39 #include "cryptoconfig.h"
40 #include <unistd.h>
41
42 using namespace QGpgME;
43
44 class CryptoConfigTest: public QGpgMETest
45 {
46 Q_OBJECT
47
48 private Q_SLOTS:
49 void testKeyserver()
50 {
51 // Repeatedly set a config value and clear it
52 // this war broken at some point so it gets a
53 // unit test.
54 for (int i = 0; i < 10; i++) {
55 auto conf = cryptoConfig();
56 QVERIFY(conf);
57 auto entry = conf->entry(QStringLiteral("gpg"),
58 QStringLiteral("Keyserver"),
59 QStringLiteral("keyserver"));
60 QVERIFY(entry);
61 const QString url(QStringLiteral("hkp://foo.bar.baz"));
62 entry->setStringValue(url);
63 conf->sync(false);
64 conf->clear();
65 entry = conf->entry(QStringLiteral("gpg"),
66 QStringLiteral("Keyserver"),
67 QStringLiteral("keyserver"));
68 QCOMPARE (entry->stringValue(), url);
69 entry->setStringValue(QString());
70 conf->sync(false);
71 conf->clear();
72 entry = conf->entry(QStringLiteral("gpg"),
73 QStringLiteral("Keyserver"),
74 QStringLiteral("keyserver"));
75 QCOMPARE (entry->stringValue(), QString());
76 }
77 }
78
79 void initTestCase()
80 {
81 QGpgMETest::initTestCase();
82 const QString gpgHome = qgetenv("GNUPGHOME");
83 qputenv("GNUPGHOME", mDir.path().toUtf8());
84 QVERIFY(mDir.isValid());
85 }
86 private:
87 QTemporaryDir mDir;
88
89 };
90
91 QTEST_MAIN(CryptoConfigTest)
92
93 #include "t-config.moc"
3838 #include <QBuffer>
3939 #include "keylistjob.h"
4040 #include "encryptjob.h"
41 #include "signencryptjob.h"
42 #include "signingresult.h"
4143 #include "qgpgmeencryptjob.h"
4244 #include "encryptionresult.h"
4345 #include "decryptionresult.h"
4547 #include "qgpgmebackend.h"
4648 #include "keylistresult.h"
4749 #include "engineinfo.h"
50 #include "verifyopaquejob.h"
4851 #include "t-support.h"
4952
5053 #define PROGRESS_TEST_SIZE 1 * 1024 * 1024
8487 std::vector<Key> keys;
8588 auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
8689 false, keys);
87 Q_ASSERT(!keylistresult.error());
88 Q_ASSERT(keys.size() == 1);
90 QVERIFY(!keylistresult.error());
91 QVERIFY(keys.size() == 1);
8992 delete listjob;
9093
9194 auto job = openpgp()->encryptJob(/*ASCII Armor */true, /* Textmode */ true);
92 Q_ASSERT(job);
95 QVERIFY(job);
9396 QByteArray cipherText;
9497 auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText);
9598 delete job;
96 Q_ASSERT(!result.error());
99 QVERIFY(!result.error());
97100 const auto cipherString = QString::fromUtf8(cipherText);
98 Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
101 QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
99102
100103 /* Now decrypt */
101104 if (!decryptSupported()) {
108111 auto decJob = new QGpgMEDecryptJob(ctx);
109112 QByteArray plainText;
110113 auto decResult = decJob->exec(cipherText, plainText);
111 Q_ASSERT(!result.error());
112 Q_ASSERT(QString::fromUtf8(plainText) == QStringLiteral("Hello World"));
114 QVERIFY(!decResult.error());
115 QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello World"));
113116 delete decJob;
114117 }
115118
124127 std::vector<Key> keys;
125128 auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
126129 false, keys);
127 Q_ASSERT(!keylistresult.error());
128 Q_ASSERT(keys.size() == 1);
130 QVERIFY(!keylistresult.error());
131 QVERIFY(keys.size() == 1);
129132 delete listjob;
130133
131134 auto job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false);
132 Q_ASSERT(job);
135 QVERIFY(job);
133136 QByteArray plainBa;
134137 plainBa.fill('X', PROGRESS_TEST_SIZE);
135138 QByteArray cipherText;
139142 connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString&, int current, int total) {
140143 // We only check for progress 0 and max progress as the other progress
141144 // lines depend on the system speed and are as such unreliable to test.
142 Q_ASSERT(total == PROGRESS_TEST_SIZE);
145 QVERIFY(total == PROGRESS_TEST_SIZE);
143146 if (current == 0) {
144147 initSeen = true;
145148 }
146149 if (current == total) {
147150 finishSeen = true;
148151 }
149 Q_ASSERT(current >= 0 && current <= total);
152 QVERIFY(current >= 0 && current <= total);
150153 });
151154 connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &,
152155 const QByteArray &,
153156 const QString,
154157 const GpgME::Error) {
155 Q_ASSERT(initSeen);
156 Q_ASSERT(finishSeen);
158 QVERIFY(initSeen);
159 QVERIFY(finishSeen);
157160 Q_EMIT asyncDone();
158161 });
159162
164167
165168 job->start(keys, inptr, outptr, Context::AlwaysTrust);
166169 QSignalSpy spy (this, SIGNAL(asyncDone()));
167 Q_ASSERT(spy.wait());
170 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
168171 }
169172
170173 void testSymmetricEncryptDecrypt()
182185 QByteArray cipherText;
183186 auto result = job->exec(std::vector<Key>(), QStringLiteral("Hello symmetric World").toUtf8(), Context::AlwaysTrust, cipherText);
184187 delete job;
185 Q_ASSERT(!result.error());
188 QVERIFY(!result.error());
186189 const auto cipherString = QString::fromUtf8(cipherText);
187 Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
190 QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
188191
189192 killAgent(mDir.path());
190193
194197 auto decJob = new QGpgMEDecryptJob(ctx2);
195198 QByteArray plainText;
196199 auto decResult = decJob->exec(cipherText, plainText);
197 Q_ASSERT(!result.error());
198 Q_ASSERT(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
200 QVERIFY(!result.error());
201 QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
199202 delete decJob;
203 }
204
205 private:
206 /* This apparently does not work under ASAN currently. TODO fix and reeanble */
207 void testEncryptDecryptNowrap()
208 {
209 /* Now decrypt */
210 if (!decryptSupported()) {
211 return;
212 }
213 auto listjob = openpgp()->keyListJob(false, false, false);
214 std::vector<Key> keys;
215 auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
216 false, keys);
217 QVERIFY(!keylistresult.error());
218 QVERIFY(keys.size() == 1);
219 delete listjob;
220
221 auto job = openpgp()->signEncryptJob(/*ASCII Armor */true, /* Textmode */ true);
222
223 auto encSignCtx = Job::context(job);
224 TestPassphraseProvider provider1;
225 encSignCtx->setPassphraseProvider(&provider1);
226 encSignCtx->setPinentryMode(Context::PinentryLoopback);
227
228 QVERIFY(job);
229 QByteArray cipherText;
230 auto result = job->exec(keys, keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText);
231 delete job;
232 QVERIFY(!result.first.error());
233 QVERIFY(!result.second.error());
234 const auto cipherString = QString::fromUtf8(cipherText);
235 QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
236
237 /* Now decrypt */
238 if (!decryptSupported()) {
239 return;
240 }
241 auto ctx = Context::createForProtocol(OpenPGP);
242 TestPassphraseProvider provider;
243 ctx->setPassphraseProvider(&provider);
244 ctx->setPinentryMode(Context::PinentryLoopback);
245 ctx->setDecryptionFlags(Context::DecryptUnwrap);
246
247 auto decJob = new QGpgMEDecryptJob(ctx);
248 QByteArray plainText;
249 auto decResult = decJob->exec(cipherText, plainText);
250
251 QVERIFY(!decResult.error());
252
253 delete decJob;
254
255 // Now verify the unwrapeped data.
256 auto verifyJob = openpgp()->verifyOpaqueJob(true);
257 QByteArray verified;
258
259 auto verResult = verifyJob->exec(plainText, verified);
260 QVERIFY(!verResult.error());
261 delete verifyJob;
262
263 QVERIFY(verResult.numSignatures() == 1);
264 auto sig = verResult.signatures()[0];
265
266 QVERIFY(verified == QStringLiteral("Hello World"));
200267 }
201268
202269 private:
211278 std::vector<Key> keys;
212279 auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
213280 false, keys);
214 Q_ASSERT(!keylistresult.error());
215 Q_ASSERT(keys.size() == 1);
281 QVERIFY(!keylistresult.error());
282 QVERIFY(keys.size() == 1);
216283 delete listjob;
217284
218285 auto ctx = Context::createForProtocol(OpenPGP);
228295 cipherText);
229296 printf("After exec\n");
230297 delete job;
231 Q_ASSERT(!result.error());
298 QVERIFY(!result.error());
232299 printf("Cipher:\n%s\n", cipherText.constData());
233300 const auto cipherString = QString::fromUtf8(cipherText);
234 Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
301 QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
235302
236303 killAgent(mDir.path());
237304
239306 QTemporaryDir tmp;
240307 qputenv("GNUPGHOME", tmp.path().toUtf8());
241308 QFile agentConf(tmp.path() + QStringLiteral("/gpg-agent.conf"));
242 Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
309 QVERIFY(agentConf.open(QIODevice::WriteOnly));
243310 agentConf.write("allow-loopback-pinentry");
244311 agentConf.close();
245312
250317 auto decJob = new QGpgMEDecryptJob(ctx2);
251318 QByteArray plainText;
252319 auto decResult = decJob->exec(cipherText, plainText);
253 Q_ASSERT(!decResult.error());
320 QVERIFY(!decResult.error());
254321 qDebug() << "Plain: " << plainText;
255 Q_ASSERT(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
322 QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
256323 delete decJob;
257324
258325 killAgent(tmp.path());
266333 QGpgMETest::initTestCase();
267334 const QString gpgHome = qgetenv("GNUPGHOME");
268335 qputenv("GNUPGHOME", mDir.path().toUtf8());
269 Q_ASSERT(mDir.isValid());
336 QVERIFY(mDir.isValid());
270337 QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
271 Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
338 QVERIFY(agentConf.open(QIODevice::WriteOnly));
272339 agentConf.write("allow-loopback-pinentry");
273340 agentConf.close();
274 Q_ASSERT(copyKeyrings(gpgHome, mDir.path()));
341 QVERIFY(copyKeyrings(gpgHome, mDir.path()));
275342 }
276343
277344 private:
6060 GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
6161 false, keys);
6262 delete job;
63 Q_ASSERT (!result.error());
64 Q_ASSERT (keys.size() == 1);
63 QVERIFY (!result.error());
64 QVERIFY (keys.size() == 1);
6565 const QString kId = QLatin1String(keys.front().keyID());
66 Q_ASSERT (kId == QStringLiteral("2D727CC768697734"));
66 QVERIFY (kId == QStringLiteral("2D727CC768697734"));
6767
68 Q_ASSERT (keys[0].subkeys().size() == 2);
69 Q_ASSERT (keys[0].subkeys()[0].publicKeyAlgorithm() == Subkey::AlgoDSA);
70 Q_ASSERT (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E);
68 QVERIFY (keys[0].subkeys().size() == 2);
69 QVERIFY (keys[0].subkeys()[0].publicKeyAlgorithm() == Subkey::AlgoDSA);
70 QVERIFY (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E);
7171 }
7272
7373 void testPubkeyAlgoAsString()
8686 { Subkey::AlgoUnknown, QString() }
8787 };
8888 Q_FOREACH (Subkey::PubkeyAlgo algo, expected.keys()) {
89 Q_ASSERT(QString::fromUtf8(Subkey::publicKeyAlgorithmAsString(algo)) ==
89 QVERIFY(QString::fromUtf8(Subkey::publicKeyAlgorithmAsString(algo)) ==
9090 expected.value(algo));
9191 }
9292 }
9696 KeyListJob *job = openpgp()->keyListJob();
9797 connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error)
9898 {
99 Q_ASSERT(keys.size() == 1);
99 QVERIFY(keys.size() == 1);
100100 Q_EMIT asyncDone();
101101 });
102102 job->start(QStringList() << "alfa@example.net");
103103 QSignalSpy spy (this, SIGNAL(asyncDone()));
104 Q_ASSERT(spy.wait());
104 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
105105 }
106106 };
107107
6262 qputenv("GNUPGHOME", dir.path().toUtf8());
6363 /* Could do this with gpgconf but this is not a gpgconf test ;-) */
6464 QFile conf(dir.path() + QStringLiteral("/gpg.conf"));
65 Q_ASSERT(conf.open(QIODevice::WriteOnly));
65 QVERIFY(conf.open(QIODevice::WriteOnly));
6666 conf.write("auto-key-locate dane");
6767 conf.close();
6868
7070 mTestpattern = QStringLiteral("wk@gnupg.org");
7171 connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error)
7272 {
73 Q_ASSERT(!result.error());
74 Q_ASSERT(keys.size() == 1);
73 QVERIFY(!result.error());
74 QVERIFY(keys.size() == 1);
7575
7676 Key k = keys.front();
77 Q_ASSERT(k.numUserIDs());
77 QVERIFY(k.numUserIDs());
7878 bool found = false;
7979 Q_FOREACH (const UserID uid, k.userIDs()) {
8080 const QString mailBox = QString::fromUtf8(uid.email());
8282 found = true;
8383 }
8484 }
85 Q_ASSERT(found);
85 QVERIFY(found);
8686 Q_EMIT asyncDone();
8787 });
8888 job->start(QStringList() << mTestpattern);
8989 QSignalSpy spy (this, SIGNAL(asyncDone()));
90 Q_ASSERT(spy.wait());
90 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
9191 qputenv("GNUPGHOME", oldHome.toUtf8());
9292 }
9393 #endif
102102
103103 connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error)
104104 {
105 Q_ASSERT(!result.isNull());
106 Q_ASSERT(!result.isTruncated());
107 Q_ASSERT(!result.error());
108 Q_ASSERT(keys.size() == 1);
105 QVERIFY(!result.isNull());
106 QVERIFY(!result.isTruncated());
107 QVERIFY(!result.error());
108 QVERIFY(keys.size() == 1);
109109
110110 Key k = keys.front();
111 Q_ASSERT(k.numUserIDs());
111 QVERIFY(k.numUserIDs());
112112 bool found = false;
113113 Q_FOREACH (const UserID uid, k.userIDs()) {
114114 const QString mailBox = QString::fromUtf8(uid.email());
116116 found = true;
117117 }
118118 }
119 Q_ASSERT(found);
119 QVERIFY(found);
120120 Q_EMIT asyncDone();
121121 });
122122 job->start(QStringList() << mTestpattern);
123123 QSignalSpy spy (this, SIGNAL(asyncDone()));
124 Q_ASSERT(spy.wait());
124 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
125125 }
126126
127127 private:
6161 GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
6262 false, keys);
6363 delete job;
64 Q_ASSERT (!result.error());
65 Q_ASSERT (keys.size() == 1);
64 QVERIFY (!result.error());
65 QVERIFY (keys.size() == 1);
6666 Key key = keys.front();
67 Q_ASSERT (key.ownerTrust() == Key::Unknown);
67 QVERIFY (key.ownerTrust() == Key::Unknown);
6868
6969 ChangeOwnerTrustJob *job2 = openpgp()->changeOwnerTrustJob();
7070 connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e)
7272 if (e) {
7373 qDebug() << "Error in result: " << e.asString();
7474 }
75 Q_ASSERT(!e);
75 QVERIFY(!e);
7676 Q_EMIT asyncDone();
7777 });
7878 job2->start(key, Key::Ultimate);
7979 QSignalSpy spy (this, SIGNAL(asyncDone()));
80 Q_ASSERT(spy.wait());
80 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
8181
8282 job = openpgp()->keyListJob(false, true, true);
8383 result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
8484 false, keys);
8585 delete job;
8686 key = keys.front();
87 Q_ASSERT (key.ownerTrust() == Key::Ultimate);
87 QVERIFY (key.ownerTrust() == Key::Ultimate);
8888
8989 ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
9090 connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
9191 {
92 Q_ASSERT(!e);
92 QVERIFY(!e);
9393 Q_EMIT asyncDone();
9494 });
9595 job3->start(key, Key::Unknown);
96 Q_ASSERT(spy.wait());
96 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
9797
9898 job = openpgp()->keyListJob(false, true, true);
9999 result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
101101 delete job;
102102
103103 key = keys.front();
104 Q_ASSERT (key.ownerTrust() == Key::Unknown);
104 QVERIFY (key.ownerTrust() == Key::Unknown);
105105 }
106106 };
107107
3333 #endif
3434
3535 #include "t-support.h"
36 #include "context.h"
3637
3738 #include <QTest>
3839
4344
4445 void QGpgMETest::initTestCase()
4546 {
47 GpgME::initializeLibrary();
4648 const QString gpgHome = qgetenv("GNUPGHOME");
4749 QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set.");
4850 }
3333 #include "interfaces/passphraseprovider.h"
3434 #include <QObject>
3535
36 #include <gpg-error.h>
37
3638 namespace GpgME
3739 {
3840 class TestPassphraseProvider : public PassphraseProvider
4143 char *getPassphrase(const char * /*useridHint*/, const char * /*description*/,
4244 bool /*previousWasBad*/, bool &/*canceled*/) Q_DECL_OVERRIDE
4345 {
44 return strdup("abc");
46 char *ret;
47 gpgrt_asprintf(&ret, "abc");
48 return ret;
4549 }
4650 };
4751 } // namespace GpgME
5963 void cleanupTestCase();
6064 };
6165
66 /* Timeout, in milliseconds, for use with QSignalSpy to wait on
67 signals. */
68 #define QSIGNALSPY_TIMEOUT 60000
69
6270 #endif // T_SUPPORT_H
3434 #include <QDebug>
3535 #include <QTest>
3636 #include <QTemporaryDir>
37 #include <QSignalSpy>
38
3739 #include "protocol.h"
3840 #include "tofuinfo.h"
3941 #include "tofupolicyjob.h"
4042 #include "verifyopaquejob.h"
4143 #include "verificationresult.h"
4244 #include "signingresult.h"
45 #include "importjob.h"
46 #include "importresult.h"
4347 #include "keylistjob.h"
4448 #include "keylistresult.h"
4549 #include "qgpgmesignjob.h"
6064 "=Crq6\n"
6165 "-----END PGP MESSAGE-----\n";
6266
67 static const char conflictKey1[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
68 "\n"
69 "mDMEWG+w/hYJKwYBBAHaRw8BAQdAiq1oStvDYg8ZfFs5DgisYJo8dJxD+C/AA21O\n"
70 "K/aif0O0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBHoJBLaV\n"
71 "DamYAgoa1L5BwMOl/x88BQJYb7D+AhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n"
72 "Ah4BAheAAAoJEL5BwMOl/x88GvwA/0SxkbLyAcshGm2PRrPsFQsSVAfwaSYFVmS2\n"
73 "cMVIw1PfAQDclRH1Z4MpufK07ju4qI33o4s0UFpVRBuSxt7A4P2ZD7g4BFhvsP4S\n"
74 "CisGAQQBl1UBBQEBB0AmVrgaDNJ7K2BSalsRo2EkRJjHGqnp5bBB0tapnF81CQMB\n"
75 "CAeIeAQYFggAIBYhBHoJBLaVDamYAgoa1L5BwMOl/x88BQJYb7D+AhsMAAoJEL5B\n"
76 "wMOl/x88OR0BAMq4/vmJUORRTmzjHcv/DDrQB030DSq666rlckGIKTShAPoDXM9N\n"
77 "0gZK+YzvrinSKZXHmn0aSwmC1/hyPybJPEljBw==\n"
78 "=p2Oj\n"
79 "-----END PGP PUBLIC KEY BLOCK-----\n";
80
81 static const char conflictKey2[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
82 "\n"
83 "mDMEWG+xShYJKwYBBAHaRw8BAQdA567gPEPJRpqKnZjlFJMRNUqruRviYMyygfF6\n"
84 "6Ok+ygu0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBJ5kRh7E\n"
85 "I98w8kgUcmkAfYFvqqHsBQJYb7FKAhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n"
86 "Ah4BAheAAAoJEGkAfYFvqqHsYR0BAOz8JjYB4VvGkt6noLS3F5TLfsedGwQkBCw5\n"
87 "znw/vGZsAQD9DSX+ekwdrN56mNO8ISt5uVS7B1ZQtouNBF+nzcwbDbg4BFhvsUoS\n"
88 "CisGAQQBl1UBBQEBB0BFupW8+Xc1ikab8TJqANjQhvFVh6uLsgcK4g9lZgbGXAMB\n"
89 "CAeIeAQYFggAIBYhBJ5kRh7EI98w8kgUcmkAfYFvqqHsBQJYb7FKAhsMAAoJEGkA\n"
90 "fYFvqqHs15ABALdN3uiV/07cJ3RkNb3WPcijGsto+lECDS11dKEwTMFeAQDx+V36\n"
91 "ocbYC/xEuwi3w45oNqGieazzcD/GBbt8OBk3BA==\n"
92 "=45IR\n"
93 "-----END PGP PUBLIC KEY BLOCK-----\n";
94
95 static const char conflictMsg1[] = "-----BEGIN PGP MESSAGE-----\n"
96 "\n"
97 "owGbwMvMwCG2z/HA4aX/5W0YT3MlMUTkb2xPSizi6ihlYRDjYJAVU2Sp4mTZNpV3\n"
98 "5QwmLqkrMLWsTCCFDFycAjCR1vcMf4U0Qrs6qzqfHJ9puGOFduLN2nVmhsumxjBE\n"
99 "mdw4lr1ehIWR4QdLuNBpe86PGx1PtNXfVAzm/hu+vfjCp5BVNjPTM9L0eAA=\n"
100 "=MfBD\n"
101 "-----END PGP MESSAGE-----\n";
102
103 static const char conflictMsg2[] = "-----BEGIN PGP MESSAGE-----\n"
104 "\n"
105 "owGbwMvMwCGWyVDbmL9q4RvG01xJDBH5GyvS8vO5OkpZGMQ4GGTFFFnmpbjJHVG+\n"
106 "b/DJQ6QIppaVCaSQgYtTACaySZHhr/SOPrdFJ89KrcwKY5i1XnflXYf2PK76SafK\n"
107 "tkxXuXzvJAvDX4kCybuqFk3HXCexz2+IrnZ+5X5EqOnuo3ens2cte+uzlhMA\n"
108 "=BIAi\n"
109 "-----END PGP MESSAGE-----\n";
110
63111 class TofuInfoTest: public QGpgMETest
64112 {
65113 Q_OBJECT
66
114 Q_SIGNALS:
115 void asyncDone();
116
117 private:
67118 bool testSupported()
68119 {
69120 return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16");
71122
72123 void testTofuCopy(TofuInfo other, const TofuInfo &orig)
73124 {
74 Q_ASSERT(!orig.isNull());
75 Q_ASSERT(!other.isNull());
76 Q_ASSERT(orig.signLast() == other.signLast());
77 Q_ASSERT(orig.signCount() == other.signCount());
78 Q_ASSERT(orig.validity() == other.validity());
79 Q_ASSERT(orig.policy() == other.policy());
125 QVERIFY(!orig.isNull());
126 QVERIFY(!other.isNull());
127 QVERIFY(orig.signLast() == other.signLast());
128 QVERIFY(orig.signCount() == other.signCount());
129 QVERIFY(orig.validity() == other.validity());
130 QVERIFY(orig.policy() == other.policy());
80131 }
81132
82133 void signAndVerify(const QString &what, const GpgME::Key &key, int expected)
93144 auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
94145 delete job;
95146
96 Q_ASSERT(!sigResult.error());
147 QVERIFY(!sigResult.error());
97148 foreach (const auto uid, keys[0].userIDs()) {
98149 auto info = uid.tofuInfo();
99 Q_ASSERT(info.signCount() == expected - 1);
150 QVERIFY(info.signCount() == expected - 1);
100151 }
101152
102153 auto verifyJob = openpgp()->verifyOpaqueJob();
105156 auto result = verifyJob->exec(signedData, verified);
106157 delete verifyJob;
107158
108 Q_ASSERT(!result.error());
109 Q_ASSERT(verified == what.toUtf8());
110
111 Q_ASSERT(result.numSignatures() == 1);
159 QVERIFY(!result.error());
160 QVERIFY(verified == what.toUtf8());
161
162 QVERIFY(result.numSignatures() == 1);
112163 auto sig = result.signatures()[0];
113164
114165 auto key2 = sig.key();
115 Q_ASSERT(!key.isNull());
116 Q_ASSERT(!strcmp (key2.primaryFingerprint(), key.primaryFingerprint()));
117 Q_ASSERT(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
166 QVERIFY(!key.isNull());
167 QVERIFY(!strcmp (key2.primaryFingerprint(), key.primaryFingerprint()));
168 QVERIFY(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
118169 auto stats = key2.userID(0).tofuInfo();
119 Q_ASSERT(!stats.isNull());
170 QVERIFY(!stats.isNull());
120171 if (stats.signCount() != expected) {
121172 std::cout << "################ Key before verify: "
122173 << key
123174 << "################ Key after verify: "
124175 << key2;
125176 }
126 Q_ASSERT(stats.signCount() == expected);
177 QVERIFY(stats.signCount() == expected);
127178 }
128179
129180 private Q_SLOTS:
133184 return;
134185 }
135186 TofuInfo tofu;
136 Q_ASSERT(tofu.isNull());
137 Q_ASSERT(!tofu.description());
138 Q_ASSERT(!tofu.signCount());
139 Q_ASSERT(!tofu.signLast());
140 Q_ASSERT(!tofu.signFirst());
141 Q_ASSERT(tofu.validity() == TofuInfo::ValidityUnknown);
142 Q_ASSERT(tofu.policy() == TofuInfo::PolicyUnknown);
187 QVERIFY(tofu.isNull());
188 QVERIFY(!tofu.description());
189 QVERIFY(!tofu.signCount());
190 QVERIFY(!tofu.signLast());
191 QVERIFY(!tofu.signFirst());
192 QVERIFY(tofu.validity() == TofuInfo::ValidityUnknown);
193 QVERIFY(tofu.policy() == TofuInfo::PolicyUnknown);
143194 }
144195
145196 void testTofuInfo()
152203 QByteArray plaintext;
153204
154205 auto ctx = Job::context(job);
155 Q_ASSERT(ctx);
206 QVERIFY(ctx);
156207 ctx->setSender("alfa@example.net");
157208
158209 auto result = job->exec(data1, plaintext);
159210 delete job;
160211
161 Q_ASSERT(!result.isNull());
162 Q_ASSERT(!result.error());
163 Q_ASSERT(!strcmp(plaintext.constData(), "Just GNU it!\n"));
164
165 Q_ASSERT(result.numSignatures() == 1);
212 QVERIFY(!result.isNull());
213 QVERIFY(!result.error());
214 QVERIFY(!strcmp(plaintext.constData(), "Just GNU it!\n"));
215
216 QVERIFY(result.numSignatures() == 1);
166217 Signature sig = result.signatures()[0];
167218 /* TOFU is always marginal */
168 Q_ASSERT(sig.validity() == Signature::Marginal);
219 QVERIFY(sig.validity() == Signature::Marginal);
169220
170221 auto stats = sig.key().userID(0).tofuInfo();
171 Q_ASSERT(!stats.isNull());
172 Q_ASSERT(sig.key().primaryFingerprint());
173 Q_ASSERT(sig.fingerprint());
174 Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
175 Q_ASSERT(stats.signFirst() == stats.signLast());
176 Q_ASSERT(stats.signCount() == 1);
177 Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
178 Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
222 QVERIFY(!stats.isNull());
223 QVERIFY(sig.key().primaryFingerprint());
224 QVERIFY(sig.fingerprint());
225 QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
226 QVERIFY(stats.signFirst() == stats.signLast());
227 QVERIFY(stats.signCount() == 1);
228 QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
229 QVERIFY(stats.validity() == TofuInfo::LittleHistory);
179230
180231 testTofuCopy(stats, stats);
181232
185236 result = job->exec(data1, plaintext);
186237 delete job;
187238
188 Q_ASSERT(!result.isNull());
189 Q_ASSERT(!result.error());
190
191 Q_ASSERT(result.numSignatures() == 1);
239 QVERIFY(!result.isNull());
240 QVERIFY(!result.error());
241
242 QVERIFY(result.numSignatures() == 1);
192243 sig = result.signatures()[0];
193244 /* TOFU is always marginal */
194 Q_ASSERT(sig.validity() == Signature::Marginal);
245 QVERIFY(sig.validity() == Signature::Marginal);
195246
196247 stats = sig.key().userID(0).tofuInfo();
197 Q_ASSERT(!stats.isNull());
198 Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
199 Q_ASSERT(stats.signFirst() == stats.signLast());
200 Q_ASSERT(stats.signCount() == 1);
201 Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
202 Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
248 QVERIFY(!stats.isNull());
249 QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
250 QVERIFY(stats.signFirst() == stats.signLast());
251 QVERIFY(stats.signCount() == 1);
252 QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
253 QVERIFY(stats.validity() == TofuInfo::LittleHistory);
203254
204255 /* Verify that another call yields the same result */
205256 job = openpgp()->verifyOpaqueJob(true);
206257 result = job->exec(data1, plaintext);
207258 delete job;
208259
209 Q_ASSERT(!result.isNull());
210 Q_ASSERT(!result.error());
211
212 Q_ASSERT(result.numSignatures() == 1);
260 QVERIFY(!result.isNull());
261 QVERIFY(!result.error());
262
263 QVERIFY(result.numSignatures() == 1);
213264 sig = result.signatures()[0];
214265 /* TOFU is always marginal */
215 Q_ASSERT(sig.validity() == Signature::Marginal);
266 QVERIFY(sig.validity() == Signature::Marginal);
216267
217268 stats = sig.key().userID(0).tofuInfo();
218 Q_ASSERT(!stats.isNull());
219 Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
220 Q_ASSERT(stats.signFirst() == stats.signLast());
221 Q_ASSERT(stats.signCount() == 1);
222 Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
223 Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
269 QVERIFY(!stats.isNull());
270 QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
271 QVERIFY(stats.signFirst() == stats.signLast());
272 QVERIFY(stats.signCount() == 1);
273 QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
274 QVERIFY(stats.validity() == TofuInfo::LittleHistory);
224275 }
225276
226277 void testTofuSignCount()
234285 GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
235286 true, keys);
236287 delete job;
237 Q_ASSERT(!keys.empty());
288 QVERIFY(!keys.empty());
238289 Key key = keys[0];
239 Q_ASSERT(!key.isNull());
290 QVERIFY(!key.isNull());
240291
241292 /* As we sign & verify quickly here we need different
242293 * messages to avoid having them treated as the same
265316 auto result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
266317 true, keys);
267318 delete job;
268 Q_ASSERT(!keys.empty());
319 QVERIFY(!keys.empty());
269320 auto key = keys[0];
270 Q_ASSERT(!key.isNull());
271 Q_ASSERT(key.userID(0).tofuInfo().isNull());
321 QVERIFY(!key.isNull());
322 QVERIFY(key.userID(0).tofuInfo().isNull());
272323 auto keyCopy = key;
273324 keyCopy.update();
274325 auto sigCnt = keyCopy.userID(0).tofuInfo().signCount();
284335 result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
285336 true, keys);
286337 delete job;
287 Q_ASSERT(!result.error());
288 Q_ASSERT(!keys.empty());
338 QVERIFY(!result.error());
339 QVERIFY(!keys.empty());
289340 auto key2 = keys[0];
290 Q_ASSERT(!key2.isNull());
341 QVERIFY(!key2.isNull());
291342 auto info = key2.userID(0).tofuInfo();
292 Q_ASSERT(!info.isNull());
293 Q_ASSERT(info.signCount());
343 QVERIFY(!info.isNull());
344 QVERIFY(info.signCount());
294345 }
295346
296347 void testTofuPolicy()
325376 << ">\n fpr: " << key.primaryFingerprint();
326377 }
327378 }
328 Q_ASSERT(!result.error());
329 Q_ASSERT(!keys.empty());
379 QVERIFY(!result.error());
380 QVERIFY(!keys.empty());
330381 auto key = keys[0];
331 Q_ASSERT(!key.isNull());
332 Q_ASSERT(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad);
382 QVERIFY(!key.isNull());
383 QVERIFY(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad);
333384 auto *tofuJob = openpgp()->tofuPolicyJob();
334385 auto err = tofuJob->exec(key, TofuInfo::PolicyBad);
335 Q_ASSERT(!err);
386 QVERIFY(!err);
336387 result = job->exec(QStringList() << QStringLiteral("bravo@example.net"),
337388 false, keys);
338 Q_ASSERT(!keys.empty());
389 QVERIFY(!keys.empty());
339390 key = keys[0];
340 Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad);
391 QVERIFY(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad);
341392 err = tofuJob->exec(key, TofuInfo::PolicyGood);
342393
343394 result = job->exec(QStringList() << QStringLiteral("bravo@example.net"),
344395 false, keys);
345396 key = keys[0];
346 Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
397 QVERIFY(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
347398 delete tofuJob;
348399 delete job;
349400 }
401
402 void testTofuConflict()
403 {
404 if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.19") {
405 return;
406 }
407
408 // Import key 1
409 auto importjob = openpgp()->importJob();
410 connect(importjob, &ImportJob::result, this,
411 [this](ImportResult result, QString, Error)
412 {
413 QVERIFY(!result.error());
414 QVERIFY(!result.imports().empty());
415 QVERIFY(result.numImported());
416 Q_EMIT asyncDone();
417 });
418 importjob->start(QByteArray(conflictKey1));
419 QSignalSpy spy (this, SIGNAL(asyncDone()));
420 QVERIFY(spy.wait());
421
422 // Verify Message 1
423 const QByteArray signedData(conflictMsg1);
424 auto verifyJob = openpgp()->verifyOpaqueJob(true);
425 QByteArray verified;
426 auto result = verifyJob->exec(signedData, verified);
427 delete verifyJob;
428
429 QVERIFY(!result.isNull());
430 QVERIFY(!result.error());
431
432 QVERIFY(result.numSignatures() == 1);
433 auto sig = result.signatures()[0];
434 QVERIFY(sig.validity() == Signature::Marginal);
435
436 auto stats = sig.key().userID(0).tofuInfo();
437 QVERIFY(!stats.isNull());
438 QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
439 QVERIFY(stats.signFirst() == stats.signLast());
440 QVERIFY(stats.signCount() == 1);
441 QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
442 QVERIFY(stats.validity() == TofuInfo::LittleHistory);
443
444 // Import key 2
445 importjob = openpgp()->importJob();
446 connect(importjob, &ImportJob::result, this,
447 [this](ImportResult result, QString, Error)
448 {
449 QVERIFY(!result.error());
450 QVERIFY(!result.imports().empty());
451 QVERIFY(result.numImported());
452 Q_EMIT asyncDone();
453 });
454 importjob->start(QByteArray(conflictKey2));
455 QSignalSpy spy2 (this, SIGNAL(asyncDone()));
456 QVERIFY(spy2.wait());
457
458 // Verify Message 2
459 const QByteArray signedData2(conflictMsg2);
460 QByteArray verified2;
461 verifyJob = openpgp()->verifyOpaqueJob(true);
462 result = verifyJob->exec(signedData2, verified2);
463 delete verifyJob;
464
465 QVERIFY(!result.isNull());
466 QVERIFY(!result.error());
467
468 QVERIFY(result.numSignatures() == 1);
469 sig = result.signatures()[0];
470 QVERIFY(sig.validity() == Signature::Unknown);
471 // TODO activate when implemented
472 // QVERIFY(sig.summary() == Signature::TofuConflict);
473
474 stats = sig.key().userID(0).tofuInfo();
475 QVERIFY(!stats.isNull());
476 QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
477 QVERIFY(stats.signFirst() == stats.signLast());
478 QVERIFY(stats.signCount() == 1);
479 QVERIFY(stats.policy() == TofuInfo::PolicyAsk);
480 QVERIFY(stats.validity() == TofuInfo::Conflict);
481 }
482
350483
351484 void initTestCase()
352485 {
353486 QGpgMETest::initTestCase();
354487 const QString gpgHome = qgetenv("GNUPGHOME");
355488 qputenv("GNUPGHOME", mDir.path().toUtf8());
356 Q_ASSERT(mDir.isValid());
489 QVERIFY(mDir.isValid());
357490 QFile conf(mDir.path() + QStringLiteral("/gpg.conf"));
358 Q_ASSERT(conf.open(QIODevice::WriteOnly));
491 QVERIFY(conf.open(QIODevice::WriteOnly));
359492 conf.write("trust-model tofu+pgp");
360493 conf.close();
361494 QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
362 Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
495 QVERIFY(agentConf.open(QIODevice::WriteOnly));
363496 agentConf.write("allow-loopback-pinentry");
364497 agentConf.close();
365 Q_ASSERT(copyKeyrings(gpgHome, mDir.path()));
498 QVERIFY(copyKeyrings(gpgHome, mDir.path()));
366499 }
367500 private:
368501 QTemporaryDir mDir;
0 /* t-various.cpp
1
2 This file is part of qgpgme, the Qt API binding for gpgme
3 Copyright (c) 2017 Intevation GmbH
4
5 QGpgME is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 QGpgME is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of this program with any edition of
21 the Qt library by Trolltech AS, Norway (or with modified versions
22 of Qt that use the same license as Qt), and distribute linked
23 combinations including the two. You must obey the GNU General
24 Public License in all respects for all of the code used other than
25 Qt. If you modify this file, you may extend this exception to
26 your version of the file, but you are not obligated to do so. If
27 you do not wish to do so, delete this exception statement from
28 your version.
29 */
30
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34
35 #include <QDebug>
36 #include <QTest>
37 #include <QSignalSpy>
38 #include <QTemporaryDir>
39 #include "keylistjob.h"
40 #include "protocol.h"
41 #include "keylistresult.h"
42 #include "context.h"
43 #include "engineinfo.h"
44 #include "dn.h"
45 #include "data.h"
46 #include "dataprovider.h"
47
48 #include "t-support.h"
49
50 using namespace QGpgME;
51 using namespace GpgME;
52
53 static const char aKey[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
54 "\n"
55 "mDMEWG+w/hYJKwYBBAHaRw8BAQdAiq1oStvDYg8ZfFs5DgisYJo8dJxD+C/AA21O\n"
56 "K/aif0O0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBHoJBLaV\n"
57 "DamYAgoa1L5BwMOl/x88BQJYb7D+AhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n"
58 "Ah4BAheAAAoJEL5BwMOl/x88GvwA/0SxkbLyAcshGm2PRrPsFQsSVAfwaSYFVmS2\n"
59 "cMVIw1PfAQDclRH1Z4MpufK07ju4qI33o4s0UFpVRBuSxt7A4P2ZD7g4BFhvsP4S\n"
60 "CisGAQQBl1UBBQEBB0AmVrgaDNJ7K2BSalsRo2EkRJjHGqnp5bBB0tapnF81CQMB\n"
61 "CAeIeAQYFggAIBYhBHoJBLaVDamYAgoa1L5BwMOl/x88BQJYb7D+AhsMAAoJEL5B\n"
62 "wMOl/x88OR0BAMq4/vmJUORRTmzjHcv/DDrQB030DSq666rlckGIKTShAPoDXM9N\n"
63 "0gZK+YzvrinSKZXHmn0aSwmC1/hyPybJPEljBw==\n"
64 "=p2Oj\n"
65 "-----END PGP PUBLIC KEY BLOCK-----\n";
66
67 class TestVarious: public QGpgMETest
68 {
69 Q_OBJECT
70
71 Q_SIGNALS:
72 void asyncDone();
73
74 private Q_SLOTS:
75 void testDN()
76 {
77 DN dn(QStringLiteral("CN=Before\\0DAfter,OU=Test,DC=North America,DC=Fabrikam,DC=COM"));
78 QVERIFY(dn.dn() == QStringLiteral("CN=Before\rAfter,OU=Test,DC=North America,DC=Fabrikam,DC=COM"));
79 QStringList attrOrder;
80 attrOrder << QStringLiteral("DC") << QStringLiteral("OU") << QStringLiteral("CN");
81 dn.setAttributeOrder(attrOrder);
82 QVERIFY(dn.prettyDN() == QStringLiteral("DC=North America,DC=Fabrikam,DC=COM,OU=Test,CN=Before\rAfter"));
83 }
84
85 void testKeyFromFile()
86 {
87 if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.14") {
88 return;
89 }
90 QGpgME::QByteArrayDataProvider dp(aKey);
91 Data data(&dp);
92 const auto keys = data.toKeys();
93 QVERIFY(keys.size() == 1);
94 const auto key = keys[0];
95 QVERIFY(!key.isNull());
96 QVERIFY(key.primaryFingerprint() == QStringLiteral("7A0904B6950DA998020A1AD4BE41C0C3A5FF1F3C"));
97 }
98
99 void testQuickUid()
100 {
101 if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.13") {
102 return;
103 }
104 KeyListJob *job = openpgp()->keyListJob(false, true, true);
105 std::vector<GpgME::Key> keys;
106 GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
107 false, keys);
108 delete job;
109 QVERIFY (!result.error());
110 QVERIFY (keys.size() == 1);
111 Key key = keys.front();
112
113 QVERIFY (key.numUserIDs() == 3);
114 const char uid[] = "Foo Bar (with comment) <foo@bar.baz>";
115
116 auto ctx = Context::createForProtocol(key.protocol());
117 QVERIFY (ctx);
118 TestPassphraseProvider provider;
119 ctx->setPassphraseProvider(&provider);
120 ctx->setPinentryMode(Context::PinentryLoopback);
121
122 QVERIFY(!ctx->addUid(key, uid));
123 delete ctx;
124 key.update();
125
126 QVERIFY (key.numUserIDs() == 4);
127 bool id_found = false;;
128 for (const auto &u: key.userIDs()) {
129 if (!strcmp (u.id(), uid)) {
130 QVERIFY (!u.isRevoked());
131 id_found = true;
132 break;
133 }
134 }
135 QVERIFY (id_found);
136
137 ctx = Context::createForProtocol(key.protocol());
138 QVERIFY (!ctx->revUid(key, uid));
139 delete ctx;
140 key.update();
141
142 bool id_revoked = false;;
143 for (const auto &u: key.userIDs()) {
144 if (!strcmp (u.id(), uid)) {
145 id_revoked = true;
146 break;
147 }
148 }
149 QVERIFY(id_revoked);
150 }
151
152 void initTestCase()
153 {
154 QGpgMETest::initTestCase();
155 const QString gpgHome = qgetenv("GNUPGHOME");
156 QVERIFY(copyKeyrings(gpgHome, mDir.path()));
157 qputenv("GNUPGHOME", mDir.path().toUtf8());
158 }
159
160 private:
161 QTemporaryDir mDir;
162 };
163
164 QTEST_MAIN(TestVarious)
165
166 #include "t-various.moc"
6969 QByteArray verified;
7070
7171 auto result = verifyJob->exec(signedData, verified);
72 Q_ASSERT(!result.error());
72 QVERIFY(!result.error());
7373 delete verifyJob;
7474
75 Q_ASSERT(result.numSignatures() == 1);
75 QVERIFY(result.numSignatures() == 1);
7676 auto sig = result.signatures()[0];
7777
7878 const auto key = sig.key(true, false);
79 Q_ASSERT(!key.isNull());
79 QVERIFY(!key.isNull());
8080
8181 bool found = false;
8282 for (const auto subkey: key.subkeys()) {
8484 found = true;
8585 }
8686 }
87 Q_ASSERT(found);
87 QVERIFY(found);
8888 }
8989 };
9090
126126 auto job = openpgp()->wksPublishJob();
127127 connect(job, &WKSPublishJob::result, this,
128128 [this] (Error err, QByteArray, QByteArray, QString, Error) {
129 Q_ASSERT(err);
129 QVERIFY(err);
130130 Q_EMIT asyncDone();
131131 });
132132 job->startCheck ("testuser1@localhost");
133133 QSignalSpy spy (this, SIGNAL(asyncDone()));
134 Q_ASSERT(spy.wait());
134 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
135135 }
136136 #ifdef DO_ONLINE_TESTS
137137 private Q_SLOTS:
146146 [this] (Error err, QByteArray, QByteArray, QString, Error) {
147147 if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") {
148148 std::cout << err;
149 Q_ASSERT(err);
149 QVERIFY(err);
150150 } else {
151 Q_ASSERT(!err);
151 QVERIFY(!err);
152152 }
153153 Q_EMIT asyncDone();
154154 });
155155 job->startCheck ("testuser1@test.gnupg.org");
156156 QSignalSpy spy (this, SIGNAL(asyncDone()));
157 Q_ASSERT(spy.wait());
157 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
158158 }
159159
160160 void testWKSPublishErrors() {
165165 auto job = openpgp()->wksPublishJob();
166166 connect(job, &WKSPublishJob::result, this,
167167 [this] (Error err, QByteArray, QByteArray, QString, Error) {
168 Q_ASSERT(err);
168 QVERIFY(err);
169169 Q_EMIT asyncDone();
170170 });
171171 job->startCreate("AB874F24E98EBB8487EE7B170F8E3D97FE7011B7",
172172 QStringLiteral("Foo@bar.baz"));
173173 QSignalSpy spy (this, SIGNAL(asyncDone()));
174 Q_ASSERT(spy.wait());
174 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
175175 }
176176
177177 void testWKSPublishCreate() {
198198 connect(keygenjob, &KeyGenerationJob::result, this,
199199 [this, &fpr](KeyGenerationResult result, QByteArray, QString, Error)
200200 {
201 Q_ASSERT(!result.error());
201 QVERIFY(!result.error());
202202 fpr = QByteArray(result.fingerprint());
203 Q_ASSERT(!fpr.isEmpty());
203 QVERIFY(!fpr.isEmpty());
204204 Q_EMIT asyncDone();
205205 });
206206 keygenjob->start(args);
207207 QSignalSpy spy (this, SIGNAL(asyncDone()));
208 Q_ASSERT(spy.wait());
208 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
209209
210210 /* Then try to create a request. */
211211 auto job = openpgp()->wksPublishJob();
212212 connect(job, &WKSPublishJob::result, this,
213213 [this] (Error err, QByteArray out, QByteArray, QString, Error) {
214 Q_ASSERT(!err);
214 QVERIFY(!err);
215215 Q_EMIT asyncDone();
216216 const QString outstr = QString(out);
217 Q_ASSERT(outstr.contains(
217 QVERIFY(outstr.contains(
218218 QStringLiteral("-----BEGIN PGP PUBLIC KEY BLOCK-----")));
219 Q_ASSERT(outstr.contains(
219 QVERIFY(outstr.contains(
220220 QStringLiteral("Content-Type: application/pgp-keys")));
221 Q_ASSERT(outstr.contains(
221 QVERIFY(outstr.contains(
222222 QStringLiteral("From: " TEST_ADDRESS)));
223223 });
224224 job->startCreate(fpr.constData(), QLatin1String(TEST_ADDRESS));
225 Q_ASSERT(spy.wait());
225 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
226226 }
227227
228228 void testWKSPublishReceive() {
234234 connect(importjob, &ImportJob::result, this,
235235 [this](ImportResult result, QString, Error)
236236 {
237 Q_ASSERT(!result.error());
238 Q_ASSERT(!result.imports().empty());
239 Q_ASSERT(result.numSecretKeysImported());
237 QVERIFY(!result.error());
238 QVERIFY(!result.imports().empty());
239 QVERIFY(result.numSecretKeysImported());
240240 Q_EMIT asyncDone();
241241 });
242242 importjob->start(QByteArray(testSecKey));
243243 QSignalSpy spy (this, SIGNAL(asyncDone()));
244 Q_ASSERT(spy.wait());
244 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
245245
246246 /* Get a response. */
247247 auto job = openpgp()->wksPublishJob();
248248 connect(job, &WKSPublishJob::result, this,
249249 [this] (Error err, QByteArray out, QByteArray, QString, Error) {
250 Q_ASSERT(!err);
250 QVERIFY(!err);
251251 Q_EMIT asyncDone();
252252 const QString outstr = QString(out);
253 Q_ASSERT(outstr.contains(
253 QVERIFY(outstr.contains(
254254 QStringLiteral("-----BEGIN PGP MESSAGE-----")));
255 Q_ASSERT(outstr.contains(
255 QVERIFY(outstr.contains(
256256 QStringLiteral("Content-Type: multipart/encrypted;")));
257 Q_ASSERT(outstr.contains(
257 QVERIFY(outstr.contains(
258258 QStringLiteral("From: " TEST_ADDRESS)));
259259 });
260260 job->startReceive(QByteArray(testResponse));
261 Q_ASSERT(spy.wait());
261 QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT));
262262 }
263263
264264 void initTestCase()
266266 QGpgMETest::initTestCase();
267267 const QString gpgHome = qgetenv("GNUPGHOME");
268268 qputenv("GNUPGHOME", mDir.path().toUtf8());
269 Q_ASSERT(mDir.isValid());
269 QVERIFY(mDir.isValid());
270270 QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
271 Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
271 QVERIFY(agentConf.open(QIODevice::WriteOnly));
272272 agentConf.write("allow-loopback-pinentry");
273273 agentConf.close();
274274 }
194194 fi
195195
196196 # Make the versioning information available to the compiler
197 AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
198 [If available, contains the Python version number currently in use.])
197
198 # JW: We don't need it and it interferes with the hack
199 # to detect multiple Pyhton versions
200 #AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
201 # [If available, contains the Python version number currently in use.])
199202
200203 # First, the library directory:
201204 ac_python_libdir=`cat<<EOD | $PYTHON -
0 ## ------------------------ -*- Autoconf -*-
1 ## Python file handling
2 ## From Andrew Dalke
3 ## Updated by James Henstridge
4 ## ------------------------
5 # Copyright (C) 1999-2017 Free Software Foundation, Inc.
6 #
7 # This file is free software; the Free Software Foundation
8 # gives unlimited permission to copy and/or distribute it,
9 # with or without modifications, as long as this notice is preserved.
10
11
12 # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
13 # ---------------------------------------------------------------------------
14 # Adds support for distributing Python modules and packages. To
15 # install modules, copy them to $(pythondir), using the python_PYTHON
16 # automake variable. To install a package with the same name as the
17 # automake package, install to $(pkgpythondir), or use the
18 # pkgpython_PYTHON automake variable.
19 #
20 # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
21 # locations to install python extension modules (shared libraries).
22 # Another macro is required to find the appropriate flags to compile
23 # extension modules.
24 #
25 # If your package is configured with a different prefix to python,
26 # users will have to add the install directory to the PYTHONPATH
27 # environment variable, or create a .pth file (see the python
28 # documentation for details).
29 #
30 # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
31 # cause an error if the version of python installed on the system
32 # doesn't meet the requirement. MINIMUM-VERSION should consist of
33 # numbers and dots only.
34 AC_DEFUN([AM_PATH_PYTHON],
35 [
36 dnl Find a Python interpreter. Python versions prior to 2.0 are not
37 dnl supported. (2.0 was released on October 16, 2000).
38 m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
39 [python2 python2.7 dnl
40 python dnl
41 python3 python3.0 python3.1 python3.2 python3.3 dnl
42 python3.4 python3.5 python3.6 python3.7 python3.8])
43
44 AC_ARG_VAR([PYTHON], [the Python interpreter])
45
46 m4_if([$1],[],[
47 dnl No version check is needed.
48 # Find any Python interpreter.
49 if test -z "$PYTHON"; then
50 AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
51 fi
52 am_display_PYTHON=python
53 ], [
54 dnl A version check is needed.
55 if test -n "$PYTHON"; then
56 # If the user set $PYTHON, use it and don't search something else.
57 AC_MSG_CHECKING([whether $PYTHON version is >= $1])
58 AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
59 [AC_MSG_RESULT([yes])],
60 [AC_MSG_RESULT([no])
61 AC_MSG_ERROR([Python interpreter is too old])])
62 am_display_PYTHON=$PYTHON
63 else
64 # Otherwise, try each interpreter until we find one that satisfies
65 # VERSION.
66 AC_CACHE_CHECK([for a Python interpreter with version >= $1],
67 [am_cv_pathless_PYTHON],[
68 for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
69 test "$am_cv_pathless_PYTHON" = none && break
70 AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
71 done])
72 # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
73 if test "$am_cv_pathless_PYTHON" = none; then
74 PYTHON=:
75 else
76 AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
77 fi
78 am_display_PYTHON=$am_cv_pathless_PYTHON
79 fi
80 ])
81
82 if test "$PYTHON" = :; then
83 dnl Run any user-specified action, or abort.
84 m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
85 else
86
87 dnl Query Python for its version number. Getting [:3] seems to be
88 dnl the best way to do this; it's what "site.py" does in the standard
89 dnl library.
90
91 AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
92 [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
93 AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
94
95 dnl Use the values of $prefix and $exec_prefix for the corresponding
96 dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
97 dnl distinct variables so they can be overridden if need be. However,
98 dnl general consensus is that you shouldn't need this ability.
99
100 AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
101 AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
102
103 dnl At times (like when building shared libraries) you may want
104 dnl to know which OS platform Python thinks this is.
105
106 AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
107 [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
108 AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
109
110 # Just factor out some code duplication.
111 am_python_setup_sysconfig="\
112 import sys
113 # Prefer sysconfig over distutils.sysconfig, for better compatibility
114 # with python 3.x. See automake bug#10227.
115 try:
116 import sysconfig
117 except ImportError:
118 can_use_sysconfig = 0
119 else:
120 can_use_sysconfig = 1
121 # Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
122 # <https://github.com/pypa/virtualenv/issues/118>
123 try:
124 from platform import python_implementation
125 if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7':
126 can_use_sysconfig = 0
127 except ImportError:
128 pass"
129
130 dnl Set up 4 directories:
131
132 dnl pythondir -- where to install python scripts. This is the
133 dnl site-packages directory, not the python standard library
134 dnl directory like in previous automake betas. This behavior
135 dnl is more consistent with lispdir.m4 for example.
136 dnl Query distutils for this directory.
137 AC_CACHE_CHECK([for $am_display_PYTHON script directory],
138 [am_cv_python_pythondir],
139 [if test "x$prefix" = xNONE
140 then
141 am_py_prefix=$ac_default_prefix
142 else
143 am_py_prefix=$prefix
144 fi
145 am_cv_python_pythondir=`$PYTHON -c "
146 $am_python_setup_sysconfig
147 if can_use_sysconfig:
148 sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
149 else:
150 from distutils import sysconfig
151 sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
152 sys.stdout.write(sitedir)"`
153 case $am_cv_python_pythondir in
154 $am_py_prefix*)
155 am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
156 am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
157 ;;
158 *)
159 case $am_py_prefix in
160 /usr|/System*) ;;
161 *)
162 am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
163 ;;
164 esac
165 ;;
166 esac
167 ])
168 AC_SUBST([pythondir], [$am_cv_python_pythondir])
169
170 dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
171 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
172 dnl more consistent with the rest of automake.
173
174 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
175
176 dnl pyexecdir -- directory for installing python extension modules
177 dnl (shared libraries)
178 dnl Query distutils for this directory.
179 AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
180 [am_cv_python_pyexecdir],
181 [if test "x$exec_prefix" = xNONE
182 then
183 am_py_exec_prefix=$am_py_prefix
184 else
185 am_py_exec_prefix=$exec_prefix
186 fi
187 am_cv_python_pyexecdir=`$PYTHON -c "
188 $am_python_setup_sysconfig
189 if can_use_sysconfig:
190 sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
191 else:
192 from distutils import sysconfig
193 sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
194 sys.stdout.write(sitedir)"`
195 case $am_cv_python_pyexecdir in
196 $am_py_exec_prefix*)
197 am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
198 am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
199 ;;
200 *)
201 case $am_py_exec_prefix in
202 /usr|/System*) ;;
203 *)
204 am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
205 ;;
206 esac
207 ;;
208 esac
209 ])
210 AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
211
212 dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
213
214 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
215
216 dnl Run any user-specified action.
217 $2
218 fi
219
220 ])
221
222
223 # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
224 # ---------------------------------------------------------------------------
225 # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
226 # Run ACTION-IF-FALSE otherwise.
227 # This test uses sys.hexversion instead of the string equivalent (first
228 # word of sys.version), in order to cope with versions such as 2.2c1.
229 # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
230 AC_DEFUN([AM_PYTHON_CHECK_VERSION],
231 [prog="import sys
232 # split strings by '.' and convert to numeric. Append some zeros
233 # because we need at least 4 digits for the hex conversion.
234 # map returns an iterator in Python 3.0 and a list in 2.x
235 minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
236 minverhex = 0
237 # xrange is not present in Python 3.0 and range returns an iterator
238 for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
239 sys.exit(sys.hexversion < minverhex)"
240 AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
3131 AC_CHECK_TOOL(MOC, moc)
3232 AC_MSG_CHECKING([moc version])
3333 mocversion=`$MOC -v 2>&1`
34 mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"`
34 mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc 5"`
3535 if test x"$mocversiongrep" != x"$mocversion"; then
3636 AC_MSG_RESULT([no])
3737 # moc was not the qt5 one, try with moc-qt5
3838 AC_CHECK_TOOL(MOC2, moc-qt5)
3939 mocversion=`$MOC2 -v 2>&1`
40 mocversiongrep=`echo $mocversion | grep "Qt 5\|moc-qt5 5\|moc 5"`
40 mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc-qt5 5|moc 5"`
4141 if test x"$mocversiongrep" != x"$mocversion"; then
4242 AC_CHECK_TOOL(QTCHOOSER, qtchooser)
4343 qt5tooldir=`QT_SELECT=qt5 qtchooser -print-env | grep QTTOOLDIR | cut -d '=' -f 2 | cut -d \" -f 2`
4444 mocversion=`$qt5tooldir/moc -v 2>&1`
45 mocversiongrep=`echo $mocversion | grep "Qt 5\|moc 5"`
45 mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc 5"`
4646 if test x"$mocversiongrep" != x"$mocversion"; then
4747 # no valid moc found
4848 have_qt5_libs="no";
113113 /* True if session keys should be exported upon decryption. */
114114 unsigned int export_session_keys : 1;
115115
116 /* True if a Pinentry was launched during the last operation. This
117 * flag is cleared with each operation. */
118 unsigned int redraw_suggested : 1;
119
116120 /* Flags for keylist mode. */
117121 gpgme_keylist_mode_t keylist_mode;
118122
119 /* The current pinnetry mode. */
123 /* The current pinentry mode. */
120124 gpgme_pinentry_mode_t pinentry_mode;
121125
122126 /* Number of certs to be included. */
535535 }
536536
537537
538 /* This function is similar to _gpgme_parse_timestamp but returns an
539 * unsigned long and 0 on error. */
540 unsigned long
541 _gpgme_parse_timestamp_ul (const char *timestamp)
542 {
543 time_t tim;
544 char *tail;
545
546 if (!*timestamp)
547 return 0; /* Shortcut empty strings. */
548
549 tim = _gpgme_parse_timestamp (timestamp, &tail);
550 if (tim == -1 || timestamp == tail || (*tail && *tail != ' '))
551 tim = 0; /* No time given or invalid engine. */
552
553 return (unsigned long)tim;
554 }
555
556
538557 /* The GPG backend uses OpenPGP algorithm numbers which we need to map
539558 to our algorithm numbers. This function MUST not change ERRNO. */
540559 int
238238 (*r_dh)->data.old_user.handle = read_cb_value;
239239 return TRACE_ERR (0);
240240 }
241
242
243 gpgme_error_t
244 gpgme_data_rewind (gpgme_data_t dh)
245 {
246 gpgme_error_t err;
247 TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh);
248
249 err = ((gpgme_data_seek (dh, 0, SEEK_SET) == -1)
250 ? gpg_error_from_syserror () : 0);
251
252 return TRACE_ERR (err);
253 }
154154 dh->pending_len = 0;
155155
156156 return TRACE_SYSRES (offset);
157 }
158
159
160 /* Convenience function to do a gpgme_data_seek (dh, 0, SEEK_SET). */
161 gpgme_error_t
162 gpgme_data_rewind (gpgme_data_t dh)
163 {
164 gpgme_error_t err;
165 TRACE_BEG (DEBUG_DATA, "gpgme_data_rewind", dh);
166
167 err = ((gpgme_data_seek (dh, 0, SEEK_SET) == -1)
168 ? gpg_error_from_syserror () : 0);
169
170 return TRACE_ERR (err);
157171 }
158172
159173
312312 }
313313
314314 va_start (arg_ptr, format);
315 res = vasprintf ((char **) line, format, arg_ptr);
315 res = gpgrt_vasprintf ((char **) line, format, arg_ptr);
316316 va_end (arg_ptr);
317317 if (res < 0)
318318 *line = NULL;
332332 return;
333333
334334 va_start (arg_ptr, format);
335 res = vasprintf (&toadd, format, arg_ptr);
335 res = gpgrt_vasprintf (&toadd, format, arg_ptr);
336336 va_end (arg_ptr);
337337 if (res < 0)
338338 {
339 free (*line);
339 gpgrt_free (*line);
340340 *line = NULL;
341341 }
342 res = asprintf (&result, "%s%s", *(char **) line, toadd);
343 free (toadd);
344 free (*line);
342 res = gpgrt_asprintf (&result, "%s%s", *(char **) line, toadd);
343 gpgrt_free (toadd);
344 gpgrt_free (*line);
345345 if (res < 0)
346346 *line = NULL;
347347 else
360360 /* The smallest possible level is 1, so force logging here by
361361 using that. */
362362 _gpgme_debug (1, "%s", *line);
363 free (*line);
363 gpgrt_free (*line);
364364 *line = NULL;
365365 }
366366
2222 #include <config.h>
2323 #endif
2424
25 #include <assert.h>
26
2527 #include "debug.h"
2628 #include "gpgme.h"
2729 #include "ops.h"
4446
4547 static gpgme_error_t
4648 decrypt_verify_start (gpgme_ctx_t ctx, int synchronous,
49 gpgme_decrypt_flags_t flags,
4750 gpgme_data_t cipher, gpgme_data_t plain)
4851 {
4952 gpgme_error_t err;
53
54 assert ((flags & GPGME_DECRYPT_VERIFY));
5055
5156 err = _gpgme_op_reset (ctx, synchronous);
5257 if (err)
7681 _gpgme_engine_set_status_handler (ctx->engine,
7782 decrypt_verify_status_handler, ctx);
7883
79 return _gpgme_engine_op_decrypt_verify (ctx->engine, cipher, plain,
80 ctx->export_session_keys,
81 ctx->override_session_key);
84 return _gpgme_engine_op_decrypt (ctx->engine,
85 flags,
86 cipher, plain,
87 ctx->export_session_keys,
88 ctx->override_session_key);
8289 }
8390
8491
96103 if (!ctx)
97104 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
98105
99 err = decrypt_verify_start (ctx, 0, cipher, plain);
106 err = decrypt_verify_start (ctx, 0, GPGME_DECRYPT_VERIFY, cipher, plain);
100107 return TRACE_ERR (err);
101108 }
102109
115122 if (!ctx)
116123 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
117124
118 err = decrypt_verify_start (ctx, 1, cipher, plain);
125 err = decrypt_verify_start (ctx, 1, GPGME_DECRYPT_VERIFY, cipher, plain);
119126 if (!err)
120127 err = _gpgme_wait_one (ctx);
121128 return TRACE_ERR (err);
122129 }
130
131
132 /* Decrypt ciphertext CIPHER within CTX and store the resulting
133 plaintext in PLAIN. */
134 gpgme_error_t
135 gpgme_op_decrypt_ext_start (gpgme_ctx_t ctx,
136 gpgme_decrypt_flags_t flags,
137 gpgme_data_t cipher,
138 gpgme_data_t plain)
139 {
140 gpgme_error_t err;
141
142 TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_ext_start", ctx,
143 "cipher=%p, plain=%p", cipher, plain);
144
145 if (!ctx)
146 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
147
148 if ((flags & GPGME_DECRYPT_VERIFY))
149 err = decrypt_verify_start (ctx, 0, flags, cipher, plain);
150 else
151 err = _gpgme_decrypt_start (ctx, 0, flags, cipher, plain);
152 return TRACE_ERR (err);
153 }
154
155
156 /* Decrypt ciphertext CIPHER within CTX and store the resulting
157 plaintext in PLAIN. */
158 gpgme_error_t
159 gpgme_op_decrypt_ext (gpgme_ctx_t ctx,
160 gpgme_decrypt_flags_t flags,
161 gpgme_data_t cipher,
162 gpgme_data_t plain)
163 {
164 gpgme_error_t err;
165
166 TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_ext", ctx,
167 "cipher=%p, plain=%p", cipher, plain);
168
169 if (!ctx)
170 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
171
172 if ((flags & GPGME_DECRYPT_VERIFY))
173 err = decrypt_verify_start (ctx, 1, flags, cipher, plain);
174 else
175 err = _gpgme_decrypt_start (ctx, 1, flags, cipher, plain);
176 if (!err)
177 err = _gpgme_wait_one (ctx);
178 return TRACE_ERR (err);
179 }
2424 #include <stdlib.h>
2525 #include <string.h>
2626 #include <errno.h>
27 #include <assert.h>
2728
2829 #include "debug.h"
2930 #include "gpgme.h"
357358 }
358359
359360
360 static gpgme_error_t
361 decrypt_start (gpgme_ctx_t ctx, int synchronous,
362 gpgme_data_t cipher, gpgme_data_t plain)
363 {
364 gpgme_error_t err;
361 gpgme_error_t
362 _gpgme_decrypt_start (gpgme_ctx_t ctx, int synchronous,
363 gpgme_decrypt_flags_t flags,
364 gpgme_data_t cipher, gpgme_data_t plain)
365 {
366 gpgme_error_t err;
367
368 assert (!(flags & GPGME_DECRYPT_VERIFY));
365369
366370 err = _gpgme_op_reset (ctx, synchronous);
367371 if (err)
389393
390394 _gpgme_engine_set_status_handler (ctx->engine, decrypt_status_handler, ctx);
391395
392 return _gpgme_engine_op_decrypt (ctx->engine, cipher, plain,
396 return _gpgme_engine_op_decrypt (ctx->engine,
397 flags,
398 cipher, plain,
393399 ctx->export_session_keys,
394400 ctx->override_session_key);
395401 }
407413 if (!ctx)
408414 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
409415
410 err = decrypt_start (ctx, 0, cipher, plain);
416 err = _gpgme_decrypt_start (ctx, 0, 0, cipher, plain);
411417 return TRACE_ERR (err);
412418 }
413419
425431 if (!ctx)
426432 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
427433
428 err = decrypt_start (ctx, 1, cipher, plain);
434 err = _gpgme_decrypt_start (ctx, 1, 0, cipher, plain);
429435 if (!err)
430436 err = _gpgme_wait_one (ctx);
431437 return TRACE_ERR (err);
5050 WANT_GPG_NAME,
5151 WANT_GPGSM_NAME,
5252 WANT_G13_NAME,
53 WANT_GPG_WKS_CLIENT_NAME,
5354 WANT_GPG_ONE_MODE
5455 };
5556
7273 char *gpg_name;
7374 char *gpgsm_name;
7475 char *g13_name;
76 char *gpg_wks_client_name;
7577 int gpg_one_mode; /* System is in gpg1 mode. */
7678 } dirinfo;
7779
332334 case WANT_G13_NAME: result = dirinfo.g13_name; break;
333335 case WANT_UISRV_SOCKET: result = dirinfo.uisrv_socket; break;
334336 case WANT_GPG_ONE_MODE: result = dirinfo.gpg_one_mode? "1":NULL; break;
337 case WANT_GPG_WKS_CLIENT_NAME:
338 if (!dirinfo.gpg_wks_client_name && dirinfo.libexecdir)
339 dirinfo.gpg_wks_client_name = _gpgme_strconcat (dirinfo.libexecdir,
340 "/",
341 "gpg-wks-client",
342 NULL);
343 result = dirinfo.gpg_wks_client_name;
344 break;
335345 }
336346 UNLOCK (dirinfo_lock);
337347 return result;
437447 return get_gpgconf_item (WANT_GPGSM_NAME);
438448 else if (!strcmp (what, "g13-name"))
439449 return get_gpgconf_item (WANT_G13_NAME);
450 else if (!strcmp (what, "gpg-wks-client-name"))
451 return get_gpgconf_item (WANT_GPG_WKS_CLIENT_NAME);
440452 else if (!strcmp (what, "agent-ssh-socket"))
441453 return get_gpgconf_item (WANT_AGENT_SSH_SOCKET);
442454 else if (!strcmp (what, "dirmngr-socket"))
264264 goto leave;
265265 if (dft_display)
266266 {
267 if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
267 if (gpgrt_asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
268268 {
269269 err = gpg_error_from_syserror ();
270270 free (dft_display);
274274
275275 err = assuan_transact (llass->assuan_ctx, optstr, NULL, NULL, NULL,
276276 NULL, NULL, NULL);
277 free (optstr);
277 gpgrt_free (optstr);
278278 if (err)
279279 goto leave;
280280 }
303303 ways, e.g., when /dev/pts is not accessible under chroot. */
304304 if (!rc)
305305 {
306 if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
306 if (gpgrt_asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
307307 {
308308 err = gpg_error_from_syserror ();
309309 goto leave;
310310 }
311311 err = assuan_transact (llass->assuan_ctx, optstr, NULL, NULL, NULL,
312312 NULL, NULL, NULL);
313 free (optstr);
313 gpgrt_free (optstr);
314314 if (err)
315315 goto leave;
316316
319319 goto leave;
320320 if (dft_ttytype)
321321 {
322 if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
322 if (gpgrt_asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype)< 0)
323323 {
324324 err = gpg_error_from_syserror ();
325325 free (dft_ttytype);
329329
330330 err = assuan_transact (llass->assuan_ctx, optstr, NULL, NULL,
331331 NULL, NULL, NULL, NULL);
332 free (optstr);
332 gpgrt_free (optstr);
333333 if (err)
334334 goto leave;
335335 }
407407 if (!value)
408408 return 0;
409409
410 if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
410 if (gpgrt_asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
411411 err = gpg_error_from_syserror ();
412412 else
413413 {
414414 err = assuan_transact (llass->assuan_ctx, optstr, NULL, NULL,
415415 NULL, NULL, NULL, NULL);
416 free (optstr);
416 gpgrt_free (optstr);
417417 }
418418 return err;
419419 }
775775 llass_set_locale,
776776 NULL, /* set_protocol */
777777 NULL, /* decrypt */
778 NULL, /* decrypt_verify */
779778 NULL, /* delete */
780779 NULL, /* edit */
781780 NULL, /* encrypt */
786785 NULL, /* import */
787786 NULL, /* keylist */
788787 NULL, /* keylist_ext */
788 NULL, /* keylist_data */
789789 NULL, /* keysign */
790790 NULL, /* tofu_policy */
791791 NULL, /* sign */
6060 void *fnc_value);
6161 gpgme_error_t (*set_locale) (void *engine, int category, const char *value);
6262 gpgme_error_t (*set_protocol) (void *engine, gpgme_protocol_t protocol);
63 gpgme_error_t (*decrypt) (void *engine, gpgme_data_t ciph,
63 gpgme_error_t (*decrypt) (void *engine,
64 gpgme_decrypt_flags_t flags,
65 gpgme_data_t ciph,
6466 gpgme_data_t plain, int export_session_key,
6567 const char *override_session_key);
66 gpgme_error_t (*decrypt_verify) (void *engine, gpgme_data_t ciph,
67 gpgme_data_t plain, int export_session_key,
68 const char *override_session_key);
6968 gpgme_error_t (*delete) (void *engine, gpgme_key_t key, int allow_secret);
7069 gpgme_error_t (*edit) (void *engine, int type, gpgme_key_t key,
7170 gpgme_data_t out, gpgme_ctx_t ctx /* FIXME */);
9998 int secret_only, int reserved,
10099 gpgme_keylist_mode_t mode,
101100 int engine_flags);
101 gpgme_error_t (*keylist_data) (void *engine, gpgme_data_t data);
102102 gpgme_error_t (*keysign) (void *engine,
103103 gpgme_key_t key, const char *userid,
104104 unsigned long expires, unsigned int flags,
269269 goto leave;
270270 if (dft_display)
271271 {
272 if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
272 if (gpgrt_asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
273273 {
274274 free (dft_display);
275275 err = gpg_error_from_syserror ();
279279
280280 err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL, NULL,
281281 NULL, NULL, NULL);
282 free (optstr);
282 gpgrt_free (optstr);
283283 if (err)
284284 goto leave;
285285 }
303303 ways, e.g., when /dev/pts is not accessible under chroot. */
304304 if (!rc)
305305 {
306 if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
306 if (gpgrt_asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
307307 {
308308 err = gpg_error_from_syserror ();
309309 goto leave;
310310 }
311311 err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL, NULL,
312312 NULL, NULL, NULL);
313 free (optstr);
313 gpgrt_free (optstr);
314314 if (err)
315315 goto leave;
316316
319319 goto leave;
320320 if (dft_ttytype)
321321 {
322 if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
322 if (gpgrt_asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype)< 0)
323323 {
324324 free (dft_ttytype);
325325 err = gpg_error_from_syserror ();
329329
330330 err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL,
331331 NULL, NULL, NULL, NULL);
332 free (optstr);
332 gpgrt_free (optstr);
333333 if (err)
334334 goto leave;
335335 }
399399 if (!value)
400400 return 0;
401401
402 if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
402 if (gpgrt_asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
403403 err = gpg_error_from_syserror ();
404404 else
405405 {
406406 err = assuan_transact (g13->assuan_ctx, optstr, NULL, NULL,
407407 NULL, NULL, NULL, NULL);
408 free (optstr);
408 gpgrt_free (optstr);
409409 }
410410
411411 return err;
790790 g13_set_locale,
791791 NULL, /* set_protocol */
792792 NULL, /* decrypt */
793 NULL, /* decrypt_verify */
794793 NULL, /* delete */
795794 NULL, /* edit */
796795 NULL, /* encrypt */
801800 NULL, /* import */
802801 NULL, /* keylist */
803802 NULL, /* keylist_ext */
803 NULL, /* keylist_data */
804804 NULL, /* keysign */
805805 NULL, /* tofu_policy */
806806 NULL, /* sign */
7373 };
7474
7575
76 /* NB.: R_LINE is allocated an gpgrt function and thus gpgrt_free
77 * shall be used to release it. This takes care of custom memory
78 * allocators and avoids problems on Windows with different runtimes
79 * used for libgpg-error/gpgrt and gpgme. */
7680 typedef gpgme_error_t (*colon_preprocessor_t) (char *line, char **rline);
7781
7882 struct engine_gpg
13451349 }
13461350 while (linep && *linep);
13471351
1348 free (line);
1352 gpgrt_free (line);
13491353 }
13501354 else
13511355 gpg->colon.fnc (gpg->colon.fnc_value, buffer);
15541558
15551559
15561560 static gpgme_error_t
1557 gpg_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
1561 gpg_decrypt (void *engine,
1562 gpgme_decrypt_flags_t flags,
1563 gpgme_data_t ciph, gpgme_data_t plain,
15581564 int export_session_key, const char *override_session_key)
15591565 {
15601566 engine_gpg_t gpg = engine;
15611567 gpgme_error_t err;
15621568
15631569 err = add_arg (gpg, "--decrypt");
1570
1571 if (!err && (flags & GPGME_DECRYPT_UNWRAP))
1572 {
1573 if (!have_gpg_version (gpg, "2.1.12"))
1574 err = gpg_error (GPG_ERR_NOT_SUPPORTED);
1575 else
1576 err = add_arg (gpg, "--unwrap");
1577 }
15641578
15651579 if (!err && export_session_key)
15661580 err = add_arg (gpg, "--show-session-key");
18521866 if (!err && use_armor)
18531867 err = add_arg (gpg, "--armor");
18541868
1869 if (!err && (flags & GPGME_ENCRYPT_WRAP))
1870 {
1871 /* gpg is current not abale to detect already compressed
1872 * packets. Thus when using
1873 * gpg --unwrap -d | gpg --no-literal -e
1874 * the encryption would add an additional compression layer.
1875 * We better suppress that. */
1876 flags |= GPGME_ENCRYPT_NO_COMPRESS;
1877 err = add_arg (gpg, "--no-literal");
1878 }
1879
18551880 if (!err && (flags & GPGME_ENCRYPT_NO_COMPRESS))
18561881 err = add_arg (gpg, "--compress-algo=none");
1882
1883 if (!err && (flags & GPGME_ENCRYPT_THROW_KEYIDS))
1884 err = add_arg (gpg, "--throw-keyids");
18571885
18581886 if (gpgme_data_get_encoding (plain) == GPGME_DATA_ENCODING_MIME
18591887 && have_gpg_version (gpg, "2.1.14"))
19231951
19241952 if (!err && (flags & GPGME_ENCRYPT_NO_COMPRESS))
19251953 err = add_arg (gpg, "--compress-algo=none");
1954
1955 if (!err && (flags & GPGME_ENCRYPT_THROW_KEYIDS))
1956 err = add_arg (gpg, "--throw-keyids");
19261957
19271958 if (gpgme_data_get_encoding (plain) == GPGME_DATA_ENCODING_MIME
19281959 && have_gpg_version (gpg, "2.1.14"))
20712102 /* This condition is only required to allow the use of gpg < 2.1.16 */
20722103 if (algo
20732104 || (flags & (GPGME_CREATE_SIGN | GPGME_CREATE_ENCR
2074 | GPGME_CREATE_CERT | GPGME_CREATE_AUTH))
2105 | GPGME_CREATE_CERT | GPGME_CREATE_AUTH
2106 | GPGME_CREATE_NOEXPIRE))
20752107 || expires)
20762108 {
20772109 err = add_arg (gpg, algo? algo : "default");
20852117 (flags & GPGME_CREATE_AUTH)? " auth":"");
20862118 err = add_arg (gpg, *tmpbuf? tmpbuf : "default");
20872119 }
2088 if (!err && expires)
2120 if (!err)
20892121 {
2090 char tmpbuf[8+20];
2091 snprintf (tmpbuf, sizeof tmpbuf, "seconds=%lu", expires);
2092 err = add_arg (gpg, tmpbuf);
2122 if ((flags & GPGME_CREATE_NOEXPIRE))
2123 err = add_arg (gpg, "never");
2124 else if (expires == 0)
2125 err = add_arg (gpg, "-");
2126 else
2127 {
2128 char tmpbuf[8+20];
2129 snprintf (tmpbuf, sizeof tmpbuf, "seconds=%lu", expires);
2130 err = add_arg (gpg, tmpbuf);
2131 }
20932132 }
20942133 }
20952134 else
21352174 err = add_arg (gpg, "--passphrase");
21362175 if (!err)
21372176 err = add_arg (gpg, "");
2177 if (!err)
2178 err = add_arg (gpg, "--batch");
21382179 }
21392180 if (!err && (flags & GPGME_CREATE_FORCE))
21402181 err = add_arg (gpg, "--yes");
21732214 err = add_arg (gpg, "--passphrase");
21742215 if (!err)
21752216 err = add_arg (gpg, "");
2217 if (!err)
2218 err = add_arg (gpg, "--batch");
21762219 }
21772220 if (!err)
21782221 err = add_arg (gpg, "--");
21992242 if (!key || !key->fpr || !userid)
22002243 return gpg_error (GPG_ERR_INV_ARG);
22012244
2202 if ((extraflags & GENKEY_EXTRAFLAG_REVOKE))
2245 if ((extraflags & GENKEY_EXTRAFLAG_SETPRIMARY))
2246 {
2247 if (!have_gpg_version (gpg, "2.1.20"))
2248 err = gpg_error (GPG_ERR_NOT_SUPPORTED);
2249 else
2250 err = add_arg (gpg, "--quick-set-primary-uid");
2251 }
2252 else if ((extraflags & GENKEY_EXTRAFLAG_REVOKE))
22032253 err = add_arg (gpg, "--quick-revuid");
22042254 else
22052255 err = add_arg (gpg, "--quick-adduid");
22392289 * USERID && !KEY - Create a new keyblock.
22402290 * !USERID && KEY - Add a new subkey to KEY (gpg >= 2.1.14)
22412291 * USERID && KEY && !ALGO - Add a new user id to KEY (gpg >= 2.1.14).
2242 *
2292 * or set a flag on a user id.
22432293 */
22442294 if (help_data)
22452295 {
25082558 n = strlen (field[1]);
25092559 if (n > 16)
25102560 {
2511 if (asprintf (r_line,
2561 if (gpgrt_asprintf (r_line,
25122562 "pub:o%s:%s:%s:%s:%s:%s::::::::\n"
25132563 "fpr:::::::::%s:",
25142564 field[6], field[3], field[2], field[1] + n - 16,
25172567 }
25182568 else
25192569 {
2520 if (asprintf (r_line,
2570 if (gpgrt_asprintf (r_line,
25212571 "pub:o%s:%s:%s:%s:%s:%s::::::::",
25222572 field[6], field[3], field[2], field[1],
25232573 field[4], field[5]) < 0)
25752625 }
25762626 *dst = '\0';
25772627
2578 if (asprintf (r_line, "uid:o%s::::%s:%s:::%s:",
2628 if (gpgrt_asprintf (r_line, "uid:o%s::::%s:%s:::%s:",
25792629 field[4], field[2], field[3], uid) < 0)
25802630 return gpg_error_from_syserror ();
25812631 }
27142764
27152765
27162766 static gpgme_error_t
2767 gpg_keylist_data (void *engine, gpgme_data_t data)
2768 {
2769 engine_gpg_t gpg = engine;
2770 gpgme_error_t err;
2771
2772 if (!have_gpg_version (gpg, "2.1.14"))
2773 return gpg_error (GPG_ERR_NOT_SUPPORTED);
2774
2775 err = add_arg (gpg, "--with-colons");
2776 if (!err)
2777 err = add_arg (gpg, "--with-fingerprint");
2778 if (!err)
2779 err = add_arg (gpg, "--import-options");
2780 if (!err)
2781 err = add_arg (gpg, "import-show");
2782 if (!err)
2783 err = add_arg (gpg, "--dry-run");
2784 if (!err)
2785 err = add_arg (gpg, "--import");
2786 if (!err)
2787 err = add_arg (gpg, "--");
2788 if (!err)
2789 err = add_data (gpg, data, -1, 0);
2790
2791 if (!err)
2792 err = start (gpg);
2793
2794 return err;
2795 }
2796
2797
2798 static gpgme_error_t
27172799 gpg_keysign (void *engine, gpgme_key_t key, const char *userid,
27182800 unsigned long expire, unsigned int flags,
27192801 gpgme_ctx_t ctx)
29853067 gpg_set_locale,
29863068 NULL, /* set_protocol */
29873069 gpg_decrypt,
2988 gpg_decrypt, /* decrypt_verify */
29893070 gpg_delete,
29903071 gpg_edit,
29913072 gpg_encrypt,
29963077 gpg_import,
29973078 gpg_keylist,
29983079 gpg_keylist_ext,
3080 gpg_keylist_data,
29993081 gpg_keysign,
30003082 gpg_tofu_policy, /* tofu_policy */
30013083 gpg_sign,
707707 #define BUFLEN 1024
708708 char buf[BUFLEN];
709709 int buflen = 0;
710 char *argv[6];
710 char *argv[7];
711711 int argc = 0;
712 int rp[2];
713 struct spawn_fd_item_s cfd[] = { {-1, 0 /* STDIN_FILENO */}, {-1, -1} };
712 int rp[2] = { -1, -1 };
713 int errp[2] = { -1, -1 };
714 struct spawn_fd_item_s cfd[] = { {-1, 0 /* STDIN_FILENO */},
715 {-1, 2 /* STDERR_FILENO */, -1},
716 {-1, -1} };
714717 int status;
715718 int nwrite;
716719
723726 argv[argc++] = gpgconf->home_dir;
724727 }
725728
729 argv[argc++] = (char*)"--runtime";
726730 argv[argc++] = (char*)arg1;
727731 argv[argc++] = arg2;
728732 argv[argc] = NULL;
729733 assert (argc < DIM (argv));
730734
731735 if (_gpgme_io_pipe (rp, 0) < 0)
732 return gpg_error_from_syserror ();
736 {
737 err = gpg_error_from_syserror ();
738 goto leave;
739 }
740
741 if (_gpgme_io_pipe (errp, 1) < 0)
742 {
743 err = gpg_error_from_syserror ();
744 goto leave;
745 }
733746
734747 cfd[0].fd = rp[0];
748 cfd[1].fd = errp[1];
735749
736750 status = _gpgme_io_spawn (gpgconf->file_name, argv,
737751 IOSPAWN_FLAG_DETACHED, cfd, NULL, NULL, NULL);
738752 if (status < 0)
739753 {
740 _gpgme_io_close (rp[0]);
741 _gpgme_io_close (rp[1]);
742 return gpg_error_from_syserror ();
743 }
754 err = gpg_error_from_syserror ();
755 goto leave;
756 }
757
758 rp[0] = -1;
759 errp[1] = -1;
744760
745761 for (;;)
746762 {
755771 if (buflen < 0)
756772 {
757773 err = gpg_error_from_syserror ();
758 _gpgme_io_close (rp[1]);
759 return err;
774 goto leave;
760775 }
761776 else if (buflen == 0)
762777 {
763778 /* All is written. */
764779 _gpgme_io_close (rp[1]);
765 return 0;
780 rp[1] = -1;
781
782 for (;;)
783 {
784 do
785 {
786 buflen = _gpgme_io_read (errp[0], buf, BUFLEN);
787 }
788 while (buflen < 0 && errno == EAGAIN);
789
790 if (buflen == 0)
791 {
792 err = 0;
793 goto leave;
794 }
795 /* XXX: Do something useful with BUF. */
796 }
766797 }
767798 }
768799
780811 }
781812 else if (nwrite < 0)
782813 {
783 _gpgme_io_close (rp[1]);
784 return gpg_error_from_syserror ();
814 err = gpg_error_from_syserror ();
815 goto leave;
785816 }
786817 }
787818
788 return 0;
819 assert (! "reached");
820
821 leave:
822 if (rp[0] != -1)
823 _gpgme_io_close (rp[0]);
824 if (rp[1] != -1)
825 _gpgme_io_close (rp[1]);
826 if (errp[0] != -1)
827 _gpgme_io_close (errp[0]);
828 if (errp[1] != -1)
829 _gpgme_io_close (errp[1]);
830
831 return err;
789832 }
790833
791834
11891232 NULL, /* set_locale */
11901233 NULL, /* set_protocol */
11911234 NULL, /* decrypt */
1192 NULL, /* decrypt_verify */
11931235 NULL, /* delete */
11941236 NULL, /* edit */
11951237 NULL, /* encrypt */
12001242 NULL, /* import */
12011243 NULL, /* keylist */
12021244 NULL, /* keylist_ext */
1245 NULL, /* keylist_data */
12031246 NULL, /* keysign */
12041247 NULL, /* tofu_policy */
12051248 NULL, /* sign */
395395 goto leave;
396396 if (dft_display)
397397 {
398 if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
398 if (gpgrt_asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
399399 {
400400 free (dft_display);
401401 err = gpg_error_from_syserror ();
405405
406406 err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL,
407407 NULL, NULL, NULL);
408 free (optstr);
408 gpgrt_free (optstr);
409409 if (err)
410410 goto leave;
411411 }
429429 ways, e.g., when /dev/pts is not accessible under chroot. */
430430 if (!rc)
431431 {
432 if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
432 if (gpgrt_asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
433433 {
434434 err = gpg_error_from_syserror ();
435435 goto leave;
436436 }
437437 err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL,
438438 NULL, NULL, NULL);
439 free (optstr);
439 gpgrt_free (optstr);
440440 if (err)
441441 goto leave;
442442
445445 goto leave;
446446 if (dft_ttytype)
447447 {
448 if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
448 if (gpgrt_asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype)< 0)
449449 {
450450 free (dft_ttytype);
451451 err = gpg_error_from_syserror ();
455455
456456 err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
457457 NULL, NULL, NULL, NULL);
458 free (optstr);
458 gpgrt_free (optstr);
459459 if (err)
460460 goto leave;
461461 }
560560 if (!value)
561561 return 0;
562562
563 if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
563 if (gpgrt_asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
564564 err = gpg_error_from_syserror ();
565565 else
566566 {
567567 err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
568568 NULL, NULL, NULL, NULL);
569 free (optstr);
569 gpgrt_free (optstr);
570570 }
571571
572572 return err;
592592 {
593593 err = assuan_read_line (ctx, &line, &linelen);
594594 if (err)
595 return err;
595 break;
596596
597597 if (*line == '#' || !linelen)
598598 continue;
600600 if (linelen >= 2
601601 && line[0] == 'O' && line[1] == 'K'
602602 && (line[2] == '\0' || line[2] == ' '))
603 return cb_err;
603 break;
604604 else if (linelen >= 4
605605 && line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
606606 && line[3] == ' ')
609609 more related to gpgme and thus probably more important
610610 than the error returned by the engine. */
611611 err = cb_err? cb_err : atoi (&line[4]);
612 cb_err = 0;
612613 }
613614 else if (linelen >= 2
614615 && line[0] == 'S' && line[1] == ' ')
645646 to stop. As with ERR we prefer a status callback
646647 generated error code, though. */
647648 err = cb_err ? cb_err : gpg_error (GPG_ERR_GENERAL);
649 cb_err = 0;
648650 }
649651 }
650652 while (!err);
653
654 /* We only want the first error from the status handler, thus we
655 * take the one saved in CB_ERR. */
656 if (!err && cb_err)
657 err = cb_err;
651658
652659 return err;
653660 }
11191126
11201127
11211128 static gpgme_error_t
1122 gpgsm_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
1129 gpgsm_decrypt (void *engine,
1130 gpgme_decrypt_flags_t flags,
1131 gpgme_data_t ciph, gpgme_data_t plain,
11231132 int export_session_key, const char *override_session_key)
11241133 {
11251134 engine_gpgsm_t gpgsm = engine;
11261135 gpgme_error_t err;
1136
1137 (void)flags;
11271138
11281139 /* gpgsm is not capable of exporting session keys right now, so we
11291140 * will ignore this if requested. */
16411652 gpgsm_assuan_simple_command (gpgsm, "GETINFO agent-check", NULL, NULL);
16421653
16431654 /* Always send list-mode option because RESET does not reset it. */
1644 if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
1655 if (gpgrt_asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
16451656 return gpg_error_from_syserror ();
16461657 err = gpgsm_assuan_simple_command (gpgsm, line, NULL, NULL);
1647 free (line);
1658 gpgrt_free (line);
16481659 if (err)
16491660 return err;
16501661
17251736 list_mode |= 2;
17261737
17271738 /* Always send list-mode option because RESET does not reset it. */
1728 if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
1739 if (gpgrt_asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
17291740 return gpg_error_from_syserror ();
17301741 err = gpgsm_assuan_simple_command (gpgsm, line, NULL, NULL);
1731 free (line);
1742 gpgrt_free (line);
17321743 if (err)
17331744 return err;
17341745
18591870 can reset any previously set value in case the default is
18601871 requested. */
18611872
1862 if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0)
1873 if (gpgrt_asprintf (&assuan_cmd,
1874 "OPTION include-certs %i", include_certs) < 0)
18631875 return gpg_error_from_syserror ();
18641876 err = gpgsm_assuan_simple_command (gpgsm, assuan_cmd, NULL, NULL);
1865 free (assuan_cmd);
1877 gpgrt_free (assuan_cmd);
18661878 if (err)
18671879 return err;
18681880 }
20472059 if (!key || !key->subkeys || !key->subkeys->fpr)
20482060 return gpg_error (GPG_ERR_INV_CERT_OBJ);
20492061
2050 if (asprintf (&line, "PASSWD -- %s", key->subkeys->fpr) < 0)
2062 if (gpgrt_asprintf (&line, "PASSWD -- %s", key->subkeys->fpr) < 0)
20512063 return gpg_error_from_syserror ();
20522064
20532065 gpgsm_clear_fd (gpgsm, OUTPUT_FD);
20562068 gpgsm->inline_data = NULL;
20572069
20582070 err = start (gpgsm, line);
2059 free (line);
2071 gpgrt_free (line);
20602072
20612073 return err;
20622074 }
20862098 gpgsm_set_locale,
20872099 NULL, /* set_protocol */
20882100 gpgsm_decrypt,
2089 gpgsm_decrypt,
20902101 gpgsm_delete, /* decrypt_verify */
20912102 NULL, /* edit */
20922103 gpgsm_encrypt,
20972108 gpgsm_import,
20982109 gpgsm_keylist,
20992110 gpgsm_keylist_ext,
2111 NULL, /* keylist_data */
21002112 NULL, /* keysign */
21012113 NULL, /* tofu_policy */
21022114 gpgsm_sign,
448448 NULL, /* set_locale */
449449 NULL, /* set_protocol */
450450 NULL, /* decrypt */
451 NULL, /* decrypt_verify */
452451 NULL, /* delete */
453452 NULL, /* edit */
454453 NULL, /* encrypt */
459458 NULL, /* import */
460459 NULL, /* keylist */
461460 NULL, /* keylist_ext */
461 NULL, /* keylist_data */
462462 NULL, /* keysign */
463463 NULL, /* tofu_policy */
464464 NULL, /* sign */
315315 goto leave;
316316 if (dft_display)
317317 {
318 if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
318 if (gpgrt_asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
319319 {
320320 err = gpg_error_from_syserror ();
321321 free (dft_display);
325325
326326 err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, NULL,
327327 NULL, NULL, NULL);
328 free (optstr);
328 gpgrt_free (optstr);
329329 if (err)
330330 goto leave;
331331 }
349349 ways, e.g., when /dev/pts is not accessible under chroot. */
350350 if (!rc)
351351 {
352 if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
352 if (gpgrt_asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
353353 {
354354 err = gpg_error_from_syserror ();
355355 goto leave;
356356 }
357357 err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, NULL,
358358 NULL, NULL, NULL);
359 free (optstr);
359 gpgrt_free (optstr);
360360 if (err)
361361 goto leave;
362362
365365 goto leave;
366366 if (dft_ttytype)
367367 {
368 if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
368 if (gpgrt_asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype)< 0)
369369 {
370370 err = gpg_error_from_syserror ();
371371 free (dft_ttytype);
375375
376376 err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL,
377377 NULL, NULL, NULL, NULL);
378 free (optstr);
378 gpgrt_free (optstr);
379379 if (err)
380380 goto leave;
381381 }
440440 if (!value)
441441 return 0;
442442
443 if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
443 if (gpgrt_asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0)
444444 err = gpg_error_from_syserror ();
445445 else
446446 {
447447 err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL,
448448 NULL, NULL, NULL, NULL);
449 free (optstr);
449 gpgrt_free (optstr);
450450 }
451451
452452 return err;
958958
959959
960960 static gpgme_error_t
961 _uiserver_decrypt (void *engine, int verify,
962 gpgme_data_t ciph, gpgme_data_t plain,
963 int export_session_key, const char *override_session_key)
961 uiserver_decrypt (void *engine,
962 gpgme_decrypt_flags_t flags,
963 gpgme_data_t ciph, gpgme_data_t plain,
964 int export_session_key, const char *override_session_key)
964965 {
965966 engine_uiserver_t uiserver = engine;
966967 gpgme_error_t err;
967968 const char *protocol;
968969 char *cmd;
970 int verify = !!(flags & GPGME_DECRYPT_VERIFY);
969971
970972 (void)override_session_key; /* Fixme: We need to see now to add this
971973 * to the UI server protocol */
981983 else
982984 return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
983985
984 if (asprintf (&cmd, "DECRYPT%s%s%s", protocol,
986 if (gpgrt_asprintf (&cmd, "DECRYPT%s%s%s", protocol,
985987 verify ? "" : " --no-verify",
986988 export_session_key ? " --export-session-key" : "") < 0)
987989 return gpg_error_from_syserror ();
991993 map_data_enc (uiserver->input_cb.data));
992994 if (err)
993995 {
994 free (cmd);
996 gpgrt_free (cmd);
995997 return gpg_error (GPG_ERR_GENERAL); /* FIXME */
996998 }
997999 uiserver->output_cb.data = plain;
9981000 err = uiserver_set_fd (uiserver, OUTPUT_FD, 0);
9991001 if (err)
10001002 {
1001 free (cmd);
1003 gpgrt_free (cmd);
10021004 return gpg_error (GPG_ERR_GENERAL); /* FIXME */
10031005 }
10041006 uiserver->inline_data = NULL;
10051007
10061008 err = start (engine, cmd);
1007 free (cmd);
1009 gpgrt_free (cmd);
10081010 return err;
1009 }
1010
1011
1012 static gpgme_error_t
1013 uiserver_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
1014 int export_session_key, const char *override_session_key)
1015 {
1016 return _uiserver_decrypt (engine, 0, ciph, plain,
1017 export_session_key, override_session_key);
1018 }
1019
1020
1021 static gpgme_error_t
1022 uiserver_decrypt_verify (void *engine, gpgme_data_t ciph, gpgme_data_t plain,
1023 int export_session_key,
1024 const char *override_session_key)
1025 {
1026 return _uiserver_decrypt (engine, 1, ciph, plain,
1027 export_session_key, override_session_key);
10281011 }
10291012
10301013
11131096 if (!recp || plain || ciph)
11141097 return gpg_error (GPG_ERR_INV_VALUE);
11151098
1116 if (asprintf (&cmd, "PREP_ENCRYPT%s%s", protocol,
1099 if (gpgrt_asprintf (&cmd, "PREP_ENCRYPT%s%s", protocol,
11171100 (flags & GPGME_ENCRYPT_EXPECT_SIGN)
11181101 ? " --expect-sign" : "") < 0)
11191102 return gpg_error_from_syserror ();
11231106 if (!plain || !ciph)
11241107 return gpg_error (GPG_ERR_INV_VALUE);
11251108
1126 if (asprintf (&cmd, "ENCRYPT%s", protocol) < 0)
1109 if (gpgrt_asprintf (&cmd, "ENCRYPT%s", protocol) < 0)
11271110 return gpg_error_from_syserror ();
11281111 }
11291112
11341117 map_data_enc (uiserver->input_cb.data));
11351118 if (err)
11361119 {
1137 free (cmd);
1120 gpgrt_free (cmd);
11381121 return err;
11391122 }
11401123 }
11461129 : map_data_enc (uiserver->output_cb.data));
11471130 if (err)
11481131 {
1149 free (cmd);
1132 gpgrt_free (cmd);
11501133 return err;
11511134 }
11521135 }
11581141 err = set_recipients (uiserver, recp);
11591142 if (err)
11601143 {
1161 free (cmd);
1144 gpgrt_free (cmd);
11621145 return err;
11631146 }
11641147 }
11651148
11661149 err = start (uiserver, cmd);
1167 free (cmd);
1150 gpgrt_free (cmd);
11681151 return err;
11691152 }
11701153
11941177 else
11951178 return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
11961179
1197 if (asprintf (&cmd, "SIGN%s%s", protocol,
1180 if (gpgrt_asprintf (&cmd, "SIGN%s%s", protocol,
11981181 (mode == GPGME_SIG_MODE_DETACH) ? " --detached" : "") < 0)
11991182 return gpg_error_from_syserror ();
12001183
12191202 err = gpg_error (GPG_ERR_INV_VALUE);
12201203 gpgme_key_unref (key);
12211204 if (err)
1222 {
1223 free (cmd);
1224 return err;
1225 }
1205 {
1206 gpgrt_free (cmd);
1207 return err;
1208 }
12261209 }
12271210
12281211 uiserver->input_cb.data = in;
12301213 map_data_enc (uiserver->input_cb.data));
12311214 if (err)
12321215 {
1233 free (cmd);
1216 gpgrt_free (cmd);
12341217 return err;
12351218 }
12361219 uiserver->output_cb.data = out;
12381221 : map_data_enc (uiserver->output_cb.data));
12391222 if (err)
12401223 {
1241 free (cmd);
1224 gpgrt_free (cmd);
12421225 return err;
12431226 }
12441227 uiserver->inline_data = NULL;
12451228
12461229 err = start (uiserver, cmd);
1247 free (cmd);
1230 gpgrt_free (cmd);
12481231 return err;
12491232 }
12501233
12731256 else
12741257 return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
12751258
1276 if (asprintf (&cmd, "VERIFY%s", protocol) < 0)
1259 if (gpgrt_asprintf (&cmd, "VERIFY%s", protocol) < 0)
12771260 return gpg_error_from_syserror ();
12781261
12791262 uiserver->input_cb.data = sig;
12811264 map_data_enc (uiserver->input_cb.data));
12821265 if (err)
12831266 {
1284 free (cmd);
1267 gpgrt_free (cmd);
12851268 return err;
12861269 }
12871270 if (plaintext)
13011284 if (!err)
13021285 err = start (uiserver, cmd);
13031286
1304 free (cmd);
1287 gpgrt_free (cmd);
13051288 return err;
13061289 }
13071290
13821365 uiserver_set_locale,
13831366 uiserver_set_protocol,
13841367 uiserver_decrypt,
1385 uiserver_decrypt_verify,
13861368 NULL, /* delete */
13871369 NULL, /* edit */
13881370 uiserver_encrypt,
13931375 NULL, /* import */
13941376 NULL, /* keylist */
13951377 NULL, /* keylist_ext */
1378 NULL, /* keylist_data */
13961379 NULL, /* keysign */
13971380 NULL, /* tofu_policy */
13981381 uiserver_sign,
651651
652652
653653 gpgme_error_t
654 _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
654 _gpgme_engine_op_decrypt (engine_t engine,
655 gpgme_decrypt_flags_t flags,
656 gpgme_data_t ciph,
655657 gpgme_data_t plain, int export_session_key,
656658 const char *override_session_key)
657659 {
661663 if (!engine->ops->decrypt)
662664 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
663665
664 return (*engine->ops->decrypt) (engine->engine, ciph, plain,
666 return (*engine->ops->decrypt) (engine->engine, flags, ciph, plain,
665667 export_session_key, override_session_key);
666 }
667
668
669 gpgme_error_t
670 _gpgme_engine_op_decrypt_verify (engine_t engine, gpgme_data_t ciph,
671 gpgme_data_t plain, int export_session_key,
672 const char *override_session_key)
673 {
674 if (!engine)
675 return gpg_error (GPG_ERR_INV_VALUE);
676
677 if (!engine->ops->decrypt_verify)
678 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
679
680 return (*engine->ops->decrypt_verify) (engine->engine, ciph, plain,
681 export_session_key,
682 override_session_key);
683668 }
684669
685670
871856
872857 return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only,
873858 reserved, mode, engine_flags);
859 }
860
861
862 gpgme_error_t
863 _gpgme_engine_op_keylist_data (engine_t engine, gpgme_data_t data)
864 {
865 if (!engine)
866 return gpg_error (GPG_ERR_INV_VALUE);
867
868 if (!engine->ops->keylist_data)
869 return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
870
871 return (*engine->ops->keylist_data) (engine->engine, data);
874872 }
875873
876874
2424 #include "gpgme.h"
2525
2626 /* Flags used by the EXTRAFLAGS arg of _gpgme_engine_op_genkey. */
27 #define GENKEY_EXTRAFLAG_ARMOR 1
28 #define GENKEY_EXTRAFLAG_REVOKE 2
27 #define GENKEY_EXTRAFLAG_ARMOR 1
28 #define GENKEY_EXTRAFLAG_REVOKE 2
29 #define GENKEY_EXTRAFLAG_SETPRIMARY 4
2930
3031
3132 struct engine;
8182 _gpgme_engine_set_colon_line_handler (engine_t engine,
8283 engine_colon_line_handler_t fnc,
8384 void *fnc_value);
84 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
85 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine,
86 gpgme_decrypt_flags_t flags,
87 gpgme_data_t ciph,
8588 gpgme_data_t plain,
8689 int export_session_key,
8790 const char *override_session_key);
88 gpgme_error_t _gpgme_engine_op_decrypt_verify (engine_t engine,
89 gpgme_data_t ciph,
90 gpgme_data_t plain,
91 int export_session_key,
92 const char *override_session_key
93 );
9491 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
9592 int allow_secret);
9693 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
147144 int reserved,
148145 gpgme_keylist_mode_t mode,
149146 int engine_flags);
147 gpgme_error_t _gpgme_engine_op_keylist_data (engine_t engine,
148 gpgme_data_t data);
150149 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
151150 gpgme_data_t out, gpgme_sig_mode_t mode,
152151 int use_armor, int use_textmode,
+0
-63
src/funopen.c less more
0 /* funopen.c - Replacement for funopen.
1 Copyright (C) 2004 g10 Code GmbH
2
3 This file is part of GPGME
4
5 GPGME is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of
8 the License, or (at your option) any later version.
9
10 GPGME is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 02111-1307, USA. */
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <stdio.h>
25
26
27 /* Replacement for the *BSD function:
28
29 FILE *funopen (void *cookie,
30 int (*readfn)(void *, char *, int),
31 int (*writefn)(void *, const char *, int),
32 fpos_t (*seekfn)(void *, fpos_t, int),
33 int (*closefn)(void *));
34
35 The functions to provide my either be NULL if not required or
36 similar to the unistd function with the exception of using the
37 cookie instead of the file descriptor.
38 */
39
40
41 #ifdef HAVE_FOPENCOOKIE
42 FILE *
43 _gpgme_funopen(void *cookie,
44 cookie_read_function_t *readfn,
45 cookie_write_function_t *writefn,
46 cookie_seek_function_t *seekfn,
47 cookie_close_function_t *closefn)
48 {
49 cookie_io_functions_t io = { NULL };
50
51 io.read = readfn;
52 io.write = writefn;
53 io.seek = seekfn;
54 io.close = closefn;
55
56 return fopencookie (cookie,
57 readfn ? ( writefn ? "rw" : "r" )
58 : ( writefn ? "w" : ""), io);
59 }
60 #else
61 #error No known way to implement funopen.
62 #endif
488488
489489
490490 static gpgme_error_t
491 addrevuid_start (gpgme_ctx_t ctx, int synchronous, int revoke,
491 addrevuid_start (gpgme_ctx_t ctx, int synchronous, int extraflags,
492492 gpgme_key_t key, const char *userid, unsigned int flags)
493493 {
494494 gpgme_error_t err;
511511 if (err)
512512 return err;
513513
514 opd->uidmode = revoke? 2 : 1;
514 opd->uidmode = extraflags? 2 : 1;
515515
516516 _gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
517517
527527 userid, NULL, 0, 0,
528528 key, flags,
529529 NULL,
530 revoke? GENKEY_EXTRAFLAG_REVOKE : 0,
530 extraflags,
531531 NULL, NULL);
532532
533533 }
583583 if (!ctx)
584584 return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
585585
586 err = addrevuid_start (ctx, 0, 1, key, userid, flags);
586 err = addrevuid_start (ctx, 0, GENKEY_EXTRAFLAG_REVOKE, key, userid, flags);
587587 return TRACE_ERR (err);
588588 }
589589
600600 if (!ctx)
601601 return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
602602
603 err = addrevuid_start (ctx, 1, 1, key, userid, flags);
603 err = addrevuid_start (ctx, 1, GENKEY_EXTRAFLAG_REVOKE, key, userid, flags);
604604 if (!err)
605605 err = _gpgme_wait_one (ctx);
606606 return TRACE_ERR (err);
607607 }
608
609
610 /* Set a flag on the USERID of KEY. The only supported flag right now
611 * is "primary" to mark the primary key. */
612 static gpg_error_t
613 set_uid_flag (gpgme_ctx_t ctx, int synchronous,
614 gpgme_key_t key, const char *userid,
615 const char *name, const char *value)
616 {
617 gpgme_error_t err;
618
619 TRACE_BEG4 (DEBUG_CTX, "gpgme_op_set_uid_flag", ctx,
620 "%d uid='%s' '%s'='%s'", synchronous, userid, name, value);
621
622 if (!ctx || !name || !key || !userid)
623 return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
624
625 if (!strcmp (name, "primary"))
626 {
627 if (value)
628 err = gpg_error (GPG_ERR_INV_ARG);
629 else
630 err = addrevuid_start (ctx, synchronous,
631 GENKEY_EXTRAFLAG_SETPRIMARY, key, userid, 0);
632 }
633 else
634 return err = gpg_error (GPG_ERR_UNKNOWN_NAME);
635
636 if (synchronous && !err)
637 err = _gpgme_wait_one (ctx);
638 return TRACE_ERR (err);
639 }
640
641
642 /* See set_uid_flag. */
643 gpgme_error_t
644 gpgme_op_set_uid_flag_start (gpgme_ctx_t ctx,
645 gpgme_key_t key, const char *userid,
646 const char *name, const char *value)
647 {
648 return set_uid_flag (ctx, 0, key, userid, name, value);
649 }
650
651
652 /* See set_uid_flag. Thsi is the synchronous variant. */
653 gpgme_error_t
654 gpgme_op_set_uid_flag (gpgme_ctx_t ctx,
655 gpgme_key_t key, const char *userid,
656 const char *name, const char *value)
657 {
658 return set_uid_flag (ctx, 1, key, userid, name, value);
659 }
507507
508508 if (!ctx || !name || !value)
509509 err = gpg_error (GPG_ERR_INV_VALUE);
510 else if (!strcmp (name, "redraw"))
511 {
512 ctx->redraw_suggested = abool;
513 }
510514 else if (!strcmp (name, "full-status"))
511515 {
512516 ctx->full_status = abool;
543547 {
544548 if (!ctx || !name)
545549 return NULL;
550 else if (!strcmp (name, "redraw"))
551 {
552 return ctx->redraw_suggested? "1":"";
553 }
546554 else if (!strcmp (name, "full-status"))
547555 {
548556 return ctx->full_status? "1":"";
176176 gpgme_io_read @136
177177 gpgme_io_write @137
178178
179 gpgme_result_ref @138
180 gpgme_result_unref @139
179 gpgme_result_ref @138
180 gpgme_result_unref @139
181181
182182 gpgme_op_import_keys @140
183183 gpgme_op_import_keys_start @141
252252 gpgme_op_query_swdb_result @190
253253
254254 gpgme_get_ctx_flag @191
255
256 gpgme_op_keylist_from_data_start @192
257
258 gpgme_op_set_uid_flag_start @193
259 gpgme_op_set_uid_flag @194
260
261 gpgme_op_decrypt_ext @195
262 gpgme_op_decrypt_ext_start @196
263
255264 ; END
256265
00 /* gpgme.h - Public interface to GnuPG Made Easy. -*- c -*-
11 * Copyright (C) 2000 Werner Koch (dd9jn)
2 * Copyright (C) 2001-2016 g10 Code GmbH
2 * Copyright (C) 2001-2017 g10 Code GmbH
33 *
44 * This file is part of GPGME.
55 *
293293 gpgme_hash_algo_t;
294294
295295
296 /* The possible signature stati. Deprecated, use error value in sig
297 status. */
298 typedef enum
299 {
300 GPGME_SIG_STAT_NONE = 0,
301 GPGME_SIG_STAT_GOOD = 1,
302 GPGME_SIG_STAT_BAD = 2,
303 GPGME_SIG_STAT_NOKEY = 3,
304 GPGME_SIG_STAT_NOSIG = 4,
305 GPGME_SIG_STAT_ERROR = 5,
306 GPGME_SIG_STAT_DIFF = 6,
307 GPGME_SIG_STAT_GOOD_EXP = 7,
308 GPGME_SIG_STAT_GOOD_EXPKEY = 8
309 }
310 _gpgme_sig_stat_t;
311 typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED(0,4);
312
313
314296 /* The available signature modes. */
315297 typedef enum
316298 {
319301 GPGME_SIG_MODE_CLEAR = 2
320302 }
321303 gpgme_sig_mode_t;
322
323
324 /* The available key and signature attributes. Deprecated, use the
325 individual result structures instead. */
326 typedef enum
327 {
328 GPGME_ATTR_KEYID = 1,
329 GPGME_ATTR_FPR = 2,
330 GPGME_ATTR_ALGO = 3,
331 GPGME_ATTR_LEN = 4,
332 GPGME_ATTR_CREATED = 5,
333 GPGME_ATTR_EXPIRE = 6,
334 GPGME_ATTR_OTRUST = 7,
335 GPGME_ATTR_USERID = 8,
336 GPGME_ATTR_NAME = 9,
337 GPGME_ATTR_EMAIL = 10,
338 GPGME_ATTR_COMMENT = 11,
339 GPGME_ATTR_VALIDITY = 12,
340 GPGME_ATTR_LEVEL = 13,
341 GPGME_ATTR_TYPE = 14,
342 GPGME_ATTR_IS_SECRET = 15,
343 GPGME_ATTR_KEY_REVOKED = 16,
344 GPGME_ATTR_KEY_INVALID = 17,
345 GPGME_ATTR_UID_REVOKED = 18,
346 GPGME_ATTR_UID_INVALID = 19,
347 GPGME_ATTR_KEY_CAPS = 20,
348 GPGME_ATTR_CAN_ENCRYPT = 21,
349 GPGME_ATTR_CAN_SIGN = 22,
350 GPGME_ATTR_CAN_CERTIFY = 23,
351 GPGME_ATTR_KEY_EXPIRED = 24,
352 GPGME_ATTR_KEY_DISABLED = 25,
353 GPGME_ATTR_SERIAL = 26,
354 GPGME_ATTR_ISSUER = 27,
355 GPGME_ATTR_CHAINID = 28,
356 GPGME_ATTR_SIG_STATUS = 29,
357 GPGME_ATTR_ERRTOK = 30,
358 GPGME_ATTR_SIG_SUMMARY = 31,
359 GPGME_ATTR_SIG_CLASS = 32
360 }
361 _gpgme_attr_t;
362 typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED(0,4);
363304
364305
365306 /* The available validities for a trust item or key. */
445386 #define GPGME_AUDITLOG_HTML 1
446387 #define GPGME_AUDITLOG_WITH_HELP 128
447388
389
390 /* The available signature notation flags. */
391 #define GPGME_SIG_NOTATION_HUMAN_READABLE 1
392 #define GPGME_SIG_NOTATION_CRITICAL 2
393
394 typedef unsigned int gpgme_sig_notation_flags_t;
395
396 /* An object to hold information about notation data. This structure
397 * shall be considered read-only and an application must not allocate
398 * such a structure on its own. */
399 struct _gpgme_sig_notation
400 {
401 struct _gpgme_sig_notation *next;
402
403 /* If NAME is a null pointer, then VALUE contains a policy URL
404 rather than a notation. */
405 char *name;
406
407 /* The value of the notation data. */
408 char *value;
409
410 /* The length of the name of the notation data. */
411 int name_len;
412
413 /* The length of the value of the notation data. */
414 int value_len;
415
416 /* The accumulated flags. */
417 gpgme_sig_notation_flags_t flags;
418
419 /* Notation data is human-readable. */
420 unsigned int human_readable : 1;
421
422 /* Notation data is critical. */
423 unsigned int critical : 1;
424
425 /* Internal to GPGME, do not use. */
426 int _unused : 30;
427 };
428 typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
429
430
431
432 /*
433 * Public structures.
434 */
435
436 /* The engine information structure.
437 * This structure shall be considered read-only and an application
438 * must not allocate such a structure on its own. */
439 struct _gpgme_engine_info
440 {
441 struct _gpgme_engine_info *next;
442
443 /* The protocol ID. */
444 gpgme_protocol_t protocol;
445
446 /* The file name of the engine binary. */
447 char *file_name;
448
449 /* The version string of the installed engine. */
450 char *version;
451
452 /* The minimum version required for GPGME. */
453 const char *req_version;
454
455 /* The home directory used, or NULL if default. */
456 char *home_dir;
457 };
458 typedef struct _gpgme_engine_info *gpgme_engine_info_t;
459
460
461 /* An object with TOFU information.
462 * This structure shall be considered read-only and an application
463 * must not allocate such a structure on its own. */
464 struct _gpgme_tofu_info
465 {
466 struct _gpgme_tofu_info *next;
467
468 /* The TOFU validity:
469 * 0 := conflict
470 * 1 := key without history
471 * 2 := key with too little history
472 * 3 := key with enough history for basic trust
473 * 4 := key with a lot of history
474 */
475 unsigned int validity : 3;
476
477 /* The TOFU policy (gpgme_tofu_policy_t). */
478 unsigned int policy : 4;
479
480 unsigned int _rfu : 25;
481
482 /* Number of signatures seen for this binding. Capped at USHRT_MAX. */
483 unsigned short signcount;
484 /* Number of encryptions done with this binding. Capped at USHRT_MAX. */
485 unsigned short encrcount;
486
487 /* Number of seconds since Epoch when the first and the most
488 * recently seen message were verified/decrypted. 0 means unknown. */
489 unsigned long signfirst;
490 unsigned long signlast;
491 unsigned long encrfirst;
492 unsigned long encrlast;
493
494 /* If non-NULL a human readable string summarizing the TOFU data. */
495 char *description;
496 };
497 typedef struct _gpgme_tofu_info *gpgme_tofu_info_t;
498
499
500 /* A subkey from a key.
501 * This structure shall be considered read-only and an application
502 * must not allocate such a structure on its own. */
503 struct _gpgme_subkey
504 {
505 struct _gpgme_subkey *next;
506
507 /* True if subkey is revoked. */
508 unsigned int revoked : 1;
509
510 /* True if subkey is expired. */
511 unsigned int expired : 1;
512
513 /* True if subkey is disabled. */
514 unsigned int disabled : 1;
515
516 /* True if subkey is invalid. */
517 unsigned int invalid : 1;
518
519 /* True if subkey can be used for encryption. */
520 unsigned int can_encrypt : 1;
521
522 /* True if subkey can be used for signing. */
523 unsigned int can_sign : 1;
524
525 /* True if subkey can be used for certification. */
526 unsigned int can_certify : 1;
527
528 /* True if subkey is secret. */
529 unsigned int secret : 1;
530
531 /* True if subkey can be used for authentication. */
532 unsigned int can_authenticate : 1;
533
534 /* True if subkey is qualified for signatures according to German law. */
535 unsigned int is_qualified : 1;
536
537 /* True if the secret key is stored on a smart card. */
538 unsigned int is_cardkey : 1;
539
540 /* True if the key is compliant to the de-vs mode. */
541 unsigned int is_de_vs : 1;
542
543 /* Internal to GPGME, do not use. */
544 unsigned int _unused : 20;
545
546 /* Public key algorithm supported by this subkey. */
547 gpgme_pubkey_algo_t pubkey_algo;
548
549 /* Length of the subkey. */
550 unsigned int length;
551
552 /* The key ID of the subkey. */
553 char *keyid;
554
555 /* Internal to GPGME, do not use. */
556 char _keyid[16 + 1];
557
558 /* The fingerprint of the subkey in hex digit form. */
559 char *fpr;
560
561 /* The creation timestamp, -1 if invalid, 0 if not available. */
562 long int timestamp;
563
564 /* The expiration timestamp, 0 if the subkey does not expire. */
565 long int expires;
566
567 /* The serial number of a smart card holding this key or NULL. */
568 char *card_number;
569
570 /* The name of the curve for ECC algorithms or NULL. */
571 char *curve;
572
573 /* The keygrip of the subkey in hex digit form or NULL if not availabale. */
574 char *keygrip;
575 };
576 typedef struct _gpgme_subkey *gpgme_subkey_t;
577
578
579 /* A signature on a user ID.
580 * This structure shall be considered read-only and an application
581 * must not allocate such a structure on its own. */
582 struct _gpgme_key_sig
583 {
584 struct _gpgme_key_sig *next;
585
586 /* True if the signature is a revocation signature. */
587 unsigned int revoked : 1;
588
589 /* True if the signature is expired. */
590 unsigned int expired : 1;
591
592 /* True if the signature is invalid. */
593 unsigned int invalid : 1;
594
595 /* True if the signature should be exported. */
596 unsigned int exportable : 1;
597
598 /* Internal to GPGME, do not use. */
599 unsigned int _unused : 28;
600
601 /* The public key algorithm used to create the signature. */
602 gpgme_pubkey_algo_t pubkey_algo;
603
604 /* The key ID of key used to create the signature. */
605 char *keyid;
606
607 /* Internal to GPGME, do not use. */
608 char _keyid[16 + 1];
609
610 /* The creation timestamp, -1 if invalid, 0 if not available. */
611 long int timestamp;
612
613 /* The expiration timestamp, 0 if the subkey does not expire. */
614 long int expires;
615
616 /* Same as in gpgme_signature_t. */
617 gpgme_error_t status;
618
619 #ifdef __cplusplus
620 unsigned int _obsolete_class _GPGME_DEPRECATED(0,4);
621 #else
622 /* Must be set to SIG_CLASS below. */
623 unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4);
624 #endif
625
626 /* The user ID string. */
627 char *uid;
628
629 /* The name part of the user ID. */
630 char *name;
631
632 /* The email part of the user ID. */
633 char *email;
634
635 /* The comment part of the user ID. */
636 char *comment;
637
638 /* Crypto backend specific signature class. */
639 unsigned int sig_class;
640
641 /* Notation data and policy URLs. */
642 gpgme_sig_notation_t notations;
643
644 /* Internal to GPGME, do not use. */
645 gpgme_sig_notation_t _last_notation;
646 };
647 typedef struct _gpgme_key_sig *gpgme_key_sig_t;
648
649
650 /* An user ID from a key.
651 * This structure shall be considered read-only and an application
652 * must not allocate such a structure on its own. */
653 struct _gpgme_user_id
654 {
655 struct _gpgme_user_id *next;
656
657 /* True if the user ID is revoked. */
658 unsigned int revoked : 1;
659
660 /* True if the user ID is invalid. */
661 unsigned int invalid : 1;
662
663 /* Internal to GPGME, do not use. */
664 unsigned int _unused : 25;
665
666 /* Origin of this user ID. */
667 unsigned int origin : 5;
668
669 /* The validity of the user ID. */
670 gpgme_validity_t validity;
671
672 /* The user ID string. */
673 char *uid;
674
675 /* The name part of the user ID. */
676 char *name;
677
678 /* The email part of the user ID. */
679 char *email;
680
681 /* The comment part of the user ID. */
682 char *comment;
683
684 /* The signatures of the user ID. */
685 gpgme_key_sig_t signatures;
686
687 /* Internal to GPGME, do not use. */
688 gpgme_key_sig_t _last_keysig;
689
690 /* The mail address (addr-spec from RFC5322) of the UID string.
691 * This is general the same as the EMAIL part of this struct but
692 * might be slightly different. If no mail address is available
693 * NULL is stored. */
694 char *address;
695
696 /* The malloced TOFU information or NULL. */
697 gpgme_tofu_info_t tofu;
698
699 /* Time of the last refresh of thsi user id. 0 if unknown. */
700 unsigned long last_update;
701 };
702 typedef struct _gpgme_user_id *gpgme_user_id_t;
703
704
705 /* A key from the keyring.
706 * This structure shall be considered read-only and an application
707 * must not allocate such a structure on its own. */
708 struct _gpgme_key
709 {
710 /* Internal to GPGME, do not use. */
711 unsigned int _refs;
712
713 /* True if key is revoked. */
714 unsigned int revoked : 1;
715
716 /* True if key is expired. */
717 unsigned int expired : 1;
718
719 /* True if key is disabled. */
720 unsigned int disabled : 1;
721
722 /* True if key is invalid. */
723 unsigned int invalid : 1;
724
725 /* True if key can be used for encryption. */
726 unsigned int can_encrypt : 1;
727
728 /* True if key can be used for signing. */
729 unsigned int can_sign : 1;
730
731 /* True if key can be used for certification. */
732 unsigned int can_certify : 1;
733
734 /* True if key is secret. */
735 unsigned int secret : 1;
736
737 /* True if key can be used for authentication. */
738 unsigned int can_authenticate : 1;
739
740 /* True if subkey is qualified for signatures according to German law. */
741 unsigned int is_qualified : 1;
742
743 /* Internal to GPGME, do not use. */
744 unsigned int _unused : 17;
745
746 /* Origin of this key. */
747 unsigned int origin : 5;
748
749 /* This is the protocol supported by this key. */
750 gpgme_protocol_t protocol;
751
752 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
753 issuer serial. */
754 char *issuer_serial;
755
756 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
757 issuer name. */
758 char *issuer_name;
759
760 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
761 ID. */
762 char *chain_id;
763
764 /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
765 owner trust. */
766 gpgme_validity_t owner_trust;
767
768 /* The subkeys of the key. */
769 gpgme_subkey_t subkeys;
770
771 /* The user IDs of the key. */
772 gpgme_user_id_t uids;
773
774 /* Internal to GPGME, do not use. */
775 gpgme_subkey_t _last_subkey;
776
777 /* Internal to GPGME, do not use. */
778 gpgme_user_id_t _last_uid;
779
780 /* The keylist mode that was active when listing the key. */
781 gpgme_keylist_mode_t keylist_mode;
782
783 /* This field gives the fingerprint of the primary key. Note that
784 * this is a copy of the FPR of the first subkey. We need it here
785 * to allow for an incomplete key object. */
786 char *fpr;
787
788 /* Time of the last refresh of the entire key. 0 if unknown. */
789 unsigned long last_update;
790 };
791 typedef struct _gpgme_key *gpgme_key_t;
792
793
794 /* An invalid key object.
795 * This structure shall be considered read-only and an application
796 * must not allocate such a structure on its own. */
797 struct _gpgme_invalid_key
798 {
799 struct _gpgme_invalid_key *next;
800
801 /* The string used to request the key. Despite the name this may
802 * not be a fingerprint. */
803 char *fpr;
804
805 /* The error code. */
806 gpgme_error_t reason;
807 };
808 typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
809
810
811
812 /*
813 * Types for callback functions.
814 */
815
816 /* Request a passphrase from the user. */
817 typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
818 const char *uid_hint,
819 const char *passphrase_info,
820 int prev_was_bad, int fd);
821
822 /* Inform the user about progress made. */
823 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
824 int type, int current, int total);
825
826 /* Status messages from gpg. */
827 typedef gpgme_error_t (*gpgme_status_cb_t) (void *opaque, const char *keyword,
828 const char *args);
829
830 /* Interact with the user about an edit operation. */
831 typedef gpgme_error_t (*gpgme_interact_cb_t) (void *opaque,
832 const char *keyword,
833 const char *args, int fd);
834
835
836
837 /*
838 * Context management functions.
839 */
840
841 /* Create a new context and return it in CTX. */
842 gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
843
844 /* Release the context CTX. */
845 void gpgme_release (gpgme_ctx_t ctx);
846
847 /* Set the flag NAME for CTX to VALUE. */
848 gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx,
849 const char *name, const char *value);
850
851 /* Get the value of the flag NAME from CTX. */
852 const char *gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name);
853
854 /* Set the protocol to be used by CTX to PROTO. */
855 gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
856
857 /* Get the protocol used with CTX */
858 gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
859
860 /* Set the crypto protocol to be used by CTX to PROTO.
861 gpgme_set_protocol actually sets the backend engine. This sets the
862 crypto protocol used in engines that support more than one crypto
863 prococol (for example, an UISERVER can support OpenPGP and CMS).
864 This is reset to the default with gpgme_set_protocol. */
865 gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx,
866 gpgme_protocol_t proto);
867
868 /* Get the sub protocol. */
869 gpgme_protocol_t gpgme_get_sub_protocol (gpgme_ctx_t ctx);
870
871 /* Get the string describing protocol PROTO, or NULL if invalid. */
872 const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
873
874 /* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
875 void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
876
877 /* Return non-zero if armor mode is set in CTX. */
878 int gpgme_get_armor (gpgme_ctx_t ctx);
879
880 /* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
881 void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
882
883 /* Return non-zero if text mode is set in CTX. */
884 int gpgme_get_textmode (gpgme_ctx_t ctx);
885
886 /* If YES is non-zero, enable offline mode in CTX, disable it otherwise. */
887 void gpgme_set_offline (gpgme_ctx_t ctx, int yes);
888
889 /* Return non-zero if offline mode is set in CTX. */
890 int gpgme_get_offline (gpgme_ctx_t ctx);
891
892 /* Use whatever the default of the backend crypto engine is. */
893 #define GPGME_INCLUDE_CERTS_DEFAULT -256
894
895 /* Include up to NR_OF_CERTS certificates in an S/MIME message. */
896 void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
897
898 /* Return the number of certs to include in an S/MIME message. */
899 int gpgme_get_include_certs (gpgme_ctx_t ctx);
900
901 /* Set keylist mode in CTX to MODE. */
902 gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
903 gpgme_keylist_mode_t mode);
904
905 /* Get keylist mode in CTX. */
906 gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
907
908 /* Set the pinentry mode for CTX to MODE. */
909 gpgme_error_t gpgme_set_pinentry_mode (gpgme_ctx_t ctx,
910 gpgme_pinentry_mode_t mode);
911
912 /* Get the pinentry mode of CTX. */
913 gpgme_pinentry_mode_t gpgme_get_pinentry_mode (gpgme_ctx_t ctx);
914
915 /* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
916 passed as first argument to the passphrase callback function. */
917 void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
918 gpgme_passphrase_cb_t cb, void *hook_value);
919
920 /* Get the current passphrase callback function in *CB and the current
921 hook value in *HOOK_VALUE. */
922 void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
923 void **hook_value);
924
925 /* Set the progress callback function in CTX to CB. HOOK_VALUE is
926 passed as first argument to the progress callback function. */
927 void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
928 void *hook_value);
929
930 /* Get the current progress callback function in *CB and the current
931 hook value in *HOOK_VALUE. */
932 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
933 void **hook_value);
934
935 /* Set the status callback function in CTX to CB. HOOK_VALUE is
936 passed as first argument to the status callback function. */
937 void gpgme_set_status_cb (gpgme_ctx_t c, gpgme_status_cb_t cb,
938 void *hook_value);
939
940 /* Get the current status callback function in *CB and the current
941 hook value in *HOOK_VALUE. */
942 void gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *cb,
943 void **hook_value);
944
945 /* This function sets the locale for the context CTX, or the default
946 locale if CTX is a null pointer. */
947 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
948 const char *value);
949
950 /* Get the information about the configured engines. A pointer to the
951 first engine in the statically allocated linked list is returned.
952 The returned data is valid until the next gpgme_ctx_set_engine_info. */
953 gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
954
955 /* Set the engine info for the context CTX, protocol PROTO, to the
956 file name FILE_NAME and the home directory HOME_DIR. */
957 gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
958 gpgme_protocol_t proto,
959 const char *file_name,
960 const char *home_dir);
961
962 /* Delete all signers from CTX. */
963 void gpgme_signers_clear (gpgme_ctx_t ctx);
964
965 /* Add KEY to list of signers in CTX. */
966 gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
967
968 /* Return the number of signers in CTX. */
969 unsigned int gpgme_signers_count (const gpgme_ctx_t ctx);
970
971 /* Return the SEQth signer's key in CTX. */
972 gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
973
974 /* Clear all notation data from the context. */
975 void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
976
977 /* Add the human-readable notation data with name NAME and value VALUE
978 to the context CTX, using the flags FLAGS. If NAME is NULL, then
979 VALUE should be a policy URL. The flag
980 GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
981 data, and false for policy URLs. */
982 gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
983 const char *value,
984 gpgme_sig_notation_flags_t flags);
985
986 /* Get the sig notations for this context. */
987 gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
988
989 /* Store a sender address in the context. */
990 gpgme_error_t gpgme_set_sender (gpgme_ctx_t ctx, const char *address);
991
992 /* Get the sender address from the context. */
993 const char *gpgme_get_sender (gpgme_ctx_t ctx);
994
995
996
997 /*
998 * Run control.
999 */
1000
1001 /* The type of an I/O callback function. */
1002 typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
1003
1004 /* The type of a function that can register FNC as the I/O callback
1005 function for the file descriptor FD with direction dir (0: for writing,
1006 1: for reading). FNC_DATA should be passed as DATA to FNC. The
1007 function should return a TAG suitable for the corresponding
1008 gpgme_remove_io_cb_t, and an error value. */
1009 typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
1010 gpgme_io_cb_t fnc,
1011 void *fnc_data, void **tag);
1012
1013 /* The type of a function that can remove a previously registered I/O
1014 callback function given TAG as returned by the register
1015 function. */
1016 typedef void (*gpgme_remove_io_cb_t) (void *tag);
1017
1018 typedef enum
1019 {
1020 GPGME_EVENT_START,
1021 GPGME_EVENT_DONE,
1022 GPGME_EVENT_NEXT_KEY,
1023 GPGME_EVENT_NEXT_TRUSTITEM
1024 }
1025 gpgme_event_io_t;
1026
1027 struct gpgme_io_event_done_data
1028 {
1029 /* A fatal IPC error or an operational error in state-less
1030 protocols. */
1031 gpgme_error_t err;
1032
1033 /* An operational errors in session-based protocols. */
1034 gpgme_error_t op_err;
1035 };
1036 typedef struct gpgme_io_event_done_data *gpgme_io_event_done_data_t;
1037
1038 /* The type of a function that is called when a context finished an
1039 operation. */
1040 typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
1041 void *type_data);
1042
1043 struct gpgme_io_cbs
1044 {
1045 gpgme_register_io_cb_t add;
1046 void *add_priv;
1047 gpgme_remove_io_cb_t remove;
1048 gpgme_event_io_cb_t event;
1049 void *event_priv;
1050 };
1051 typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
1052
1053 /* Set the I/O callback functions in CTX to IO_CBS. */
1054 void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
1055
1056 /* Get the current I/O callback functions. */
1057 void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
1058
1059 /* Wrappers around the internal I/O functions for use with
1060 gpgme_passphrase_cb_t and gpgme_interact_cb_t. */
1061 @API__SSIZE_T@ gpgme_io_read (int fd, void *buffer, size_t count);
1062 @API__SSIZE_T@ gpgme_io_write (int fd, const void *buffer, size_t count);
1063 int gpgme_io_writen (int fd, const void *buffer, size_t count);
1064
1065 /* Process the pending operation and, if HANG is non-zero, wait for
1066 the pending operation to finish. */
1067 gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
1068
1069 gpgme_ctx_t gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status,
1070 gpgme_error_t *op_err, int hang);
1071
1072 /* Cancel a pending asynchronous operation. */
1073 gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
1074
1075 /* Cancel a pending operation asynchronously. */
1076 gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx);
1077
1078
1079
1080 /*
1081 * Functions to handle data objects.
1082 */
1083
1084 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1085 the handle HANDLE. Return the number of characters read, 0 on EOF
1086 and -1 on error. If an error occurs, errno is set. */
1087 typedef @API__SSIZE_T@ (*gpgme_data_read_cb_t) (void *handle, void *buffer,
1088 size_t size);
1089
1090 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1091 the handle HANDLE. Return the number of characters written, or -1
1092 on error. If an error occurs, errno is set. */
1093 typedef @API__SSIZE_T@ (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
1094 size_t size);
1095
1096 /* Set the current position from where the next read or write starts
1097 in the data object with the handle HANDLE to OFFSET, relativ to
1098 WHENCE. Returns the new offset in bytes from the beginning of the
1099 data object. */
1100 typedef @API__OFF_T@ (*gpgme_data_seek_cb_t) (void *handle,
1101 @API__OFF_T@ offset, int whence);
1102
1103 /* Close the data object with the handle HANDLE. */
1104 typedef void (*gpgme_data_release_cb_t) (void *handle);
1105
1106 struct gpgme_data_cbs
1107 {
1108 gpgme_data_read_cb_t read;
1109 gpgme_data_write_cb_t write;
1110 gpgme_data_seek_cb_t seek;
1111 gpgme_data_release_cb_t release;
1112 };
1113 typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
1114
1115 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1116 the handle DH. Return the number of characters read, 0 on EOF and
1117 -1 on error. If an error occurs, errno is set. */
1118 @API__SSIZE_T@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
1119
1120 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1121 the handle DH. Return the number of characters written, or -1 on
1122 error. If an error occurs, errno is set. */
1123 @API__SSIZE_T@ gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
1124
1125 /* Set the current position from where the next read or write starts
1126 in the data object with the handle DH to OFFSET, relativ to WHENCE.
1127 Returns the new offset in bytes from the beginning of the data
1128 object. */
1129 @API__OFF_T@ gpgme_data_seek (gpgme_data_t dh, @API__OFF_T@ offset, int whence);
1130
1131 /* Create a new data buffer and return it in R_DH. */
1132 gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
1133
1134 /* Destroy the data buffer DH. */
1135 void gpgme_data_release (gpgme_data_t dh);
1136
1137 /* Create a new data buffer filled with SIZE bytes starting from
1138 BUFFER. If COPY is zero, copying is delayed until necessary, and
1139 the data is taken from the original location when needed. */
1140 gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
1141 const char *buffer, size_t size,
1142 int copy);
1143
1144 /* Destroy the data buffer DH and return a pointer to its content.
1145 The memory has be to released with gpgme_free() by the user. It's
1146 size is returned in R_LEN. */
1147 char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
1148
1149 /* Release the memory returned by gpgme_data_release_and_get_mem() and
1150 some other functions. */
1151 void gpgme_free (void *buffer);
1152
1153 gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
1154 gpgme_data_cbs_t cbs,
1155 void *handle);
1156
1157 gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
1158
1159 gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
1160
1161 /* Return the encoding attribute of the data buffer DH */
1162 gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
1163
1164 /* Set the encoding attribute of data buffer DH to ENC */
1165 gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
1166 gpgme_data_encoding_t enc);
1167
1168 /* Get the file name associated with the data object with handle DH, or
1169 NULL if there is none. */
1170 char *gpgme_data_get_file_name (gpgme_data_t dh);
1171
1172 /* Set the file name associated with the data object with handle DH to
1173 FILE_NAME. */
1174 gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
1175 const char *file_name);
1176
1177 /* Set a flag for the data object DH. See the manual for details. */
1178 gpg_error_t gpgme_data_set_flag (gpgme_data_t dh,
1179 const char *name, const char *value);
1180
1181 /* Try to identify the type of the data in DH. */
1182 gpgme_data_type_t gpgme_data_identify (gpgme_data_t dh, int reserved);
1183
1184
1185 /* Create a new data buffer filled with the content of file FNAME.
1186 COPY must be non-zero. For delayed read, please use
1187 gpgme_data_new_from_fd or gpgme_data_new_from_stream instead. */
1188 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
1189 const char *fname,
1190 int copy);
1191
1192 /* Create a new data buffer filled with LENGTH bytes starting from
1193 OFFSET within the file FNAME or stream FP (exactly one must be
1194 non-zero). */
1195 gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
1196 const char *fname, FILE *fp,
1197 @API__OFF_T@ offset, size_t length);
1198
1199 /* Convenience function to do a gpgme_data_seek (dh, 0, SEEK_SET). */
1200 gpgme_error_t gpgme_data_rewind (gpgme_data_t dh);
1201
1202
1203
1204 /*
1205 * Key and trust functions.
1206 */
1207
1208 /* Get the key with the fingerprint FPR from the crypto backend. If
1209 SECRET is true, get the secret key. */
1210 gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
1211 gpgme_key_t *r_key, int secret);
1212
1213 /* Create a dummy key to specify an email address. */
1214 gpgme_error_t gpgme_key_from_uid (gpgme_key_t *key, const char *name);
1215
1216 /* Acquire a reference to KEY. */
1217 void gpgme_key_ref (gpgme_key_t key);
1218
1219 /* Release a reference to KEY. If this was the last one the key is
1220 destroyed. */
1221 void gpgme_key_unref (gpgme_key_t key);
1222 void gpgme_key_release (gpgme_key_t key);
1223
1224
1225
1226 /*
1227 * Encryption.
1228 */
1229
1230 /* An object to return results from an encryption operation.
1231 * This structure shall be considered read-only and an application
1232 * must not allocate such a structure on its own. */
1233 struct _gpgme_op_encrypt_result
1234 {
1235 /* The list of invalid recipients. */
1236 gpgme_invalid_key_t invalid_recipients;
1237 };
1238 typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
1239
1240 /* Retrieve a pointer to the result of the encrypt operation. */
1241 gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
1242
1243 /* The valid encryption flags. */
1244 typedef enum
1245 {
1246 GPGME_ENCRYPT_ALWAYS_TRUST = 1,
1247 GPGME_ENCRYPT_NO_ENCRYPT_TO = 2,
1248 GPGME_ENCRYPT_PREPARE = 4,
1249 GPGME_ENCRYPT_EXPECT_SIGN = 8,
1250 GPGME_ENCRYPT_NO_COMPRESS = 16,
1251 GPGME_ENCRYPT_SYMMETRIC = 32,
1252 GPGME_ENCRYPT_THROW_KEYIDS = 64,
1253 GPGME_ENCRYPT_WRAP = 128
1254 }
1255 gpgme_encrypt_flags_t;
1256
1257 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1258 store the resulting ciphertext in CIPHER. */
1259 gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
1260 gpgme_encrypt_flags_t flags,
1261 gpgme_data_t plain, gpgme_data_t cipher);
1262 gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
1263 gpgme_encrypt_flags_t flags,
1264 gpgme_data_t plain, gpgme_data_t cipher);
1265
1266 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1267 store the resulting ciphertext in CIPHER. Also sign the ciphertext
1268 with the signers in CTX. */
1269 gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
1270 gpgme_key_t recp[],
1271 gpgme_encrypt_flags_t flags,
1272 gpgme_data_t plain,
1273 gpgme_data_t cipher);
1274 gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
1275 gpgme_encrypt_flags_t flags,
1276 gpgme_data_t plain, gpgme_data_t cipher);
1277
1278
1279 /*
1280 * Decryption.
1281 */
1282
1283 /* An object to hold information about a recipient.
1284 * This structure shall be considered read-only and an application
1285 * must not allocate such a structure on its own. */
1286 struct _gpgme_recipient
1287 {
1288 struct _gpgme_recipient *next;
1289
1290 /* The key ID of key for which the text was encrypted. */
1291 char *keyid;
1292
1293 /* Internal to GPGME, do not use. */
1294 char _keyid[16 + 1];
1295
1296 /* The public key algorithm of the recipient key. */
1297 gpgme_pubkey_algo_t pubkey_algo;
1298
1299 /* The status of the recipient. */
1300 gpgme_error_t status;
1301 };
1302 typedef struct _gpgme_recipient *gpgme_recipient_t;
1303
1304 /* An object to return results from a decryption operation.
1305 * This structure shall be considered read-only and an application
1306 * must not allocate such a structure on its own. */
1307 struct _gpgme_op_decrypt_result
1308 {
1309 char *unsupported_algorithm;
1310
1311 /* Key should not have been used for encryption. */
1312 unsigned int wrong_key_usage : 1;
1313
1314 /* Internal to GPGME, do not use. */
1315 int _unused : 31;
1316
1317 gpgme_recipient_t recipients;
1318
1319 /* The original file name of the plaintext message, if
1320 available. */
1321 char *file_name;
1322
1323 /* A textual representation of the session key used to decrypt the
1324 * message, if available */
1325 char *session_key;
1326 };
1327 typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
1328
1329 /* Retrieve a pointer to the result of the decrypt operation. */
1330 gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
1331
1332 /* The valid decryption flags. */
1333 typedef enum
1334 {
1335 GPGME_DECRYPT_VERIFY = 1,
1336 GPGME_DECRYPT_UNWRAP = 128
1337 }
1338 gpgme_decrypt_flags_t;
1339
1340 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1341 plaintext in PLAIN. */
1342 gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
1343 gpgme_data_t plain);
1344 gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
1345 gpgme_data_t cipher, gpgme_data_t plain);
1346
1347 /* Decrypt ciphertext CIPHER and make a signature verification within
1348 CTX and store the resulting plaintext in PLAIN. */
1349 gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
1350 gpgme_data_t cipher,
1351 gpgme_data_t plain);
1352 gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
1353 gpgme_data_t plain);
1354
1355 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1356 * plaintext in PLAIN. With the flag GPGME_DECRYPT_VERIFY also do a
1357 * signature verification pn the plaintext. */
1358 gpgme_error_t gpgme_op_decrypt_ext_start (gpgme_ctx_t ctx,
1359 gpgme_decrypt_flags_t flags,
1360 gpgme_data_t cipher,
1361 gpgme_data_t plain);
1362 gpgme_error_t gpgme_op_decrypt_ext (gpgme_ctx_t ctx,
1363 gpgme_decrypt_flags_t flags,
1364 gpgme_data_t cipher,
1365 gpgme_data_t plain);
1366
1367
1368
1369 /*
1370 * Signing.
1371 */
1372
1373 /* An object with signatures data.
1374 * This structure shall be considered read-only and an application
1375 * must not allocate such a structure on its own. */
1376 struct _gpgme_new_signature
1377 {
1378 struct _gpgme_new_signature *next;
1379
1380 /* The type of the signature. */
1381 gpgme_sig_mode_t type;
1382
1383 /* The public key algorithm used to create the signature. */
1384 gpgme_pubkey_algo_t pubkey_algo;
1385
1386 /* The hash algorithm used to create the signature. */
1387 gpgme_hash_algo_t hash_algo;
1388
1389 /* Internal to GPGME, do not use. Must be set to the same value as
1390 CLASS below. */
1391 unsigned long _obsolete_class;
1392
1393 /* Signature creation time. */
1394 long int timestamp;
1395
1396 /* The fingerprint of the signature. */
1397 char *fpr;
1398
1399 #ifdef __cplusplus
1400 unsigned int _obsolete_class_2;
1401 #else
1402 /* Must be set to SIG_CLASS below. */
1403 unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4);
1404 #endif
1405
1406 /* Crypto backend specific signature class. */
1407 unsigned int sig_class;
1408 };
1409 typedef struct _gpgme_new_signature *gpgme_new_signature_t;
1410
1411
1412 /* An object to return results from a signing operation.
1413 * This structure shall be considered read-only and an application
1414 * must not allocate such a structure on its own. */
1415 struct _gpgme_op_sign_result
1416 {
1417 /* The list of invalid signers. */
1418 gpgme_invalid_key_t invalid_signers;
1419 gpgme_new_signature_t signatures;
1420 };
1421 typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
1422
1423 /* Retrieve a pointer to the result of the signing operation. */
1424 gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1425
1426 /* Sign the plaintext PLAIN and store the signature in SIG. */
1427 gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
1428 gpgme_data_t plain, gpgme_data_t sig,
1429 gpgme_sig_mode_t mode);
1430 gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
1431 gpgme_data_t plain, gpgme_data_t sig,
1432 gpgme_sig_mode_t mode);
1433
1434
1435 /*
1436 * Verify.
1437 */
1438
1439 /* Flags used for the SUMMARY field in a gpgme_signature_t. */
1440 typedef enum
1441 {
1442 GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
1443 GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
1444 GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
1445 GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
1446 GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
1447 GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
1448 GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
1449 GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
1450 GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
1451 GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
1452 GPGME_SIGSUM_SYS_ERROR = 0x0800, /* A system error occurred. */
1453 GPGME_SIGSUM_TOFU_CONFLICT=0x1000 /* Tofu conflict detected. */
1454 }
1455 gpgme_sigsum_t;
1456
1457
1458 /* An object to hold the verification status of a signature.
1459 * This structure shall be considered read-only and an application
1460 * must not allocate such a structure on its own. */
1461 struct _gpgme_signature
1462 {
1463 struct _gpgme_signature *next;
1464
1465 /* A summary of the signature status. */
1466 gpgme_sigsum_t summary;
1467
1468 /* The fingerprint of the signature. This can be a subkey. */
1469 char *fpr;
1470
1471 /* The status of the signature. */
1472 gpgme_error_t status;
1473
1474 /* Notation data and policy URLs. */
1475 gpgme_sig_notation_t notations;
1476
1477 /* Signature creation time. */
1478 unsigned long timestamp;
1479
1480 /* Signature expiration time or 0. */
1481 unsigned long exp_timestamp;
1482
1483 /* Key should not have been used for signing. */
1484 unsigned int wrong_key_usage : 1;
1485
1486 /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1487 unsigned int pka_trust : 2;
1488
1489 /* Validity has been verified using the chain model. */
1490 unsigned int chain_model : 1;
1491
1492 /* Internal to GPGME, do not use. */
1493 int _unused : 28;
1494
1495 gpgme_validity_t validity;
1496 gpgme_error_t validity_reason;
1497
1498 /* The public key algorithm used to create the signature. */
1499 gpgme_pubkey_algo_t pubkey_algo;
1500
1501 /* The hash algorithm used to create the signature. */
1502 gpgme_hash_algo_t hash_algo;
1503
1504 /* The mailbox from the PKA information or NULL. */
1505 char *pka_address;
1506
1507 /* If non-NULL, a possible incomplete key object with the data
1508 * available for the signature. */
1509 gpgme_key_t key;
1510 };
1511 typedef struct _gpgme_signature *gpgme_signature_t;
1512
1513 /* An object to return the results of a verify operation.
1514 * This structure shall be considered read-only and an application
1515 * must not allocate such a structure on its own. */
1516 struct _gpgme_op_verify_result
1517 {
1518 gpgme_signature_t signatures;
1519
1520 /* The original file name of the plaintext message, if
1521 available. */
1522 char *file_name;
1523 };
1524 typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
1525
1526 /* Retrieve a pointer to the result of the verify operation. */
1527 gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
1528
1529 /* Verify within CTX that SIG is a valid signature for TEXT. */
1530 gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
1531 gpgme_data_t signed_text,
1532 gpgme_data_t plaintext);
1533 gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
1534 gpgme_data_t signed_text,
1535 gpgme_data_t plaintext);
1536
1537
1538 /*
1539 * Import/Export
1540 */
1541
1542 #define GPGME_IMPORT_NEW 1 /* The key was new. */
1543 #define GPGME_IMPORT_UID 2 /* The key contained new user IDs. */
1544 #define GPGME_IMPORT_SIG 4 /* The key contained new signatures. */
1545 #define GPGME_IMPORT_SUBKEY 8 /* The key contained new sub keys. */
1546 #define GPGME_IMPORT_SECRET 16 /* The key contained a secret key. */
1547
1548
1549 /* An object to hold results for one imported key.
1550 * This structure shall be considered read-only and an application
1551 * must not allocate such a structure on its own. */
1552 struct _gpgme_import_status
1553 {
1554 struct _gpgme_import_status *next;
1555
1556 /* Fingerprint. */
1557 char *fpr;
1558
1559 /* If a problem occurred, the reason why the key could not be
1560 imported. Otherwise GPGME_No_Error. */
1561 gpgme_error_t result;
1562
1563 /* The result of the import, the GPGME_IMPORT_* values bit-wise
1564 ORed. 0 means the key was already known and no new components
1565 have been added. */
1566 unsigned int status;
1567 };
1568 typedef struct _gpgme_import_status *gpgme_import_status_t;
1569
1570 /* Import result object.
1571 * This structure shall be considered read-only and an application
1572 * must not allocate such a structure on its own. */
1573 struct _gpgme_op_import_result
1574 {
1575 /* Number of considered keys. */
1576 int considered;
1577
1578 /* Keys without user ID. */
1579 int no_user_id;
1580
1581 /* Imported keys. */
1582 int imported;
1583
1584 /* Imported RSA keys. */
1585 int imported_rsa;
1586
1587 /* Unchanged keys. */
1588 int unchanged;
1589
1590 /* Number of new user ids. */
1591 int new_user_ids;
1592
1593 /* Number of new sub keys. */
1594 int new_sub_keys;
1595
1596 /* Number of new signatures. */
1597 int new_signatures;
1598
1599 /* Number of new revocations. */
1600 int new_revocations;
1601
1602 /* Number of secret keys read. */
1603 int secret_read;
1604
1605 /* Number of secret keys imported. */
1606 int secret_imported;
1607
1608 /* Number of secret keys unchanged. */
1609 int secret_unchanged;
1610
1611 /* Number of new keys skipped. */
1612 int skipped_new_keys;
1613
1614 /* Number of keys not imported. */
1615 int not_imported;
1616
1617 /* List of keys for which an import was attempted. */
1618 gpgme_import_status_t imports;
1619 };
1620 typedef struct _gpgme_op_import_result *gpgme_import_result_t;
1621
1622 /* Retrieve a pointer to the result of the import operation. */
1623 gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
1624
1625 /* Import the key in KEYDATA into the keyring. */
1626 gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
1627 gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
1628
1629 /* Import the keys from the array KEYS into the keyring. */
1630 gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1631 gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1632
1633
1634 /* Export the keys found by PATTERN into KEYDATA. */
1635 gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
1636 gpgme_export_mode_t mode,
1637 gpgme_data_t keydata);
1638 gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
1639 gpgme_export_mode_t mode,
1640 gpgme_data_t keydata);
1641
1642 gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
1643 const char *pattern[],
1644 gpgme_export_mode_t mode,
1645 gpgme_data_t keydata);
1646 gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
1647 gpgme_export_mode_t mode,
1648 gpgme_data_t keydata);
1649
1650 /* Export the keys from the array KEYS into KEYDATA. */
1651 gpgme_error_t gpgme_op_export_keys_start (gpgme_ctx_t ctx,
1652 gpgme_key_t keys[],
1653 gpgme_export_mode_t mode,
1654 gpgme_data_t keydata);
1655 gpgme_error_t gpgme_op_export_keys (gpgme_ctx_t ctx,
1656 gpgme_key_t keys[],
1657 gpgme_export_mode_t mode,
1658 gpgme_data_t keydata);
1659
1660
1661
1662 /*
1663 * Key generation.
1664 */
1665
1666 /* Flags for the key creation functions. */
1667 #define GPGME_CREATE_SIGN (1 << 0) /* Allow usage: signing. */
1668 #define GPGME_CREATE_ENCR (1 << 1) /* Allow usage: encryption. */
1669 #define GPGME_CREATE_CERT (1 << 2) /* Allow usage: certification. */
1670 #define GPGME_CREATE_AUTH (1 << 3) /* Allow usage: authentication. */
1671 #define GPGME_CREATE_NOPASSWD (1 << 7) /* Create w/o passphrase. */
1672 #define GPGME_CREATE_SELFSIGNED (1 << 8) /* Create self-signed cert. */
1673 #define GPGME_CREATE_NOSTORE (1 << 9) /* Do not store the key. */
1674 #define GPGME_CREATE_WANTPUB (1 << 10) /* Return the public key. */
1675 #define GPGME_CREATE_WANTSEC (1 << 11) /* Return the secret key. */
1676 #define GPGME_CREATE_FORCE (1 << 12) /* Force creation. */
1677 #define GPGME_CREATE_NOEXPIRE (1 << 13) /* Create w/o expiration. */
1678
1679 /* An object to return result from a key generation.
1680 * This structure shall be considered read-only and an application
1681 * must not allocate such a structure on its own. */
1682 struct _gpgme_op_genkey_result
1683 {
1684 /* A primary key was generated. */
1685 unsigned int primary : 1;
1686
1687 /* A sub key was generated. */
1688 unsigned int sub : 1;
1689
1690 /* A user id was generated. */
1691 unsigned int uid : 1;
1692
1693 /* Internal to GPGME, do not use. */
1694 unsigned int _unused : 29;
1695
1696 /* The fingerprint of the generated key. */
1697 char *fpr;
1698
1699 /* A memory data object with the created public key. Only set when
1700 * GPGME_CREATE_WANTPUB has been used. */
1701 gpgme_data_t pubkey;
1702
1703 /* A memory data object with the created secret key. Only set when
1704 * GPGME_CREATE_WANTSEC has been used. */
1705 gpgme_data_t seckey;
1706 };
1707 typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
1708
1709 /* Generate a new keypair and add it to the keyring. PUBKEY and
1710 SECKEY should be null for now. PARMS specifies what keys should be
1711 generated. */
1712 gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
1713 gpgme_data_t pubkey, gpgme_data_t seckey);
1714 gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
1715 gpgme_data_t pubkey, gpgme_data_t seckey);
1716
1717 /* Generate a key pair using the modern interface. */
1718 gpgme_error_t gpgme_op_createkey_start (gpgme_ctx_t ctx,
1719 const char *userid,
1720 const char *algo,
1721 unsigned long reserved,
1722 unsigned long expires,
1723 gpgme_key_t certkey,
1724 unsigned int flags);
1725 gpgme_error_t gpgme_op_createkey (gpgme_ctx_t ctx,
1726 const char *userid,
1727 const char *algo,
1728 unsigned long reserved,
1729 unsigned long expires,
1730 gpgme_key_t certkey,
1731 unsigned int flags);
1732 /* Add a new subkey to KEY. */
1733 gpgme_error_t gpgme_op_createsubkey_start (gpgme_ctx_t ctx,
1734 gpgme_key_t key,
1735 const char *algo,
1736 unsigned long reserved,
1737 unsigned long expires,
1738 unsigned int flags);
1739 gpgme_error_t gpgme_op_createsubkey (gpgme_ctx_t ctx,
1740 gpgme_key_t key,
1741 const char *algo,
1742 unsigned long reserved,
1743 unsigned long expires,
1744 unsigned int flags);
1745
1746 /* Add USERID to an existing KEY. */
1747 gpgme_error_t gpgme_op_adduid_start (gpgme_ctx_t ctx,
1748 gpgme_key_t key, const char *userid,
1749 unsigned int reserved);
1750 gpgme_error_t gpgme_op_adduid (gpgme_ctx_t ctx,
1751 gpgme_key_t key, const char *userid,
1752 unsigned int reserved);
1753
1754 /* Revoke a USERID from a KEY. */
1755 gpgme_error_t gpgme_op_revuid_start (gpgme_ctx_t ctx,
1756 gpgme_key_t key, const char *userid,
1757 unsigned int reserved);
1758 gpgme_error_t gpgme_op_revuid (gpgme_ctx_t ctx,
1759 gpgme_key_t key, const char *userid,
1760 unsigned int reserved);
1761
1762 /* Set a flag on the USERID of KEY. See the manual for supported flags. */
1763 gpgme_error_t gpgme_op_set_uid_flag_start (gpgme_ctx_t ctx,
1764 gpgme_key_t key, const char *userid,
1765 const char *name, const char *value);
1766 gpgme_error_t gpgme_op_set_uid_flag (gpgme_ctx_t ctx,
1767 gpgme_key_t key, const char *userid,
1768 const char *name, const char *value);
1769
1770
1771 /* Retrieve a pointer to the result of a genkey, createkey, or
1772 * createsubkey operation. */
1773 gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
1774
1775
1776 /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
1777 keys are also deleted. */
1778 gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
1779 int allow_secret);
1780 gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
1781 int allow_secret);
1782
1783
1784 /*
1785 * Key signing interface
1786 */
1787
1788 /* Flags for the key signing functions. */
1789 #define GPGME_KEYSIGN_LOCAL (1 << 7) /* Create a local signature. */
1790 #define GPGME_KEYSIGN_LFSEP (1 << 8) /* Indicate LF separated user ids. */
1791 #define GPGME_KEYSIGN_NOEXPIRE (1 << 9) /* Force no expiration. */
1792
1793
1794 /* Sign the USERID of KEY using the current set of signers. */
1795 gpgme_error_t gpgme_op_keysign_start (gpgme_ctx_t ctx,
1796 gpgme_key_t key, const char *userid,
1797 unsigned long expires,
1798 unsigned int flags);
1799 gpgme_error_t gpgme_op_keysign (gpgme_ctx_t ctx,
1800 gpgme_key_t key, const char *userid,
1801 unsigned long expires,
1802 unsigned int flags);
1803
1804
1805
1806
1807 /*
1808 * Key edit interface
1809 */
1810
1811 /* Flags to select the mode of the interact. */
1812 #define GPGME_INTERACT_CARD (1 << 0) /* Use --card-edit mode. */
1813
1814
1815 /* Edit the KEY. Send status and command requests to FNC and
1816 output of edit commands to OUT. */
1817 gpgme_error_t gpgme_op_interact_start (gpgme_ctx_t ctx,
1818 gpgme_key_t key,
1819 unsigned int flags,
1820 gpgme_interact_cb_t fnc,
1821 void *fnc_value,
1822 gpgme_data_t out);
1823 gpgme_error_t gpgme_op_interact (gpgme_ctx_t ctx, gpgme_key_t key,
1824 unsigned int flags,
1825 gpgme_interact_cb_t fnc,
1826 void *fnc_value,
1827 gpgme_data_t out);
1828
1829
1830 /* Set the Tofu policy of KEY to POLCIY. */
1831 gpgme_error_t gpgme_op_tofu_policy_start (gpgme_ctx_t ctx,
1832 gpgme_key_t key,
1833 gpgme_tofu_policy_t policy);
1834 gpgme_error_t gpgme_op_tofu_policy (gpgme_ctx_t ctx,
1835 gpgme_key_t key,
1836 gpgme_tofu_policy_t policy);
1837
1838
1839
1840
1841 /*
1842 * Key listing
1843 */
1844
1845 /* An object to return results from a key listing operation.
1846 * This structure shall be considered read-only and an application
1847 * must not allocate such a structure on its own. */
1848 struct _gpgme_op_keylist_result
1849 {
1850 unsigned int truncated : 1;
1851
1852 /* Internal to GPGME, do not use. */
1853 unsigned int _unused : 31;
1854 };
1855 typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
1856
1857 /* Retrieve a pointer to the result of the key listing operation. */
1858 gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
1859
1860 /* Start a keylist operation within CTX, searching for keys which
1861 * match PATTERN. If SECRET_ONLY is true, only secret keys are
1862 * returned. */
1863 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
1864 int secret_only);
1865 gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
1866 const char *pattern[],
1867 int secret_only, int reserved);
1868
1869 /* List the keys contained in DATA. */
1870 gpgme_error_t gpgme_op_keylist_from_data_start (gpgme_ctx_t ctx,
1871 gpgme_data_t data,
1872 int reserved);
1873
1874 /* Return the next key from the keylist in R_KEY. */
1875 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
1876
1877 /* Terminate a pending keylist operation within CTX. */
1878 gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
1879
1880
1881
1882 /*
1883 * Protecting keys
1884 */
1885
1886 /* Change the passphrase for KEY. FLAGS is reserved for future use
1887 and must be passed as 0. */
1888 gpgme_error_t gpgme_op_passwd_start (gpgme_ctx_t ctx, gpgme_key_t key,
1889 unsigned int flags);
1890 gpgme_error_t gpgme_op_passwd (gpgme_ctx_t ctx, gpgme_key_t key,
1891 unsigned int flags);
1892
1893
1894
1895 /*
1896 * Trust items and operations.
1897 */
1898
1899 /* An object to hold data of a trust item.
1900 * This structure shall be considered read-only and an application
1901 * must not allocate such a structure on its own. */
1902 struct _gpgme_trust_item
1903 {
1904 /* Internal to GPGME, do not use. */
1905 unsigned int _refs;
1906
1907 /* The key ID to which the trust item belongs. */
1908 char *keyid;
1909
1910 /* Internal to GPGME, do not use. */
1911 char _keyid[16 + 1];
1912
1913 /* The type of the trust item, 1 refers to a key, 2 to a user ID. */
1914 int type;
1915
1916 /* The trust level. */
1917 int level;
1918
1919 /* The owner trust if TYPE is 1. */
1920 char *owner_trust;
1921
1922 /* Internal to GPGME, do not use. */
1923 char _owner_trust[2];
1924
1925 /* The calculated validity. */
1926 char *validity;
1927
1928 /* Internal to GPGME, do not use. */
1929 char _validity[2];
1930
1931 /* The user name if TYPE is 2. */
1932 char *name;
1933 };
1934 typedef struct _gpgme_trust_item *gpgme_trust_item_t;
1935
1936 /* Start a trustlist operation within CTX, searching for trust items
1937 which match PATTERN. */
1938 gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
1939 const char *pattern, int max_level);
1940
1941 /* Return the next trust item from the trustlist in R_ITEM. */
1942 gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
1943 gpgme_trust_item_t *r_item);
1944
1945 /* Terminate a pending trustlist operation within CTX. */
1946 gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
1947
1948 /* Acquire a reference to ITEM. */
1949 void gpgme_trust_item_ref (gpgme_trust_item_t item);
1950
1951 /* Release a reference to ITEM. If this was the last one the trust
1952 item is destroyed. */
1953 void gpgme_trust_item_unref (gpgme_trust_item_t item);
1954
1955
1956
1957 /*
1958 * Audit log
1959 */
1960
1961 /* Return the auditlog for the current session. This may be called
1962 after a successful or failed operation. If no audit log is
1963 available GPG_ERR_NO_DATA is returned. */
1964 gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
1965 unsigned int flags);
1966 gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
1967 unsigned int flags);
1968
1969
1970
1971 /*
1972 * Spawn interface
1973 */
1974
1975 /* Flags for the spawn operations. */
1976 #define GPGME_SPAWN_DETACHED 1
1977 #define GPGME_SPAWN_ALLOW_SET_FG 2
1978
1979
1980 /* Run the command FILE with the arguments in ARGV. Connect stdin to
1981 DATAIN, stdout to DATAOUT, and STDERR to DATAERR. If one the data
1982 streams is NULL, connect to /dev/null instead. */
1983 gpgme_error_t gpgme_op_spawn_start (gpgme_ctx_t ctx,
1984 const char *file, const char *argv[],
1985 gpgme_data_t datain,
1986 gpgme_data_t dataout, gpgme_data_t dataerr,
1987 unsigned int flags);
1988 gpgme_error_t gpgme_op_spawn (gpgme_ctx_t ctx,
1989 const char *file, const char *argv[],
1990 gpgme_data_t datain,
1991 gpgme_data_t dataout, gpgme_data_t dataerr,
1992 unsigned int flags);
1993
1994
1995 /*
1996 * Low-level Assuan protocol access.
1997 */
1998 typedef gpgme_error_t (*gpgme_assuan_data_cb_t)
1999 (void *opaque, const void *data, size_t datalen);
2000
2001 typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t)
2002 (void *opaque, const char *name, const char *args,
2003 gpgme_data_t *r_data);
2004
2005 typedef gpgme_error_t (*gpgme_assuan_status_cb_t)
2006 (void *opaque, const char *status, const char *args);
2007
2008 /* Send the Assuan COMMAND and return results via the callbacks.
2009 Asynchronous variant. */
2010 gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx,
2011 const char *command,
2012 gpgme_assuan_data_cb_t data_cb,
2013 void *data_cb_value,
2014 gpgme_assuan_inquire_cb_t inq_cb,
2015 void *inq_cb_value,
2016 gpgme_assuan_status_cb_t stat_cb,
2017 void *stat_cb_value);
2018
2019 /* Send the Assuan COMMAND and return results via the callbacks.
2020 Synchronous variant. */
2021 gpgme_error_t gpgme_op_assuan_transact_ext (gpgme_ctx_t ctx,
2022 const char *command,
2023 gpgme_assuan_data_cb_t data_cb,
2024 void *data_cb_value,
2025 gpgme_assuan_inquire_cb_t inq_cb,
2026 void *inq_cb_value,
2027 gpgme_assuan_status_cb_t stat_cb,
2028 void *stat_cb_value,
2029 gpgme_error_t *op_err);
2030
2031
2032 /*
2033 * Crypto container support.
2034 */
2035
2036 /* An object to return results from a VFS mount operation.
2037 * This structure shall be considered read-only and an application
2038 * must not allocate such a structure on its own. */
2039 struct _gpgme_op_vfs_mount_result
2040 {
2041 char *mount_dir;
2042 };
2043 typedef struct _gpgme_op_vfs_mount_result *gpgme_vfs_mount_result_t;
2044
2045 gpgme_vfs_mount_result_t gpgme_op_vfs_mount_result (gpgme_ctx_t ctx);
2046
2047 /* The container is automatically unmounted when the context is reset
2048 or destroyed. Transmission errors are returned directly,
2049 operational errors are returned in OP_ERR. */
2050 gpgme_error_t gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file,
2051 const char *mount_dir, unsigned int flags,
2052 gpgme_error_t *op_err);
2053
2054 gpgme_error_t gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[],
2055 const char *container_file,
2056 unsigned int flags, gpgme_error_t *op_err);
2057
2058
2059 /*
2060 * Interface to gpgconf(1).
2061 */
2062
2063 /* The expert level at which a configuration option or group of
2064 options should be displayed. See the gpgconf(1) documentation for
2065 more details. */
2066 typedef enum
2067 {
2068 GPGME_CONF_BASIC = 0,
2069 GPGME_CONF_ADVANCED = 1,
2070 GPGME_CONF_EXPERT = 2,
2071 GPGME_CONF_INVISIBLE = 3,
2072 GPGME_CONF_INTERNAL = 4
2073 }
2074 gpgme_conf_level_t;
2075
2076
2077 /* The data type of a configuration option argument. See the gpgconf(1)
2078 documentation for more details. */
2079 typedef enum
2080 {
2081 /* Basic types. */
2082 GPGME_CONF_NONE = 0,
2083 GPGME_CONF_STRING = 1,
2084 GPGME_CONF_INT32 = 2,
2085 GPGME_CONF_UINT32 = 3,
2086
2087 /* Complex types. */
2088 GPGME_CONF_FILENAME = 32,
2089 GPGME_CONF_LDAP_SERVER = 33,
2090 GPGME_CONF_KEY_FPR = 34,
2091 GPGME_CONF_PUB_KEY = 35,
2092 GPGME_CONF_SEC_KEY = 36,
2093 GPGME_CONF_ALIAS_LIST = 37
2094 }
2095 gpgme_conf_type_t;
2096
2097 /* For now, compatibility. */
2098 #define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
2099
2100
2101 /* This represents a single argument for a configuration option.
2102 Which of the members of value is used depends on the ALT_TYPE. */
2103 typedef struct gpgme_conf_arg
2104 {
2105 struct gpgme_conf_arg *next;
2106 /* True if the option appears without an (optional) argument. */
2107 unsigned int no_arg;
2108 union
2109 {
2110 unsigned int count;
2111 unsigned int uint32;
2112 int int32;
2113 char *string;
2114 } value;
2115 } *gpgme_conf_arg_t;
2116
2117
2118 /* The flags of a configuration option. See the gpgconf
2119 documentation for details. */
2120 #define GPGME_CONF_GROUP (1 << 0)
2121 #define GPGME_CONF_OPTIONAL (1 << 1)
2122 #define GPGME_CONF_LIST (1 << 2)
2123 #define GPGME_CONF_RUNTIME (1 << 3)
2124 #define GPGME_CONF_DEFAULT (1 << 4)
2125 #define GPGME_CONF_DEFAULT_DESC (1 << 5)
2126 #define GPGME_CONF_NO_ARG_DESC (1 << 6)
2127 #define GPGME_CONF_NO_CHANGE (1 << 7)
2128
2129
2130 /* The representation of a single configuration option. See the
2131 gpg-conf documentation for details. */
2132 typedef struct gpgme_conf_opt
2133 {
2134 struct gpgme_conf_opt *next;
2135
2136 /* The option name. */
2137 char *name;
2138
2139 /* The flags for this option. */
2140 unsigned int flags;
2141
2142 /* The level of this option. */
2143 gpgme_conf_level_t level;
2144
2145 /* The localized description of this option. */
2146 char *description;
2147
2148 /* The type and alternate type of this option. */
2149 gpgme_conf_type_t type;
2150 gpgme_conf_type_t alt_type;
2151
2152 /* The localized (short) name of the argument, if any. */
2153 char *argname;
2154
2155 /* The default value. */
2156 gpgme_conf_arg_t default_value;
2157 char *default_description;
2158
2159 /* The default value if the option is not set. */
2160 gpgme_conf_arg_t no_arg_value;
2161 char *no_arg_description;
2162
2163 /* The current value if the option is set. */
2164 gpgme_conf_arg_t value;
2165
2166 /* The new value, if any. NULL means reset to default. */
2167 int change_value;
2168 gpgme_conf_arg_t new_value;
2169
2170 /* Free for application use. */
2171 void *user_data;
2172 } *gpgme_conf_opt_t;
2173
2174
2175 /* The representation of a component that can be configured. See the
2176 gpg-conf documentation for details. */
2177 typedef struct gpgme_conf_comp
2178 {
2179 struct gpgme_conf_comp *next;
2180
2181 /* Internal to GPGME, do not use! */
2182 gpgme_conf_opt_t *_last_opt_p;
2183
2184 /* The component name. */
2185 char *name;
2186
2187 /* A human-readable description for the component. */
2188 char *description;
2189
2190 /* The program name (an absolute path to the program). */
2191 char *program_name;
2192
2193 /* A linked list of options for this component. */
2194 struct gpgme_conf_opt *options;
2195 } *gpgme_conf_comp_t;
2196
2197
2198 /* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg
2199 default" is prepared. If type is a string type, VALUE should point
2200 to the string. Else, it should point to an unsigned or signed
2201 integer respectively. */
2202 gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
2203 gpgme_conf_type_t type, const void *value);
2204
2205 /* This also releases all chained argument structures! */
2206 void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
2207
2208 /* Register a change for the value of OPT to ARG. If RESET is 1 (do
2209 not use any values but 0 or 1), ARG is ignored and the option is
2210 not changed (reverting a previous change). Otherwise, if ARG is
2211 NULL, the option is cleared or reset to its default. The change
2212 is done with gpgconf's --runtime option to immediately take effect. */
2213 gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
2214 gpgme_conf_arg_t arg);
2215
2216 /* Release a set of configurations. */
2217 void gpgme_conf_release (gpgme_conf_comp_t conf);
2218
2219 /* Retrieve the current configurations. */
2220 gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
2221
2222 /* Save the configuration of component comp. This function does not
2223 follow chained components! */
2224 gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
2225
2226
2227 /* Information about software versions.
2228 * This structure shall be considered read-only and an application
2229 * must not allocate such a structure on its own. */
2230 typedef struct _gpgme_op_query_swdb_result
2231 {
2232 /* RFU */
2233 struct _gpgme_op_query_swdb_result *next;
2234
2235 /* The name of the package (e.g. "gpgme", "gnupg") */
2236 char *name;
2237
2238 /* The version number of the installed version. */
2239 char *iversion;
2240
2241 /* The time the online info was created. */
2242 unsigned long created;
2243
2244 /* The time the online info was retrieved. */
2245 unsigned long retrieved;
2246
2247 /* This bit is set if an error occured or some of the information
2248 * in this structure may not be set. */
2249 unsigned int warning : 1;
2250
2251 /* An update is available. */
2252 unsigned int update : 1;
2253
2254 /* The update is important. */
2255 unsigned int urgent : 1;
2256
2257 /* No information at all available. */
2258 unsigned int noinfo : 1;
2259
2260 /* The package name is not known. */
2261 unsigned int unknown : 1;
2262
2263 /* The information here is too old. */
2264 unsigned int tooold : 1;
2265
2266 /* Other error. */
2267 unsigned int error : 1;
2268
2269 unsigned int _reserved : 25;
2270
2271 /* The version number of the latest released version. */
2272 char *version;
2273
2274 /* The release date of that version. */
2275 unsigned long reldate;
2276
2277 } *gpgme_query_swdb_result_t;
2278
2279
2280 /* Run the gpgconf --query-swdb command. */
2281 gpgme_error_t gpgme_op_query_swdb (gpgme_ctx_t ctx,
2282 const char *name, const char *iversion,
2283 unsigned int reserved);
2284
2285 /* Return the result from the last query_swdb operation. */
2286 gpgme_query_swdb_result_t gpgme_op_query_swdb_result (gpgme_ctx_t ctx);
2287
2288
2289
2290
2291 /*
2292 * Various functions.
2293 */
2294
2295 /* Set special global flags; consult the manual before use. */
2296 int gpgme_set_global_flag (const char *name, const char *value);
2297
2298 /* Check that the library fulfills the version requirement. Note:
2299 This is here only for the case where a user takes a pointer from
2300 the old version of this function. The new version and macro for
2301 run-time checks are below. */
2302 const char *gpgme_check_version (const char *req_version);
2303
2304 /* Check that the library fulfills the version requirement and check
2305 for struct layout mismatch involving bitfields. */
2306 const char *gpgme_check_version_internal (const char *req_version,
2307 size_t offset_sig_validity);
2308
2309 #define gpgme_check_version(req_version) \
2310 gpgme_check_version_internal (req_version, \
2311 offsetof (struct _gpgme_signature, validity))
2312
2313 /* Return the default values for various directories. */
2314 const char *gpgme_get_dirinfo (const char *what);
2315
2316 /* Get the information about the configured and installed engines. A
2317 pointer to the first engine in the statically allocated linked list
2318 is returned in *INFO. If an error occurs, it is returned. The
2319 returned data is valid until the next gpgme_set_engine_info. */
2320 gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
2321
2322 /* Set the default engine info for the protocol PROTO to the file name
2323 FILE_NAME and the home directory HOME_DIR. */
2324 gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
2325 const char *file_name,
2326 const char *home_dir);
2327
2328 /* Verify that the engine implementing PROTO is installed and
2329 available. */
2330 gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
2331
2332
2333 /* Reference counting for result objects. */
2334 void gpgme_result_ref (void *result);
2335 void gpgme_result_unref (void *result);
2336
2337 /* Return a public key algorithm string (e.g. "rsa2048"). Caller must
2338 free using gpgme_free. */
2339 char *gpgme_pubkey_algo_string (gpgme_subkey_t subkey);
2340
2341 /* Return a statically allocated string with the name of the public
2342 key algorithm ALGO, or NULL if that name is not known. */
2343 const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
2344
2345 /* Return a statically allocated string with the name of the hash
2346 algorithm ALGO, or NULL if that name is not known. */
2347 const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
2348
2349 /* Return the addr-spec from a user id. Caller must free the result
2350 * with gpgme_free. */
2351 char *gpgme_addrspec_from_uid (const char *uid);
2352
2353
2354
2355 /*
2356 * Deprecated types, constants and functions.
2357 */
4482358
4492359 /* The possible stati for gpgme_op_edit. The use of that function and
4502360 * these status codes are deprecated in favor of gpgme_op_interact. */
5612471 }
5622472 gpgme_status_code_t;
5632473
564
565 /* The available signature notation flags. */
566 #define GPGME_SIG_NOTATION_HUMAN_READABLE 1
567 #define GPGME_SIG_NOTATION_CRITICAL 2
568
569 typedef unsigned int gpgme_sig_notation_flags_t;
570
571 struct _gpgme_sig_notation
572 {
573 struct _gpgme_sig_notation *next;
574
575 /* If NAME is a null pointer, then VALUE contains a policy URL
576 rather than a notation. */
577 char *name;
578
579 /* The value of the notation data. */
580 char *value;
581
582 /* The length of the name of the notation data. */
583 int name_len;
584
585 /* The length of the value of the notation data. */
586 int value_len;
587
588 /* The accumulated flags. */
589 gpgme_sig_notation_flags_t flags;
590
591 /* Notation data is human-readable. */
592 unsigned int human_readable : 1;
593
594 /* Notation data is critical. */
595 unsigned int critical : 1;
596
597 /* Internal to GPGME, do not use. */
598 int _unused : 30;
599 };
600 typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
601
602
603
604 /*
605 * Public structures.
606 */
607
608 /* The engine information structure. */
609 struct _gpgme_engine_info
610 {
611 struct _gpgme_engine_info *next;
612
613 /* The protocol ID. */
614 gpgme_protocol_t protocol;
615
616 /* The file name of the engine binary. */
617 char *file_name;
618
619 /* The version string of the installed engine. */
620 char *version;
621
622 /* The minimum version required for GPGME. */
623 const char *req_version;
624
625 /* The home directory used, or NULL if default. */
626 char *home_dir;
627 };
628 typedef struct _gpgme_engine_info *gpgme_engine_info_t;
629
630
631 /* An object with TOFU information. */
632 struct _gpgme_tofu_info
633 {
634 struct _gpgme_tofu_info *next;
635
636 /* The TOFU validity:
637 * 0 := conflict
638 * 1 := key without history
639 * 2 := key with too little history
640 * 3 := key with enough history for basic trust
641 * 4 := key with a lot of history
642 */
643 unsigned int validity : 3;
644
645 /* The TOFU policy (gpgme_tofu_policy_t). */
646 unsigned int policy : 4;
647
648 unsigned int _rfu : 25;
649
650 /* Number of signatures seen for this binding. Capped at USHRT_MAX. */
651 unsigned short signcount;
652 /* Number of encryptions done with this binding. Capped at USHRT_MAX. */
653 unsigned short encrcount;
654
655 /* Number of seconds since Epoch when the first and the most
656 * recently seen message were verified/decrypted. 0 means unknown. */
657 unsigned long signfirst;
658 unsigned long signlast;
659 unsigned long encrfirst;
660 unsigned long encrlast;
661
662 /* If non-NULL a human readable string summarizing the TOFU data. */
663 char *description;
664 };
665 typedef struct _gpgme_tofu_info *gpgme_tofu_info_t;
666
667
668 /* A subkey from a key. */
669 struct _gpgme_subkey
670 {
671 struct _gpgme_subkey *next;
672
673 /* True if subkey is revoked. */
674 unsigned int revoked : 1;
675
676 /* True if subkey is expired. */
677 unsigned int expired : 1;
678
679 /* True if subkey is disabled. */
680 unsigned int disabled : 1;
681
682 /* True if subkey is invalid. */
683 unsigned int invalid : 1;
684
685 /* True if subkey can be used for encryption. */
686 unsigned int can_encrypt : 1;
687
688 /* True if subkey can be used for signing. */
689 unsigned int can_sign : 1;
690
691 /* True if subkey can be used for certification. */
692 unsigned int can_certify : 1;
693
694 /* True if subkey is secret. */
695 unsigned int secret : 1;
696
697 /* True if subkey can be used for authentication. */
698 unsigned int can_authenticate : 1;
699
700 /* True if subkey is qualified for signatures according to German law. */
701 unsigned int is_qualified : 1;
702
703 /* True if the secret key is stored on a smart card. */
704 unsigned int is_cardkey : 1;
705
706 /* Internal to GPGME, do not use. */
707 unsigned int _unused : 21;
708
709 /* Public key algorithm supported by this subkey. */
710 gpgme_pubkey_algo_t pubkey_algo;
711
712 /* Length of the subkey. */
713 unsigned int length;
714
715 /* The key ID of the subkey. */
716 char *keyid;
717
718 /* Internal to GPGME, do not use. */
719 char _keyid[16 + 1];
720
721 /* The fingerprint of the subkey in hex digit form. */
722 char *fpr;
723
724 /* The creation timestamp, -1 if invalid, 0 if not available. */
725 long int timestamp;
726
727 /* The expiration timestamp, 0 if the subkey does not expire. */
728 long int expires;
729
730 /* The serial number of a smart card holding this key or NULL. */
731 char *card_number;
732
733 /* The name of the curve for ECC algorithms or NULL. */
734 char *curve;
735
736 /* The keygrip of the subkey in hex digit form or NULL if not availabale. */
737 char *keygrip;
738 };
739 typedef struct _gpgme_subkey *gpgme_subkey_t;
740
741
742 /* A signature on a user ID. */
743 struct _gpgme_key_sig
744 {
745 struct _gpgme_key_sig *next;
746
747 /* True if the signature is a revocation signature. */
748 unsigned int revoked : 1;
749
750 /* True if the signature is expired. */
751 unsigned int expired : 1;
752
753 /* True if the signature is invalid. */
754 unsigned int invalid : 1;
755
756 /* True if the signature should be exported. */
757 unsigned int exportable : 1;
758
759 /* Internal to GPGME, do not use. */
760 unsigned int _unused : 28;
761
762 /* The public key algorithm used to create the signature. */
763 gpgme_pubkey_algo_t pubkey_algo;
764
765 /* The key ID of key used to create the signature. */
766 char *keyid;
767
768 /* Internal to GPGME, do not use. */
769 char _keyid[16 + 1];
770
771 /* The creation timestamp, -1 if invalid, 0 if not available. */
772 long int timestamp;
773
774 /* The expiration timestamp, 0 if the subkey does not expire. */
775 long int expires;
776
777 /* Same as in gpgme_signature_t. */
778 gpgme_error_t status;
779
780 #ifdef __cplusplus
781 unsigned int _obsolete_class _GPGME_DEPRECATED(0,4);
782 #else
783 /* Must be set to SIG_CLASS below. */
784 unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4);
785 #endif
786
787 /* The user ID string. */
788 char *uid;
789
790 /* The name part of the user ID. */
791 char *name;
792
793 /* The email part of the user ID. */
794 char *email;
795
796 /* The comment part of the user ID. */
797 char *comment;
798
799 /* Crypto backend specific signature class. */
800 unsigned int sig_class;
801
802 /* Notation data and policy URLs. */
803 gpgme_sig_notation_t notations;
804
805 /* Internal to GPGME, do not use. */
806 gpgme_sig_notation_t _last_notation;
807 };
808 typedef struct _gpgme_key_sig *gpgme_key_sig_t;
809
810
811 /* An user ID from a key. */
812 struct _gpgme_user_id
813 {
814 struct _gpgme_user_id *next;
815
816 /* True if the user ID is revoked. */
817 unsigned int revoked : 1;
818
819 /* True if the user ID is invalid. */
820 unsigned int invalid : 1;
821
822 /* Internal to GPGME, do not use. */
823 unsigned int _unused : 30;
824
825 /* The validity of the user ID. */
826 gpgme_validity_t validity;
827
828 /* The user ID string. */
829 char *uid;
830
831 /* The name part of the user ID. */
832 char *name;
833
834 /* The email part of the user ID. */
835 char *email;
836
837 /* The comment part of the user ID. */
838 char *comment;
839
840 /* The signatures of the user ID. */
841 gpgme_key_sig_t signatures;
842
843 /* Internal to GPGME, do not use. */
844 gpgme_key_sig_t _last_keysig;
845
846 /* The mail address (addr-spec from RFC5322) of the UID string.
847 * This is general the same as the EMAIL part of this struct but
848 * might be slightly different. If no mail address is available
849 * NULL is stored. */
850 char *address;
851
852 /* The malloced TOFU information or NULL. */
853 gpgme_tofu_info_t tofu;
854 };
855 typedef struct _gpgme_user_id *gpgme_user_id_t;
856
857
858 /* A key from the keyring. */
859 struct _gpgme_key
860 {
861 /* Internal to GPGME, do not use. */
862 unsigned int _refs;
863
864 /* True if key is revoked. */
865 unsigned int revoked : 1;
866
867 /* True if key is expired. */
868 unsigned int expired : 1;
869
870 /* True if key is disabled. */
871 unsigned int disabled : 1;
872
873 /* True if key is invalid. */
874 unsigned int invalid : 1;
875
876 /* True if key can be used for encryption. */
877 unsigned int can_encrypt : 1;
878
879 /* True if key can be used for signing. */
880 unsigned int can_sign : 1;
881
882 /* True if key can be used for certification. */
883 unsigned int can_certify : 1;
884
885 /* True if key is secret. */
886 unsigned int secret : 1;
887
888 /* True if key can be used for authentication. */
889 unsigned int can_authenticate : 1;
890
891 /* True if subkey is qualified for signatures according to German law. */
892 unsigned int is_qualified : 1;
893
894 /* Internal to GPGME, do not use. */
895 unsigned int _unused : 22;
896
897 /* This is the protocol supported by this key. */
898 gpgme_protocol_t protocol;
899
900 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
901 issuer serial. */
902 char *issuer_serial;
903
904 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the
905 issuer name. */
906 char *issuer_name;
907
908 /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain
909 ID. */
910 char *chain_id;
911
912 /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the
913 owner trust. */
914 gpgme_validity_t owner_trust;
915
916 /* The subkeys of the key. */
917 gpgme_subkey_t subkeys;
918
919 /* The user IDs of the key. */
920 gpgme_user_id_t uids;
921
922 /* Internal to GPGME, do not use. */
923 gpgme_subkey_t _last_subkey;
924
925 /* Internal to GPGME, do not use. */
926 gpgme_user_id_t _last_uid;
927
928 /* The keylist mode that was active when listing the key. */
929 gpgme_keylist_mode_t keylist_mode;
930
931 /* This field gives the fingerprint of the primary key. Note that
932 * this is a copy of the FPR of the first subkey. We need it here
933 * to allow for an incomplete key object. */
934 char *fpr;
935 };
936 typedef struct _gpgme_key *gpgme_key_t;
937
938
939 /* An invalid key object. */
940 struct _gpgme_invalid_key
941 {
942 struct _gpgme_invalid_key *next;
943
944 /* The string used to request the key. Despite the name this may
945 * not be a fingerprint. */
946 char *fpr;
947
948 /* The error code. */
949 gpgme_error_t reason;
950 };
951 typedef struct _gpgme_invalid_key *gpgme_invalid_key_t;
952
953
954
955 /*
956 * Types for callback functions.
957 */
958
959 /* Request a passphrase from the user. */
960 typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook,
961 const char *uid_hint,
962 const char *passphrase_info,
963 int prev_was_bad, int fd);
964
965 /* Inform the user about progress made. */
966 typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what,
967 int type, int current, int total);
968
969 /* Status messages from gpg. */
970 typedef gpgme_error_t (*gpgme_status_cb_t) (void *opaque, const char *keyword,
971 const char *args);
972
973 /* Interact with the user about an edit operation. */
974 typedef gpgme_error_t (*gpgme_interact_cb_t) (void *opaque,
975 const char *keyword,
976 const char *args, int fd);
977
9782474 /* The callback type used by the deprecated functions gpgme_op_edit
9792475 * and gpgme_op_card_edit. */
9802476 typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque,
9812477 gpgme_status_code_t status,
9822478 const char *args, int fd);
983
984
985
986
987 /*
988 * Context management functions.
989 */
990
991 /* Create a new context and return it in CTX. */
992 gpgme_error_t gpgme_new (gpgme_ctx_t *ctx);
993
994 /* Release the context CTX. */
995 void gpgme_release (gpgme_ctx_t ctx);
996
997 /* Set the flag NAME for CTX to VALUE. */
998 gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx,
999 const char *name, const char *value);
1000
1001 /* Get the value of the flag NAME from CTX. */
1002 const char *gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name);
1003
1004 /* Set the protocol to be used by CTX to PROTO. */
1005 gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto);
1006
1007 /* Get the protocol used with CTX */
1008 gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx);
1009
1010 /* Set the crypto protocol to be used by CTX to PROTO.
1011 gpgme_set_protocol actually sets the backend engine. This sets the
1012 crypto protocol used in engines that support more than one crypto
1013 prococol (for example, an UISERVER can support OpenPGP and CMS).
1014 This is reset to the default with gpgme_set_protocol. */
1015 gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx,
1016 gpgme_protocol_t proto);
1017
1018 /* Get the sub protocol. */
1019 gpgme_protocol_t gpgme_get_sub_protocol (gpgme_ctx_t ctx);
1020
1021 /* Get the string describing protocol PROTO, or NULL if invalid. */
1022 const char *gpgme_get_protocol_name (gpgme_protocol_t proto);
1023
1024 /* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
1025 void gpgme_set_armor (gpgme_ctx_t ctx, int yes);
1026
1027 /* Return non-zero if armor mode is set in CTX. */
1028 int gpgme_get_armor (gpgme_ctx_t ctx);
1029
1030 /* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
1031 void gpgme_set_textmode (gpgme_ctx_t ctx, int yes);
1032
1033 /* Return non-zero if text mode is set in CTX. */
1034 int gpgme_get_textmode (gpgme_ctx_t ctx);
1035
1036 /* If YES is non-zero, enable offline mode in CTX, disable it otherwise. */
1037 void gpgme_set_offline (gpgme_ctx_t ctx, int yes);
1038
1039 /* Return non-zero if offline mode is set in CTX. */
1040 int gpgme_get_offline (gpgme_ctx_t ctx);
1041
1042 /* Use whatever the default of the backend crypto engine is. */
1043 #define GPGME_INCLUDE_CERTS_DEFAULT -256
1044
1045 /* Include up to NR_OF_CERTS certificates in an S/MIME message. */
1046 void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs);
1047
1048 /* Return the number of certs to include in an S/MIME message. */
1049 int gpgme_get_include_certs (gpgme_ctx_t ctx);
1050
1051 /* Set keylist mode in CTX to MODE. */
1052 gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx,
1053 gpgme_keylist_mode_t mode);
1054
1055 /* Get keylist mode in CTX. */
1056 gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx);
1057
1058 /* Set the pinentry mode for CTX to MODE. */
1059 gpgme_error_t gpgme_set_pinentry_mode (gpgme_ctx_t ctx,
1060 gpgme_pinentry_mode_t mode);
1061
1062 /* Get the pinentry mode of CTX. */
1063 gpgme_pinentry_mode_t gpgme_get_pinentry_mode (gpgme_ctx_t ctx);
1064
1065 /* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
1066 passed as first argument to the passphrase callback function. */
1067 void gpgme_set_passphrase_cb (gpgme_ctx_t ctx,
1068 gpgme_passphrase_cb_t cb, void *hook_value);
1069
1070 /* Get the current passphrase callback function in *CB and the current
1071 hook value in *HOOK_VALUE. */
1072 void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb,
1073 void **hook_value);
1074
1075 /* Set the progress callback function in CTX to CB. HOOK_VALUE is
1076 passed as first argument to the progress callback function. */
1077 void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb,
1078 void *hook_value);
1079
1080 /* Get the current progress callback function in *CB and the current
1081 hook value in *HOOK_VALUE. */
1082 void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb,
1083 void **hook_value);
1084
1085 /* Set the status callback function in CTX to CB. HOOK_VALUE is
1086 passed as first argument to the status callback function. */
1087 void gpgme_set_status_cb (gpgme_ctx_t c, gpgme_status_cb_t cb,
1088 void *hook_value);
1089
1090 /* Get the current status callback function in *CB and the current
1091 hook value in *HOOK_VALUE. */
1092 void gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *cb,
1093 void **hook_value);
1094
1095 /* This function sets the locale for the context CTX, or the default
1096 locale if CTX is a null pointer. */
1097 gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category,
1098 const char *value);
1099
1100 /* Get the information about the configured engines. A pointer to the
1101 first engine in the statically allocated linked list is returned.
1102 The returned data is valid until the next gpgme_ctx_set_engine_info. */
1103 gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx);
1104
1105 /* Set the engine info for the context CTX, protocol PROTO, to the
1106 file name FILE_NAME and the home directory HOME_DIR. */
1107 gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx,
1108 gpgme_protocol_t proto,
1109 const char *file_name,
1110 const char *home_dir);
1111
1112 /* Delete all signers from CTX. */
1113 void gpgme_signers_clear (gpgme_ctx_t ctx);
1114
1115 /* Add KEY to list of signers in CTX. */
1116 gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key);
1117
1118 /* Return the number of signers in CTX. */
1119 unsigned int gpgme_signers_count (const gpgme_ctx_t ctx);
1120
1121 /* Return the SEQth signer's key in CTX. */
1122 gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq);
1123
1124 /* Retrieve the signature status of signature IDX in CTX after a
1125 successful verify operation in R_STAT (if non-null). The creation
1126 time stamp of the signature is returned in R_CREATED (if non-null).
1127 The function returns a string containing the fingerprint.
1128 Deprecated, use verify result directly. */
1129 const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
1130 _gpgme_sig_stat_t *r_stat,
1131 time_t *r_created) _GPGME_DEPRECATED(0,4);
1132
1133 /* Retrieve certain attributes of a signature. IDX is the index
1134 number of the signature after a successful verify operation. WHAT
1135 is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
1136 one. WHATIDX is to be passed as 0 for most attributes . */
1137 unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
1138 _gpgme_attr_t what, int whatidx)
1139 _GPGME_DEPRECATED(0,4);
1140 const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
1141 _gpgme_attr_t what, int whatidx)
1142 _GPGME_DEPRECATED(0,4);
1143
1144
1145 /* Get the key used to create signature IDX in CTX and return it in
1146 R_KEY. */
1147 gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
1148 _GPGME_DEPRECATED(0,4);
1149
1150
1151 /* Clear all notation data from the context. */
1152 void gpgme_sig_notation_clear (gpgme_ctx_t ctx);
1153
1154 /* Add the human-readable notation data with name NAME and value VALUE
1155 to the context CTX, using the flags FLAGS. If NAME is NULL, then
1156 VALUE should be a policy URL. The flag
1157 GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
1158 data, and false for policy URLs. */
1159 gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
1160 const char *value,
1161 gpgme_sig_notation_flags_t flags);
1162
1163 /* Get the sig notations for this context. */
1164 gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx);
1165
1166 /* Store a sender address in the context. */
1167 gpgme_error_t gpgme_set_sender (gpgme_ctx_t ctx, const char *address);
1168
1169 /* Get the sender address from the context. */
1170 const char *gpgme_get_sender (gpgme_ctx_t ctx);
1171
1172
1173
1174 /*
1175 * Run control.
1176 */
1177
1178 /* The type of an I/O callback function. */
1179 typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd);
1180
1181 /* The type of a function that can register FNC as the I/O callback
1182 function for the file descriptor FD with direction dir (0: for writing,
1183 1: for reading). FNC_DATA should be passed as DATA to FNC. The
1184 function should return a TAG suitable for the corresponding
1185 gpgme_remove_io_cb_t, and an error value. */
1186 typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir,
1187 gpgme_io_cb_t fnc,
1188 void *fnc_data, void **tag);
1189
1190 /* The type of a function that can remove a previously registered I/O
1191 callback function given TAG as returned by the register
1192 function. */
1193 typedef void (*gpgme_remove_io_cb_t) (void *tag);
1194
1195 typedef enum
1196 {
1197 GPGME_EVENT_START,
1198 GPGME_EVENT_DONE,
1199 GPGME_EVENT_NEXT_KEY,
1200 GPGME_EVENT_NEXT_TRUSTITEM
1201 }
1202 gpgme_event_io_t;
1203
1204 struct gpgme_io_event_done_data
1205 {
1206 /* A fatal IPC error or an operational error in state-less
1207 protocols. */
1208 gpgme_error_t err;
1209
1210 /* An operational errors in session-based protocols. */
1211 gpgme_error_t op_err;
1212 };
1213 typedef struct gpgme_io_event_done_data *gpgme_io_event_done_data_t;
1214
1215 /* The type of a function that is called when a context finished an
1216 operation. */
1217 typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type,
1218 void *type_data);
1219
1220 struct gpgme_io_cbs
1221 {
1222 gpgme_register_io_cb_t add;
1223 void *add_priv;
1224 gpgme_remove_io_cb_t remove;
1225 gpgme_event_io_cb_t event;
1226 void *event_priv;
1227 };
1228 typedef struct gpgme_io_cbs *gpgme_io_cbs_t;
1229
1230 /* Set the I/O callback functions in CTX to IO_CBS. */
1231 void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
1232
1233 /* Get the current I/O callback functions. */
1234 void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
1235
1236 /* Wrappers around the internal I/O functions for use with
1237 gpgme_passphrase_cb_t and gpgme_interact_cb_t. */
1238 @API__SSIZE_T@ gpgme_io_read (int fd, void *buffer, size_t count);
1239 @API__SSIZE_T@ gpgme_io_write (int fd, const void *buffer, size_t count);
1240 int gpgme_io_writen (int fd, const void *buffer, size_t count);
1241
1242 /* Process the pending operation and, if HANG is non-zero, wait for
1243 the pending operation to finish. */
1244 gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);
1245
1246 gpgme_ctx_t gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status,
1247 gpgme_error_t *op_err, int hang);
1248
1249 /* Cancel a pending asynchronous operation. */
1250 gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx);
1251
1252 /* Cancel a pending operation asynchronously. */
1253 gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx);
1254
1255
1256
1257 /*
1258 * Functions to handle data objects.
1259 */
1260
1261 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1262 the handle HANDLE. Return the number of characters read, 0 on EOF
1263 and -1 on error. If an error occurs, errno is set. */
1264 typedef @API__SSIZE_T@ (*gpgme_data_read_cb_t) (void *handle, void *buffer,
1265 size_t size);
1266
1267 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1268 the handle HANDLE. Return the number of characters written, or -1
1269 on error. If an error occurs, errno is set. */
1270 typedef @API__SSIZE_T@ (*gpgme_data_write_cb_t) (void *handle, const void *buffer,
1271 size_t size);
1272
1273 /* Set the current position from where the next read or write starts
1274 in the data object with the handle HANDLE to OFFSET, relativ to
1275 WHENCE. Returns the new offset in bytes from the beginning of the
1276 data object. */
1277 typedef @API__OFF_T@ (*gpgme_data_seek_cb_t) (void *handle,
1278 @API__OFF_T@ offset, int whence);
1279
1280 /* Close the data object with the handle HANDLE. */
1281 typedef void (*gpgme_data_release_cb_t) (void *handle);
1282
1283 struct gpgme_data_cbs
1284 {
1285 gpgme_data_read_cb_t read;
1286 gpgme_data_write_cb_t write;
1287 gpgme_data_seek_cb_t seek;
1288 gpgme_data_release_cb_t release;
1289 };
1290 typedef struct gpgme_data_cbs *gpgme_data_cbs_t;
1291
1292 /* Read up to SIZE bytes into buffer BUFFER from the data object with
1293 the handle DH. Return the number of characters read, 0 on EOF and
1294 -1 on error. If an error occurs, errno is set. */
1295 @API__SSIZE_T@ gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size);
1296
1297 /* Write up to SIZE bytes from buffer BUFFER to the data object with
1298 the handle DH. Return the number of characters written, or -1 on
1299 error. If an error occurs, errno is set. */
1300 @API__SSIZE_T@ gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size);
1301
1302 /* Set the current position from where the next read or write starts
1303 in the data object with the handle DH to OFFSET, relativ to WHENCE.
1304 Returns the new offset in bytes from the beginning of the data
1305 object. */
1306 @API__OFF_T@ gpgme_data_seek (gpgme_data_t dh, @API__OFF_T@ offset, int whence);
1307
1308 /* Create a new data buffer and return it in R_DH. */
1309 gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh);
1310
1311 /* Destroy the data buffer DH. */
1312 void gpgme_data_release (gpgme_data_t dh);
1313
1314 /* Create a new data buffer filled with SIZE bytes starting from
1315 BUFFER. If COPY is zero, copying is delayed until necessary, and
1316 the data is taken from the original location when needed. */
1317 gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh,
1318 const char *buffer, size_t size,
1319 int copy);
1320
1321 /* Destroy the data buffer DH and return a pointer to its content.
1322 The memory has be to released with gpgme_free() by the user. It's
1323 size is returned in R_LEN. */
1324 char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len);
1325
1326 /* Release the memory returned by gpgme_data_release_and_get_mem() and
1327 some other functions. */
1328 void gpgme_free (void *buffer);
1329
1330 gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh,
1331 gpgme_data_cbs_t cbs,
1332 void *handle);
1333
1334 gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd);
1335
1336 gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream);
1337
1338 /* Return the encoding attribute of the data buffer DH */
1339 gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh);
1340
1341 /* Set the encoding attribute of data buffer DH to ENC */
1342 gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh,
1343 gpgme_data_encoding_t enc);
1344
1345 /* Get the file name associated with the data object with handle DH, or
1346 NULL if there is none. */
1347 char *gpgme_data_get_file_name (gpgme_data_t dh);
1348
1349 /* Set the file name associated with the data object with handle DH to
1350 FILE_NAME. */
1351 gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
1352 const char *file_name);
1353
1354 /* Set a flag for the data object DH. See the manual for details. */
1355 gpg_error_t gpgme_data_set_flag (gpgme_data_t dh,
1356 const char *name, const char *value);
1357
1358 /* Try to identify the type of the data in DH. */
1359 gpgme_data_type_t gpgme_data_identify (gpgme_data_t dh, int reserved);
1360
1361
1362 /* Create a new data buffer which retrieves the data from the callback
1363 function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
1364 instead. */
1365 gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
1366 int (*read_cb) (void*,char *,
1367 size_t,size_t*),
1368 void *read_cb_value)
1369 _GPGME_DEPRECATED(0,4);
1370
1371 /* Create a new data buffer filled with the content of file FNAME.
1372 COPY must be non-zero. For delayed read, please use
1373 gpgme_data_new_from_fd or gpgme_data_new_from_stream instead. */
1374 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
1375 const char *fname,
1376 int copy);
1377
1378 /* Create a new data buffer filled with LENGTH bytes starting from
1379 OFFSET within the file FNAME or stream FP (exactly one must be
1380 non-zero). */
1381 gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh,
1382 const char *fname, FILE *fp,
1383 @API__OFF_T@ offset, size_t length);
1384
1385 /* Reset the read pointer in DH. Deprecated, please use
1386 gpgme_data_seek instead. */
1387 gpgme_error_t gpgme_data_rewind (gpgme_data_t dh) _GPGME_DEPRECATED(0,4);
1388
1389
1390
1391 /*
1392 * Key and trust functions.
1393 */
1394
1395 /* Get the key with the fingerprint FPR from the crypto backend. If
1396 SECRET is true, get the secret key. */
1397 gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr,
1398 gpgme_key_t *r_key, int secret);
1399
1400 /* Create a dummy key to specify an email address. */
1401 gpgme_error_t gpgme_key_from_uid (gpgme_key_t *key, const char *name);
1402
1403 /* Acquire a reference to KEY. */
1404 void gpgme_key_ref (gpgme_key_t key);
1405
1406 /* Release a reference to KEY. If this was the last one the key is
1407 destroyed. */
1408 void gpgme_key_unref (gpgme_key_t key);
1409 void gpgme_key_release (gpgme_key_t key);
1410
1411 /* Return the value of the attribute WHAT of KEY, which has to be
1412 representable by a string. IDX specifies the sub key or user ID
1413 for attributes related to sub keys or user IDs. Deprecated, use
1414 key structure directly instead. */
1415 const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
1416 const void *reserved, int idx)
1417 _GPGME_DEPRECATED(0,4);
1418
1419 /* Return the value of the attribute WHAT of KEY, which has to be
1420 representable by an unsigned integer. IDX specifies the sub key or
1421 user ID for attributes related to sub keys or user IDs.
1422 Deprecated, use key structure directly instead. */
1423 unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
1424 const void *reserved, int idx)
1425 _GPGME_DEPRECATED(0,4);
1426
1427 /* Return the value of the attribute WHAT of a signature on user ID
1428 UID_IDX in KEY, which has to be representable by a string. IDX
1429 specifies the signature. Deprecated, use key structure directly
1430 instead. */
1431 const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
1432 _gpgme_attr_t what,
1433 const void *reserved, int idx)
1434 _GPGME_DEPRECATED(0,4);
1435
1436 /* Return the value of the attribute WHAT of a signature on user ID
1437 UID_IDX in KEY, which has to be representable by an unsigned
1438 integer string. IDX specifies the signature. Deprecated, use key
1439 structure directly instead. */
1440 unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
1441 _gpgme_attr_t what,
1442 const void *reserved, int idx)
1443 _GPGME_DEPRECATED(0,4);
1444
1445
1446
1447 /*
1448 * Encryption.
1449 */
1450
1451 struct _gpgme_op_encrypt_result
1452 {
1453 /* The list of invalid recipients. */
1454 gpgme_invalid_key_t invalid_recipients;
1455 };
1456 typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t;
1457
1458 /* Retrieve a pointer to the result of the encrypt operation. */
1459 gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx);
1460
1461 /* The valid encryption flags. */
1462 typedef enum
1463 {
1464 GPGME_ENCRYPT_ALWAYS_TRUST = 1,
1465 GPGME_ENCRYPT_NO_ENCRYPT_TO = 2,
1466 GPGME_ENCRYPT_PREPARE = 4,
1467 GPGME_ENCRYPT_EXPECT_SIGN = 8,
1468 GPGME_ENCRYPT_NO_COMPRESS = 16,
1469 GPGME_ENCRYPT_SYMMETRIC = 32
1470 }
1471 gpgme_encrypt_flags_t;
1472
1473 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1474 store the resulting ciphertext in CIPHER. */
1475 gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[],
1476 gpgme_encrypt_flags_t flags,
1477 gpgme_data_t plain, gpgme_data_t cipher);
1478 gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[],
1479 gpgme_encrypt_flags_t flags,
1480 gpgme_data_t plain, gpgme_data_t cipher);
1481
1482 /* Encrypt plaintext PLAIN within CTX for the recipients RECP and
1483 store the resulting ciphertext in CIPHER. Also sign the ciphertext
1484 with the signers in CTX. */
1485 gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx,
1486 gpgme_key_t recp[],
1487 gpgme_encrypt_flags_t flags,
1488 gpgme_data_t plain,
1489 gpgme_data_t cipher);
1490 gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
1491 gpgme_encrypt_flags_t flags,
1492 gpgme_data_t plain, gpgme_data_t cipher);
1493
1494
1495 /*
1496 * Decryption.
1497 */
1498
1499 struct _gpgme_recipient
1500 {
1501 struct _gpgme_recipient *next;
1502
1503 /* The key ID of key for which the text was encrypted. */
1504 char *keyid;
1505
1506 /* Internal to GPGME, do not use. */
1507 char _keyid[16 + 1];
1508
1509 /* The public key algorithm of the recipient key. */
1510 gpgme_pubkey_algo_t pubkey_algo;
1511
1512 /* The status of the recipient. */
1513 gpgme_error_t status;
1514 };
1515 typedef struct _gpgme_recipient *gpgme_recipient_t;
1516
1517 struct _gpgme_op_decrypt_result
1518 {
1519 char *unsupported_algorithm;
1520
1521 /* Key should not have been used for encryption. */
1522 unsigned int wrong_key_usage : 1;
1523
1524 /* Internal to GPGME, do not use. */
1525 int _unused : 31;
1526
1527 gpgme_recipient_t recipients;
1528
1529 /* The original file name of the plaintext message, if
1530 available. */
1531 char *file_name;
1532
1533 /* A textual representation of the session key used to decrypt the
1534 * message, if available */
1535 char *session_key;
1536 };
1537 typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
1538
1539 /* Retrieve a pointer to the result of the decrypt operation. */
1540 gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx);
1541
1542 /* Decrypt ciphertext CIPHER within CTX and store the resulting
1543 plaintext in PLAIN. */
1544 gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
1545 gpgme_data_t plain);
1546 gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx,
1547 gpgme_data_t cipher, gpgme_data_t plain);
1548
1549 /* Decrypt ciphertext CIPHER and make a signature verification within
1550 CTX and store the resulting plaintext in PLAIN. */
1551 gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx,
1552 gpgme_data_t cipher,
1553 gpgme_data_t plain);
1554 gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
1555 gpgme_data_t plain);
1556
1557
1558 /*
1559 * Signing.
1560 */
1561
1562 struct _gpgme_new_signature
1563 {
1564 struct _gpgme_new_signature *next;
1565
1566 /* The type of the signature. */
1567 gpgme_sig_mode_t type;
1568
1569 /* The public key algorithm used to create the signature. */
1570 gpgme_pubkey_algo_t pubkey_algo;
1571
1572 /* The hash algorithm used to create the signature. */
1573 gpgme_hash_algo_t hash_algo;
1574
1575 /* Internal to GPGME, do not use. Must be set to the same value as
1576 CLASS below. */
1577 unsigned long _obsolete_class;
1578
1579 /* Signature creation time. */
1580 long int timestamp;
1581
1582 /* The fingerprint of the signature. */
1583 char *fpr;
1584
1585 #ifdef __cplusplus
1586 unsigned int _obsolete_class_2;
1587 #else
1588 /* Must be set to SIG_CLASS below. */
1589 unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4);
1590 #endif
1591
1592 /* Crypto backend specific signature class. */
1593 unsigned int sig_class;
1594 };
1595 typedef struct _gpgme_new_signature *gpgme_new_signature_t;
1596
1597 struct _gpgme_op_sign_result
1598 {
1599 /* The list of invalid signers. */
1600 gpgme_invalid_key_t invalid_signers;
1601 gpgme_new_signature_t signatures;
1602 };
1603 typedef struct _gpgme_op_sign_result *gpgme_sign_result_t;
1604
1605 /* Retrieve a pointer to the result of the signing operation. */
1606 gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx);
1607
1608 /* Sign the plaintext PLAIN and store the signature in SIG. */
1609 gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx,
1610 gpgme_data_t plain, gpgme_data_t sig,
1611 gpgme_sig_mode_t mode);
1612 gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx,
1613 gpgme_data_t plain, gpgme_data_t sig,
1614 gpgme_sig_mode_t mode);
1615
1616
1617 /*
1618 * Verify.
1619 */
1620
1621 /* Flags used for the SUMMARY field in a gpgme_signature_t. */
1622 typedef enum
1623 {
1624 GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */
1625 GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
1626 GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
1627 GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
1628 GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
1629 GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
1630 GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
1631 GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
1632 GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
1633 GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
1634 GPGME_SIGSUM_SYS_ERROR = 0x0800, /* A system error occurred. */
1635 GPGME_SIGSUM_TOFU_CONFLICT=0x1000 /* Tofu conflict detected. */
1636 }
1637 gpgme_sigsum_t;
1638
1639
1640 struct _gpgme_signature
1641 {
1642 struct _gpgme_signature *next;
1643
1644 /* A summary of the signature status. */
1645 gpgme_sigsum_t summary;
1646
1647 /* The fingerprint of the signature. This can be a subkey. */
1648 char *fpr;
1649
1650 /* The status of the signature. */
1651 gpgme_error_t status;
1652
1653 /* Notation data and policy URLs. */
1654 gpgme_sig_notation_t notations;
1655
1656 /* Signature creation time. */
1657 unsigned long timestamp;
1658
1659 /* Signature expiration time or 0. */
1660 unsigned long exp_timestamp;
1661
1662 /* Key should not have been used for signing. */
1663 unsigned int wrong_key_usage : 1;
1664
1665 /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */
1666 unsigned int pka_trust : 2;
1667
1668 /* Validity has been verified using the chain model. */
1669 unsigned int chain_model : 1;
1670
1671 /* Internal to GPGME, do not use. */
1672 int _unused : 28;
1673
1674 gpgme_validity_t validity;
1675 gpgme_error_t validity_reason;
1676
1677 /* The public key algorithm used to create the signature. */
1678 gpgme_pubkey_algo_t pubkey_algo;
1679
1680 /* The hash algorithm used to create the signature. */
1681 gpgme_hash_algo_t hash_algo;
1682
1683 /* The mailbox from the PKA information or NULL. */
1684 char *pka_address;
1685
1686 /* If non-NULL, a possible incomplete key object with the data
1687 * available for the signature. */
1688 gpgme_key_t key;
1689 };
1690 typedef struct _gpgme_signature *gpgme_signature_t;
1691
1692 struct _gpgme_op_verify_result
1693 {
1694 gpgme_signature_t signatures;
1695
1696 /* The original file name of the plaintext message, if
1697 available. */
1698 char *file_name;
1699 };
1700 typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;
1701
1702 /* Retrieve a pointer to the result of the verify operation. */
1703 gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx);
1704
1705 /* Verify within CTX that SIG is a valid signature for TEXT. */
1706 gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
1707 gpgme_data_t signed_text,
1708 gpgme_data_t plaintext);
1709 gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig,
1710 gpgme_data_t signed_text,
1711 gpgme_data_t plaintext);
1712
1713
1714 /*
1715 * Import/Export
1716 */
1717
1718 #define GPGME_IMPORT_NEW 1 /* The key was new. */
1719 #define GPGME_IMPORT_UID 2 /* The key contained new user IDs. */
1720 #define GPGME_IMPORT_SIG 4 /* The key contained new signatures. */
1721 #define GPGME_IMPORT_SUBKEY 8 /* The key contained new sub keys. */
1722 #define GPGME_IMPORT_SECRET 16 /* The key contained a secret key. */
1723
1724
1725 struct _gpgme_import_status
1726 {
1727 struct _gpgme_import_status *next;
1728
1729 /* Fingerprint. */
1730 char *fpr;
1731
1732 /* If a problem occurred, the reason why the key could not be
1733 imported. Otherwise GPGME_No_Error. */
1734 gpgme_error_t result;
1735
1736 /* The result of the import, the GPGME_IMPORT_* values bit-wise
1737 ORed. 0 means the key was already known and no new components
1738 have been added. */
1739 unsigned int status;
1740 };
1741 typedef struct _gpgme_import_status *gpgme_import_status_t;
1742
1743 /* Import result object. */
1744 struct _gpgme_op_import_result
1745 {
1746 /* Number of considered keys. */
1747 int considered;
1748
1749 /* Keys without user ID. */
1750 int no_user_id;
1751
1752 /* Imported keys. */
1753 int imported;
1754
1755 /* Imported RSA keys. */
1756 int imported_rsa;
1757
1758 /* Unchanged keys. */
1759 int unchanged;
1760
1761 /* Number of new user ids. */
1762 int new_user_ids;
1763
1764 /* Number of new sub keys. */
1765 int new_sub_keys;
1766
1767 /* Number of new signatures. */
1768 int new_signatures;
1769
1770 /* Number of new revocations. */
1771 int new_revocations;
1772
1773 /* Number of secret keys read. */
1774 int secret_read;
1775
1776 /* Number of secret keys imported. */
1777 int secret_imported;
1778
1779 /* Number of secret keys unchanged. */
1780 int secret_unchanged;
1781
1782 /* Number of new keys skipped. */
1783 int skipped_new_keys;
1784
1785 /* Number of keys not imported. */
1786 int not_imported;
1787
1788 /* List of keys for which an import was attempted. */
1789 gpgme_import_status_t imports;
1790 };
1791 typedef struct _gpgme_op_import_result *gpgme_import_result_t;
1792
1793 /* Retrieve a pointer to the result of the import operation. */
1794 gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx);
1795
1796 /* Import the key in KEYDATA into the keyring. */
1797 gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata);
1798 gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata);
1799 gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
1800 int *nr) _GPGME_DEPRECATED(0,4);
1801
1802 /* Import the keys from the array KEYS into the keyring. */
1803 gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1804 gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t keys[]);
1805
1806
1807 /* Export the keys found by PATTERN into KEYDATA. */
1808 gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
1809 gpgme_export_mode_t mode,
1810 gpgme_data_t keydata);
1811 gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
1812 gpgme_export_mode_t mode,
1813 gpgme_data_t keydata);
1814
1815 gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx,
1816 const char *pattern[],
1817 gpgme_export_mode_t mode,
1818 gpgme_data_t keydata);
1819 gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
1820 gpgme_export_mode_t mode,
1821 gpgme_data_t keydata);
1822
1823 /* Export the keys from the array KEYS into KEYDATA. */
1824 gpgme_error_t gpgme_op_export_keys_start (gpgme_ctx_t ctx,
1825 gpgme_key_t keys[],
1826 gpgme_export_mode_t mode,
1827 gpgme_data_t keydata);
1828 gpgme_error_t gpgme_op_export_keys (gpgme_ctx_t ctx,
1829 gpgme_key_t keys[],
1830 gpgme_export_mode_t mode,
1831 gpgme_data_t keydata);
1832
1833
1834
1835 /*
1836 * Key generation.
1837 */
1838
1839 /* Flags for the key creation functions. */
1840 #define GPGME_CREATE_SIGN (1 << 0) /* Allow usage: signing. */
1841 #define GPGME_CREATE_ENCR (1 << 1) /* Allow usage: encryption. */
1842 #define GPGME_CREATE_CERT (1 << 2) /* Allow usage: certification. */
1843 #define GPGME_CREATE_AUTH (1 << 3) /* Allow usage: authentication. */
1844 #define GPGME_CREATE_NOPASSWD (1 << 7) /* Create w/o passphrase. */
1845 #define GPGME_CREATE_SELFSIGNED (1 << 8) /* Create self-signed cert. */
1846 #define GPGME_CREATE_NOSTORE (1 << 9) /* Do not store the key. */
1847 #define GPGME_CREATE_WANTPUB (1 << 10) /* Return the public key. */
1848 #define GPGME_CREATE_WANTSEC (1 << 11) /* Return the secret key. */
1849 #define GPGME_CREATE_FORCE (1 << 12) /* Force creation. */
1850
1851 struct _gpgme_op_genkey_result
1852 {
1853 /* A primary key was generated. */
1854 unsigned int primary : 1;
1855
1856 /* A sub key was generated. */
1857 unsigned int sub : 1;
1858
1859 /* A user id was generated. */
1860 unsigned int uid : 1;
1861
1862 /* Internal to GPGME, do not use. */
1863 unsigned int _unused : 29;
1864
1865 /* The fingerprint of the generated key. */
1866 char *fpr;
1867
1868 /* A memory data object with the created public key. Only set when
1869 * GPGME_CREATE_WANTPUB has been used. */
1870 gpgme_data_t pubkey;
1871
1872 /* A memory data object with the created secret key. Only set when
1873 * GPGME_CREATE_WANTSEC has been used. */
1874 gpgme_data_t seckey;
1875 };
1876 typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t;
1877
1878 /* Generate a new keypair and add it to the keyring. PUBKEY and
1879 SECKEY should be null for now. PARMS specifies what keys should be
1880 generated. */
1881 gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
1882 gpgme_data_t pubkey, gpgme_data_t seckey);
1883 gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms,
1884 gpgme_data_t pubkey, gpgme_data_t seckey);
1885
1886 /* Generate a key pair using the modern interface. */
1887 gpgme_error_t gpgme_op_createkey_start (gpgme_ctx_t ctx,
1888 const char *userid,
1889 const char *algo,
1890 unsigned long reserved,
1891 unsigned long expires,
1892 gpgme_key_t certkey,
1893 unsigned int flags);
1894 gpgme_error_t gpgme_op_createkey (gpgme_ctx_t ctx,
1895 const char *userid,
1896 const char *algo,
1897 unsigned long reserved,
1898 unsigned long expires,
1899 gpgme_key_t certkey,
1900 unsigned int flags);
1901 /* Add a new subkey to KEY. */
1902 gpgme_error_t gpgme_op_createsubkey_start (gpgme_ctx_t ctx,
1903 gpgme_key_t key,
1904 const char *algo,
1905 unsigned long reserved,
1906 unsigned long expires,
1907 unsigned int flags);
1908 gpgme_error_t gpgme_op_createsubkey (gpgme_ctx_t ctx,
1909 gpgme_key_t key,
1910 const char *algo,
1911 unsigned long reserved,
1912 unsigned long expires,
1913 unsigned int flags);
1914
1915 /* Add USERID to an existing KEY. */
1916 gpgme_error_t gpgme_op_adduid_start (gpgme_ctx_t ctx,
1917 gpgme_key_t key, const char *userid,
1918 unsigned int reserved);
1919 gpgme_error_t gpgme_op_adduid (gpgme_ctx_t ctx,
1920 gpgme_key_t key, const char *userid,
1921 unsigned int reserved);
1922
1923 /* Revoke a USERID from a KEY. */
1924 gpgme_error_t gpgme_op_revuid_start (gpgme_ctx_t ctx,
1925 gpgme_key_t key, const char *userid,
1926 unsigned int reserved);
1927 gpgme_error_t gpgme_op_revuid (gpgme_ctx_t ctx,
1928 gpgme_key_t key, const char *userid,
1929 unsigned int reserved);
1930
1931
1932
1933 /* Retrieve a pointer to the result of a genkey, createkey, or
1934 * createsubkey operation. */
1935 gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx);
1936
1937
1938 /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
1939 keys are also deleted. */
1940 gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
1941 int allow_secret);
1942 gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key,
1943 int allow_secret);
1944
1945
1946 /*
1947 * Key signing interface
1948 */
1949
1950 /* Flags for the key signing functions. */
1951 #define GPGME_KEYSIGN_LOCAL (1 << 7) /* Create a local signature. */
1952 #define GPGME_KEYSIGN_LFSEP (1 << 8) /* Indicate LF separated user ids. */
1953 #define GPGME_KEYSIGN_NOEXPIRE (1 << 9) /* Force no expiration. */
1954
1955
1956 /* Sign the USERID of KEY using the current set of signers. */
1957 gpgme_error_t gpgme_op_keysign_start (gpgme_ctx_t ctx,
1958 gpgme_key_t key, const char *userid,
1959 unsigned long expires,
1960 unsigned int flags);
1961 gpgme_error_t gpgme_op_keysign (gpgme_ctx_t ctx,
1962 gpgme_key_t key, const char *userid,
1963 unsigned long expires,
1964 unsigned int flags);
1965
1966
1967
1968
1969 /*
1970 * Key edit interface
1971 */
1972
1973 /* Flags to select the mode of the interact. */
1974 #define GPGME_INTERACT_CARD (1 << 0) /* Use --card-edit mode. */
1975
1976
1977 /* Edit the KEY. Send status and command requests to FNC and
1978 output of edit commands to OUT. */
1979 gpgme_error_t gpgme_op_interact_start (gpgme_ctx_t ctx,
1980 gpgme_key_t key,
1981 unsigned int flags,
1982 gpgme_interact_cb_t fnc,
1983 void *fnc_value,
1984 gpgme_data_t out);
1985 gpgme_error_t gpgme_op_interact (gpgme_ctx_t ctx, gpgme_key_t key,
1986 unsigned int flags,
1987 gpgme_interact_cb_t fnc,
1988 void *fnc_value,
1989 gpgme_data_t out);
19902479
19912480 gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
19922481 gpgme_edit_cb_t fnc, void *fnc_value,
20032492 gpgme_data_t out)
20042493 _GPGME_DEPRECATED(1,7);
20052494
2006
2007 /* Set the Tofu policy of KEY to POLCIY. */
2008 gpgme_error_t gpgme_op_tofu_policy_start (gpgme_ctx_t ctx,
2009 gpgme_key_t key,
2010 gpgme_tofu_policy_t policy);
2011 gpgme_error_t gpgme_op_tofu_policy (gpgme_ctx_t ctx,
2012 gpgme_key_t key,
2013 gpgme_tofu_policy_t policy);
2014
2015
2016
2017
2018 /*
2019 * Key listing
2020 */
2021
2022 struct _gpgme_op_keylist_result
2023 {
2024 unsigned int truncated : 1;
2025
2026 /* Internal to GPGME, do not use. */
2027 unsigned int _unused : 31;
2028 };
2029 typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
2030
2031 /* Retrieve a pointer to the result of the key listing operation. */
2032 gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx);
2033
2034 /* Start a keylist operation within CTX, searching for keys which
2035 match PATTERN. If SECRET_ONLY is true, only secret keys are
2036 returned. */
2037 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern,
2038 int secret_only);
2039 gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx,
2040 const char *pattern[],
2041 int secret_only, int reserved);
2042
2043 /* Return the next key from the keylist in R_KEY. */
2044 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key);
2045
2046 /* Terminate a pending keylist operation within CTX. */
2047 gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx);
2048
2049 /* Change the passphrase for KEY. FLAGS is reserved for future use
2050 and must be passed as 0. */
2051 gpgme_error_t gpgme_op_passwd_start (gpgme_ctx_t ctx, gpgme_key_t key,
2052 unsigned int flags);
2053 gpgme_error_t gpgme_op_passwd (gpgme_ctx_t ctx, gpgme_key_t key,
2054 unsigned int flags);
2055
2056
2057
2058 /*
2059 * Trust items and operations.
2060 */
2061
2062 struct _gpgme_trust_item
2063 {
2064 /* Internal to GPGME, do not use. */
2065 unsigned int _refs;
2066
2067 /* The key ID to which the trust item belongs. */
2068 char *keyid;
2069
2070 /* Internal to GPGME, do not use. */
2071 char _keyid[16 + 1];
2072
2073 /* The type of the trust item, 1 refers to a key, 2 to a user ID. */
2074 int type;
2075
2076 /* The trust level. */
2077 int level;
2078
2079 /* The owner trust if TYPE is 1. */
2080 char *owner_trust;
2081
2082 /* Internal to GPGME, do not use. */
2083 char _owner_trust[2];
2084
2085 /* The calculated validity. */
2086 char *validity;
2087
2088 /* Internal to GPGME, do not use. */
2089 char _validity[2];
2090
2091 /* The user name if TYPE is 2. */
2092 char *name;
2093 };
2094 typedef struct _gpgme_trust_item *gpgme_trust_item_t;
2095
2096 /* Start a trustlist operation within CTX, searching for trust items
2097 which match PATTERN. */
2098 gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx,
2099 const char *pattern, int max_level);
2100
2101 /* Return the next trust item from the trustlist in R_ITEM. */
2102 gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx,
2103 gpgme_trust_item_t *r_item);
2104
2105 /* Terminate a pending trustlist operation within CTX. */
2106 gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx);
2107
2108 /* Acquire a reference to ITEM. */
2109 void gpgme_trust_item_ref (gpgme_trust_item_t item);
2110
2111 /* Release a reference to ITEM. If this was the last one the trust
2112 item is destroyed. */
2113 void gpgme_trust_item_unref (gpgme_trust_item_t item);
2495 /* The possible signature stati. Deprecated, use error value in sig
2496 status. */
2497 typedef enum
2498 {
2499 GPGME_SIG_STAT_NONE = 0,
2500 GPGME_SIG_STAT_GOOD = 1,
2501 GPGME_SIG_STAT_BAD = 2,
2502 GPGME_SIG_STAT_NOKEY = 3,
2503 GPGME_SIG_STAT_NOSIG = 4,
2504 GPGME_SIG_STAT_ERROR = 5,
2505 GPGME_SIG_STAT_DIFF = 6,
2506 GPGME_SIG_STAT_GOOD_EXP = 7,
2507 GPGME_SIG_STAT_GOOD_EXPKEY = 8
2508 }
2509 _gpgme_sig_stat_t;
2510 typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED(0,4);
2511
2512 /* The available key and signature attributes. Deprecated, use the
2513 individual result structures instead. */
2514 typedef enum
2515 {
2516 GPGME_ATTR_KEYID = 1,
2517 GPGME_ATTR_FPR = 2,
2518 GPGME_ATTR_ALGO = 3,
2519 GPGME_ATTR_LEN = 4,
2520 GPGME_ATTR_CREATED = 5,
2521 GPGME_ATTR_EXPIRE = 6,
2522 GPGME_ATTR_OTRUST = 7,
2523 GPGME_ATTR_USERID = 8,
2524 GPGME_ATTR_NAME = 9,
2525 GPGME_ATTR_EMAIL = 10,
2526 GPGME_ATTR_COMMENT = 11,
2527 GPGME_ATTR_VALIDITY = 12,
2528 GPGME_ATTR_LEVEL = 13,
2529 GPGME_ATTR_TYPE = 14,
2530 GPGME_ATTR_IS_SECRET = 15,
2531 GPGME_ATTR_KEY_REVOKED = 16,
2532 GPGME_ATTR_KEY_INVALID = 17,
2533 GPGME_ATTR_UID_REVOKED = 18,
2534 GPGME_ATTR_UID_INVALID = 19,
2535 GPGME_ATTR_KEY_CAPS = 20,
2536 GPGME_ATTR_CAN_ENCRYPT = 21,
2537 GPGME_ATTR_CAN_SIGN = 22,
2538 GPGME_ATTR_CAN_CERTIFY = 23,
2539 GPGME_ATTR_KEY_EXPIRED = 24,
2540 GPGME_ATTR_KEY_DISABLED = 25,
2541 GPGME_ATTR_SERIAL = 26,
2542 GPGME_ATTR_ISSUER = 27,
2543 GPGME_ATTR_CHAINID = 28,
2544 GPGME_ATTR_SIG_STATUS = 29,
2545 GPGME_ATTR_ERRTOK = 30,
2546 GPGME_ATTR_SIG_SUMMARY = 31,
2547 GPGME_ATTR_SIG_CLASS = 32
2548 }
2549 _gpgme_attr_t;
2550 typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED(0,4);
2551
2552 /* Retrieve the signature status of signature IDX in CTX after a
2553 successful verify operation in R_STAT (if non-null). The creation
2554 time stamp of the signature is returned in R_CREATED (if non-null).
2555 The function returns a string containing the fingerprint.
2556 Deprecated, use verify result directly. */
2557 const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
2558 _gpgme_sig_stat_t *r_stat,
2559 time_t *r_created) _GPGME_DEPRECATED(0,4);
2560
2561 /* Retrieve certain attributes of a signature. IDX is the index
2562 number of the signature after a successful verify operation. WHAT
2563 is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
2564 one. WHATIDX is to be passed as 0 for most attributes . */
2565 unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx,
2566 _gpgme_attr_t what, int whatidx)
2567 _GPGME_DEPRECATED(0,4);
2568 const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx,
2569 _gpgme_attr_t what, int whatidx)
2570 _GPGME_DEPRECATED(0,4);
2571
2572
2573 /* Get the key used to create signature IDX in CTX and return it in
2574 R_KEY. */
2575 gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
2576 _GPGME_DEPRECATED(0,4);
2577
2578 /* Create a new data buffer which retrieves the data from the callback
2579 function READ_CB. Deprecated, please use gpgme_data_new_from_cbs
2580 instead. */
2581 gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh,
2582 int (*read_cb) (void*,char *,
2583 size_t,size_t*),
2584 void *read_cb_value)
2585 _GPGME_DEPRECATED(0,4);
2586
2587 /* Return the value of the attribute WHAT of KEY, which has to be
2588 representable by a string. IDX specifies the sub key or user ID
2589 for attributes related to sub keys or user IDs. Deprecated, use
2590 key structure directly instead. */
2591 const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what,
2592 const void *reserved, int idx)
2593 _GPGME_DEPRECATED(0,4);
2594
2595 /* Return the value of the attribute WHAT of KEY, which has to be
2596 representable by an unsigned integer. IDX specifies the sub key or
2597 user ID for attributes related to sub keys or user IDs.
2598 Deprecated, use key structure directly instead. */
2599 unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what,
2600 const void *reserved, int idx)
2601 _GPGME_DEPRECATED(0,4);
2602
2603 /* Return the value of the attribute WHAT of a signature on user ID
2604 UID_IDX in KEY, which has to be representable by a string. IDX
2605 specifies the signature. Deprecated, use key structure directly
2606 instead. */
2607 const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx,
2608 _gpgme_attr_t what,
2609 const void *reserved, int idx)
2610 _GPGME_DEPRECATED(0,4);
2611
2612 /* Return the value of the attribute WHAT of a signature on user ID
2613 UID_IDX in KEY, which has to be representable by an unsigned
2614 integer string. IDX specifies the signature. Deprecated, use key
2615 structure directly instead. */
2616 unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx,
2617 _gpgme_attr_t what,
2618 const void *reserved, int idx)
2619 _GPGME_DEPRECATED(0,4);
2620
2621
2622 gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata,
2623 int *nr) _GPGME_DEPRECATED(0,4);
21142624
21152625 /* Release the trust item ITEM. Deprecated, use
21162626 gpgme_trust_item_unref. */
21322642 const void *reserved, int idx)
21332643 _GPGME_DEPRECATED(0,4);
21342644
2135
2136
2137 /*
2138 * Audit log
2139 */
2140
2141 /* Return the auditlog for the current session. This may be called
2142 after a successful or failed operation. If no audit log is
2143 available GPG_ERR_NO_DATA is returned. */
2144 gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output,
2145 unsigned int flags);
2146 gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output,
2147 unsigned int flags);
2148
2149
2150
2151 /*
2152 * Spawn interface
2153 */
2154
2155 /* Flags for the spawn operations. */
2156 #define GPGME_SPAWN_DETACHED 1
2157 #define GPGME_SPAWN_ALLOW_SET_FG 2
2158
2159
2160 /* Run the command FILE with the arguments in ARGV. Connect stdin to
2161 DATAIN, stdout to DATAOUT, and STDERR to DATAERR. If one the data
2162 streams is NULL, connect to /dev/null instead. */
2163 gpgme_error_t gpgme_op_spawn_start (gpgme_ctx_t ctx,
2164 const char *file, const char *argv[],
2165 gpgme_data_t datain,
2166 gpgme_data_t dataout, gpgme_data_t dataerr,
2167 unsigned int flags);
2168 gpgme_error_t gpgme_op_spawn (gpgme_ctx_t ctx,
2169 const char *file, const char *argv[],
2170 gpgme_data_t datain,
2171 gpgme_data_t dataout, gpgme_data_t dataerr,
2172 unsigned int flags);
2173
2174
2175 /*
2176 * Low-level Assuan protocol access.
2177 */
2178 typedef gpgme_error_t (*gpgme_assuan_data_cb_t)
2179 (void *opaque, const void *data, size_t datalen);
2180
2181 typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t)
2182 (void *opaque, const char *name, const char *args,
2183 gpgme_data_t *r_data);
2184
2185 typedef gpgme_error_t (*gpgme_assuan_status_cb_t)
2186 (void *opaque, const char *status, const char *args);
2187
2188 /* Send the Assuan COMMAND and return results via the callbacks.
2189 Asynchronous variant. */
2190 gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx,
2191 const char *command,
2192 gpgme_assuan_data_cb_t data_cb,
2193 void *data_cb_value,
2194 gpgme_assuan_inquire_cb_t inq_cb,
2195 void *inq_cb_value,
2196 gpgme_assuan_status_cb_t stat_cb,
2197 void *stat_cb_value);
2198
2199 /* Send the Assuan COMMAND and return results via the callbacks.
2200 Synchronous variant. */
2201 gpgme_error_t gpgme_op_assuan_transact_ext (gpgme_ctx_t ctx,
2202 const char *command,
2203 gpgme_assuan_data_cb_t data_cb,
2204 void *data_cb_value,
2205 gpgme_assuan_inquire_cb_t inq_cb,
2206 void *inq_cb_value,
2207 gpgme_assuan_status_cb_t stat_cb,
2208 void *stat_cb_value,
2209 gpgme_error_t *op_err);
2210
2211 /* Compat. */
2645 /* Compat.
2646 * This structure shall be considered read-only and an application
2647 * must not allocate such a structure on its own. */
22122648 struct _gpgme_op_assuan_result
22132649 {
22142650 /* Deprecated. Use the second value in a DONE event or the
22322668 gpgme_assuan_status_cb_t status_cb,
22332669 void *status_cb_value) _GPGME_DEPRECATED(1,2);
22342670
2235
2236 /*
2237 * Crypto container support.
2238 */
2239
2240 struct _gpgme_op_vfs_mount_result
2241 {
2242 char *mount_dir;
2243 };
2244 typedef struct _gpgme_op_vfs_mount_result *gpgme_vfs_mount_result_t;
2245
2246 gpgme_vfs_mount_result_t gpgme_op_vfs_mount_result (gpgme_ctx_t ctx);
2247
2248 /* The container is automatically unmounted when the context is reset
2249 or destroyed. Transmission errors are returned directly,
2250 operational errors are returned in OP_ERR. */
2251 gpgme_error_t gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file,
2252 const char *mount_dir, unsigned int flags,
2253 gpgme_error_t *op_err);
2254
2255 gpgme_error_t gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[],
2256 const char *container_file,
2257 unsigned int flags, gpgme_error_t *op_err);
2258
2259
2260 /*
2261 * Interface to gpgconf(1).
2262 */
2263
2264 /* The expert level at which a configuration option or group of
2265 options should be displayed. See the gpgconf(1) documentation for
2266 more details. */
2267 typedef enum
2268 {
2269 GPGME_CONF_BASIC = 0,
2270 GPGME_CONF_ADVANCED = 1,
2271 GPGME_CONF_EXPERT = 2,
2272 GPGME_CONF_INVISIBLE = 3,
2273 GPGME_CONF_INTERNAL = 4
2274 }
2275 gpgme_conf_level_t;
2276
2277
2278 /* The data type of a configuration option argument. See the gpgconf(1)
2279 documentation for more details. */
2280 typedef enum
2281 {
2282 /* Basic types. */
2283 GPGME_CONF_NONE = 0,
2284 GPGME_CONF_STRING = 1,
2285 GPGME_CONF_INT32 = 2,
2286 GPGME_CONF_UINT32 = 3,
2287
2288 /* Complex types. */
2289 GPGME_CONF_FILENAME = 32,
2290 GPGME_CONF_LDAP_SERVER = 33,
2291 GPGME_CONF_KEY_FPR = 34,
2292 GPGME_CONF_PUB_KEY = 35,
2293 GPGME_CONF_SEC_KEY = 36,
2294 GPGME_CONF_ALIAS_LIST = 37
2295 }
2296 gpgme_conf_type_t;
2297
2298 /* For now, compatibility. */
2299 #define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
2300
2301
2302 /* This represents a single argument for a configuration option.
2303 Which of the members of value is used depends on the ALT_TYPE. */
2304 typedef struct gpgme_conf_arg
2305 {
2306 struct gpgme_conf_arg *next;
2307 /* True if the option appears without an (optional) argument. */
2308 unsigned int no_arg;
2309 union
2310 {
2311 unsigned int count;
2312 unsigned int uint32;
2313 int int32;
2314 char *string;
2315 } value;
2316 } *gpgme_conf_arg_t;
2317
2318
2319 /* The flags of a configuration option. See the gpgconf
2320 documentation for details. */
2321 #define GPGME_CONF_GROUP (1 << 0)
2322 #define GPGME_CONF_OPTIONAL (1 << 1)
2323 #define GPGME_CONF_LIST (1 << 2)
2324 #define GPGME_CONF_RUNTIME (1 << 3)
2325 #define GPGME_CONF_DEFAULT (1 << 4)
2326 #define GPGME_CONF_DEFAULT_DESC (1 << 5)
2327 #define GPGME_CONF_NO_ARG_DESC (1 << 6)
2328 #define GPGME_CONF_NO_CHANGE (1 << 7)
2329
2330
2331 /* The representation of a single configuration option. See the
2332 gpg-conf documentation for details. */
2333 typedef struct gpgme_conf_opt
2334 {
2335 struct gpgme_conf_opt *next;
2336
2337 /* The option name. */
2338 char *name;
2339
2340 /* The flags for this option. */
2341 unsigned int flags;
2342
2343 /* The level of this option. */
2344 gpgme_conf_level_t level;
2345
2346 /* The localized description of this option. */
2347 char *description;
2348
2349 /* The type and alternate type of this option. */
2350 gpgme_conf_type_t type;
2351 gpgme_conf_type_t alt_type;
2352
2353 /* The localized (short) name of the argument, if any. */
2354 char *argname;
2355
2356 /* The default value. */
2357 gpgme_conf_arg_t default_value;
2358 char *default_description;
2359
2360 /* The default value if the option is not set. */
2361 gpgme_conf_arg_t no_arg_value;
2362 char *no_arg_description;
2363
2364 /* The current value if the option is set. */
2365 gpgme_conf_arg_t value;
2366
2367 /* The new value, if any. NULL means reset to default. */
2368 int change_value;
2369 gpgme_conf_arg_t new_value;
2370
2371 /* Free for application use. */
2372 void *user_data;
2373 } *gpgme_conf_opt_t;
2374
2375
2376 /* The representation of a component that can be configured. See the
2377 gpg-conf documentation for details. */
2378 typedef struct gpgme_conf_comp
2379 {
2380 struct gpgme_conf_comp *next;
2381
2382 /* Internal to GPGME, do not use! */
2383 gpgme_conf_opt_t *_last_opt_p;
2384
2385 /* The component name. */
2386 char *name;
2387
2388 /* A human-readable description for the component. */
2389 char *description;
2390
2391 /* The program name (an absolute path to the program). */
2392 char *program_name;
2393
2394 /* A linked list of options for this component. */
2395 struct gpgme_conf_opt *options;
2396 } *gpgme_conf_comp_t;
2397
2398
2399 /* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg
2400 default" is prepared. If type is a string type, VALUE should point
2401 to the string. Else, it should point to an unsigned or signed
2402 integer respectively. */
2403 gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
2404 gpgme_conf_type_t type, const void *value);
2405
2406 /* This also releases all chained argument structures! */
2407 void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
2408
2409 /* Register a change for the value of OPT to ARG. If RESET is 1 (do
2410 not use any values but 0 or 1), ARG is ignored and the option is
2411 not changed (reverting a previous change). Otherwise, if ARG is
2412 NULL, the option is cleared or reset to its default. */
2413 gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
2414 gpgme_conf_arg_t arg);
2415
2416 /* Release a set of configurations. */
2417 void gpgme_conf_release (gpgme_conf_comp_t conf);
2418
2419 /* Retrieve the current configurations. */
2420 gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p);
2421
2422 /* Save the configuration of component comp. This function does not
2423 follow chained components! */
2424 gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
2425
2426
2427 /* Information about software versions. */
2428 typedef struct _gpgme_op_query_swdb_result
2429 {
2430 /* RFU */
2431 struct _gpgme_op_query_swdb_result *next;
2432
2433 /* The name of the package (e.g. "gpgme", "gnupg") */
2434 char *name;
2435
2436 /* The version number of the installed version. */
2437 char *iversion;
2438
2439 /* The time the online info was created. */
2440 unsigned long created;
2441
2442 /* The time the online info was retrieved. */
2443 unsigned long retrieved;
2444
2445 /* This bit is set if an error occured or some of the information
2446 * in this structure may not be set. */
2447 unsigned int warning : 1;
2448
2449 /* An update is available. */
2450 unsigned int update : 1;
2451
2452 /* The update is important. */
2453 unsigned int urgent : 1;
2454
2455 /* No information at all available. */
2456 unsigned int noinfo : 1;
2457
2458 /* The package name is not known. */
2459 unsigned int unknown : 1;
2460
2461 /* The information here is too old. */
2462 unsigned int tooold : 1;
2463
2464 /* Other error. */
2465 unsigned int error : 1;
2466
2467 unsigned int _reserved : 25;
2468
2469 /* The version number of the latest released version. */
2470 char *version;
2471
2472 /* The release date of that version. */
2473 unsigned long reldate;
2474
2475 } *gpgme_query_swdb_result_t;
2476
2477
2478 /* Run the gpgconf --query-swdb command. */
2479 gpgme_error_t gpgme_op_query_swdb (gpgme_ctx_t ctx,
2480 const char *name, const char *iversion,
2481 unsigned int reserved);
2482
2483 /* Return the result from the last query_swdb operation. */
2484 gpgme_query_swdb_result_t gpgme_op_query_swdb_result (gpgme_ctx_t ctx);
2485
2486
2487
2488
2489 /*
2490 * Various functions.
2491 */
2492
2493 /* Set special global flags; consult the manual before use. */
2494 int gpgme_set_global_flag (const char *name, const char *value);
2495
2496 /* Check that the library fulfills the version requirement. Note:
2497 This is here only for the case where a user takes a pointer from
2498 the old version of this function. The new version and macro for
2499 run-time checks are below. */
2500 const char *gpgme_check_version (const char *req_version);
2501
2502 /* Check that the library fulfills the version requirement and check
2503 for struct layout mismatch involving bitfields. */
2504 const char *gpgme_check_version_internal (const char *req_version,
2505 size_t offset_sig_validity);
2506
2507 #define gpgme_check_version(req_version) \
2508 gpgme_check_version_internal (req_version, \
2509 offsetof (struct _gpgme_signature, validity))
2510
2511 /* Return the default values for various directories. */
2512 const char *gpgme_get_dirinfo (const char *what);
2513
2514 /* Get the information about the configured and installed engines. A
2515 pointer to the first engine in the statically allocated linked list
2516 is returned in *INFO. If an error occurs, it is returned. The
2517 returned data is valid until the next gpgme_set_engine_info. */
2518 gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
2519
2520 /* Set the default engine info for the protocol PROTO to the file name
2521 FILE_NAME and the home directory HOME_DIR. */
2522 gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto,
2523 const char *file_name,
2524 const char *home_dir);
2525
2526 /* Verify that the engine implementing PROTO is installed and
2527 available. */
2528 gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto);
2529
2530
2531 /* Reference counting for result objects. */
2532 void gpgme_result_ref (void *result);
2533 void gpgme_result_unref (void *result);
2534
2535 /* Return a public key algorithm string (e.g. "rsa2048"). Caller must
2536 free using gpgme_free. */
2537 char *gpgme_pubkey_algo_string (gpgme_subkey_t subkey);
2538
2539 /* Return a statically allocated string with the name of the public
2540 key algorithm ALGO, or NULL if that name is not known. */
2541 const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
2542
2543 /* Return a statically allocated string with the name of the hash
2544 algorithm ALGO, or NULL if that name is not known. */
2545 const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
2546
2547 /* Return the addr-spec from a user id. Caller must free the result
2548 * with gpgme_free. */
2549 char *gpgme_addrspec_from_uid (const char *uid);
2550
2551
2552
2553 /*
2554 * Deprecated types.
2555 */
2671
2672
25562673 typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED(0,4);
25572674 typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED(0,4);
25582675 typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED(0,4);
192192
193193 #define PARSE_NEXT(x) \
194194 (x) = strtol (args, &tail, 0); \
195 if (errno || args == tail || *tail != ' ') \
195 if (errno || args == tail || !(*tail == ' ' || !*tail)) \
196196 /* The crypto backend does not behave. */ \
197197 return trace_gpg_error (GPG_ERR_INV_ENGINE); \
198198 args = tail;
248248 default:
249249 break;
250250 }
251 return 0;
251 return err;
252252 }
253253
254254
235235 &uid->comment, dst);
236236
237237 uid->address = _gpgme_mailbox_from_userid (uid->uid);
238 if (uid->address && uid->email && !strcmp (uid->address, uid->email))
239 {
240 /* The ADDRESS is the same as EMAIL: Save some space. */
241 free (uid->address);
242 uid->address = uid->email;
238 if ((!uid->email || !*uid->email) && uid->address && uid->name
239 && !strcmp (uid->name, uid->address))
240 {
241 /* Name and address are the same. This is a mailbox only key.
242 Use address as email and remove name. */
243 *uid->name = '\0';
244 uid->email = uid->address;
243245 }
244246
245247 if (!key->uids)
338340 while (subkey)
339341 {
340342 gpgme_subkey_t next = subkey->next;
341 if (subkey->fpr)
342 free (subkey->fpr);
343 if (subkey->curve)
344 free (subkey->curve);
345 if (subkey->keygrip)
346 free (subkey->keygrip);
347 if (subkey->card_number)
348 free (subkey->card_number);
343 free (subkey->fpr);
344 free (subkey->curve);
345 free (subkey->keygrip);
346 free (subkey->card_number);
349347 free (subkey);
350348 subkey = next;
351349 }
385383 tofu = tofu_next;
386384 }
387385
388 if (uid->address && uid->address != uid->email)
389 free (uid->address);
390
386 free (uid->address);
391387 free (uid);
392388 uid = next_uid;
393389 }
394390
395 if (key->issuer_serial)
396 free (key->issuer_serial);
397 if (key->issuer_name)
398 free (key->issuer_name);
399
400 if (key->chain_id)
401 free (key->chain_id);
402 if (key->fpr)
403 free (key->fpr);
391 free (key->issuer_serial);
392 free (key->issuer_name);
393 free (key->chain_id);
394 free (key->fpr);
404395
405396 free (key);
406397 }
415415 }
416416
417417
418 /* Parse the compliance field. */
419 static void
420 parse_pub_field18 (gpgme_subkey_t subkey, char *field)
421 {
422 char *p, *endp;
423 unsigned long ul;
424
425 for (p = field; p && (ul = strtoul (p, &endp, 10)) && p != endp; p = endp)
426 {
427 switch (ul)
428 {
429 case 23: subkey->is_de_vs = 1; break;
430 }
431 }
432 }
433
434
418435 /* Parse a tfs record. */
419436 static gpg_error_t
420437 parse_tfs_record (gpgme_user_id_t uid, char **field, int nfield)
534551 RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK
535552 }
536553 rectype = RT_NONE;
537 #define NR_FIELDS 17
554 #define NR_FIELDS 20
538555 char *field[NR_FIELDS];
539556 int fields = 0;
540557 void *hook;
711728 return gpg_error_from_syserror ();
712729 }
713730
731 /* Field 18 has the compliance flags. */
732 if (fields >= 17 && *field[17])
733 parse_pub_field18 (subkey, field[17]);
734
735 if (fields >= 20)
736 {
737 key->last_update = _gpgme_parse_timestamp_ul (field[18]);
738 key->origin = 0; /* Fixme: Not yet defined in gpg. */
739 }
740
714741 break;
715742
716743 case RT_SUB:
784811 return gpg_error_from_syserror ();
785812 }
786813
814 /* Field 18 has the compliance flags. */
815 if (fields >= 17 && *field[17])
816 parse_pub_field18 (subkey, field[17]);
817
787818 break;
788819
789820 case RT_UID:
792823 {
793824 if (_gpgme_key_append_name (key, field[9], 1))
794825 return gpg_error (GPG_ERR_ENOMEM); /* FIXME */
795 else
796 {
797 if (field[1])
798 set_userid_flags (key, field[1]);
799 opd->tmp_uid = key->_last_uid;
800 }
826
827 if (field[1])
828 set_userid_flags (key, field[1]);
829 opd->tmp_uid = key->_last_uid;
830 if (fields >= 20)
831 {
832 opd->tmp_uid->last_update = _gpgme_parse_timestamp_ul (field[18]);
833 opd->tmp_uid->origin = 0; /* Fixme: Not yet defined in gpg. */
834 }
801835 }
802836 break;
803837
11161150 }
11171151
11181152
1153 /* Start a keylist operation within CTX to show keys contained
1154 * in DATA. */
1155 gpgme_error_t
1156 gpgme_op_keylist_from_data_start (gpgme_ctx_t ctx, gpgme_data_t data,
1157 int reserved)
1158 {
1159 gpgme_error_t err;
1160 void *hook;
1161 op_data_t opd;
1162
1163 TRACE_BEG (DEBUG_CTX, "gpgme_op_keylist_from_data_start", ctx);
1164
1165 if (!ctx || !data || reserved)
1166 return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
1167
1168 err = _gpgme_op_reset (ctx, 2);
1169 if (err)
1170 return TRACE_ERR (err);
1171
1172 err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook,
1173 sizeof (*opd), release_op_data);
1174 opd = hook;
1175 if (err)
1176 return TRACE_ERR (err);
1177
1178 _gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx);
1179 err = _gpgme_engine_set_colon_line_handler (ctx->engine,
1180 keylist_colon_handler, ctx);
1181 if (err)
1182 return TRACE_ERR (err);
1183
1184 err = _gpgme_engine_op_keylist_data (ctx->engine, data);
1185 return TRACE_ERR (err);
1186 }
1187
1188
11191189 /* Return the next key from the keylist in R_KEY. */
11201190 gpgme_error_t
11211191 gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key)
125125
126126 gpgme_op_query_swdb;
127127 gpgme_op_query_swdb_result;
128
129 gpgme_op_set_uid_flag_start;
130 gpgme_op_set_uid_flag;
131
132 gpgme_op_decrypt_ext;
133 gpgme_op_decrypt_ext_start;
128134 };
129135
130136
222228 gpgme_op_import_start;
223229 gpgme_op_keylist_end;
224230 gpgme_op_keylist_ext_start;
231 gpgme_op_keylist_from_data_start;
225232 gpgme_op_keylist_next;
226233 gpgme_op_keylist_result;
227234 gpgme_op_keylist_start;
9393 _gpgme_release_result (ctx);
9494 LOCK (ctx->lock);
9595 ctx->canceled = 0;
96 ctx->redraw_suggested = 0;
9697 UNLOCK (ctx->lock);
9798
9899 if (ctx->engine && no_reset)
8888 gpgme_error_t _gpgme_decrypt_status_handler (void *priv,
8989 gpgme_status_code_t code,
9090 char *args);
91 gpgme_error_t _gpgme_decrypt_start (gpgme_ctx_t ctx, int synchronous,
92 gpgme_decrypt_flags_t flags,
93 gpgme_data_t cipher, gpgme_data_t plain);
9194
9295
9396 /* From signers.c. */
286286 int rc;
287287
288288 /* Under Linux we can figure out the highest used file descriptor by
289 * reading /proc/self/fd. This is in the common cases much fast than
290 * for example doing 4096 close calls where almost all of them will
291 * fail. */
292 #ifdef __linux__
293 {
294 DIR *dir = NULL;
295 struct dirent *dir_entry;
296 const char *s;
297 int x;
298
299 dir = opendir ("/proc/self/fd");
300 if (dir)
301 {
302 while ((dir_entry = readdir (dir)))
303 {
304 s = dir_entry->d_name;
305 if ( *s < '0' || *s > '9')
306 continue;
307 x = atoi (s);
308 if (x > fds)
309 fds = x;
310 }
311 closedir (dir);
312 }
313 if (fds != -1)
314 {
315 fds++;
316 source = "/proc";
317 }
318 }
319 #endif /* __linux__ */
289 * reading /proc/self/fd. This is in the common cases much faster
290 * than for example doing 4096 close calls where almost all of them
291 * will fail.
292 *
293 * Unfortunately we can't call opendir between fork and exec in a
294 * multi-threaded process because opendir uses malloc and thus a
295 * mutex which may deadlock with a malloc in another thread. Thus
296 * the code is not used until we can have a opendir variant which
297 * does not use malloc. */
298 /* #ifdef __linux__ */
299 /* { */
300 /* DIR *dir = NULL; */
301 /* struct dirent *dir_entry; */
302 /* const char *s; */
303 /* int x; */
304
305 /* dir = opendir ("/proc/self/fd"); */
306 /* if (dir) */
307 /* { */
308 /* while ((dir_entry = readdir (dir))) */
309 /* { */
310 /* s = dir_entry->d_name; */
311 /* if ( *s < '0' || *s > '9') */
312 /* continue; */
313 /* x = atoi (s); */
314 /* if (x > fds) */
315 /* fds = x; */
316 /* } */
317 /* closedir (dir); */
318 /* } */
319 /* if (fds != -1) */
320 /* { */
321 /* fds++; */
322 /* source = "/proc"; */
323 /* } */
324 /* } */
325 /* #endif /\* __linux__ *\/ */
320326
321327 #ifdef RLIMIT_NOFILE
322328 if (fds == -1)
452458 /* Intermediate child to prevent zombie processes. */
453459 if ((pid = fork ()) == 0)
454460 {
455 int max_fds = get_max_fds ();
456 int fd;
457
458461 /* Child. */
462 int max_fds = -1;
463 int fd;
459464 int seen_stdin = 0;
460465 int seen_stdout = 0;
461466 int seen_stderr = 0;
463468 if (atfork)
464469 atfork (atforkvalue, 0);
465470
466 /* First close all fds which will not be inherited. */
467 for (fd = 0; fd < max_fds; fd++)
468 {
469 for (i = 0; fd_list[i].fd != -1; i++)
470 if (fd_list[i].fd == fd)
471 break;
472 if (fd_list[i].fd == -1)
473 close (fd);
474 }
471 /* First close all fds which will not be inherited. If we
472 * have closefrom(2) we first figure out the highest fd we
473 * do not want to close, then call closefrom, and on success
474 * use the regular code to close all fds up to the start
475 * point of closefrom. Note that Solaris' closefrom does
476 * not return errors. */
477 #ifdef HAVE_CLOSEFROM
478 {
479 fd = -1;
480 for (i = 0; fd_list[i].fd != -1; i++)
481 if (fd_list[i].fd > fd)
482 fd = fd_list[i].fd;
483 fd++;
484 #ifdef __sun
485 closefrom (fd);
486 max_fds = fd;
487 #else /*!__sun */
488 while ((i = closefrom (fd)) && errno == EINTR)
489 ;
490 if (!i || errno == EBADF)
491 max_fds = fd;
492 #endif /*!__sun*/
493 }
494 #endif /*HAVE_CLOSEFROM*/
495 if (max_fds == -1)
496 max_fds = get_max_fds ();
497 for (fd = 0; fd < max_fds; fd++)
498 {
499 for (i = 0; fd_list[i].fd != -1; i++)
500 if (fd_list[i].fd == fd)
501 break;
502 if (fd_list[i].fd == -1)
503 close (fd);
504 }
475505
476506 /* And now dup and close those to be duplicated. */
477507 for (i = 0; fd_list[i].fd != -1; i++)
3030 #include "debug.h"
3131
3232
33 /* The status handler for progress status lines which also monitors
34 * the PINENTRY_LAUNCHED status. */
3335 gpgme_error_t
3436 _gpgme_progress_status_handler (void *priv, gpgme_status_code_t code,
3537 char *args)
4042 int type = 0;
4143 int current = 0;
4244 int total = 0;
45
46 if (code == GPGME_STATUS_PINENTRY_LAUNCHED)
47 {
48 ctx->redraw_suggested = 1;
49 return 0;
50 }
4351
4452 if (code != GPGME_STATUS_PROGRESS || !*args || !ctx->progress_cb)
4553 return 0;
9494 #define stpcpy(a,b) _gpgme_stpcpy ((a), (b))
9595 #endif /*!HAVE_STPCPY*/
9696
97 #if !HAVE_VASPRINTF
98 #include <stdarg.h>
99 int vasprintf (char **result, const char *format, va_list args);
100 int asprintf (char **result, const char *format, ...);
101 #endif
97
98 /* Due to a bug in mingw32's snprintf related to the 'l' modifier and
99 for increased portability we use our snprintf on all systems. */
100 #undef snprintf
101 #define snprintf gpgrt_snprintf
102
102103
103104 #if REPLACE_TTYNAME_R
104105 int _gpgme_ttyname_r (int fd, char *buf, size_t buflen);
163164 point to the next non-parsed character in TIMESTRING. */
164165 time_t _gpgme_parse_timestamp (const char *timestamp, char **endp);
165166
167 /* Variant of _gpgme_parse_timestamp to return an unsigned long or 0
168 * on error or missing timestamp. */
169 unsigned long _gpgme_parse_timestamp_ul (const char *timestamp);
166170
167171 gpgme_error_t _gpgme_map_gnupg_error (char *err);
168172
+0
-206
src/vasprintf.c less more
0 /* Like vsprintf but provides a pointer to malloc'd storage, which must
1 be freed by the caller.
2 Copyright (C) 1994, 2002 Free Software Foundation, Inc.
3
4 This file is part of the libiberty library.
5 Libiberty is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 Libiberty is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with libiberty; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <stdio.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27
28
29 #ifndef va_copy /* According to POSIX, va_copy is a macro. */
30 #if defined (__GNUC__) && defined (__PPC__) \
31 && (defined (_CALL_SYSV) || defined (_WIN32))
32 #define va_copy(d, s) (*(d) = *(s))
33 #elif defined (MUST_COPY_VA_BYVAL)
34 #define va_copy(d, s) ((d) = (s))
35 #else
36 #define va_copy(d, s) memcpy ((d), (s), sizeof (va_list))
37 #endif
38 #endif
39
40
41 #ifdef TEST
42 int global_total_width;
43 #endif
44
45 static int int_vasprintf (char **, const char *, va_list *);
46
47 static int
48 int_vasprintf (result, format, args)
49 char **result;
50 const char *format;
51 va_list *args;
52 {
53 #ifdef HAVE_W32CE_SYSTEM
54 /* No va_copy and the replacement above doesn't work. */
55 #define MAX_STRLEN 256
56 *result = malloc (MAX_STRLEN);
57 if (*result != NULL)
58 {
59 int res = _vsnprintf (*result, MAX_STRLEN, format, *args);
60 (*result)[MAX_STRLEN - 1] = '\0';
61 return res;
62 }
63 else
64 return 0;
65 #else
66 const char *p = format;
67 /* Add one to make sure that it is never zero, which might cause malloc
68 to return NULL. */
69 int total_width = strlen (format) + 1;
70 va_list ap;
71
72 va_copy (ap, *args);
73
74 while (*p != '\0')
75 {
76 if (*p++ == '%')
77 {
78 while (strchr ("-+ #0", *p))
79 ++p;
80 if (*p == '*')
81 {
82 ++p;
83 total_width += abs (va_arg (ap, int));
84 }
85 else
86 total_width += strtoul (p, (char **) &p, 10);
87 if (*p == '.')
88 {
89 ++p;
90 if (*p == '*')
91 {
92 ++p;
93 total_width += abs (va_arg (ap, int));
94 }
95 else
96 total_width += strtoul (p, (char **) &p, 10);
97 }
98 while (strchr ("hlL", *p))
99 ++p;
100 /* Should be big enough for any format specifier except %s and floats. */
101 total_width += 30;
102 switch (*p)
103 {
104 case 'd':
105 case 'i':
106 case 'o':
107 case 'u':
108 case 'x':
109 case 'X':
110 case 'c':
111 (void) va_arg (ap, int);
112 break;
113 case 'f':
114 case 'e':
115 case 'E':
116 case 'g':
117 case 'G':
118 (void) va_arg (ap, double);
119 /* Since an ieee double can have an exponent of 307, we'll
120 make the buffer wide enough to cover the gross case. */
121 total_width += 307;
122 break;
123 case 's':
124 {
125 char *tmp = va_arg (ap, char *);
126 if (tmp)
127 total_width += strlen (tmp);
128 else /* in case the vsprintf does prints a text */
129 total_width += 25; /* e.g. "(null pointer reference)" */
130 }
131 break;
132 case 'p':
133 case 'n':
134 (void) va_arg (ap, char *);
135 break;
136 }
137 p++;
138 }
139 }
140 #ifdef TEST
141 global_total_width = total_width;
142 #endif
143 *result = malloc (total_width);
144 if (*result != NULL)
145 return vsprintf (*result, format, *args);
146 else
147 return 0;
148 #endif
149 }
150
151 int
152 vasprintf (result, format, args)
153 char **result;
154 const char *format;
155 #if defined (_BSD_VA_LIST_) && defined (__FreeBSD__)
156 _BSD_VA_LIST_ args;
157 #else
158 va_list args;
159 #endif
160 {
161 return int_vasprintf (result, format, &args);
162 }
163
164
165 int
166 asprintf (char **buf, const char *fmt, ...)
167 {
168 int status;
169 va_list ap;
170
171 va_start (ap, fmt);
172 status = vasprintf (buf, fmt, ap);
173 va_end (ap);
174 return status;
175 }
176
177
178 #ifdef TEST
179 void
180 checkit (const char* format, ...)
181 {
182 va_list args;
183 char *result;
184
185 va_start (args, format);
186 vasprintf (&result, format, args);
187 if (strlen (result) < global_total_width)
188 printf ("PASS: ");
189 else
190 printf ("FAIL: ");
191 printf ("%d %s\n", global_total_width, result);
192 }
193
194 int
195 main (void)
196 {
197 checkit ("%d", 0x12345678);
198 checkit ("%200d", 5);
199 checkit ("%.300d", 6);
200 checkit ("%100.150d", 7);
201 checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
202 777777777777777777333333333333366666666666622222222222777777777777733333");
203 checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx");
204 }
205 #endif /* TEST */
4545 int did_prepare_new_sig;
4646 int only_newsig_seen;
4747 int plaintext_seen;
48 int conflict_user_seen;
4849 } *op_data_t;
4950
5051
679680 goto leave;
680681 }
681682
683 if (sig->key && sig->key->fpr && strcmp (sig->key->fpr, fpr))
684 {
685 /* GnuPG since 2.1.17 emits multiple TOFU_USER lines with
686 different fingerprints in case of conflicts for a signature. */
687 err = gpg_error (GPG_ERR_DUP_VALUE);
688 goto leave;
689 }
690
682691 args = tail;
683692 tail = strchr (args, ' ');
684693 if (tail == args)
705714 else if (!sig->key->fpr)
706715 {
707716 err = trace_gpg_error (GPG_ERR_INTERNAL);
708 goto leave;
709 }
710 else if (strcmp (sig->key->fpr, fpr))
711 {
712 /* The engine did not emit NEWSIG before a new key. */
713 err = trace_gpg_error (GPG_ERR_INV_ENGINE);
714717 goto leave;
715718 }
716719
929932 calc_sig_summary (sig);
930933 err = prepare_new_sig (opd);
931934 opd->only_newsig_seen = 1;
935 opd->conflict_user_seen = 0;
932936 return err;
933937
934938 case GPGME_STATUS_GOODSIG:
994998
995999 case GPGME_STATUS_TOFU_USER:
9961000 opd->only_newsig_seen = 0;
997 return sig ? parse_tofu_user (sig, args, ctx->protocol)
998 /* */ : trace_gpg_error (GPG_ERR_INV_ENGINE);
1001 if (!sig)
1002 return trace_gpg_error (GPG_ERR_INV_ENGINE);
1003 err = parse_tofu_user (sig, args, ctx->protocol);
1004 /* gpg emits TOFU User lines for each conflicting key.
1005 * GPGME does not expose this to have a clean API and
1006 * a GPGME user can do a keylisting with the address
1007 * normalisation.
1008 * So when a duplicated TOFU_USER line is encountered
1009 * we ignore the conflicting tofu stats emited afterwards.
1010 */
1011 if (gpg_err_code (err) == GPG_ERR_DUP_VALUE)
1012 {
1013 opd->conflict_user_seen = 1;
1014 break;
1015 }
1016 opd->conflict_user_seen = 0;
1017 return trace_gpg_error (err);
9991018
10001019 case GPGME_STATUS_TOFU_STATS:
10011020 opd->only_newsig_seen = 0;
1021 if (opd->conflict_user_seen)
1022 break;
10021023 return sig ? parse_tofu_stats (sig, args)
10031024 /* */ : trace_gpg_error (GPG_ERR_INV_ENGINE);
10041025
10051026 case GPGME_STATUS_TOFU_STATS_LONG:
10061027 opd->only_newsig_seen = 0;
1028 if (opd->conflict_user_seen)
1029 break;
10071030 return sig ? parse_tofu_stats_long (sig, args, ctx->raw_description)
10081031 /* */ : trace_gpg_error (GPG_ERR_INV_ENGINE);
10091032
3838 VALUE "FileDescription", "GPGME - GnuPG Made Easy\0"
3939 VALUE "FileVersion", "@LIBGPGME_LT_CURRENT@.@LIBGPGME_LT_AGE@.@LIBGPGME_LT_REVISION@.@BUILD_REVISION@\0"
4040 VALUE "InternalName", "gpgme\0"
41 VALUE "LegalCopyright", "Copyright © 2001-2016 g10 Code GmbH\0"
41 VALUE "LegalCopyright", "Copyright © 2001-2017 g10 Code GmbH\0"
4242 VALUE "LegalTrademarks", "\0"
4343 VALUE "OriginalFilename", "gpgme.dll\0"
4444 VALUE "PrivateBuild", "\0"
137137 return gpg_error (GPG_ERR_UNUSABLE_PUBKEY);
138138 }
139139
140 if (asprintf (&cmd, "RECIPIENT %s", recp[i]->subkeys->fpr) < 0)
140 if (gpgrt_asprintf (&cmd, "RECIPIENT %s", recp[i]->subkeys->fpr) < 0)
141141 {
142142 err = gpg_error_from_syserror ();
143143 free (container_file_esc);
146146
147147 err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL,
148148 NULL, NULL, op_err);
149 free (cmd);
149 gpgrt_free (cmd);
150150 if (err || *op_err)
151151 {
152152 free (container_file_esc);
155155 recp++;
156156 }
157157
158 if (asprintf (&cmd, "CREATE -- %s", container_file_esc) < 0)
158 if (gpgrt_asprintf (&cmd, "CREATE -- %s", container_file_esc) < 0)
159159 {
160160 err = gpg_error_from_syserror ();
161161 free (container_file_esc);
165165
166166 err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL,
167167 NULL, NULL, op_err);
168 free (cmd);
168 gpgrt_free (cmd);
169169
170170 return err;
171171 }
183183 if (err)
184184 return err;
185185
186 if (asprintf (&cmd, "OPEN -- %s", container_file_esc) < 0)
186 if (gpgrt_asprintf (&cmd, "OPEN -- %s", container_file_esc) < 0)
187187 {
188188 err = gpg_error_from_syserror ();
189189 free (container_file_esc);
193193
194194 err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL,
195195 NULL, NULL, op_err);
196 free (cmd);
196 gpgrt_free (cmd);
197197 if (err || *op_err)
198198 return err;
199199
205205 if (err)
206206 return err;
207207
208 if (asprintf (&cmd, "MOUNT -- %s", mount_dir_esc) < 0)
208 if (gpgrt_asprintf (&cmd, "MOUNT -- %s", mount_dir_esc) < 0)
209209 {
210210 err = gpg_error_from_syserror ();
211211 free (mount_dir_esc);
215215 }
216216 else
217217 {
218 if (asprintf (&cmd, "MOUNT") < 0)
218 if (gpgrt_asprintf (&cmd, "MOUNT") < 0)
219219 return gpg_error_from_syserror ();
220220 }
221221
222222 err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL,
223223 _gpgme_vfs_mount_status_handler, ctx, op_err);
224 free (cmd);
224 gpgrt_free (cmd);
225225
226226 return err;
227227 }
699699 for (;;)
700700 {
701701 LOCK (ctx->mutex);
702 if (ctx->stop_me)
702 if (ctx->stop_me && !ctx->nbytes)
703703 {
704704 UNLOCK (ctx->mutex);
705705 break;
716716 TRACE_LOG ("got data to send");
717717 LOCK (ctx->mutex);
718718 }
719 if (ctx->stop_me)
719 if (ctx->stop_me && !ctx->nbytes)
720720 {
721721 UNLOCK (ctx->mutex);
722722 break;
775775 TRACE_LOG ("waiting for close");
776776 WaitForSingleObject (ctx->close_ev, INFINITE);
777777
778 if (ctx->nbytes)
779 TRACE_LOG1 ("still %d bytes in buffer at close time", ctx->nbytes);
780
778781 CloseHandle (ctx->close_ev);
779782 CloseHandle (ctx->have_data);
780783 CloseHandle (ctx->is_empty);
890893 if (ctx->have_data)
891894 SetEvent (ctx->have_data);
892895 UNLOCK (ctx->mutex);
896
897 /* Give the writer a chance to flush the buffer. */
898 WaitForSingleObject (ctx->is_empty, INFINITE);
893899
894900 #ifdef HAVE_W32CE_SYSTEM
895901 /* Scenario: We never create a full pipe, but already started
16361642 "with your installation.\n"
16371643 "Please report the problem to your "
16381644 "distributor of GpgME.\n\n"
1639 "Developers Note: The install dir can be "
1645 "Developer's Note: The install dir can be "
16401646 "manually set with: gpgme_set_global_flag",
16411647 _gpgme_get_inst_dir ());
16421648 MessageBoxA (NULL, msg, "GpgME not installed correctly", MB_OK);
1643 free (msg);
1649 gpgrt_free (msg);
16441650 gpg_err_set_errno (EIO);
16451651 return TRACE_SYSRES (-1);
16461652 }
576576 "Install Directory");
577577 if (tmp)
578578 {
579 if (gpgrt_asprintf (&dir, "%s\\bin", tmp) == -1)
579 dir = _gpgme_strconcat (tmp, "\\bin", NULL);
580 free (tmp);
581 if (!dir)
580582 return NULL;
581 free (tmp);
582583 }
583584 }
584585 if (dir)
4444
4545 CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \
4646 gpg-agent.conf pubring.kbx~ S.gpg-agent gpg.conf pubring.gpg~ \
47 random_seed S.gpg-agent .gpg-v21-migrated pubring-stamp
47 random_seed S.gpg-agent .gpg-v21-migrated pubring-stamp \
48 tofu.db *.conf.gpgconf.bak
4849
4950 private_keys = \
5051 13CD0F3BDF24BE53FE192D62F18737256FF6E4FD \
3333
3434 #include <gpgme.h>
3535
36
37 #define fail_if_err(err) \
38 do \
39 { \
40 if (err) \
41 { \
42 fprintf (stderr, "%s:%d: %s: %s\n", \
43 __FILE__, __LINE__, gpgme_strsource (err), \
44 gpgme_strerror (err)); \
45 exit (1); \
46 } \
47 } \
48 while (0)
49
50
51 void
52 init_gpgme (gpgme_protocol_t proto)
53 {
54 gpgme_error_t err;
55
56 gpgme_check_version (NULL);
57 setlocale (LC_ALL, "");
58 gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
59 #ifndef HAVE_W32_SYSTEM
60 gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
61 #endif
62
63 err = gpgme_engine_check_version (proto);
64 fail_if_err (err);
65 }
66
36 #include "t-support.h"
6737
6838 static char *
6939 spaces (char *str, int extra)
250220
251221
252222 int
223 lookup (gpgme_conf_comp_t conf,
224 const char *component,
225 const char *option,
226 gpgme_conf_comp_t *comp,
227 gpgme_conf_opt_t *opt)
228 {
229 *comp = conf;
230 while (*comp && strcmp ((*comp)->name, component))
231 *comp = (*comp)->next;
232
233 if (*comp)
234 {
235 *opt = (*comp)->options;
236 while (*opt && strcmp ((*opt)->name, option))
237 *opt = (*opt)->next;
238
239 /* Allow for the option not to be there. */
240 if (*opt)
241 return 1; /* Found. */
242 }
243
244 return 0; /* Not found. */
245 }
246
247 #include <assert.h>
248
249
250 int
253251 main (void)
254252 {
255253 gpgme_ctx_t ctx;
257255 gpgme_conf_comp_t conf;
258256 gpgme_conf_comp_t comp;
259257 int first;
260
261 #ifndef ENABLE_GPGCONF
262 return 0;
263 #endif
258 int i, N = 10;
264259
265260 init_gpgme (GPGME_PROTOCOL_GPGCONF);
266261
282277 comp = comp->next;
283278 }
284279
285 #if 1
286280 /* Now change something. */
287 {
288 unsigned int count = 1;
281 fprintf (stderr, " dirmngr.verbose ");
282 for (i = 0; i < N; i++) {
283 unsigned int count = i % 4 + 1; /* counts must not be zero */
289284 gpgme_conf_arg_t arg;
290285 gpgme_conf_opt_t opt;
291286
292287 err = gpgme_conf_arg_new (&arg, GPGME_CONF_NONE, &count);
293288 fail_if_err (err);
294289
295 comp = conf;
296 while (comp && strcmp (comp->name, "dirmngr"))
297 comp = comp->next;
298
299 if (comp)
300 {
301 opt = comp->options;
302 while (opt && strcmp (opt->name, "verbose"))
303 opt = opt->next;
304
305 /* Allow for the verbose option not to be there. */
306 if (opt)
307 {
308 err = gpgme_conf_opt_change (opt, 0, arg);
309 fail_if_err (err);
310
311 err = gpgme_op_conf_save (ctx, comp);
312 fail_if_err (err);
313 }
314 }
290 if (lookup (conf, "dirmngr", "verbose", &comp, &opt))
291 {
292 /* Found. */
293 err = gpgme_conf_opt_change (opt, 0, arg);
294 fail_if_err (err);
295
296 err = gpgme_op_conf_save (ctx, comp);
297 fail_if_err (err);
298 }
299 else
300 {
301 fprintf (stderr, "Skipping test, option dirmngr.verbose not found.\n");
302 break;
303 }
304
305 /* Reload config and verify that the value was updated. */
306 gpgme_conf_release (conf);
307 err = gpgme_op_conf_load (ctx, &conf);
308 fail_if_err (err);
309 if (lookup (conf, "dirmngr", "verbose", &comp, &opt))
310 {
311 /* Found. */
312 test (opt->alt_type == GPGME_CONF_NONE);
313 test (opt->value);
314 test ((unsigned long) opt->value->value.count == count);
315 }
316
317 fprintf (stderr, ".");
318 fflush (stderr);
315319 }
316 #endif
320
321 /* Now change something else. */
322 fprintf (stderr, " gpg.keyserver ");
323 for (i = 0; i < N; i++) {
324 const char *values[2] = { "hkp://foo.bar", "hkps://bar.foo" };
325 gpgme_conf_arg_t arg;
326 gpgme_conf_opt_t opt;
327
328 err = gpgme_conf_arg_new (&arg, GPGME_CONF_STRING, values[i%2]);
329 fail_if_err (err);
330
331 if (lookup (conf, "gpg", "keyserver", &comp, &opt))
332 {
333 /* Found. */
334 test (opt->alt_type == GPGME_CONF_STRING);
335 err = gpgme_conf_opt_change (opt, 0, arg);
336 fail_if_err (err);
337
338 err = gpgme_op_conf_save (ctx, comp);
339 fail_if_err (err);
340 }
341 else
342 {
343 fprintf (stderr, "Skipping test, option gpg.keyserver not found.\n");
344 break;
345 }
346
347 /* Reload config and verify that the value was updated. */
348 gpgme_conf_release (conf);
349 err = gpgme_op_conf_load (ctx, &conf);
350 fail_if_err (err);
351 if (lookup (conf, "gpg", "keyserver", &comp, &opt))
352 {
353 /* Found. */
354 test (opt->alt_type == GPGME_CONF_STRING);
355 test (opt->value);
356 test (opt->value->value.string);
357 test (strcmp (opt->value->value.string, values[i%2]) == 0);
358 }
359
360 fprintf (stderr, ".");
361 fflush (stderr);
362 }
363 fprintf (stderr, "\n");
317364
318365 gpgme_conf_release (conf);
319
366 gpgme_release (ctx);
320367 return 0;
321368 }
4545 } \
4646 } \
4747 while (0)
48
49
50 #ifdef GPGRT_HAVE_MACRO_FUNCTION
51 void GPGRT_ATTR_NORETURN
52 _test (const char *expr, const char *file, int line,
53 const char *func)
54 {
55 fprintf (stderr, "Test \"%s\" in %s failed (%s:%d)\n",
56 expr, func, file, line);
57 exit (1);
58 }
59 # define test(expr) \
60 ((expr) \
61 ? (void) 0 \
62 : _test (#expr, __FILE__, __LINE__, __FUNCTION__))
63 #else /*!GPGRT_HAVE_MACRO_FUNCTION*/
64 void
65 _test (const char *expr, const char *file, int line)
66 {
67 fprintf (stderr, "Test \"%s\" failed (%s:%d)\n",
68 expr, file, line);
69 exit (1);
70 }
71 # define test(expr) \
72 ((expr) \
73 ? (void) 0 \
74 : _test (#expr, __FILE__, __LINE__))
75 #endif /*!GPGRT_HAVE_MACRO_FUNCTION*/
4876
4977
5078 static const char *
3131
3232 #include "t-support.h"
3333
34 #define THREAD_COUNT 100
34 #define THREAD_COUNT 10
3535
3636 static const char test_text1[] = "Just GNU it!\n";
3737 static const char test_sig1[] =
3131
3232 #include "t-support.h"
3333
34 #define THREAD_COUNT 100
34 #define THREAD_COUNT 10
3535
3636 void *
3737 start_keylist (void *arg)
7979 " --cms use the CMS protocol\n"
8080 " --export-session-key show the session key\n"
8181 " --override-session-key STRING use STRING as session key\n"
82 " --unwrap remove only the encryption layer\n"
8283 , stderr);
8384 exit (ex);
8485 }
9192 gpgme_error_t err;
9293 gpgme_ctx_t ctx;
9394 gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
95 gpgme_decrypt_flags_t flags = 0;
9496 FILE *fp_in = NULL;
9597 gpgme_data_t in = NULL;
9698 gpgme_data_t out = NULL;
98100 int print_status = 0;
99101 int export_session_key = 0;
100102 const char *override_session_key = NULL;
103 int raw_output = 0;
101104
102105 if (argc)
103106 { argc--; argv++; }
143146 if (!argc)
144147 show_usage (1);
145148 override_session_key = *argv;
149 argc--; argv++;
150 }
151 else if (!strcmp (*argv, "--unwrap"))
152 {
153 flags |= GPGME_DECRYPT_UNWRAP;
154 raw_output = 1;
146155 argc--; argv++;
147156 }
148157 else if (!strncmp (*argv, "--", 2))
210219 exit (1);
211220 }
212221
213 err = gpgme_op_decrypt (ctx, in, out);
222 err = gpgme_op_decrypt_ext (ctx, flags, in, out);
214223 result = gpgme_op_decrypt_result (ctx);
215224 if (err)
216225 {
219228 }
220229 if (result)
221230 {
222 print_result (result);
231 if (!raw_output)
232 print_result (result);
233 if (!raw_output)
234 fputs ("Begin Output:\n", stdout);
223235 print_data (out);
236 if (!raw_output)
237 fputs ("End Output.\n", stdout);
224238 }
225239
226240 gpgme_data_release (out);
8787 " --uiserver use the UI server\n"
8888 " --loopback use a loopback pinentry\n"
8989 " --key NAME encrypt to key NAME\n"
90 " --throw-keyids use this option\n"
91 " --wrap assume input is valid OpenPGP message\n"
9092 " --symmetric encrypt symmetric (OpenPGP only)\n"
9193 , stderr);
9294 exit (ex);
169171 keyargs[keycount++] = *argv;
170172 argc--; argv++;
171173 }
174 else if (!strcmp (*argv, "--throw-keyids"))
175 {
176 flags |= GPGME_ENCRYPT_THROW_KEYIDS;
177 argc--; argv++;
178 }
179 else if (!strcmp (*argv, "--wrap"))
180 {
181 flags |= GPGME_ENCRYPT_WRAP;
182 argc--; argv++;
183 }
172184 else if (!strcmp (*argv, "--loopback"))
173185 {
174186 use_loopback = 1;
203203 " for addkey: FPR [ALGO [USAGE [EXPIRESECONDS]]]\n"
204204 " for adduid: FPR USERID\n"
205205 " for revuid: FPR USERID\n"
206 " for set-primary: FPR USERID\n"
206207 "Options:\n"
207208 " --addkey add a subkey to the key with FPR\n"
208209 " --adduid add a user id to the key with FPR\n"
209 " --revuid Revoke a user id from the key with FPR\n"
210 " --revuid revoke a user id from the key with FPR\n"
211 " --set-primary set the primary key flag on USERID\n"
210212 " --verbose run in verbose mode\n"
211213 " --status print status lines from the backend\n"
212214 " --progress print progress info\n"
233235 int addkey = 0;
234236 int adduid = 0;
235237 int revuid = 0;
238 int setpri = 0;
236239 const char *userid;
237240 const char *algo = NULL;
238241 const char *newuserid = NULL;
258261 addkey = 1;
259262 adduid = 0;
260263 revuid = 0;
264 setpri = 0;
261265 argc--; argv++;
262266 }
263267 else if (!strcmp (*argv, "--adduid"))
265269 addkey = 0;
266270 adduid = 1;
267271 revuid = 0;
272 setpri = 0;
268273 argc--; argv++;
269274 }
270275 else if (!strcmp (*argv, "--revuid"))
272277 addkey = 0;
273278 adduid = 0;
274279 revuid = 1;
280 setpri = 0;
281 argc--; argv++;
282 }
283 else if (!strcmp (*argv, "--set-primary"))
284 {
285 addkey = 0;
286 adduid = 0;
287 revuid = 0;
288 setpri = 1;
275289 argc--; argv++;
276290 }
277291 else if (!strcmp (*argv, "--verbose"))
318332 show_usage (1);
319333 }
320334
321 if (adduid || revuid)
335 if (adduid || revuid || setpri)
322336 {
323337 if (argc != 2)
324338 show_usage (1);
357371 gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
358372 }
359373
360 if (addkey || adduid || revuid)
374 if (addkey || adduid || revuid || setpri)
361375 {
362376 gpgme_key_t akey;
363377
399413 exit (1);
400414 }
401415 }
416 else if (setpri)
417 {
418 err = gpgme_op_set_uid_flag (ctx, akey, newuserid, "primary", NULL);
419 if (err)
420 {
421 fprintf (stderr, PGM ": gpgme_op_set_uid_flag failed: %s\n",
422 gpg_strerror (err));
423 exit (1);
424 }
425 }
402426 gpgme_key_unref (akey);
403427 }
404428 else
412436 }
413437 }
414438
415 result = gpgme_op_genkey_result (ctx);
416 if (!result)
417 {
418 fprintf (stderr, PGM": gpgme_op_genkey_result returned NULL\n");
419 exit (1);
420 }
421
422 printf ("Generated key: %s (%s)\n",
423 result->fpr ? result->fpr : "none",
424 result->primary ? (result->sub ? "primary, sub" : "primary")
425 /**/ : (result->sub ? "sub" : "none"));
426
427 if (result->fpr && strlen (result->fpr) < 40)
428 fprintf (stderr, PGM": generated key has unexpected fingerprint\n");
429 if (!result->primary)
430 fprintf (stderr, PGM": primary key was not generated\n");
431 if (!result->sub)
432 fprintf (stderr, PGM": sub key was not generated\n");
433 if (!result->uid)
434 fprintf (stderr, PGM": uid was not generated\n");
439 if (!setpri)
440 {
441 result = gpgme_op_genkey_result (ctx);
442 if (!result)
443 {
444 fprintf (stderr, PGM": gpgme_op_genkey_result returned NULL\n");
445 exit (1);
446 }
447
448 printf ("Generated key: %s (%s)\n",
449 result->fpr ? result->fpr : "none",
450 result->primary ? (result->sub ? "primary, sub" : "primary")
451 /**/ : (result->sub ? "sub" : "none"));
452
453 if (result->fpr && strlen (result->fpr) < 40)
454 fprintf (stderr, PGM": generated key has unexpected fingerprint\n");
455 if (!result->primary)
456 fprintf (stderr, PGM": primary key was not generated\n");
457 if (!result->sub)
458 fprintf (stderr, PGM": sub key was not generated\n");
459 if (!result->uid)
460 fprintf (stderr, PGM": uid was not generated\n");
461 }
435462
436463 gpgme_release (ctx);
437464 return 0;
4040 static int
4141 show_usage (int ex)
4242 {
43 fputs ("usage: " PGM " [options] [USERID]\n\n"
43 fputs ("usage: " PGM " [options] [USERID_or_FILE]\n\n"
4444 "Options:\n"
4545 " --verbose run in verbose mode\n"
4646 " --openpgp use the OpenPGP protocol (default)\n"
5555 " --validate use GPGME_KEYLIST_MODE_VALIDATE\n"
5656 " --import import all keys\n"
5757 " --offline use offline mode\n"
58 " --from-file list all keys in the given file\n"
5859 " --require-gnupg required at least the given GnuPG version\n"
5960 , stderr);
6061 exit (ex);
9798 gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
9899 int only_secret = 0;
99100 int offline = 0;
101 int from_file = 0;
102 gpgme_data_t data = NULL;
103
100104
101105 if (argc)
102106 { argc--; argv++; }
176180 offline = 1;
177181 argc--; argv++;
178182 }
183 else if (!strcmp (*argv, "--from-file"))
184 {
185 from_file = 1;
186 argc--; argv++;
187 }
179188 else if (!strcmp (*argv, "--require-gnupg"))
180189 {
181190 argc--; argv++;
190199
191200 if (argc > 1)
192201 show_usage (1);
202 else if (from_file && !argc)
203 show_usage (1);
193204
194205 init_gpgme (protocol);
195206
201212
202213 gpgme_set_offline (ctx, offline);
203214
204 err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, only_secret);
215 if (from_file)
216 {
217 err = gpgme_data_new_from_file (&data, *argv, 1);
218 fail_if_err (err);
219
220 err = gpgme_op_keylist_from_data_start (ctx, data, 0);
221 }
222 else
223 err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, only_secret);
205224 fail_if_err (err);
206225
207226 while (!(err = gpgme_op_keylist_next (ctx, &key)))
222241 key->can_sign? "s":"",
223242 key->can_certify? "c":"",
224243 key->can_authenticate? "a":"");
225 printf ("flags :%s%s%s%s%s%s%s\n",
244 printf ("flags :%s%s%s%s%s%s%s%s\n",
226245 key->secret? " secret":"",
227246 key->revoked? " revoked":"",
228247 key->expired? " expired":"",
229248 key->disabled? " disabled":"",
230249 key->invalid? " invalid":"",
231 key->is_qualified? " qualifid":"",
250 key->is_qualified? " qualified":"",
251 key->subkeys && key->subkeys->is_de_vs? " de-vs":"",
232252 key->subkeys && key->subkeys->is_cardkey? " cardkey":"");
253 printf ("upd : %lu (%u)\n", key->last_update, key->origin);
233254
234255 subkey = key->subkeys;
235256 if (subkey)
247268 subkey->can_sign? "s":"",
248269 subkey->can_certify? "c":"",
249270 subkey->can_authenticate? "a":"");
250 printf ("flags %2d:%s%s%s%s%s%s%s\n",
271 printf ("flags %2d:%s%s%s%s%s%s%s%s\n",
251272 nsub,
252273 subkey->secret? " secret":"",
253274 subkey->revoked? " revoked":"",
254275 subkey->expired? " expired":"",
255276 subkey->disabled? " disabled":"",
256277 subkey->invalid? " invalid":"",
257 subkey->is_qualified? " qualifid":"",
278 subkey->is_qualified? " qualified":"",
279 subkey->is_de_vs? " de-vs":"",
258280 subkey->is_cardkey? " cardkey":"");
259281 }
260282 for (nuids=0, uid=key->uids; uid; uid = uid->next, nuids++)
267289 printf (" name: %s\n", uid->name);
268290 if (uid->comment)
269291 printf (" cmmnt: %s\n", uid->comment);
292 printf (" upd: %lu (%u)\n", uid->last_update, uid->origin);
270293 printf (" valid: %s\n",
271294 uid->validity == GPGME_VALIDITY_UNKNOWN? "unknown":
272295 uid->validity == GPGME_VALIDITY_UNDEFINED? "undefined":
319342 err = gpgme_op_keylist_end (ctx);
320343 fail_if_err (err);
321344 keyarray[keyidx] = NULL;
345 gpgme_data_release (data);
322346
323347 result = gpgme_op_keylist_result (ctx);
324348 if (result->truncated)
102102 int print_status = 0;
103103 int use_loopback = 0;
104104 const char *sender = NULL;
105 const char *s;
105106
106107 if (argc)
107108 { argc--; argv++; }
228229 exit (1);
229230 }
230231
232 if ((s = gpgme_get_ctx_flag (ctx, "redraw")) && *s)
233 fputs ("Screen redraw suggested\n", stdout);
234
231235 fputs ("Begin Output:\n", stdout);
232236 print_data (out);
233237 fputs ("End Output.\n", stdout);
1414
1515 GPG_AGENT_INFO=
1616 export GPG_AGENT_INFO
17 GPG_AGENT=$(which gpg-agent)
1718
1819 token=$(echo "gpgme-$(pwd)" | tr ' ' '_')
1920
2021 if [ "$1" = "--stop" ]; then
21 if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
22 if [ "$(gpg-connect-agent --no-autostart getval\ $token /bye 2>/dev/null | head -1)" \
2223 != "D set" ]; then
2324 echo "gpg-agent not running" >&2
2425 exit 0
2829 exit 0
2930 fi
3031
31 if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
32 if [ "$(gpg-connect-agent --no-autostart getval\ $token /bye 2>/dev/null | head -1)" \
3233 = "D set" ]; then
3334 echo "gpg-agent already running" >&2
3435 exit 0
3536 fi
3637
37 echo "starting gpg-agent " >&2
38 gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1
39 if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
38 echo "starting gpg-agent.." >&2
39
40 # GnuPG prior to 2.1.12 needs --allow-loopback-pinentry for the
41 # loopback entry to work. Old versions do not understand this though,
42 # so we need to be careful.
43 if "$GPG_AGENT" --gpgconf-test --allow-loopback-pinentry &&
44 test -f "$GNUPGHOME/gpg-agent.conf" &&
45 ! grep -q allow-loopback-pinentry "$GNUPGHOME/gpg-agent.conf"; then
46 echo allow-loopback-pinentry >> "$GNUPGHOME/gpg-agent.conf"
47 fi
48
49 gpg-connect-agent --agent-program="${GPG_AGENT}|--debug-quick-random" putval\ $token\ set /bye
50 if [ $? -ne 0 -o "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
4051 != "D set" ]; then
4152 echo "error starting gpg-agent" >&2
4253 exit 1
124124 "gpgconf-name",
125125 "gpg-name",
126126 "gpgsm-name",
127 "g13-name", NULL };
127 "g13-name",
128 "gpg-wks-client-name",
129 NULL };
128130 const char *s;
129131 int i;
130132