1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-09 21:28:51 +01:00
Commit Graph

8708 Commits

Author SHA1 Message Date
NIIBE Yutaka
37aa23c55c ecc-sos: Fix gpg-agent for SOS handling.
* agent/cvt-openpgp.c (scan_pgp_format): New.
(do_unprotect): Fix NBITS in SOS.  Use scan_pgp_format.
(convert_from_openpgp_main): Always use opaque MPI.
Use GCRYMPI_FLAG_USER1 for encrypted data.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-18 15:45:31 +09:00
NIIBE Yutaka
1e079f4601 ecc-sos: gpg-agent access ECC public key as opaque string.
* agent/cvt-openpgp.c (extract_private_key): Use "/q" for public key.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-14 16:45:15 +09:00
NIIBE Yutaka
8513ab8bf3 ecc-sos: Use opaque for key from agent.
* g10/export.c (cleartext_secret_key_to_openpgp): Use /q.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-14 14:56:23 +09:00
NIIBE Yutaka
93cefe9497 ecc-sos: Compatible mode for SOS.
* g10/build-packet.c (sos_write): Add an argument COMPAT.  When
COMPAT=1, NBITS specifies number of bits when interpreted as MPI,
except the case when the first octet is zero.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-14 14:28:39 +09:00
NIIBE Yutaka
58ad686bfe ecc-sos: No need to expose sos_write.
* g10/build-packet.c (sos_write): Rename from gpg_sos_write.
* g10/packet.h (gpg_sos_write): Remove.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-14 14:10:23 +09:00
NIIBE Yutaka
e02347b2ab ecc-sos: Clean up use of mpi_get_opaque.
* g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Tidy up.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-12 13:42:07 +09:00
NIIBE Yutaka
e6c975280a ecc-sos: Remove zero-octet removal on write.
* g10/build-packet.c (gpg_mpi_write): Don't remove zero bits.
* g10/packet.h (CALC_NBITS): Remove.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-08 11:42:20 +09:00
NIIBE Yutaka
70af2165ec ecc-sos: Fix gpg_mpi_write for opaque bit string.
* g10/build-packet.c (gpg_mpi_write): Handle opaque bit string
when it's has exact number of bits.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 19:00:38 +09:00
NIIBE Yutaka
4cc4ff03a2 ecc-sos: Fix reading SEXP from agent.
* g10/keygen.c (ecckey_from_sexp): Use GCRYMPI_FMT_OPAQUE.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 13:12:09 +09:00
NIIBE Yutaka
a9b31fc3e4 ecc-sos: Fix parsing key for EdDSA/ECDH.
* g10/parse-packet.c (parse_key): Read by sos_read.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 11:56:28 +09:00
NIIBE Yutaka
ed4c1e213a ecc-sos: public key is MPI with the prefix 0x40.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
f27a581090 sos: don't change NBITS.
For SOS, an ECC point with prefix 0x40 can be represented in two ways.
One for 0x40 interpreted as 7-bit, another as 8-bit (MSB is zero).

This matters for fingerprint computation, so, the representation
should be preserved, or we should use another flag to hold the
difference in the representation...

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
638328a33d sos: Fix fingerprint computation.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
f031b0fb6c agent: Fix converting to OpenPGP.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
3fae9540c6 Fix exporting key for ECC.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
0e40b033b8 gpg: Fix for the condition calling gpg_sos_write.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
5b094067f7 gpg: Use opaque MPI for shared point.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
b73fef0376 gpg: Implement the fix-up of zero for SOS.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
ac977526ac gpg: Use opaque MPI for ECDH.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
c31fd44737 gpg: Use GCRYMPI_FLAG_USER2 for SOS, and hash_public_key with that.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:08 +09:00
NIIBE Yutaka
93bcc87bd0 Add sos_read.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:07 +09:00
NIIBE Yutaka
120f4e8c67 gpg: Use opaque byte MPI interface for ECC key.
* g10/keygen.c (ecckey_from_sexp): Parse by GCRYMPI_FMT_OPAQUE.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:07 +09:00
NIIBE Yutaka
2096965c53 gpg: Introduce SOS (Simply Octet String) support.
* g10/build-packet.c (gpg_sos_write): New.
(do_key): Use gpg_sos_write.
(do_signature): Use gpg_sos_write for EdDSA.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-05-04 10:57:07 +09:00
Werner Koch
5da6925a33
sm: Add support to export ECC private keys.
* sm/minip12.c [TEST]: Remove test code.  Include util.h, tlv.h. and
openpgpdefs.h.  Remove the class and tag constants and replace them by
those from tlv.h.
(builder_add_oid, builder_add_mpi): New.
(build_key_sequence): Rename to ...
(build_rsa_key_sequence): this.
(build_ecc_key_sequence): New.
(p12_build): Call RSA or ECC builder.
(p12_raw_build): Ditto.
* sm/export.c (gpgsm_p12_export): Use correct armor header for ECC.
(sexp_to_kparms): Support ECC.

* sm/t-minip12.c: New to replace the former TEST code in minip12.h.
--

