aboutsummaryrefslogtreecommitdiffstats
path: root/g10/build-packet.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* gpg: Improve detection of input data read errors.Werner Koch2024-09-061-3/+10
| | | | | | | | | | | | * g10/build-packet.c (do_plaintext): Better error checking for iobuf_copy. -- Fixes-commit: 695cb04af5218cd7b42c7eaaefc186472b99a995 GnuPG-bug-id: 6528 The original fix handles only the disk full case but didn't bother about read errors (i.e. I/O problems on an external drive).
* gpg: Implement Kyber encryption.Werner Koch2024-04-151-2/+7
| | | | | | | | | | * g10/build-packet.c (do_pubkey_enc): Support Kyber. * g10/pkglue.c (do_encrypt_kem): Implement. -- Note that the code does only work for ky768_cv25519 for now. GnuPG-bug-id: 6815
* gpg: Changed internal data format for Kyber.Werner Koch2024-04-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | * g10/packet.h (PKT_pubkey_enc): Add field seskey_algo. (struct pubkey_enc_list): Ditto. * g10/misc.c (pubkey_get_nenc): Change value for Kyber from 4 to 3. * g10/parse-packet.c (parse_pubkeyenc): Store the Kyber algo in the new field and adjust data. Do not store the length byte in data[2]. * g10/build-packet.c (do_pubkey_enc): Take the session algo for Kyber from the new field. * g10/encrypt.c (write_pubkey_enc): Ses the seskey_algo. * g10/mainproc.c (proc_pubkey_enc): Copy it. * g10/pubkey-enc.c (get_it): Support Kyber decryption. * g10/seskey.c (encode_session_key): Handle Kyber different from ECDH. -- Having always the single byte in the packet data than to store and retrieve it from an MPI is much easier. Thus this patch changes the original internal format. With this chnages decryption of the slighly modified test data works now. See the bug tracker for test data. GnuPG-bug-id: 6815
* gpg: Initial support for generating Kyber subkeys.Werner Koch2024-04-031-17/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/openpgpdefs.h (PUBKEY_ALGO_KY768_25519): Remove. (PUBKEY_ALGO_KY1024_448): Remove. (PUBKEY_ALGO_KYBER): New. Use them everywhere instead of the removed. * g10/build-packet.c (gpg_mpi_write_nohdr): Rename to (gpg_mpi_write_opaque_nohdr): this. Change callers. (gpg_mpi_write_opaque_32): New. (do_key): Support Kyber keys using the revised format. * g10/gpg.h (MAX_EXTERN_KEYPARM_BITS): New. * g10/parse-packet.c (read_octet_string): Add arg nbytes so support reading with a length prefix. Adjust callers. (parse_key): Parse Kyber public keys. * g10/misc.c (pubkey_get_npkey): Support Kyber. (pubkey_get_nskey): Ditto. * g10/keyid.c (pubkey_string): Support dual algorithms. (do_hash_public_key): Support Kyber. (nbits_from_pk): Ditto. (keygrip_from_pk): Return the Kyber part for the ECC+Kyber dual algo. * g10/keygen.c (struct common_gen_cb_parm_s): Add genkey_result2. Note that this callback is not yet used. (ecckey_from_sexp): Add optional arg sexp2 and use it for Kyber. Change callers. (ecckey_from_sexp): Do not leak LIST in case of an error. (common_gen): Add arg keyparms2, change callers, and support Kyber. (gen_kyber): New. (get_keysize_range): Support Kyber. (fixup_keysize): Simplify and support Kyber. (do_create): Handle Kyber. (parse_key_parameter_part): Remove algo strings "ky768" and "ky1024" and add a generic "kyber" with default parameters. -- This uses a revised format which is more aligned with the usual OpenPGP structure. A lot of things are still missing. For example support for handling two keygrips and checking both of them in a -K listing. There is also only ky768_bp384 as fixed algorithm for now. No passphrase for the Kyber part of the dual algorithm is on purpose. A test was done using gpg --quick-gen-key pqc1 nistp256 and then running gpg -v --quick-add-key <fingerprint> kyber which creates a v5 subkey on a v4 primary key. A second test using gpg --quick-gen-key pqc2 Ed448 followed by a --quick-add-key created a v5 key with a v5 subkey. GnuPG-bug-id: 6815
* gpg: new list-option show-x509-notationsWerner Koch2024-03-121-0/+66
| | | | | | | | | | | * g10/gpg.c (parse_list_options): Add new option. * g10/options.h (LIST_SHOW_X509_NOTATIONS): New. * g10/build-packet.c (search_sig_notations): New. * g10/keylist.c (print_x509_notations): New. (list_signature_print): Use macros for the sig classes. Call print_x509_notations. (list_keyblock_print): Call list_signature_print if x509 notation printing is enabled.
* gpg: Fix gpg_mpi_write for the unused opaque case.Werner Koch2024-02-211-1/+3
| | | | | | | | | * g10/build-packet.c (gpg_mpi_write): Take care of the fact that get_opaque already returns a bit-exact value. -- Fixes-commit: ab17f7b6c392782718f57eaea94fc18a0ff49389 Reported-by: Falko Strenzke <[email protected]>
* gpg: Print status line and proper diagnostics for write errors.Werner Koch2023-06-091-3/+11
| | | | | | | | | * common/iobuf.c (file_filter): Improve diagnostics. * g10/build-packet.c (do_plaintext): Make sure to cache all error cases. -- GnuPG-bug-id: 6528
* gpg: Allow adding of Additional Decryption Subkeys.Werner Koch2023-03-011-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/free-packet.c (copy_public_key): Factor some code out to ... (copy_public_key_basics): new. * g10/build-packet.c (build_sig_subpkt_from_sig): New arg signhints. * g10/packet.h (PUBKEY_USAGE_RENC): Fix value. (SIGNHINT_KEYSIG, SIGNHINT_SELFSIG): Moved from sign.c. (SIGNHINT_ADSK): New. (PKT_public_key): Change pubkey_usage from byte to u16. (PKT_user_id): Cosmetic fix: change help_key_usage from int to u16. * g10/getkey.c (parse_key_usage): Make public. * g10/misc.c (openpgp_pk_algo_usage): Take PUBKEY_USAGE_RENC in account. * g10/sign.c (update_keysig_packet): Set SIGNHINT_ADSK. (make_keysig_packet): Ditto. (do_sign): No time warp check in ADSK mode. * g10/sig-check.c (check_signature_metadata_validity): Ditto. * g10/keygen.c (struct opaque_data_usage_and_pk): Remove. (write_keybinding): Do not use the removed struct. (do_add_key_flags): Support PUBKEY_USAGE_RENC and others. (keygen_add_key_flags_and_expire): Rewrite and make public. * g10/keyedit.c (enum cmdids): Add cmdADDADSK. (keyedit_menu): Add command "addadsk". (menu_addadsk): New. -- This makes use of a new encryption flag: The "restricted encryption key" (2nd,0x04) does not take part in any automatic selection of encryption keys. It is only found on a subkey signature (type 0x18), one that refers to the key the flag applies to. Followup patches will add encryption support and a --quick command. GnuPG-bug-id: 6395
* gpg: New export option "mode1003".Werner Koch2022-12-021-3/+21
| | | | | | | | | | | | | | | | | | | | | | * agent/command.c (cmd_export_key): Add option --mode1003. (command_has_option): Ditto. * g10/build-packet.c (do_key): Implement mode 1003. * g10/parse-packet.c (parse_key): Ditto. * g10/options.h (EXPORT_MODE1003): New.o * g10/call-agent.c (agent_export_key): Add arg mode1003. * g10/export.c (parse_export_options): Add "mode1003" (secret_key_to_mode1003): New. (receive_seckey_from_agent): Add arg mode1003. (do_export_one_keyblock): Pass option down. -- This option allows to export a secret key in GnuPG's native format. Thus no re-encryption is required and further the public key parameters are also authenticated if a protection passphrase has been used. Note that --import is not yet able to handle this new mode. Although old version of GnuPG will bail out with "invalid packet" if a mode1003 exported secret key is seen.
* gpg: Fix assertion failure due to errors in encrypt_filter.Werner Koch2022-09-291-0/+3
| | | | | | | | | | | | | | | * common/iobuf.c (iobuf_copy): Use log_assert. Explicitly cast error return value. * g10/build-packet.c (do_plaintext): Check for iobuf_copy error. * g10/encrypt.c (encrypt_filter): Immediately set header_okay. -- The second fix avoids repeated error message about non-compliant keys. Updates-commit: a51067a21f688086bd8e44234a88ae367582cc76 Ported-from: aa0c942521d89f4f0aac90bacaf8a7a7cefc88d8 GnuPG-bug-id: 6174
* gpg: Replace an assert by a log_fatal.Werner Koch2022-04-141-3/+6
| | | | | | * g10/build-packet.c (do_signature): Use log_fatal. -- GnuPG-bug-id: 5809
* gpg,ecc: Handle external representation as SOS with opaque MPI.NIIBE Yutaka2020-06-091-7/+100
| | | | | | | | | | | | | | | | | | | | * g10/pkglue.h (sexp_extract_param_sos): New. * g10/build-packet.c (sos_write): New. (do_key, do_pubkey_enc, do_signature): Use sos_write for ECC. * g10/export.c (cleartext_secret_key_to_openpgp): Use sexp_extract_param_sos. (transfer_format_to_openpgp): Use opaque MPI for ECC. * g10/keygen.c (ecckey_from_sexp): Use sexp_extract_param_sos. * g10/keyid.c (hash_public_key): Handle opaque MPI for SOS. * g10/parse-packet.c (sos_read): New. (parse_pubkeyenc,parse_signature,parse_key): Use sos_read for ECC. * g10/pkglue.c (sexp_extract_param_sos): New. (pk_verify): Handle opaque MPI for SOS. (pk_encrypt): Use sexp_extract_param_sos. * g10/seskey.c (encode_session_key): Use opaque MPI. * g10/sign.c (do_sign): Use sexp_extract_param_sos. Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: Move a keydb function to another file.Werner Koch2019-11-271-0/+43
| | | | | | | * g10/keydb.c (build_keyblock_image): Move to ... * g10/build-packet.c (build_keyblock_image): here. Signed-off-by: Werner Koch <[email protected]>
* gpg: Rework the signature subpacket iteration function.Werner Koch2019-09-051-1/+1
| | | | | | | | | | | | * g10/parse-packet.c (enum_sig_subpkt): Replace first arg by two args so that the entire signature packet is available. Change all callers. (parse_sig_subpkt): Ditto. -- This patch is a prerequisite to support the new attestation key signatures. Signed-off-by: Werner Koch <[email protected]>
* gpg: Do not allow creation of user ids larger than our parser allows.Werner Koch2019-05-211-1/+7
| | | | | | | | | | | | | | | | | | * g10/parse-packet.c: Move max packet lengths constants to ... * g10/packet.h: ... here. * g10/build-packet.c (do_user_id): Return an error if too data is too large. * g10/keygen.c (write_uid): Return an error for too large data. -- This can lead to keyring corruption becuase we expect that our parser is abale to parse packts created by us. Test case is gpg --batch --passphrase 'abc' -v \ --quick-gen-key $(yes 'a'| head -4000|tr -d '\n') GnuPG-bug-id: 4532 Signed-off-by: Werner Koch <[email protected]>
* gpg: Implement v5 keys and v5 signatures.Werner Koch2019-03-141-43/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/build-packet.c (gpg_mpi_write): New optional arg R_NWRITTEN. Allow NULL for OUT. Change all callers. (do_key): Support v5 keys. (build_sig_subpkt_from_sig): Support 32 byte fingerprints. * g10/parse-packet.c (parse_signature): First try to set the keyid from the issuer fingerprint. (parse_key): Support v5 keys. (create_gpg_control): Better make sure to always allocate the static size of the struct in case future compilers print warnings. * g10/keyid.c (hash_public_key): Add v5 support. (keyid_from_pk): Ditto. (keyid_from_fingerprint): Ditto. (fingerprint_from_pk): Ditto. * g10/keygen.c (KEYGEN_FLAG_CREATE_V5_KEY): New. (pVERSION, pSUBVERSION): New. (add_feature_v5): New. (keygen_upd_std_prefs): Call it. (do_create_from_keygrip): Add arg keygen_flags and support the v5 flag. (common_gen): Support the v5 flag. (parse_key_parameter_part): New flags v4 and v5. (parse_key_parameter_string): Add args for version and subversion. (read_parameter_file): New keywords "Key-Version" and "Subkey-Version". (quickgen_set_para): Add arg 'version'. (quick_generate_keypair, generate_keypair): Support version parms. (do_generate_keypair): Support v5 key flag. (generate_subkeypair): Ditto. (generate_card_subkeypair): Preparse for keyflags. (gen_card_key): Ditto. * g10/sig-check.c (check_signature2): Add args extrahash and extrahashlen. (check_signature_end): Ditto. (check_signature_end_simple): Ditto. Use them. * g10/mainproc.c (proc_plaintext): Put extra hash infor into the control packet. (do_check_sig): Add args extrahas and extrahashlen and pass them on. (issuer_fpr_raw): Support 32 byte fingerprint. (check_sig_and_print): get extra hash data and pass it on. -- Note that this is only basic support and requires more fine tuning/fixing. Signed-off-by: Werner Koch <[email protected]>
* gpg: Unfinished support for v5 signatures.Werner Koch2018-10-241-1/+1
| | | | | | | | | | | | * g10/parse-packet.c (parse_signature): Allow for v5 signatures. * g10/sig-check.c (check_signature_end_simple): Support the 64bit v5 byte count. * g10/sign.c (hash_sigversion_to_magic): Ditto. (write_signature_packets): Request v5 sig for v5 keys. Remove useless condition. (make_keysig_packet): Request v5 sig for v5 keys. Signed-off-by: Werner Koch <[email protected]>
* Fix use of strncpy, which is actually good to use memcpy.NIIBE Yutaka2018-09-061-1/+1
| | | | | | | * common/ssh-utils.c (get_fingerprint): Use memcpy. * g10/build-packet.c (string_to_notation): Use memcpy. Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: Implement AEAD for SKESK packets.Werner Koch2018-01-231-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * g10/packet.h (PKT_symkey_enc): Add field aead_algo. * g10/build-packet.c (do_symkey_enc): Support version 5 packets. * g10/parse-packet.c (parse_symkeyenc): Ditto. * g10/encrypt.c (encrypt_symmetric): Force using a random session key in AEAD mode. (encrypt_seskey): Add and support arg aead_algo. (write_symkey_enc): Ditto. (encrypt_simple): Adjust accordingly. (encrypt_filter): Ditto. * g10/gpgcompose.c (sk_esk): For now call encrypt_seskey without AEAD support. * g10/mainproc.c (symkey_decrypt_seskey): Support AEAD. Nver call BUG but return an error. (proc_symkey_enc): Call symkey_decrypt_seskey in a bug compatible way. * g10/import.c (check_prefs): Check AEAD preferences. * g10/keyedit.c (show_prefs): Print AEAD preferences. -- For easier debugging this patch also changes some diagnostics to also print the encryption mode with the cipher algorithm. Signed-off-by: Werner Koch <[email protected]>
* gpg: First take on PKT_ENCRYPTED_AEAD.Werner Koch2018-01-211-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/openpgpdefs.h (PKT_ENCRYPTED_AEAD): New const. * g10/dek.h (DEK): Increase size of use_aead to 4 bits. * g10/filter.h (cipher_filter_context_t): Add new fields for AEAD. * g10/packet.h (PKT_encrypted): Add fields aead_algo, cipher_algo, and chunkbyte. * g10/build-packet.c (do_encrypted_aead): New. (build_packet): Call it. * g10/parse-packet.c (dump_sig_subpkt): Handle SIGSUBPKT_PREF_AEAD. (parse_one_sig_subpkt, can_handle_critical): Ditto. (parse_encrypted): Clear new PKT_ENCRYPTED fields. (parse_encrypted_aead): New. (parse): Call it. * g10/gpg.c (main): Take care of --rfc4880bis option when checking compliance. * g10/cipher-aead.c: Replace the stub by real code. * g10/decrypt-data.c (decode_filter_ctx_t): Add fields for use with AEAD. (aead_set_nonce): New. (aead_set_ad): New. (decrypt_data): Support AEAD. (aead_underflow): New. (aead_decode_filter): New. * g10/encrypt.c (use_aead): Make that new fucntion work. (encrypt_simple): Use default_aead_algo() instead of EAX. * g10/mainproc.c (proc_encrypted): Support AEAD. (do_proc_packets): Support PKT_ENCRYPTED_AEAD. -- This code has seen only a very few manual tests. Encrypting always uses a 64k chunks and decryption has not been tested with larger chunks. Those small chunks make debugging much faster. Tests can be done using: gpg --rfc4880bis --pinentry-mode=loopback --passphrase abc \ --force-aead --aead-algo ocb --s2k-mode 0 --cipher AES \ -v -z 0 --status-fd 2 -c <INFILE >OUTFILE and gpg --rfc4880bis --pinentry-mode=loopback --passphrase=abc \ --status-fd 2 -v -d <INFILE >OUTFILE Signed-off-by: Werner Koch <[email protected]>
* doc: Comment fixes and one trailing comma fix.Werner Koch2017-07-201-2/+2
| | | | --
* gpg: New option --key-origin.Werner Koch2017-07-131-3/+3
| | | | | | | | | | | | | | | * g10/keydb.h (KEYORG_): Rename to KEYORG_. * g10/packet.h (PKT_user_id): Rename field keysrc to keyorg. Adjust users. (PKT_public_key): Ditto. (PKT_ring_trust): Ditto. * g10/options.h (struct opt): Add field key_origin. * g10/getkey.c (parse_key_origin): New. * g10/gpg.c (oKeyOrigin): New. (opts): Add "keys-origin". (main): Set option. Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix actual leak and possible leaks in the packet parser.Werner Koch2017-03-301-1/+1
| | | | | | | | | | | | | | | * g10/packet.h (struct parse_packet_ctx_s): Change LAST_PKT deom a pointer to its struct. (init_parse_packet): Adjust for LAST_PKT not being a pointer. * g10/parse-packet.c (parse): Ditto. Free the last packet before storing a new one in case of a deep link. (parse_ring_trust): Adjust for LAST_PKT not being a pointer. * g10/free-packet.c (free_packet): Ditto. * g10/t-keydb-get-keyblock.c (do_test): Release keyblock. -- Fixes-commit: afa86809087909a8ba2f9356588bf90cc923529c Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix export porting of zero length user ID packets.Werner Koch2017-03-301-2/+10
| | | | | | | | | | | * g10/build-packet.c (do_user_id): Avoid indeterminate length header. -- We are able to import such user ids but when exporting them the exported data could not be imported again because the parser bails out on invalid keyrings. This is now fixed and should be backported. Signed-off-by: Werner Koch <[email protected]>
* gpg: Revamp reading and writing of ring trust packets.Werner Koch2017-03-301-8/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/parse-packet.c (parse_trust): Rename to ... (parse_ring_trust): this. Change args and implement new ring trust packet format. (parse): Add special ring trust packet handling. * g10/packet.h (PKT_user_id): New fields KEYUPDATE, UPDATEURL, and KEYSRC. (PKT_public_key): Ditto. (RING_TRUST_SIG, RING_TRUST_KEY, RING_TRUST_UID): New consts. (PKT_ring_trust): New. (struct packet_struct): Remove member RING_TRUST. (strcu parse_packet_ctx_s): Add field SKIP_META. (init_parse_packet): Init SKIPT_META. * g10/free-packet.c (release_public_key_parts): Free UDPATEURL. (free_user_id): Ditto. * g10/mainproc.c (list_node): Remove printing of non-documented "rtv" lines. * g10/build-packet.c (build_packet_and_meta): New. (do_ring_trust): New. * g10/export.c (write_keyblock_to_output): Use build_packet_and_meta in backup mode. (do_export_one_keyblock): Ditto. * g10/import.c (read_block): Add arg WITH_META. Skip ring trust packets if that ism not set. (import): Call read_block WITH_META in restore mode. * g10/keydb.h (KEYSRC_UNKNOWN, KEYSRC_FILE, KEYSRC_KS, KEYSRC_PREF_KS) (KEYSRC_WKD, KEYSRC_WKD_SD, KEYSRC_DANE): New constants. They are not yet used, though. * g10/keydb.c (parse_keyblock_image): Allow ring trust packets. (build_keyblock_image): Ditto. Use build_packet_and_meta. * g10/keyring.c (keyring_get_keyblock): Remove specila treatment of ring trust packets. (write_keyblock): Use build_packet_and_meta. Remove special treatment of ring trust packets and initialization of the signature caches. -- This patch introduced the framework to store meta data for keys and user ids in the keyrings/keyboxes. Ring trust packets are implementation defined and have always been used in gpg to cache the signature verification status. Ring trust packets are only exported with the export option "backup" and only imported with the import option "restore". The new code uses a cleaner way to handle the ring trust packets: When the parser reads a ring trust packet and the previously read packet matches the type of that ring trust packet, the information is stored in that previously read packet (signature, user id, or primary key) and the next packet is read immediately. Thus only the parser sees the ring trust packets. Ring trust packets are written by using the new function build_packet_and_meta instead of build_packet. That function writes a ring trust packet when the needed information is available. As a side-effect of this patch the signature status cache works again and "gpg --check-sigs" is thus much faster. Signed-off-by: Werner Koch <[email protected]>
* indent: Re-indent parts of build-packet.cWerner Koch2017-03-291-146/+152
| | | | --
* Remove -I option to common.NIIBE Yutaka2017-03-071-5/+5
| | | | | | | | | | | | | * dirmngr/Makefile.am (AM_CPPFLAGS): Remove -I$(top_srcdir)/common. * g10/Makefile.am (AM_CPPFLAGS): Ditto. * g13/Makefile.am (AM_CPPFLAGS): Ditto. * kbx/Makefile.am (AM_CPPFLAGS): Ditto. * scd/Makefile.am (AM_CPPFLAGS): Ditto. * sm/Makefile.am (AM_CPPFLAGS): Ditto. * tools/Makefile.am (AM_CPPFLAGS): Ditto. * Throughout: Follow the change. Signed-off-by: NIIBE Yutaka <[email protected]>
* Clean up word replication.Yuri Chornoivan2017-02-211-1/+1
| | | | | | | | | -- This fixes extra word repetitions (like "the the" or "is is") in the code and docs. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* Change all http://www.gnu.org in license notices to https://Werner Koch2016-11-051-1/+1
| | | | --
* gpg: Enable the Issuer Fingerprint from rfc4880bisWerner Koch2016-10-281-10/+5
| | | | | | | | | | | | | | | | * g10/build-packet.c (build_sig_subpkt_from_sig): Always write the new Issuer Fingerprint sub-packet. * g10/mainproc.c (check_sig_and_print): Always consider that sub-packet. -- The specs for this sub-packet have been pushed to the OpenPGP WG's repo today. See-also: https://mailarchive.ietf.org/arch/msg/\ openpgp/GvPo2eSL9GW9WcGhOocY7KBa9FY Signed-off-by: Werner Koch <[email protected]>
* gpg: New option --mimemode.Werner Koch2016-07-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | * g10/gpg.c (oMimemode): New. (opts): Add --mimemode. (main): Use --mimemode only in rfc4880bis compliance mode. * g10/options.h (struct opt): Add field "mimemode". * g10/build-packet.c (do_plaintext): Allow for mode 'm'. * g10/encrypt.c (encrypt_simple, encrypt_crypt): Use 'm' if requested. * g10/plaintext.c (handle_plaintext): Handle 'm' mode. * g10/sign.c (write_plaintext_packet): Handle 'm' mode. (sign_file, sign_symencrypt_file): Use 'm' if requested. -- Thsi patch prepares for a proposed change in RFC4880bis to support a MIME flag. A literal data packet with the mime flag set is handled like a 't' or 'u' but CR are not removed. The PLAINTEXT status line will also indicate a MIME content. If --mimemode is used without --rfc4880bis 't' will be used. Signed-off-by: Werner Koch <[email protected]>
* gpg: Add experimental support for an issuer fpr.Werner Koch2016-06-201-14/+35
| | | | | | | | | | | | | | | | | | | | | * common/openpgpdefs.h (SIGSUBPKT_ISSUER_FPR): New. * g10/build-packet.c (build_sig_subpkt_from_sig): Add arg PKSK and insert the issuer fpr if needed. * g10/sign.c (write_signature_packets): Pass signing key. (make_keysig_packet): Ditto. (update_keysig_packet): Ditto. * g10/parse-packet.c (dump_sig_subpkt): Print issuer fpr. (parse_one_sig_subpkt): Detect issuer fpr. (can_handle_critical): Add issuer fpr. * g10/mainproc.c (check_sig_and_print): Try to get key via fingerprint. * g10/gpgv.c (keyserver_import_fprint): New stub. * g10/test-stubs.c (keyserver_import_fprint): New stub. -- This support is enabled with the --rfc4880bis option and intended to test to recently proposed issuer fpr. Signed-off-by: Werner Koch <[email protected]>
* gpg: Do not abort on certain invalid packets.Werner Koch2016-06-021-0/+2
| | | | | | | | | | | | | | | * g10/build-packet.c (write_fake_data): Check for non-opaque data. * g10/seskey.c (do_encode_md): Return NULL instead of abort. -- The first may happen if the usage flags of an algorithm do not match the allowed usage. When writing a backsig this would lead to a log_bug in libgcrypt due to the use of a regular MPI as opaque data. The second may happen with all kind of invalid data. It is easy to avoid an abort, though. Signed-off-by: Werner Koch <[email protected]>
* g10: Allow User ID length >= 256.NIIBE Yutaka2016-06-011-1/+1
| | | | | | | | | | * build-packet.c (do_user_id): Call write_header2 with HDRLEN not set. -- Reported-by: Daniel Kahn Gillmor <[email protected]> GnuPG-bug-id: 2374 Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: New status code NOTATION_FLAGS.Werner Koch2016-05-311-2/+4
| | | | | | | | * common/status.h (STATUS_NOTATION_FLAGS: New. * g10/packet.h (struct notation): Add flags.human. (notation_t): New typedef. * g10/build-packet.c (sig_to_notation): Set flags.human. * g10/keylist.c (show_notation): Write STATUS_NOTATION_FLAGS.
* Some minor string changes and fixed a printf format.Werner Koch2016-05-041-1/+1
| | | | | | | * g10/build-packet.c (notation_value_to_human_readable_string): Use %zu for size_t. Signed-off-by: Werner Koch <[email protected]>
* gpg: Remove all assert.h and s/assert/log_assert/.Werner Koch2016-04-291-7/+6
| | | | Signed-off-by: Werner Koch <[email protected]>
* g10: Fix exporting secret keys of certain sizes.Justus Winter2016-04-071-1/+1
| | | | | | | | | | | | | * g10/build-packet.c (do_key): Do not use the header length specified by the public key packet from the keyring, but let 'write_header2' compute the required length. -- Specifically exporting RSA keys of length 1024 failed, as the encoded public key packet requires 141 bytes a length that fits into one byte, but the secret key is significantly larger, making the export fail. GnuPG-bug-id: 2307 Signed-off-by: Justus Winter <[email protected]>
* gpg: Allow the caller to write the contents of a plaintext packet.Neal H. Walfield2016-03-021-8/+16
| | | | | | | | | * g10/build-packet.c (do_plaintext): Change the semantics such that if PT->BUF is NULL, it is the caller's responsibility to write the content (and disable partial body length mode, if appropriate). -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Add a new function for creating binary notations.Neal H. Walfield2016-03-021-2/+77
| | | | | | | * g10/build-packet.c (blob_to_notation): New function. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Refactor the printing of binary notations.Neal H. Walfield2016-03-021-4/+28
| | | | | | | | | | | * g10/build-packet.c (sig_to_notation): Break printing of binary notations into... (notation_value_to_human_readable_string): ... this new function. Provide a small preview of the binary data substituting non-printable characters with '?'. -- Signed-off-by: Neal H. Walfield <[email protected]>
* 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-251-12/+165
| | | | | -- 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]>
* gpg: Use higher-level functions.Neal H. Walfield2016-02-231-16/+6
| | | | | | | | | | * 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: More accurately name function.Neal H. Walfield2016-02-231-2/+2
| | | | | | | | * 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]>
* 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: Create all MPIs with RFC-4880 correct length headers.Werner Koch2015-03-161-1/+19
| | | | | | | | | | * g10/build-packet.c (gpg_mpi_write): Strip leading zeroes. -- This used not to work with opaque MPI as returned by Libgcrypt from ECC operations. This patch fixes this. Signed-off-by: Werner Koch <[email protected]>