aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* gpg: More carefully encode a packet's length.Neal H. Walfield2016-02-251-1/+8
| | | | | | | | | * g10/build-packet.c (write_header2): Make sure the length bits are cleared. Fail if HDRLEN is set and the specified length can't be encoded in the available space. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Avoid directly twiddling bits.Neal H. Walfield2016-02-251-3/+4
| | | | | | | | | * g10/build-packet.c (do_plaintext): Use ctb_new_format_p to check the packet's format. (write_header2): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Improve documentation and comments related to OpenPGP packets.Neal H. Walfield2016-02-253-66/+362
| | | | | -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Add some asserts.Neal H. Walfield2016-02-251-4/+62
| | | | | | | | | | | | | | | | | | | * g10/build-packet.c (ctb_new_format_p): New function. (ctb_pkttype): New function. (do_user_id): Add some asserts. (do_key): Likewise. (do_symkey_enc): Likewise. (do_pubkey_enc): Likewise. (do_plaintext): Likewise. (do_encrypted): Likewise. (do_encrypted_mdc): Likewise. (do_compressed): Likewise. (do_signature): Likewise. (do_signature): Likewise. (write_header2): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Avoid an unnecessary copy.Neal H. Walfield2016-02-251-14/+9
| | | | | | | | * g10/build-packet.c (sig_to_notation): Avoid an unnecessary copy of the data: the size of the packet is fixed. -- Signed-off-by: Neal H. Walfield <[email protected]>
* common: Reduce buffer size.Neal H. Walfield2016-02-231-2/+2
| | | | | | | | | | * common/iobuf.c (iobuf_copy): Change buffer size from 1 MB to 32 KB. -- Change suggested by Werner based on the observation that other buffers are of a similar size. Signed-off-by: Neal H. Walfield <[email protected]>
* common: Improve a function's documentation and comments.Neal H. Walfield2016-02-231-10/+14
| | | | | | | | * common/iobuf.c (iobuf_set_partial_body_length_mode): Fix documentation and comment. Add an assert. -- Signed-off-by: Neal H. Walfield <[email protected]>
* common: Add log_assert.Neal H. Walfield2016-02-231-0/+4
| | | | | | | * common/logging.h (log_assert): New macro. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Use higher-level functions.Neal H. Walfield2016-02-232-16/+9
| | | | | | | | | | * g10/build-packet.c (do_symkey_enc): Use iobuf_write instead of iobuf_put in a loop. Use iobuf_copy instead of iobuf_read and iobuf_write in a loop. Move the memory wiping from here... * common/iobuf.c (iobuf_copy): ... to here. -- Signed-off-by: Neal H. Walfield <[email protected]>
* common: Check for an error before reading.Neal H. Walfield2016-02-231-0/+3
| | | | | | | | * common/iobuf.c (iobuf_copy): If DEST has a pending error, don't start copying. -- Signed-off-by: Neal H. Walfield <[email protected]>
* common: More accurately name function.Neal H. Walfield2016-02-234-5/+5
| | | | | | | | * common/iobuf.c (iobuf_set_partial_block_mode): Rename from this... (iobuf_set_partial_body_length_mode): ... to this. Update callers. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g13: Add commands --suspend and --remove.Werner Koch2016-02-2318-210/+1029
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g13/g13.c (aSuspend, aResume): New. (opts): Add commands --suspend and --resume. (main): Implement dummy command aUmount. Implement commands aResume and aSuspend. * g13/sh-cmd.c (cmd_suspend): New. (cmd_resume): New. (register_commands): Add commands RESUME and SUSPEND. * g13/server.c (cmd_suspend): New. (cmd_resume): New. (register_commands): Add commands RESUME and SUSPEND. * g13/be-dmcrypt.c (be_dmcrypt_suspend_container): New. (be_dmcrypt_resume_container): New. * g13/backend.c (be_suspend_container): New. (be_resume_container): New. * g13/suspend.c, g13/suspend.h: New. * g13/mount.c (parse_header, read_keyblob_prefix, read_keyblob) (decrypt_keyblob, g13_is_container): Move to ... * g13/keyblob.c: new file. (keyblob_read): Rename to g13_keyblob_read and make global. (keyblob_decrypt): Rename to g13_keyblob_decrypt and make global. * g13/sh-dmcrypt.c (check_blockdev): Add arg expect_busy. (sh_dmcrypt_suspend_container): New. (sh_dmcrypt_resume_container): New. * g13/call-syshelp.c (call_syshelp_run_suspend): New. (call_syshelp_run_resume): New. -- The --suspend command can be used before a hibernate operation to make the encrypted partition inaccessible and wipe the key from the memory. Before --suspend is called a sync(1) should be run to make sure that their are no dirty buffers (dmsetup, as called by g13, actually does this for you but it does not harm to do it anyway. After the partition has been suspended a echo 3 >proc/sys/vm/drop_caches required to flush all caches which may still have content from the encrypted partition. The --resume command reverses the effect of the suspend but to do this it needs to decrypt again. Now, if the .gnupg directory lives on the encrypted partition this will be problematic because due to the suspend all processes accessing data on the encrypted partition will be put into an uninterruptible sleep (ps(1) shows a state of 'D'). This needs to be avoided. A workaround is to have a separate GnuPG home directory (say, "~/.gnupg-fallback") with only the public keys required to decrypt the partition along with a properly setup conf files. A GNUPGHOME=$(pwd)/.gnupg-fallback g13 --resume should then be able to resume the encrypted partition using the private key stored on a smartcard. The implementation is pretty basic right now but useful to me. Signed-off-by: Werner Koch <[email protected]>
* g13: Run mount after dmsetup.Werner Koch2016-02-232-15/+51
| | | | | | | | * g13/g13-syshelp.c (main): Reject userids with a slash. * g13/sh-dmcrypt.c (sh_dmcrypt_mount_container): Run mount if a mountpoint is known. Signed-off-by: Werner Koch <[email protected]>
* tests/openpgp: Qualify executables with extension.Justus Winter2016-02-231-2/+3
| | | | | | | * tests/openpgp/Makefile.am (required_pgms): Qualify executables with '$EXEEXT'. Signed-off-by: Justus Winter <[email protected]>
* tests/openpgp: Reimplement 'pinentry.sh' in c.Justus Winter2016-02-233-1/+60
| | | | | | | | | | | * tests/openpgp/Makefile.am: Build new program. * tests/openpgp/defs.inc: Use the new program. * tests/openpgp/fake-pinentry.c: New file. -- Building an executable that does not require an interpreter makes it easier to use on Windows. Signed-off-by: Justus Winter <[email protected]>
* tests/openpgp: Avoid dependency on source files.Justus Winter2016-02-232-3/+4206
| | | | | | | | * tests/openpgp/plain-largeo.asc: New file. * tests/openpgp/version.test: Dearmor the new file instead of relying on the source being present. Signed-off-by: Justus Winter <[email protected]>
* tests/openpgp: Fix file removal.Justus Winter2016-02-231-1/+1
| | | | | | * tests/openpgp/version.test: Fix file removal. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Provide a way to wait for multiple processes.Justus Winter2016-02-234-75/+144
| | | | | | | | | | * common/exechelp-posix.c (gnupg_wait_process): Generalize to 'gnupg_wait_processes'. * common/exechelp-w32.c (gnupg_wait_process): Likewise. * common/exechelp-w32ce.c (gnupg_wait_process): New function stub. * common/exechelp.h (gnupg_wait_process): New prototype. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Add general pipe function.Justus Winter2016-02-234-31/+59
| | | | | | | | | | | | | | | * common/exechelp-posix.c (gnupg_create_pipe): New function. * common/exechelp-w32.c (INHERIT_{READ,WRITE,BOTH}): New macros. (create_inheritable_pipe): Generalize so that both ends can be inherited. (do_create_pipe): Rename argument accordingly. (gnupg_create_{in,out}bound_pipe): Use new flags. (gnupg_create_pipe): New function. (gnupg_spawn_process): Use new flags. * common/exechelp-w32ce.c (gnupg_create_pipe): New stub. * common/exechelp.h (gnupg_create_pipe): New prototype. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Mute the Windows version.Justus Winter2016-02-231-3/+4
| | | | | | | | * common/exechelp-w32.c (gnupg_wait_process): Do not print an error if the exit code can be returned. This makes the Windows version behave like the POSIX version. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Avoid magic numbers.Justus Winter2016-02-231-2/+2
| | | | | | * common/exechelp-w32.c (do_create_pipe): Use symbolic names. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Disable debugging by default.Justus Winter2016-02-231-1/+1
| | | | | | * common/exechelp-w32.c (DEBUG_W32_SPAWN): Set to 0. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Fix handle leak.Justus Winter2016-02-231-0/+1
| | | | | | | * common/exechelp-w32.c (gnupg_spawn_process_detached): Close process handle. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Fix opening the 'nul' device.Justus Winter2016-02-231-5/+5
| | | | | | | * common/exechelp-w32.c (gnupg_spawn_process): Fix opening the 'nul' device. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Fix error handling.Justus Winter2016-02-231-2/+2
| | | | | | * common/exechelp-w32.c (gnupg_spawn_process): Close the right handle. Signed-off-by: Justus Winter <[email protected]>
* common/exechelp: Fix pipe creation.Justus Winter2016-02-231-1/+1
| | | | | | | * common/exechelp-w32.c (gnupg_spawn_process): Fix the creation of the input pipe. Signed-off-by: Justus Winter <[email protected]>
* tools/mk-tdata: Fix data generation on Windows.Justus Winter2016-02-231-0/+6
| | | | | | | * tools/mk-tdata.c (main): Set stdout to binary mode to avoid newline conversion. Signed-off-by: Justus Winter <[email protected]>
* gpg: Systematically detect and fix signatures that are out of order.Neal H. Walfield2016-02-191-125/+564
| | | | | | | | | | | | | | * g10/keyedit.c (sig_comparison): New function. (fix_key_signature_order): Merge functionality into... (check_all_keysigs): ... this function. Rewrite to eliminate duplicates and use a systematic approach to detecting and moving signatures that are out of order instead of a heuristic. (fix_keyblock): Don't call fix_key_signature_order. Call check_all_keysigs instead after collapsing the uids. -- Signed-off-by: Neal H. Walfield <[email protected]> GnuPG-bug-id: 2236
* gpg: Split check_key_signature2.Neal H. Walfield2016-02-192-92/+286
| | | | | | | | | | | | * g10/sig-check.c (hash_uid_node): Rename from this... (hash_uid_packet): ... to this. Take a PKT_user_id instead of a KBNODE. (check_key_signature2): Split the basic signature checking functionality into... (check_signature_over_key_or_uid): ... this new function. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Split print_and_check_one_sig.Neal H. Walfield2016-02-191-11/+20
| | | | | | | | | * g10/keyedit.c (print_and_check_one_sig): Split the print functionality into... (print_one_sig): ... this new function. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Split the function check_signature_end.Neal H. Walfield2016-02-191-5/+23
| | | | | | | | | * g10/sig-check.c (check_signature_end): Break the basic signature check into... (check_signature_end_simple): ... this new function. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Use format_keyid rather than manually formatting the keyid.Neal H. Walfield2016-02-192-5/+4
| | | | | | | | | * g10/keyedit.c (menu_addrevoker): Use format_keyid rather than manually formatting the keyid. * g10/keygen.c (card_write_key_to_backup_file): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Initialize the primary key when generating a key.Neal H. Walfield2016-02-191-0/+7
| | | | | | | | * g10/keygen.c (do_generate_keypair): Initialize pri_psk->flags.primary, pri_psk->keyid and pri_psk->main_keyid. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Add accessor & utility functions for pk->keyid and pk->main_keyid.Neal H. Walfield2016-02-193-3/+94
| | | | | | | | | | | | | | | | | * g10/keydb.h (keyid_cmp): New function. * g10/keyid.c (pk_keyid): New function. (pk_main_keyid): New function. (keyid_copy): New function. (pk_keyid_str): New function. * g10/packet.h (PKT_public_key): Update comments for main_keyid and keyid. -- Signed-off-by: Neal H. Walfield <[email protected]> Before accessing pk->keyid, it is necessary to call keyid_from_pk (pk, NULL) to ensure that pk->keyid is valid. Because it is easy to forget to do this, these accessor functions take care of it.
* gpgparsemail: Allow weirdly-mixed pkcs7 signatures.Daniel Kahn Gillmor2016-02-181-17/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * tools/gpgparsemail.c: Add and check info->signing_protocol_2. -- Some mailers in the wild will generate messages that have the a weird structure where they use the x- prefix in one part and drop it in another. For example, the main MIME part as a whole has: Content-Type: multipart/signed; protocol="application/x-pkcs7-signature" but the signature sub-part has: Content-Type: application/pkcs7-signature (or vice versa, where the x- prefix is in the sub-part but not the protocol= section on the main MIME object) This change also avoids allocating strings for these comparisons, since the const strings in question are already available in the built executable, and no dynamic labels are needed. === - 2 lines reformatted to keep them below 90 cols. - wk
* gpg: Clean up dangling agent_open and agent_closed declarations.Daniel Kahn Gillmor2016-02-182-4/+1
| | | | | | | | | | | | | | * g10/keydb.h: Remove agent_open, agent_close declarations/ * g10/migrate.c: #include <unistd.h> for access() -- agent_open() is only defined statically in common/simple-pw-query.c, it is neither used nor referenced anywhere else. agent_close doesn't exist anywhere. The removal of these declarations removes an unecessary inclusion of libassuan.h. migrate.c was relying on keydb.h -> libassuan.h -> unistd.h for the declaration of access(), so we now handle that explicitly instead.
* w32: Make scdaemon build again due to libusb problem.Werner Koch2016-02-161-1/+7
| | | | | | | | | | | * configure.ac: Add hack to disable libusb for Windows. Also use $host instead of $target in the switch -- The new test for libusb does not support cross-compiling. As a quick workaround we disable libusb for Windows because we can't use it anyway. Signed-off-by: Werner Koch <[email protected]>
* w32: Do not error out if gpgconf is not installed.Werner Koch2016-02-161-3/+1
| | | | | | | | | | | * common/homedir.c (check_portable_app): Remove error message. -- It is sometimes useful to install just gpgv and no other parts. Our test for a portable application returned an error if gpgconf is not installed. That error is not required but was merely a debug aid. Signed-off-by: Werner Koch <[email protected]>
* gpg: Make ASCII armor decoding more robust to encoding errors.Neal H. Walfield2016-02-161-0/+18
| | | | | | | | | | * g10/armor.c (radix64_read): If the = is followed by the string "3D", check if the following four characters are valid radix 64 and are followed by a new line. If so, warn and ignore the '3D'. -- Signed-off-by: Neal H. Walfield <[email protected]> GnuPG-bug-id: 2250
* doc: Add a gnupg-module-overview picture.Werner Koch2016-02-163-15/+939
| | | | | | | | | | | | | | | | | | | | | | * doc/gnupg-module-overview.svg: New. * doc/debugging.texi (Component interaction): New. * doc/Makefile.am (EXTRA_DIST): Add PNG and PDF versions of gnupg-module-overview.svg. Remove two eps files. (BUILT_SOURCES): Add gnupg-module-overview.pdf and .png. Remove gnupg-card-architecture.epsl (gnupg_TEXINFOS): Add gnupg-module-overview.svg (gnupg.dvi): New. (DISTCLEANFILES): Remove build eps files. -- Many thanks to Emanuel Schütze for helping with the redesign of the module overview. The original file has been used by mere for years in talks but was never a proper part of GnuPG. The EPS files have been removed due to their size. Thus to build the "dvi" target the convert tool is required. Signed-off-by: Werner Koch <[email protected]>
* common, g10: Fix indentation to silence GCC-6.NIIBE Yutaka2016-02-153-17/+17
| | | | | | | | | | * common/iobuf.c (iobuf_ioctl): Fix. * g10/encrypt.c (encrypt_filter): Likewise. * g10/keyring.c (prepare_search): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: fix for memory alignment.NIIBE Yutaka2016-02-151-6/+14
| | | | | | | | | * dirmngr/dns-stuff.c (get_dns_cert): Cast through void *. (getsrv, get_dns_cname): Make sure it's aligned for HEADER. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* Put asterisks in front of two function descriptions.Werner Koch2016-02-141-9/+9
| | | | | | | -- This helps visual impaired hackers to easier read comments and also helps use when looking at a printout.
* gpg: Add hidden key-edit subcommand "change-usage".Werner Koch2016-02-143-11/+146
| | | | | | | | | | | | * g10/keyedit.c (cmdCHANGEUSAGE): New. (cmds): Add command "change-usage". (keyedit_menu): Handle that command. (menu_changeusage): New. * g10/keygen.c (keygen_add_key_flags): New. (ask_key_flags): Add optional arg current. -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Improve API documentation.Neal H. Walfield2016-02-143-13/+24
| | | | | | | | | | * g10/seskey.c (make_session_key): Improve documentation. (encode_session_key): Improve documentation. * g10/encrypt.c (encrypt_seskey): Remove gratuitous initialization. * g10/dek.h (DEK): Improve documenation. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Fix calc_header_length when LEN is 0 and improve documentation.Neal H. Walfield2016-02-141-4/+8
| | | | | | | | | * g10/build-packet.c (calc_header_length): Return the correct haeder size when LEN is 0. Fix documentation. -- Signed-off-by: Neal H. Walfield <[email protected]> GnuPG-bug-id: 2240
* gpg: Fix format_keyid when dynamically allocating the buffer.Neal H. Walfield2016-02-142-3/+6
| | | | | | | | * g10/keyid.c (format_keyid): Return a char *, not a const char *. If BUFFER is NULL, then set LEN to the static buffer's size. -- Signed-off-by: Neal H. Walfield <[email protected]>
* common: Fix comment.Neal H. Walfield2016-02-141-1/+1
| | | | | | | * common/iobuf.c (iobuf_flush_temp): Fix comment. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g13: Require a confirmation before g13 is used for DM-Crypt.Werner Koch2016-02-133-1/+27
| | | | | | | | * g13/g13-syshelp.c (g13_syshelp_i_know_what_i_am_doing): * g13/sh-dmcrypt.c (sh_dmcrypt_create_container): Call it. (sh_dmcrypt_mount_container): Call it. Signed-off-by: Werner Koch <[email protected]>
* g13: Second chunk of code to support dm-crypt.Werner Koch2016-02-1318-121/+951
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g13/be-dmcrypt.c, g13/be-dmcrypt.h: New. * g13/Makefile.am (g13_SOURCES): Add them. * g13/backend.c: Include be-dmcrypt.h and call-syshelp.h. (no_such_backend): Rename to _no_such_backend and provide replacement macro. (be_is_supported_conttype): Support DM-Crypt. (be_take_lock_for_create): Call set_segvice for DM-Crypt. (be_create_new_keys): Make it a dummy for DM-Crypt. (be_create_container): Call be_dmcrypt_create_container. (be_mount_container): call be_dmcrypt_mount_container. * g13/g13-syshelp.c (main): Enable verbose mode. * g13/g13tuple.c (get_tupledesc_data): New. * g13/g13tuple.h (unref_tupledesc): New. * g13/g13.h (server_control_): Add field "recipients". * g13/g13.c (main): Fix setting of recipients via cmdline. (g13_deinit_default_ctrl): Release recipients list. (g13_request_shutdown): New. Replace all direct update of shutdown_pending by calls this function. * g13/server.c (server_local_s): Remove field recipients which is now part of CTRL. (reset_notify, cmd_recipient, cmd_create): Adjust for this change. * g13/create.c (encrypt_keyblob): Rename to g13_encrypt_keyblob. (g13_create_container): Support DM-Crypt. * g13/mount.c (parse_header): Allow for meta data copies. (g13_mount_container): Support DM-Crypt. * g13/sh-cmd.c (cmd_create): Make it work. (cmd_mount): New. * g13/sh-dmcrypt.c (sh_dmcrypt_create_container): Make it work. (sh_dmcrypt_mount_container): New. -- With this patch we can now create an encrypted partition and partly mount it (i.e. setup keys and create the mapped device). We do not yet create a file system or mount that file system Signed-off-by: Werner Koch <[email protected]>