GnuPG-bug-id: 4921
2020-04-27 19:54:39 +02:00
Werner Koch
5ea878274e
common: Add an easy to use DER builder.
* common/tlv-builder.c: New.
* common/tlv.c: Remove stuff only used by GnuPG 1.
(put_tlv_to_membuf, get_tlv_length): Move to ...
* common/tlv-builder.c: here.
* common/tlv.h (tlv_builder_t): New.
--

Such code should actually go into libksba and we will eventually do
that.  However, for now it is easier to keep it here.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-24 15:37:48 +02:00
Werner Koch
c03f80dc19
sm: Minor debug output format changes.
--
2020-04-23 10:00:18 +02:00
Werner Koch
95d83cf906
sm: Support decryption of ECDH data.
* sm/decrypt.c: Include tlv.h.
(string_from_gcry_buffer): New.
(hash_ecc_cms_shared_info): New.
(ecdh_decrypt): New.
(prepare_decryption): Support ECDH.  Add arg pk_algo.
(gpgsm_decrypt): Lift some variables from an inner code block.
--

Note: This has only been tested with a single messages created by
OpenSSL and taken from the Mozilla bug tracker.  In particular the
code to included UserKeyingMaterial (ukm) has not been tested.

GnuPG-bug-id: 4098
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-23 09:59:13 +02:00
Werner Koch
5d015b38eb
common: Add functions to help create DER objects.
* common/tlv.c (put_tlv_to_membuf): New.
(get_tlv_length): New.
* common/tlv.h: Include membuf.h.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-23 09:51:15 +02:00
Werner Koch
8dfef5197a
sm: Support import of PKCS#12 encoded ECC private keys.
* sm/minip12.c: Include ksba.h.
(oid_pcPublicKey): New const.
(parse_bag_data): Add arg 'r-curve'.  Support parsing of ECC private
keys.
(p12_parse): Add arg 'r_curve'.
* sm/import.c (parse_p12): Support ECC import.
--

GnuPG-bug-id: 4921
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-21 21:05:39 +02:00
Werner Koch
a6d2f31337
sm: Replace some debug message by log_error or log_info
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-21 21:05:32 +02:00
Werner Koch
f05a32e5c9
scd:nks: Allow retrieving certificates from a Signature Card v.20
* scd/app-nks.c: Major rework to support non-RSA cards.
--

This is a fist step so support this ECC card.  The code has been
reworked while taking care that old cards should keep on working.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-17 16:09:58 +02:00
Werner Koch
3633ca6e21
scd: Detect missing card in "getinfo all_active_apps".
* scd/app.c (send_card_and_app_list): Detect no app case.
--

This is a minor nug fix to return a better error message.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-17 16:09:54 +02:00
Werner Koch
bbb7edb880
sm: Always allow authorityInfoAccess lookup if CRLs are also enabled.
* sm/certchain.c (find_up): Disable external lookups in offline mode.
Always allow AKI lookup if CRLs are also enabled.
--

GnuPG-bug-id: 4898
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-16 19:05:49 +02:00
Werner Koch
f5efbd5a11
sm: Lookup missing issuers first using authorityInfoAccess.
* sm/call-dirmngr.c (gpgsm_dirmngr_lookup): Add optional arg URL and
adjust all callers.
* sm/certchain.c (oidstr_caIssuers): New.
(struct find_up_store_certs_s): Add additional fields.
(find_up_store_certs_cb): Store the fingerprint.
(find_up_via_auth_info_access): New.
(find_up): Try the AIA URI first.
--

Note that --auto-issuer-key-retrieve is required to use that.

GnuPG-bug-id: 4898
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-16 18:03:13 +02:00
Werner Koch
7f1be1ea52
dirmngr: Allow http URLs with "LOOKUP --url"
* dirmngr/crlfetch.c (read_cert_via_http): New.
(fetch_cert_by_url): Implement http scheme.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-16 17:53:27 +02:00
Werner Koch
cec397e002
gpg: Make AEAD modes subject to compliance checks.
* g10/decrypt-data.c (decrypt_data): Move aead algo detection up.
--

Note that the AEAD modes are not yet approved for --compliance=de-vs

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-16 08:52:29 +02:00
Werner Koch
5c47e7825b
indent: Some typo and indentation changes for gpg.
--
2020-04-15 22:23:10 +02:00
Werner Koch
df0edaf91a
gpg: Fix broken setting of AEAD algo.
* g10/main.h (DEFAULT_AEAD_ALGO): Set to OCB.
--

With the old code and using libgcrypt 1.9 would have switched from the
high performance OCB to the ugly EAX mode.  We are free software, we
are OCB.
2020-04-15 22:21:46 +02:00
Werner Koch
c0d5c67354
sm,dirmngr: Restrict allowed parameters used with rsaPSS.
* sm/certcheck.c (extract_pss_params): Check the used PSS params.
* dirmngr/crlcache.c (finish_sig_check): Ditto.
* dirmngr/validate.c (check_cert_sig): Ditto.
--

GnuPG-bug-id: 4538

