1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-29 02:22:45 +02:00
Commit Graph

645 Commits

Author SHA1 Message Date
NIIBE Yutaka
a9895a5a72 common: Fix strsplit.
* common/stringhelp.c (strsplit): Fix arguments order.
2015-10-01 08:57:06 +09:00
Neal H. Walfield
c8584a1e55 common: Add mkdir_p.
* common/mkdir_p.c: New file.
* common/mkdir_p.h: New file.
* common/Makefile.am (common_sources): Add mkdir_p.c and mkdir_p.h.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-30 12:58:31 +02:00
Neal H. Walfield
5576146ede common: Remove unused files.
* common/xmalloc.c: Remove file.
* common/xmalloc.h: Remove file.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-30 12:58:31 +02:00
Neal H. Walfield
270d3f55f9 common: Include <gpg-error.h>.
* common/logging.h: Include <gpg-error.h>.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.

logging.h uses estream_t and as such should directly include
<gpg-error.h>.
2015-09-30 12:58:30 +02:00
NIIBE Yutaka
5c067d54d3 ssh: Fix fingerprint computation for EdDSA key.
* common/ssh-utils.c (get_fingerprint): Handle the prefix of 0x40.
* common/t-ssh-utils.c (sample_keys): Add a new key.

--

Also adding Ed25519 test key.
2015-09-29 15:33:59 +09:00
Werner Koch
f1effdc5ec
common: Provide two new error code replacements.
* common/util.h (GPG_ERR_FALSE, GPG_ERR_TRUE): Rew replcements.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-28 18:40:38 +02:00
Werner Koch
83811e3f1f
common: Change calling convention for gnupg_spawn_process.
* common/exechelp.h (GNUPG_SPAWN_NONBLOCK): New.
(GNUPG_SPAWN_RUN_ASFW, GNUPG_SPAWN_DETACHED): Macro to replace the
numbers.
* common/exechelp.h (gnupg_spawn_process): Change function to not take
an optional stream for stdin but to return one.
* common/exechelp-posix.c (gnupg_spawn_process): Implement change.
(create_pipe_and_estream): Add args outbound and nonblock.
* common/exechelp-w32.c (gnupg_spawn_process): Implement change.
--

In 2.1 this function is only used at one place and the stdin parameter
is not used.  Thus this change is trivial for the callers but along
with estream's new es_poll it is overall simpler to use.

Note that the Windows version has not been tested.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-28 18:40:38 +02:00
Werner Koch
12ff806d1b
ssh: Add 256, 384 and 521 bit test keys for the fingerprint.
* common/t-ssh-utils.c (sample_keys): Add 3 new keys.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-22 10:01:31 +02:00
Werner Koch
2167951b27
ssh: Fix fingerprint computation for 384 bit ECDSA keys.
* common/ssh-utils.c (get_fingerprint): Fix hashed string.
--

That was an obvious c+p bug which should have been caught by a test
case.

GnuPG-bug-id: 2075
Debian-bug-id: 795636
2015-09-22 09:28:35 +02:00
Neal H. Walfield
8499c4f84a common: Add new function strlist_length.
* common/strlist.c (strlist_length): New function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-19 01:26:48 +02:00
Werner Koch
b4bc1c8b10
http: Add flag to force use of TOR (part 1)
* common/http.h (HTTP_FLAG_FORCE_TOR): New.
* common/http.c (http_raw_connect, send_request): Detect flag and
return an error for now.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-18 16:21:30 +02:00
Neal H. Walfield
219de84df9 iobuf: Reduce verbosity of test.
* common/t-iobuf.c (main): Reduce verbosity.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:38:41 +02:00
Neal H. Walfield
f2d75ac7dc iobuf: Add the IOBUF_INPUT_TEMP type to improve input temp handling.
* common/iobuf.h (enum iobuf_use): Add new member, IOBUF_INPUT_TEMP.
* common/iobuf.c (iobuf_temp_with_content): Create the iobuf as an
IOBUF_INPUT_TEMP, not an IOBUF_INPUT buffer.  Assert that LENGTH ==
A->D.SIZE.
(iobuf_push_filter2): If A is an IOBUF_INPUT_TEMP, then make the new
filter an IOBUF_INPUT filter and set its buffer size to
IOBUF_BUFFER_SIZE.
(underflow): If A is an IOBUF_INPUT_TEMP, then just return EOF; don't
remove already read data.
(iobuf_seek): If A is an IOBUF_INPUT_TEMP, don't discard the buffered
data.
(iobuf_alloc): Allow USE == IOBUF_INPUT_TEMP.
(pop_filter): Allow USE == IOBUF_INPUT_TEMP.
(iobuf_peek): Allow USE == IOBUF_INPUT_TEMP.
(iobuf_writebyte): Fail if USE == IOBUF_INPUT_TEMP.
(iobuf_write): Fail if USE == IOBUF_INPUT_TEMP.
(iobuf_writestr): Fail if USE == IOBUF_INPUT_TEMP.
(iobuf_flush_temp): Fail if USE == IOBUF_INPUT_TEMP.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.

