Commit Graph

56 Commits

Author SHA1 Message Date
Ben McGinnes
f61d4f585f IDENTIFY
* Fixed sp error in docstring.
2018-03-05 09:40:41 +11:00
Werner Koch
7f5f26fd66
doc: Replace http: by https: in core source files.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-11-16 13:27:00 +01:00
Werner Koch
51f9acbca9
core: Use const char * where appropriate.
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-13 20:59:07 +02:00
Werner Koch
4a200146b6
core: Mark unused function args.
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-13 20:53:49 +02:00
Werner Koch
3972f476e0
core: Do not pass const char* to functions taking a char*.
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-13 20:44:59 +02:00
Ben Kibbey
6a7ee33abd Fix including nil bytes in keylist output.
* src/gpgme-tool.c (cmd_keylist,gt_result): use strlen().

Signed-off-by: Ben Kibbey <bjk@luxsci.net>
2016-07-19 11:14:23 +02:00
Werner Koch
d8d5f5a167
core: New GPGME_DATA_ENCODING_MIME.
* src/gpgme.h.in (GPGME_DATA_ENCODING_MIME): New.
* src/data.c (gpgme_data_set_encoding): Adjust check.
* src/engine-gpg.c (have_gpg_version): New.
(gpg_encrypt, gpg_encrypt_sign): Pass flag '--mimemode'.
(gpg_sign): Ditto.

* lang/cpp/src/data.h (GpgME): Add MimeEncoding.
* lang/cpp/src/data.cpp (encoding, setEncoding): Support MimeEncoding.

* src/gpgme-tool.c (server_data_encoding): Add flag --mime.
--

This feature allows an application to declare that the encrypted or
signed data is a valid MIME part.

What is missing is a way to return that information to the application
after decryption/verification.  This can be done by setting the
encoding of the output data object; however this requires some
internal additions to our processing model.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-13 14:45:02 +02:00
Werner Koch
5905e8bbd8
tests: Add new test tool run-identify.
* src/gpgme-tool.c (gt_identify): Add new strings.
* tests/run-identify.c: New.
* tests/Makefile.am (noinst_PROGRAMS): Add run-identify.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-21 16:18:00 +02:00
Werner Koch
f0ccce855b
gpgme-tool: Switch to argparse.c for option parsing.
* src/argparse.c, src/argparse.h: New. Taken from current gnupg.
* src/Makefile.am (gpgme_tool_SOURCES): New.
* src/gpgme-tool.c: Remove all argp.h stuff.
(my_strusage): New.
(main): Change to use argparse.
--

As a GnuPG related tool the user should get the same experience in
option parsing as with gpg et al.  Thus we use the same parser.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-31 20:34:00 +02:00
Werner Koch
2b632bbb78
Add an export secret key feature.
* src/gpgme.h.in (GPGME_EXPORT_MODE_SECRET): New.
(GPGME_EXPORT_MODE_RAW): New.
(GPGME_EXPORT_MODE_PKCS12): New.
* src/export.c (export_start, export_ext_start): Allow new flags.
* src/engine-gpg.c (export_common): Support secret key export.
* src/engine-gpgsm.c (gpgsm_export, gpgsm_export_ext): Ditto.

* src/gpgme-tool.c (cmd_export): Add options --secret, --raw,
and --pkcs12.
* tests/run-export.c (main): Likewise.
--

Note that exporting secret X.509 keys requires GnuPG 2.1.8.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-24 12:41:24 +02:00
Werner Koch
c23f889710
Add option --lib-version to gpgme-tool.
* src/gpgme-tool.c (options, parse_options):  Add --lib-version
(CMD_LIBVERSION): New.
(main): Implement.
2015-07-23 11:40:09 +02:00
Werner Koch
4160ef90a1 gpgme-tool: Print fingerprint and keyid with keyservers.
* src/gpgme-tool.c (cmd_keylist): Print keyid.  Print FPR only if
available.
2014-08-12 18:50:14 +02:00
Werner Koch
e5ab116072 gpgme-tool: Fix segv for external key listing.
* src/gpgme-tool.c (result_xml_escape): Allow for DATA being NULL.
2014-08-12 17:42:08 +02:00
Werner Koch
4dc9af2415 Add new keylist mode GPGME_KEYLIST_MODE_WITH_SECRET.
* src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_SECRET): New.
* src/engine-gpg.c (gpg_keylist_build_options): Handle new mode.
* src/engine-gpgsm.c (gpgsm_keylist, gpgsm_keylist_ext): Ditto.
* src/keylist.c (parse_sec_field15): Add arg key and take care of
--with-secret output.