# ------------------------ >8 ------------------------
See
https://www.metzdowd.com/pipermail/cryptography/2019-November/035449.html

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-15 11:06:59 +02:00
NIIBE Yutaka
50b320952e regexp: Fix generation of _unicode_mapping.c.
* configure.ac (AWK_HEX_NUMBER_OPTION): Detect GNU Awk.
* regexp/Makefile.am: Use AWK_HEX_NUMBER_OPTION.
* regexp/parse-unidata.awk: Don't use strtonum.

GnuPG-bug-id: 4915
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-04-15 14:10:08 +09:00
Werner Koch
6c28d9343e
sm: Support rsaPSS verification also for CMS signatures.
* sm/certcheck.c (gpgsm_check_cert_sig): Factor PSS parsing out to ...
(extract_pss_params): new.
(gpgsm_check_cms_signature): Implement PSS.
--

GnuPG-bug-id: 4538
2020-04-14 15:46:04 +02:00
Werner Koch
ba34f14153
dirmngr: Support rsaPSS also in the general validate module.
* dirmngr/validate.c (hash_algo_from_buffer): New.
(uint_from_buffer): New.
(check_cert_sig): Support rsaPSS.
* sm/certcheck.c (gpgsm_check_cert_sig): Fix small memory leak on
error.
--

Yes, I know that there is a lot of code duplication.  In fact some of
the code is ugly and it would be better if we enhance Libgcrypt to
guarantee that returned memory buffers via gcry_sexp_extract_param are
allways Nul terminated and we should also enhance that function to
directly extract into an unsigned int or char *.

GnuPG-bug-id: 4538
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-09 13:05:55 +02:00
Werner Koch
b45ab0ca08
sm,dirmngr: Support rsaPSS signature verification.
* sm/certcheck.c (hash_algo_from_buffer): New.
(uint_from_buffer): New.
(gpgsm_check_cert_sig): Handle PSS.
* dirmngr/crlcache.c (hash_algo_from_buffer): New.
(uint_from_buffer): New.
(start_sig_check): Detect PSS and extract hash algo.  New arg to
return a PSS flag.
(finish_sig_check): New arg use_pss.  Extract PSS args and use them.
(crl_parse_insert): Pass use_pss flag along.
--

GnuPG-bug-id: 4538
Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-09 12:20:19 +02:00
Werner Koch
5d5b70ae0f
common: New function to map hash algo names.
* common/sexputil.c (hash_algo_to_string): New.
--

Libgcrypt expects lowercase names and it is cumbersome to downcase
those retrieved via gcry_md_algo_name.  It is easier and also faster
to use a dedicated map function.
2020-04-09 12:20:19 +02:00
Werner Koch
bfedc760ef
scd:p15: Return a display S/N via Assuan.
* scd/app-p15.c (make_pin_prompt): Factor some code out to ...
(get_dispserialno): this.
(do_getattr): Use new fucntion for a $DISPSERIALNO.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-09 12:20:18 +02:00
NIIBE Yutaka
fd79cadf7b gpg: ECDH: Accept longer padding.
* g10/pubkey-enc.c (get_it): Remove check which mandates shorter
padding.

--

According to the section 8 of RFC 6637, the sender MAY use 21 bytes of
padding for AES-128 to provide 40-byte "m".

Reported-by: Metin Savignano
GnuPG-bug-id: 4908
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2020-04-08 09:29:43 +09:00
Werner Koch
9ec8d984be
scd:p15: Show a pretty PIN prompt.
* scd/app-p15.c (struct prkdf_object_s): New fields common_name and
serial_number.
(release_prkdflist): Free them.
(keygrip_from_prkdf): Parse cert and set them.
(any_control_or_space): New.
(make_pin_prompt): New.
(verify_pin): Construct a pretty PIN prompt.
(do_sign): Remove debug output.
--

The D-Trust card has the SerialNumber part of the Subject printed on
the front matter, we assume this is also possible with other cards and
thus we show this as serial number.

The holder of the card is also extracted from the card's subject.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-07 20:38:15 +02:00
Werner Koch
f28795b615
scd: Return GPG_ERR_BAD_PIN on 0x63Cn status word.
* scd/iso7816.c (map_sw): Detect 0x63Cn status code.
--

I really wonder when that got lost and we ended up with a simple card
error.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-07 19:09:27 +02:00
Werner Koch
60d018f6a9
scd: Factor common PIN status check out.
* scd/iso7816.h (ISO7816_VERIFY_ERROR): New.
(ISO7816_VERIFY_NO_PIN): New.
(ISO7816_VERIFY_BLOCKED): New.
(ISO7816_VERIFY_NULLPIN): New.
(ISO7816_VERIFY_NOT_NEEDED): New.
* scd/iso7816.c (iso7816_verify_status): New.
* scd/app-nks.c (get_chv_status): Use new function.
* scd/app-piv.c (get_chv_status): Ditto.
(verify_chv): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2020-04-07 18:26:00 +02:00
Werner Koch
5ec1f66793
doc: Typo fix in code comment.
--
2020-04-07 16:03:21 +02:00