Introduce a new iobuf type, IOBUF_INPUT_TEMP.  Use this for the iobuf
created by iobuf_temp_with_content instead of IOBUF_INPUT.  This was
necessary so that seeking and peeking correctly work on this type of
iobuf.  In particular, seeking didn't work because we discarded the
buffered data and peeking didn't work because we discarded data which
was already read, which made seeking later impossible.
2015-09-02 10:24:49 +02:00
Neal H. Walfield
5ff5e72b9c iobuf: Rename IOBUF_TEMP to IOBUF_OUTPUT_TEMP.
* common/iobuf.h (enum iobuf_use): Rename IOBUF_TEMP to
IOBUF_OUTPUT_TEMP.  Update users.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:07:41 +02:00
Neal H. Walfield
24259d856b iobuf: Use a first-class enum.
* common/iobuf.h (enum iobuf_use): Name the IOBUF_OUTPUT, etc. enum.
(struct iobuf_struct): Change the field use's type to it.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:07:40 +02:00
Neal H. Walfield
8522cdc226 iobuf: Fix test.
* common/t-iobuf.c (content_filter): If there is nothing to read,
don't forget to set *LEN to 0.
(main): Fix checks.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:07:40 +02:00
Werner Koch
99c9bf7def
common: Assume an utf-8 locale on iconv errors.
* common/utf8conv.c (handle_iconv_error): Use utf-8 as fallback.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-01 07:37:12 +02:00
Werner Koch
bc23e69b70
common: Fix regression in building argpase.c standalone.
* common/argparse.c (is_native_utf8) [GNUPG_MAJOR_VERSION]: New.
2015-09-01 07:37:12 +02:00
Werner Koch
9cdff09743
gpg: Print a new FAILURE status after most commands.
* common/status.h (STATUS_FAILURE): New.
* g10/cpr.c (write_status_failure): New.
* g10/gpg.c (main): Call write_status_failure for all commands which
print an error message here.
* g10/call-agent.c (start_agent): Print an STATUS_ERROR if we can't
set the pinentry mode.
--