* src/gpgme-tool.c (gt_get_keylist_mode, cmd_keylist_mode): Add
"with_secret".  Print card info and and secret flag for subkeys.
--

Note: This mode may only be used with GnuPG >= 2.1.
2014-06-04 09:57:54 +02:00
Werner Koch
991cde9e79 Add GPGME_ENCRYPT_NO_COMPRESS flag.
* src/gpgme.h.in (GPGME_ENCRYPT_NO_COMPRESS): New.
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Implement it.
* src/gpgme-tool.c (_cmd_sign_encrypt): Add option --no-compress.
2014-05-08 11:31:30 +02:00
Werner Koch
4f2d652e60 Add GPGME_PROTOCOL_SPAWN and gpgme_op_spawn.
* src/gpgme.h.in (GPGME_PROTOCOL_SPAWN): New.
(GPGME_SPAWN_DETACHED, GPGME_SPAWN_ALLOW_SET_FG): New.
* src/gpgme.c (gpgme_set_protocol): Add new protocol.
(gpgme_get_protocol_name): Ditto.
* src/spawn.c: New.
* src/libgpgme.vers, src/gpgme.def: Add new public functions.
* src/engine-spawn.c: New.
* src/Makefile.am: Add new files.
* src/engine-backend.h (struct engine_ops): Add OPSPAWN.
* src/engine.c (engine_ops): Add _gpgme_engine_ops_spawn.
(gpgme_get_engine_info): Add Spawn to the list of protocols.
(_gpgme_engine_op_spawn): New.

* src/gpgme-tool.c (gt_protocol_from_name): Add new protocol.
(gt_spawn, cmd_spawn): New.
2014-04-10 13:01:00 +02:00
Werner Koch
8579091c4f Add function gpgme_data_identify.
* src/gpgme.h.in (gpgme_data_type_t): New.
(gpgme_data_identify): New prototype.
* src/data-identify.c: New.
* src/parsetlv.c, src/parsetlv.h: New.  Take from gpa.
* src/libgpgme.vers, src/gpgme.def: Add gpgme_data_identify.
* src/gpgme-tool.c (status): Add STATUS_IDENTIFY_RESULT.
(gt_identify): New.
(cmd_identify): New.

(hlp_passwd): Move close to cmd_passwd.
--