This status line can be used similar to the error code returned by
commands send over the Assuan interface in gpgsm.  We don't emit them
in gpgsm because there we already have that Assuan interface to return
proper error code.  This change helps GPGME to return better error
codes.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-25 15:26:33 +02:00
Werner Koch
b8adfc4186
doc: Remove C++ style comments and update HACKING.
--
2015-08-20 17:42:55 +02:00
Neal H. Walfield
49f922286f common/iobuf.c: Make control flow more obvious.
* common/iobuf.c (iobuf_read): Make control flow more obvious.
(iobuf_get_filelength): Likewise.
(iobuf_get_fd): Likewise.
(iobuf_seek): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:27 +02:00
Neal H. Walfield
c5da750cf3 common/iobuf.c: Add some sanity checks to catch programmer bugs.
* common/iobuf.c (iobuf_alloc): Check that BUFSIZE is not 0.
(iobuf_readbyte): Check that A is an input filter.  Check that the
amount of read data is at most the amount of buffered data.
(iobuf_read): Check that A is an input filter.
(iobuf_writebyte): Check that A is not an input filter.
(iobuf_writestr): Check that A is not an input filter.
(iobuf_flush_temp): Check that A is not an input filter.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:27 +02:00
Neal H. Walfield
e291b631c3 common/iobuf.c:iobuf_write_temp: Elide redundant code.
* common/iobuf.c (iobuf_write_temp): Don't repeat iobuf_flush_temp.
Use it directly.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:26 +02:00
Neal H. Walfield
a6d4bca3b5 common/iobuf.c: Have iobuf_writestr use iobuf_write, not iobuf_writebyte
* common/iobuf.c (iobuf_write): Don't write a byte at a time.  Use
iobuf_write.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:26 +02:00
Neal H. Walfield
1bfd1e4324 common/iobuf: Improve documentation and code comments.
common/iobuf.h: Improve documentation and code comments.
common/iobuf.c: Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:25 +02:00
Neal H. Walfield
0d40c4e83f common/iobuf.c: Adjust buffer size of filters in front of temp filters.
* common/iobuf.c (iobuf_push_filter2): If the head filter is a temp
filter, use IOBUF_BUFFER_SIZE for the new filter.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:25 +02:00
Neal H. Walfield
827cc922d8 common/iobuf.c: Buffered data should not be processed by new filters.
* common/iobuf.c (iobuf_push_filter2): If the pipeline is an output or
temp pipeline, the new filter shouldn't assume ownership of the old
head's internal buffer: the data was written before the filter was
added.
* common/t-iobuf.c (double_filter): New function.
(main): Add test cases for the above bug.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:24 +02:00
Neal H. Walfield
616181f3c7 common/iobuf.c: Flush the pipeline in iobuf_temp_to_buffer.
* common/iobuf.c (iobuf_temp_to_buffer): Flush each filter in the
pipeline and copy the data from the last (not the first) filter's
internal buffer.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:23 +02:00
Neal H. Walfield
15ae99f887 common/iobuf.c: Combine iobuf_open, iobuf_create and iobuf_openrw.
* common/iobuf.c (do_open): New function, which is a generalization of
iobuf_open, iobuf_Create, iobuf_openrw.
(iobuf_open): Call do_open.
(iobuf_create): Likewise.
(iobuf_openrw): Likewise.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:23 +02:00
Neal H. Walfield
8402815d8e common/iobuf.h: Remove iobuf_open_fd_or_name.
* common/iobuf.h (iobuf_open_fd_or_name): Remove prototype.  Replace
use with either iobuf_open or iobuf_fdopen_nc, as appropriate.
* common/iobuf.c (iobuf_open): Remove function.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:22 +02:00
Neal H. Walfield
6d49a2b669 common/iobuf.c: Rename iobuf_flush and make it a static function.
* common/iobuf.h (iobuf_flush): Remove prototype.
* common/iobuf.c (filter_flush): New static prototype.
(iobuf_flush): Rename...
(filter_flush): ... to this.  Make static.  Simplify code.  Update
callers.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:21 +02:00
Neal H. Walfield
1f94646a86 common/iobuf.c: Don't abort freeing a pipeline if freeing a filter fails
* common/iobuf.c (iobuf_cancel): Don't abort freeing a pipeline if
freeing a filter fails.  This needs to a memory leak.  Instead, keep
freeing and return the error code of the first filter that fails.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:21 +02:00
Neal H. Walfield
a250f73783 common/iobuf.c: Improve iobuf_peek.
* common/iobuf.c (underflow): Take additional parameter
clear_pending_eof.  If not set, don't clear a pending eof when
returning EOF.  Update callers.
(iobuf_peek): Fill the internal buffer, if needed, to be able to
better satisfy any request.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:20 +02:00
Neal H. Walfield
c7ad36eb0d common/iobuf.c: When requested, fill the buffer even if it is not empty.
* common/iobuf.c (underflow): Don't require that the buffer be empty.
When called, fill any available space.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:20 +02:00
Neal H. Walfield
e76c75d872 common/t-iobuf.c: Add a test case for multiple EOFs.
common/t-iobuf.c (main): Add a test case for multiple EOFs in an INPUT
pipeline.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:19 +02:00
Neal H. Walfield
4e32c602f5 common/iobuf.c: Better respect boundary conditions in iobuf_read_line.
* common/iobuf.c (iobuf_read_line): Be more careful with boundary
conditions.
* common/iobuf.h: Include <gpg-error.h>.
* common/t-iobuf.c: New file.
* common/Makefile.am (module_tests): Add t-iobuf.
(t_mbox_util_LDADD): New variable.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:19 +02:00
Neal H. Walfield
fa9fda23c2 common/iobuf.c: Fix filter type for iobuf_temp_with_content.
* common/iobuf.c (iobuf_temp_with_content): Set the filter type to
IOBUF_INPUT, not IOBUF_TEMP, which is only for output filters that
write into a dynamic buffer.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:18 +02:00
Neal H. Walfield
75fd86bbd1 common/iobuf.h: Remove unimplemented prototypes.
* common/iobuf.h (iobuf_unread): Remove unimplemented prototype.
(iobuf_clear_eof): Likewise.
(iobuf_append): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:17 +02:00
Neal H. Walfield
679acc671e common/iobuf.c: Refactor code to not need the desc field.
* common/iobuf.h (struct iobuf_struct): Remove field desc.
* common/iobuf.c (iobuf_desc): New function.  When a filter's
description is needed, use this instead of the filter's desc field.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:17 +02:00
Neal H. Walfield
12fc56bcb5 common/iobuf.h: Clarify semantics of nofast. Simplify implementation.
* common/iobuf.h (struct iobuf_struct): Clarify semantics of nofast.
Simplify use of nofast to implement just these semantics.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:16 +02:00
Neal H. Walfield
e8c0b6abf8 common/iobuf.c: Remove dead code (directfp).
* common/iobuf.h (struct iobuf_struct): Remove field directfp.  Remove
all uses of it.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:16 +02:00
Neal H. Walfield
f05d60b381 common/iobuf.c: Remove dead code (opaque).
* common/iobuf.h (struct iobuf_struct): Remove field opaque.  Remove
all uses of it.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:15 +02:00
Neal H. Walfield
c06eabac8e common/iobuf.h: Replace further use of literals with symbolic constants.
* common/iobuf.c: Move BLOCK_FILTER_INPUT,
BLOCK_FILTER_OUTPUT_BLOCK_FILTER_TEMP from here...
* common/iobuf.h: ... to here and rename to IOBUF_INPUT, IOBUF_OUTPUT
and IOBUF_TEMP, respectively.  Where appropriate, use these macros
instead of a literal.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-20 14:16:14 +02:00
Ben Kibbey
f126ca6156 Inform a user about inquire length limit.
* common/status.h (INQUIRE_MAXLEN): New.
* g10/call-agent.c (default_inquire_cb): Send STATUS_INQUIRE_MAXLEN.
client when inquiring a passphrase over pinentry-loopback.

--
This is to inform a user about the maximum length of a passphrase. The
limit is the same that gpg-agent uses.
2015-08-15 17:14:13 -04:00
Neal H. Walfield
c80643c5ec common/iobuf.c: Replace use of literals with symbolic constants.
* common/iobuf.c (BLOCK_FILTER_INPUT): Define.  Where appropriate, use
this instead of a literal.
(BLOCK_FILTER_OUTPUT): Likewise.
(BLOCK_FILTER_TEMP): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-08-08 13:09:00 +02:00
Werner Koch
9f31ab3d21
common: Change alias for Curve25519 to "cv25519".
* common/openpgp-oid.c (oidtable): Change alias.
--

This is a cosmetic change so that common and expected common
algorithms line up nicely in a keylisting.  For example:

  pub   ed25519/C68CE6D1ED0319C8 2015-08-06
  uid                 [ultimate] Curve25519 Test 150806.1
  sub   cv25519/49238B9F0712C9BF 2015-08-06
  sub   rsa2048/8AEAF74014699D2C 2015-08-06
  sub   cv25519/8EC3776830B08736 2015-08-06

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-08-07 09:37:49 +02:00
NIIBE Yutaka
e5891a82c3 Curve25519 support.
* agent/cvt-openpgp.c (get_keygrip): Handle Curve25519.
(convert_secret_key, convert_transfer_key): Ditto.
* common/openpgp-oid.c (oidtable): Add Curve25519.
(oid_crv25519, openpgp_oid_is_crv25519): New.
* common/util.h (openpgp_oid_is_crv25519): New.
* g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Handle the case
with Montgomery curve which uses x-only coordinate.
* g10/keygen.c (gen_ecc): Handle Curve25519.
(ask_curve): Change the API and second arg is to return subkey algo.
(generate_keypair, generate_subkeypair): Follow chage of ask_curve.
* g10/keyid.c (keygrip_from_pk): Handle Curve25519.
* g10/pkglue.c (pk_encrypt): Handle Curve25519.
* g10/pubkey-enc.c (get_it): Handle the case with Montgomery curve.
* scd/app-openpgp.c (ECC_FLAG_DJB_TWEAK): New.
(send_key_attr): Work with general ECC, Ed25519, and Curve25519.
(get_public_key): Likewise.
(ecc_writekey): Handle flag_djb_tweak.

--

When libgcrypt has Curve25519, GnuPG now supports Curve25519.
2015-08-06 17:00:41 +09:00
NIIBE Yutaka
a6e4053089 common: extend API of openpgp_oid_to_curve for canonical name.
* common/openpgp-oid.c (openpgp_oid_to_curve): Add CANON argument.
* common/util.h: Update.
* g10/import.c (transfer_secret_keys): Follow the change.
* g10/keyid.c (pubkey_string): Likewise.
* g10/keylist.c (list_keyblock_print, list_keyblock_colon): Likewise.
* parse-packet.c (parse_key): Likewise.
* scd/app-openpgp.c (send_key_attr, get_public_key): Likewise.

--

Change the function so that caller can select canonical name of curve
or name for printing.  Suggested by wk.
2015-08-06 16:51:14 +09:00
Werner Koch
4bc75337f3
common,w32: Avoid unused var warning about msgcache.
* common/i18n.c (USE_MSGCACHE): New.
(msgcache) [!USE_MSGCACHE]: Do not define.
(i18n_localegettext): Repalce #if conditions by USE_MSGCACHE.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-07-28 17:38:44 +02:00
Werner Koch
18f1e627c6
w32: Try more places to find an installed Pinentry.
* common/homedir.c (get_default_pinentry_name): Re-implement to
support several choices for Windows.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-07-28 13:52:12 +02:00