It is often useful to have a way to identify the data which needs
processing.  This is such a common task that it makes sense to
implement this in gpgme to avoid diverging implementations.
2013-08-09 19:19:26 +02:00
Werner Koch
0c1de7abd5 gpgme-tool: Allow for symmetric encryption.
* src/gpgme-tool.c (gt_sign_encrypt): Pass NULL for recp if no
recipients are given.
2013-05-22 16:20:14 +02:00
Werner Koch
6d0d8e7ba0 Make definition of off_t robust against misbehaving w32 toolchains.
* configure.ac (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
and gpgme_ssize_t.
(API__OFF_T, API__SSIZE_T): New ac_subst.
* src/gpgme.h.in: Replace all ssize_t and off_t by ac_subst macros.
* src/assuan-support.c, src/ath-pthread.c, src/ath.c, src/ath.h
* src/data-compat.c, src/data-fd.c, src/data-mem.c, src/data-stream.c
* src/data-user.c, src/data.c, src/data.h, src/engine-gpgsm.c
* src/engine-uiserver.c, src/gpgme-tool.c, src/gpgme.c: Replace off_t
by gpgme_off_t and sszie_t by gpgme_ssize_t.
* src/ath-pthread.c, src/ath.h: Include gpgme.h.
--

For a detailed description, see the gpgme.texi diff.
2013-05-16 17:48:50 +02:00
Werner Koch
02a2cf0ccb gpgme_tool: Support GPG's new pinentry-mode.
* src/gpgme-tool.c (log_error): Do not always print the error source.
(gt_set_pinentry_mode): New.
(server_passphrase_cb): New.
(cmd_pinentry_mode): New.
(register_commands): Add cmd_pinentry_mode.
(options): Add option --gpg-binary.
(struct args): Add field gpg-binary.
(parse_options, main): Implement that option.
2013-02-07 21:03:44 +01:00
Werner Koch
51fd6d8292 Use gpg_error_from_syserror instead of directly accessing errno.
--

Also fixed a couple of minor thing; e.g. save the error before calling
cleanup functions.  Do not save the errno if only free is called
in between.
2013-02-06 17:35:40 +01:00
Werner Koch
e11e7fc558 gpgme-tool: Use membuf functions to build up strings.
* src/gpgme-tool.c (clear_membuf, init_membuf, put_membuf)
(put_membuf_str, get_membuf, peek_membuf): Add membuf functions.
Take from GnuPG master's common/membuf.[ch] and patch for our use.
(result_xml_escape): Rewrite using new functions.
--

First counting, then allocating, and finally copying data is prone to
errors.  We better use the membuf functions which make it much easier.
2012-10-11 17:02:50 +02:00
Werner Koch
aa30b47aa0 gpgme-tool: Change license from LPGLv2+ to GPLv3+
* src/gpgme-tool.c: Change license notice.
--

gpgme-tool.c is a standalone program, thus it makes no sense to keep
it under the LGPL.  We already had the manual under GPLv3+.
2012-10-11 16:54:58 +02:00
W. Trevor King
3f1329e1c9 gpgme-tool: escape special characters in output XML data (<, >, and &).
[[PGP Signed Part:Undecided]]
src/gpgme-tool.c (result_xml_escape_replacement, result_xml_escape):
New.
(result_xml_tag_data): Use result_xml_escape() to escape data.
(result_add_error): Use unescaped < and >.
--

This is a general solution for generating valid XML, but the specific
output that inspired the change was from the KEYLIST command:

  <uid>William Trevor King <wking@tremily.us></uid>

Now the uids are properly escaped:

   <uid>William Trevor King &lt;wking@tremily.us&gt;</uid>

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-11 16:22:46 +02:00
W. Trevor King
c28ebca9f2 gpgme-tool: Fix chain_id -> chain-id in KEYLIST XML.
[[PGP Signed Part:Undecided]]
src/gpgme-tool.c (cmd_keylist): Use <chain-id> instead of <chain_id>.
--
All the other tags map struct attribute underscores to hyphens, so
fixing <chain_id> follows the priciple of least surprise.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-11 16:18:24 +02:00
W. Trevor King
3d69b51f7f gpgme-tool: Return more detailed XML from KEYLIST
src/gpgme-tool.c (cmd_keylist): Convert output from a list of
to more detailed XML.
(xml_preamble1, xml_preamble2, xml_end): Make global.
(result_add_protocol, result_add_validity): New functions for
generating XML from GPGME types.
(result_add_string): Treat NULL strings as "".
(result_xml_tag_data): Make 'data' a 'const char' so we can use the
value returned by gpgme_get_protocol_name directly.
--

This is a first pass at returning most of the gpgme_key_t data from the
KEYLIST call.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-09-28 08:31:51 +02:00
W. Trevor King
dda3702a90 gpgme-tool: Initialize input_fd and output_fd
* src/gpgme-tool.c (gpgme_server): Initialize input_fd and output_fd.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-09-28 08:25:48 +02:00
Werner Koch
193eb62538 gpgme-tool: Fix handling of file descriptors
* src/gpgme-tool.c (server_reset_fds): Use close/CloseHandle instead
of the assuan close functions.
(_cmd_decrypt_verify, _cmd_sign_encrypt, cmd_verify, cmd_import)
(cmd_export, cmd_genkey, cmd_getauditlog): Use SERVER object instead
of assuan_get_*_fd functions.
--

Although we used our own handlers for INPUT and OUTPUT, we still used
assuan_get_input_fd, assuan_get_output_fd and their close functions.
That clearly can't work because libassuan does not have any values for
them.
2012-09-26 09:37:22 +02:00
Werner Koch
139e798c87 Remove all trailing whitespace from source files
--
Command used:  sed -i 's,[ \t]*$,,' FILE
2012-09-25 15:29:49 +02:00
W. Trevor King
c318e69d8f gpgme-tool: add help messages for a number of commands.
* src/gpgme-tool.c (hlp_engine, hlp_sub_protocol, hlp_armor, hlp_textmode,
hlp_include_certs, hlp_keylist_mode, hlp_input, hlp_output, hlp_message,
hlp_recipient, hlp_signer, hlp_signers_clear, hlp_decrypt, hlp_decrypt_verify,
hlp_encrypt, hlp_sign_encrypt, hlp_sign, hlp_verify, hlp_import): New strings.
(hlp_protocol): Fix typo.
(register_commands): Add documentation strings.
(doc): Mention Assuan.
2012-04-03 15:20:27 +02:00
Werner Koch
ce1d166ef7 Allow multiple patterns for KEYLIST. 2010-12-08 09:55:00 +00:00
Werner Koch
c2ef39811d Enable debugging feature for W32CE.
kFreeBSD portability fix.
2010-10-07 10:58:51 +00:00
Marcus Brinkmann
cf2d82c41c Too embarrassing for a changelog entry. 2010-08-04 07:40:33 +00:00
Marcus Brinkmann
6aa92258ce 2010-08-03 Marcus Brinkmann <marcus@g10code.de>
* gpgme-tool.c (result_encrypt_to_xml, result_sign_to_xml)
	(result_verify_to_xml, result_import_to_xml)
        (result_genkey_to_xml):	Check vigorously for null pointers.
2010-08-03 09:16:01 +00:00
Marcus Brinkmann
f5d82bf1df 2010-06-10 Marcus Brinkmann <marcus@g10code.de>
* gpgme-tool.c (gpgme_server): Use special hack for Windows CE to
	get at stdin and stdout.
2010-06-10 17:29:43 +00:00
Marcus Brinkmann
13774269c0 2010-06-09 Marcus Brinkmann <marcus@g10code.de>
* gpgme-tool.c (result_add_timestamp): Add missing NULL argument.
	(result_sign_to_xml): Protect against NULL fingerprint.
	(struct server): New members input_fd, input_filename,
	input_stream output_fd, output_filename, output_stream,
	message_filename, message_stream.
	(server_reset_fds): Deallocate those.
	(server_parse_fd): New function.
	(server_data_obj): Take optional filename argument and direction
	argument.  Also take new argument to return a filestream that
	needs to be closed after destroying the data object.
	Change all callers, too.
	(input_notify, output_notify): Removed.
	(cmd_input, cmd_output): New functions.
	(gpgme_server): Do not register input and output notifier.
	(register_commands): Use cmd_input and cmd_output.
	(cmd_message): Rewritten to use server_parse_fd.
	(cmd_delete, cmd_keylist): Fix inverted option check.
	(main) [HAVE_W32CE_SYSTEM]: Sleep a bit to work around bug in ssh.
2010-06-09 13:23:30 +00:00
Marcus Brinkmann
8d27defa02 2010-05-12 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Check for setlocale.

src/
2010-05-12  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme-tool.c (main): Protect call to setlocale with
	HAVE_SETLOCALE.
2010-05-12 17:40:08 +00:00
Marcus Brinkmann
be3a828e70 2010-05-07 Marcus Brinkmann <marcus@g10code.de>
* engine-g13.c, gpgme.c, engine-gpgsm.c, engine-gpg.c,
	op-support.c, engine-assuan.c, gpgme-tool.c: Include <locale.h>
	only if available with HAVE_LOCALE_H and conditionalize use of
	LC_CTYPE on its definition.
	* engine-gpgconf.c: Do not include <locale.h>.
2010-05-07 01:32:54 +00:00
Marcus Brinkmann
97df297ae2 2010-05-07 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (gpgsm_new, start): Cast between int and
	assuan_fd_t.
	* assuan-support.c (my_pipe, my_close, my_read, my_write): Likewise.
	* gpgme-tool.c (server_data_obj, server_reset_fds, gpgme_server),
	(my_recvmsg, my_sendmsg, my_spawn): Likewise.
	* engine-assuan.c (start): Likewise.
	* engine-g13.c (start): Likewise.
2010-05-07 01:06:14 +00:00
Marcus Brinkmann
749325d6c1 2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Require libgpg-error 1.8.

src/
2010-05-06  Marcus Brinkmann  <marcus@g10code.de>

	* sign.c, data-user.c, conversion.c, debug.c, verify.c, data.c,
	decrypt.c, delete.c, assuan-support.c, import.c, engine-gpgsm.c,
	data-mem.c, op-support.c, w32-io.c, w32-util.c, data-compat.c: Use
	gpg_error_from_syserror instead gpg_error_from_errno, and use
	gpg_err_set_errno to set error number.
	* setenv.c: Include <gpg-error.h> and define __set_errno to use
	gpg_err_set_errno.
	* gpgme-tool.c (ARGP_ERR_UNKNOWN): Define to EDEADLOCK (which is
	mapped in Windows CE) instead of E2BIG (which is not).
	(gt_import_keys): Initialize err.
2010-05-06 13:39:55 +00:00
Werner Koch
2281024d4c Add option GPGME_EXPORT_MODE_MINIMAL 2010-02-16 20:07:03 +00:00
Werner Koch
9fb8b16f88 Convert C++ comments to C90 comments. 2010-02-16 19:37:51 +00:00
Werner Koch
1b2fb1b737 Support gpgme_op_apsswd for GPG. 2010-01-08 19:15:06 +00:00
Marcus Brinkmann
77d8ea8916 2010-01-07 Marcus Brinkmann <marcus@g10code.de>
* gpgme-tool.c (result_xml_write_cb_t, struct result_xml_state):
	New types.
	(MAX_TAGS): New macro.
	(result_init, result_xml_indent, result_xml_tag_start)
	(result_xml_tag_data, result_xml_tag_end, result_add_error)
	(result_add_pubkey_algo, result_add_hash_algo, result_add_keyid)
	(result_add_fpr, result_add_timestamp, result_add_sig_mode)
	(result_add_value, result_add_string, result_encrypt_to_xml)
	(result_decrypt_to_xml, result_sign_to_xml)
	(result_verify_to_xml, result_import_to_xml)
	(result_genkey_to_xml, result_keylist_to_xml)
	(result_vfs_mount_to_xml): New functions.
	(gt_result): Rewritten.
2010-01-07 18:16:54 +00:00
Werner Koch
97c5d4d312 Add an API to change passphrases. Currently only implemented for
GPGSM.  Requires GnuPG 2.1
2010-01-05 17:36:53 +00:00
Werner Koch
c2ee84a87a Add flags to the getauditlog command. 2009-12-01 11:21:47 +00:00
Werner Koch
dce41d1ffa Fix segv in printf like functions. 2009-12-01 11:00:27 +00:00
Marcus Brinkmann
ef640ca8ef 2009-11-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme-tool.c (gpgme_server): Use assuan_fd_t and assuan_fdopen
	on fds.
2009-11-25 17:57:05 +00:00
Marcus Brinkmann
e88c7782bf 2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* gpgme.c (gpgme_new): Set default sub protocol.
	* gpgme-tool.c: Implement get sub protocol.
2009-11-10 14:54:39 +00:00
Marcus Brinkmann
96cf17b159 2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
	Assuan is available.

m4/
2009-11-10  Marcus Brinkmann  <marcus@g10code.de>

	* libassuan.m4: Fix LIBASSUAN_VERSION.

src/
2009-11-10  Marcus Brinkmann  <marcus@g10code.de>

	* Makefile.am (uiserver_components): New variable.
	(main_sources): Add it.
	* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
	implement it.  Adjust callers.
	(gpgme_key_from_uid): New function.
	* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
	(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
	GPGME_ENCRYPT_EXPECT_SIGN.
	(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
	* libgpgme.vers, gpgme.def: Add new functions.
	* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
	(gpgme_set_sub_protocol): New function.
	(gpgme_get_protocol_name): Add UIServer and default protocol.
	* assuan-support.c: Return correct error values, implement
	socketpair for POSIX.
	* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
	w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
	arguments.  Implement it for POSIX.  Adjust all callers.
	* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
	(_gpgme_engine_op_decrypt_verify): New prototypes.  Adjust all
	users.
	* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
	engine.
	(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
	function.
	* decrypt-verify.c (decrypt_verify_start): Call
	_gpgme_engine_op_decrypt_verify.
	* util.h, posix-util.c,
	w32-util.c (_gpgme_get_uiserver_socket_path): New function.
	* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
	* gpgme-tool.c: Some support for UIServer protocol.
	* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00