diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2022-09-16 07:45:18 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2022-09-16 07:45:18 +0900 |
commit | b8e317c2a634907810564598cde8cf691ef03d88 (patch) | |
tree | 7978657ccc96ec5a55c31801e14bca75291cfe4c /common | |
parent | 028733bb89982a39cf1341937417c9d76f39b2ef (diff) | |
download | gpg2-b8e317c2a634907810564598cde8cf691ef03d88.tar.gz gpg2-b8e317c2a634907810564598cde8cf691ef03d88.tar.bz2 gpg2-b8e317c2a634907810564598cde8cf691ef03d88.zip |
Imported Upstream version 2.3.1upstream/2.3.1
Diffstat (limited to 'common')
-rw-r--r-- | common/Makefile.am | 2 | ||||
-rw-r--r-- | common/Makefile.in | 97 | ||||
-rw-r--r-- | common/comopt.c | 131 | ||||
-rw-r--r-- | common/comopt.h | 50 | ||||
-rw-r--r-- | common/exechelp-posix.c | 7 | ||||
-rw-r--r-- | common/name-value.c | 6 | ||||
-rw-r--r-- | common/openpgp-fpr.c | 283 | ||||
-rw-r--r-- | common/openpgpdefs.h | 20 | ||||
-rw-r--r-- | common/recsel.c | 8 |
9 files changed, 591 insertions, 13 deletions
diff --git a/common/Makefile.am b/common/Makefile.am index 2621634..62bc9c9 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -97,6 +97,8 @@ common_sources = \ name-value.c name-value.h \ recsel.c recsel.h \ ksba-io-support.c ksba-io-support.h \ + openpgp-fpr.c \ + comopt.c comopt.h \ compliance.c compliance.h \ pkscreening.c pkscreening.h diff --git a/common/Makefile.in b/common/Makefile.in index 73e60d3..923673d 100644 --- a/common/Makefile.in +++ b/common/Makefile.in @@ -216,10 +216,10 @@ am__libcommon_a_SOURCES_DIST = common-defs.h util.h utilproto.h \ agent-opt.c helpfile.c mkdir_p.c mkdir_p.h exectool.c \ exectool.h server-help.c server-help.h name-value.c \ name-value.h recsel.c recsel.h ksba-io-support.c \ - ksba-io-support.h compliance.c compliance.h pkscreening.c \ - pkscreening.h w32-reg.c w32-cmdline.c exechelp-w32ce.c \ - exechelp-w32.c exechelp-posix.c get-passphrase.c \ - get-passphrase.h + ksba-io-support.h openpgp-fpr.c comopt.c comopt.h compliance.c \ + compliance.h pkscreening.c pkscreening.h w32-reg.c \ + w32-cmdline.c exechelp-w32ce.c exechelp-w32.c exechelp-posix.c \ + get-passphrase.c get-passphrase.h @HAVE_W32_SYSTEM_TRUE@am__objects_1 = libcommon_a-w32-reg.$(OBJEXT) \ @HAVE_W32_SYSTEM_TRUE@ libcommon_a-w32-cmdline.$(OBJEXT) @HAVE_W32CE_SYSTEM_TRUE@@HAVE_W32_SYSTEM_TRUE@am__objects_2 = libcommon_a-exechelp-w32ce.$(OBJEXT) @@ -256,6 +256,7 @@ am__objects_5 = libcommon_a-i18n.$(OBJEXT) \ libcommon_a-server-help.$(OBJEXT) \ libcommon_a-name-value.$(OBJEXT) libcommon_a-recsel.$(OBJEXT) \ libcommon_a-ksba-io-support.$(OBJEXT) \ + libcommon_a-openpgp-fpr.$(OBJEXT) libcommon_a-comopt.$(OBJEXT) \ libcommon_a-compliance.$(OBJEXT) \ libcommon_a-pkscreening.$(OBJEXT) $(am__objects_1) \ $(am__objects_2) $(am__objects_3) $(am__objects_4) @@ -281,9 +282,10 @@ am__libcommonpth_a_SOURCES_DIST = common-defs.h util.h utilproto.h \ agent-opt.c helpfile.c mkdir_p.c mkdir_p.h exectool.c \ exectool.h server-help.c server-help.h name-value.c \ name-value.h recsel.c recsel.h ksba-io-support.c \ - ksba-io-support.h compliance.c compliance.h pkscreening.c \ - pkscreening.h w32-reg.c w32-cmdline.c exechelp-w32ce.c \ - exechelp-w32.c exechelp-posix.c call-gpg.c call-gpg.h + ksba-io-support.h openpgp-fpr.c comopt.c comopt.h compliance.c \ + compliance.h pkscreening.c pkscreening.h w32-reg.c \ + w32-cmdline.c exechelp-w32ce.c exechelp-w32.c exechelp-posix.c \ + call-gpg.c call-gpg.h @HAVE_W32_SYSTEM_TRUE@am__objects_7 = \ @HAVE_W32_SYSTEM_TRUE@ libcommonpth_a-w32-reg.$(OBJEXT) \ @HAVE_W32_SYSTEM_TRUE@ libcommonpth_a-w32-cmdline.$(OBJEXT) @@ -333,6 +335,8 @@ am__objects_11 = libcommonpth_a-i18n.$(OBJEXT) \ libcommonpth_a-name-value.$(OBJEXT) \ libcommonpth_a-recsel.$(OBJEXT) \ libcommonpth_a-ksba-io-support.$(OBJEXT) \ + libcommonpth_a-openpgp-fpr.$(OBJEXT) \ + libcommonpth_a-comopt.$(OBJEXT) \ libcommonpth_a-compliance.$(OBJEXT) \ libcommonpth_a-pkscreening.$(OBJEXT) $(am__objects_7) \ $(am__objects_8) $(am__objects_9) $(am__objects_10) @@ -454,6 +458,7 @@ am__depfiles_remade = ./$(DEPDIR)/gpgrlhelp.Po \ ./$(DEPDIR)/libcommon_a-b64dec.Po \ ./$(DEPDIR)/libcommon_a-b64enc.Po \ ./$(DEPDIR)/libcommon_a-ccparray.Po \ + ./$(DEPDIR)/libcommon_a-comopt.Po \ ./$(DEPDIR)/libcommon_a-compliance.Po \ ./$(DEPDIR)/libcommon_a-convert.Po \ ./$(DEPDIR)/libcommon_a-dotlock.Po \ @@ -477,6 +482,7 @@ am__depfiles_remade = ./$(DEPDIR)/gpgrlhelp.Po \ ./$(DEPDIR)/libcommon_a-mischelp.Po \ ./$(DEPDIR)/libcommon_a-mkdir_p.Po \ ./$(DEPDIR)/libcommon_a-name-value.Po \ + ./$(DEPDIR)/libcommon_a-openpgp-fpr.Po \ ./$(DEPDIR)/libcommon_a-openpgp-oid.Po \ ./$(DEPDIR)/libcommon_a-openpgp-s2k.Po \ ./$(DEPDIR)/libcommon_a-percent.Po \ @@ -510,6 +516,7 @@ am__depfiles_remade = ./$(DEPDIR)/gpgrlhelp.Po \ ./$(DEPDIR)/libcommonpth_a-b64enc.Po \ ./$(DEPDIR)/libcommonpth_a-call-gpg.Po \ ./$(DEPDIR)/libcommonpth_a-ccparray.Po \ + ./$(DEPDIR)/libcommonpth_a-comopt.Po \ ./$(DEPDIR)/libcommonpth_a-compliance.Po \ ./$(DEPDIR)/libcommonpth_a-convert.Po \ ./$(DEPDIR)/libcommonpth_a-dotlock.Po \ @@ -532,6 +539,7 @@ am__depfiles_remade = ./$(DEPDIR)/gpgrlhelp.Po \ ./$(DEPDIR)/libcommonpth_a-mischelp.Po \ ./$(DEPDIR)/libcommonpth_a-mkdir_p.Po \ ./$(DEPDIR)/libcommonpth_a-name-value.Po \ + ./$(DEPDIR)/libcommonpth_a-openpgp-fpr.Po \ ./$(DEPDIR)/libcommonpth_a-openpgp-oid.Po \ ./$(DEPDIR)/libcommonpth_a-openpgp-s2k.Po \ ./$(DEPDIR)/libcommonpth_a-percent.Po \ @@ -899,9 +907,10 @@ common_sources = common-defs.h util.h utilproto.h fwddecl.h i18n.c \ ssh-utils.c ssh-utils.h agent-opt.c helpfile.c mkdir_p.c \ mkdir_p.h strlist.c strlist.h exectool.c exectool.h \ server-help.c server-help.h name-value.c name-value.h recsel.c \ - recsel.h ksba-io-support.c ksba-io-support.h compliance.c \ - compliance.h pkscreening.c pkscreening.h $(am__append_10) \ - $(am__append_11) $(am__append_12) $(am__append_13) + recsel.h ksba-io-support.c ksba-io-support.h openpgp-fpr.c \ + comopt.c comopt.h compliance.c compliance.h pkscreening.c \ + pkscreening.h $(am__append_10) $(am__append_11) \ + $(am__append_12) $(am__append_13) # Sources only useful without NPTH. without_npth_sources = \ @@ -1149,6 +1158,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-b64dec.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-b64enc.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-ccparray.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-comopt.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-compliance.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-convert.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-dotlock.Po@am__quote@ # am--include-marker @@ -1172,6 +1182,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-mischelp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-mkdir_p.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-name-value.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-openpgp-fpr.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-openpgp-oid.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-openpgp-s2k.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommon_a-percent.Po@am__quote@ # am--include-marker @@ -1205,6 +1216,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-b64enc.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-call-gpg.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-ccparray.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-comopt.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-compliance.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-convert.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-dotlock.Po@am__quote@ # am--include-marker @@ -1227,6 +1239,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-mischelp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-mkdir_p.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-name-value.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-openpgp-fpr.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-openpgp-oid.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-openpgp-s2k.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcommonpth_a-percent.Po@am__quote@ # am--include-marker @@ -1958,6 +1971,34 @@ libcommon_a-ksba-io-support.obj: ksba-io-support.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -c -o libcommon_a-ksba-io-support.obj `if test -f 'ksba-io-support.c'; then $(CYGPATH_W) 'ksba-io-support.c'; else $(CYGPATH_W) '$(srcdir)/ksba-io-support.c'; fi` +libcommon_a-openpgp-fpr.o: openpgp-fpr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -MT libcommon_a-openpgp-fpr.o -MD -MP -MF $(DEPDIR)/libcommon_a-openpgp-fpr.Tpo -c -o libcommon_a-openpgp-fpr.o `test -f 'openpgp-fpr.c' || echo '$(srcdir)/'`openpgp-fpr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommon_a-openpgp-fpr.Tpo $(DEPDIR)/libcommon_a-openpgp-fpr.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='openpgp-fpr.c' object='libcommon_a-openpgp-fpr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -c -o libcommon_a-openpgp-fpr.o `test -f 'openpgp-fpr.c' || echo '$(srcdir)/'`openpgp-fpr.c + +libcommon_a-openpgp-fpr.obj: openpgp-fpr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -MT libcommon_a-openpgp-fpr.obj -MD -MP -MF $(DEPDIR)/libcommon_a-openpgp-fpr.Tpo -c -o libcommon_a-openpgp-fpr.obj `if test -f 'openpgp-fpr.c'; then $(CYGPATH_W) 'openpgp-fpr.c'; else $(CYGPATH_W) '$(srcdir)/openpgp-fpr.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommon_a-openpgp-fpr.Tpo $(DEPDIR)/libcommon_a-openpgp-fpr.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='openpgp-fpr.c' object='libcommon_a-openpgp-fpr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -c -o libcommon_a-openpgp-fpr.obj `if test -f 'openpgp-fpr.c'; then $(CYGPATH_W) 'openpgp-fpr.c'; else $(CYGPATH_W) '$(srcdir)/openpgp-fpr.c'; fi` + +libcommon_a-comopt.o: comopt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -MT libcommon_a-comopt.o -MD -MP -MF $(DEPDIR)/libcommon_a-comopt.Tpo -c -o libcommon_a-comopt.o `test -f 'comopt.c' || echo '$(srcdir)/'`comopt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommon_a-comopt.Tpo $(DEPDIR)/libcommon_a-comopt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comopt.c' object='libcommon_a-comopt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -c -o libcommon_a-comopt.o `test -f 'comopt.c' || echo '$(srcdir)/'`comopt.c + +libcommon_a-comopt.obj: comopt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -MT libcommon_a-comopt.obj -MD -MP -MF $(DEPDIR)/libcommon_a-comopt.Tpo -c -o libcommon_a-comopt.obj `if test -f 'comopt.c'; then $(CYGPATH_W) 'comopt.c'; else $(CYGPATH_W) '$(srcdir)/comopt.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommon_a-comopt.Tpo $(DEPDIR)/libcommon_a-comopt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comopt.c' object='libcommon_a-comopt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -c -o libcommon_a-comopt.obj `if test -f 'comopt.c'; then $(CYGPATH_W) 'comopt.c'; else $(CYGPATH_W) '$(srcdir)/comopt.c'; fi` + libcommon_a-compliance.o: compliance.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommon_a_CFLAGS) $(CFLAGS) -MT libcommon_a-compliance.o -MD -MP -MF $(DEPDIR)/libcommon_a-compliance.Tpo -c -o libcommon_a-compliance.o `test -f 'compliance.c' || echo '$(srcdir)/'`compliance.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommon_a-compliance.Tpo $(DEPDIR)/libcommon_a-compliance.Po @@ -2728,6 +2769,34 @@ libcommonpth_a-ksba-io-support.obj: ksba-io-support.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -c -o libcommonpth_a-ksba-io-support.obj `if test -f 'ksba-io-support.c'; then $(CYGPATH_W) 'ksba-io-support.c'; else $(CYGPATH_W) '$(srcdir)/ksba-io-support.c'; fi` +libcommonpth_a-openpgp-fpr.o: openpgp-fpr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -MT libcommonpth_a-openpgp-fpr.o -MD -MP -MF $(DEPDIR)/libcommonpth_a-openpgp-fpr.Tpo -c -o libcommonpth_a-openpgp-fpr.o `test -f 'openpgp-fpr.c' || echo '$(srcdir)/'`openpgp-fpr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommonpth_a-openpgp-fpr.Tpo $(DEPDIR)/libcommonpth_a-openpgp-fpr.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='openpgp-fpr.c' object='libcommonpth_a-openpgp-fpr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -c -o libcommonpth_a-openpgp-fpr.o `test -f 'openpgp-fpr.c' || echo '$(srcdir)/'`openpgp-fpr.c + +libcommonpth_a-openpgp-fpr.obj: openpgp-fpr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -MT libcommonpth_a-openpgp-fpr.obj -MD -MP -MF $(DEPDIR)/libcommonpth_a-openpgp-fpr.Tpo -c -o libcommonpth_a-openpgp-fpr.obj `if test -f 'openpgp-fpr.c'; then $(CYGPATH_W) 'openpgp-fpr.c'; else $(CYGPATH_W) '$(srcdir)/openpgp-fpr.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommonpth_a-openpgp-fpr.Tpo $(DEPDIR)/libcommonpth_a-openpgp-fpr.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='openpgp-fpr.c' object='libcommonpth_a-openpgp-fpr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -c -o libcommonpth_a-openpgp-fpr.obj `if test -f 'openpgp-fpr.c'; then $(CYGPATH_W) 'openpgp-fpr.c'; else $(CYGPATH_W) '$(srcdir)/openpgp-fpr.c'; fi` + +libcommonpth_a-comopt.o: comopt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -MT libcommonpth_a-comopt.o -MD -MP -MF $(DEPDIR)/libcommonpth_a-comopt.Tpo -c -o libcommonpth_a-comopt.o `test -f 'comopt.c' || echo '$(srcdir)/'`comopt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommonpth_a-comopt.Tpo $(DEPDIR)/libcommonpth_a-comopt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comopt.c' object='libcommonpth_a-comopt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -c -o libcommonpth_a-comopt.o `test -f 'comopt.c' || echo '$(srcdir)/'`comopt.c + +libcommonpth_a-comopt.obj: comopt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -MT libcommonpth_a-comopt.obj -MD -MP -MF $(DEPDIR)/libcommonpth_a-comopt.Tpo -c -o libcommonpth_a-comopt.obj `if test -f 'comopt.c'; then $(CYGPATH_W) 'comopt.c'; else $(CYGPATH_W) '$(srcdir)/comopt.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommonpth_a-comopt.Tpo $(DEPDIR)/libcommonpth_a-comopt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comopt.c' object='libcommonpth_a-comopt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -c -o libcommonpth_a-comopt.obj `if test -f 'comopt.c'; then $(CYGPATH_W) 'comopt.c'; else $(CYGPATH_W) '$(srcdir)/comopt.c'; fi` + libcommonpth_a-compliance.o: compliance.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcommonpth_a_CFLAGS) $(CFLAGS) -MT libcommonpth_a-compliance.o -MD -MP -MF $(DEPDIR)/libcommonpth_a-compliance.Tpo -c -o libcommonpth_a-compliance.o `test -f 'compliance.c' || echo '$(srcdir)/'`compliance.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcommonpth_a-compliance.Tpo $(DEPDIR)/libcommonpth_a-compliance.Po @@ -3100,6 +3169,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/libcommon_a-b64dec.Po -rm -f ./$(DEPDIR)/libcommon_a-b64enc.Po -rm -f ./$(DEPDIR)/libcommon_a-ccparray.Po + -rm -f ./$(DEPDIR)/libcommon_a-comopt.Po -rm -f ./$(DEPDIR)/libcommon_a-compliance.Po -rm -f ./$(DEPDIR)/libcommon_a-convert.Po -rm -f ./$(DEPDIR)/libcommon_a-dotlock.Po @@ -3123,6 +3193,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/libcommon_a-mischelp.Po -rm -f ./$(DEPDIR)/libcommon_a-mkdir_p.Po -rm -f ./$(DEPDIR)/libcommon_a-name-value.Po + -rm -f ./$(DEPDIR)/libcommon_a-openpgp-fpr.Po -rm -f ./$(DEPDIR)/libcommon_a-openpgp-oid.Po -rm -f ./$(DEPDIR)/libcommon_a-openpgp-s2k.Po -rm -f ./$(DEPDIR)/libcommon_a-percent.Po @@ -3156,6 +3227,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/libcommonpth_a-b64enc.Po -rm -f ./$(DEPDIR)/libcommonpth_a-call-gpg.Po -rm -f ./$(DEPDIR)/libcommonpth_a-ccparray.Po + -rm -f ./$(DEPDIR)/libcommonpth_a-comopt.Po -rm -f ./$(DEPDIR)/libcommonpth_a-compliance.Po -rm -f ./$(DEPDIR)/libcommonpth_a-convert.Po -rm -f ./$(DEPDIR)/libcommonpth_a-dotlock.Po @@ -3178,6 +3250,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/libcommonpth_a-mischelp.Po -rm -f ./$(DEPDIR)/libcommonpth_a-mkdir_p.Po -rm -f ./$(DEPDIR)/libcommonpth_a-name-value.Po + -rm -f ./$(DEPDIR)/libcommonpth_a-openpgp-fpr.Po -rm -f ./$(DEPDIR)/libcommonpth_a-openpgp-oid.Po -rm -f ./$(DEPDIR)/libcommonpth_a-openpgp-s2k.Po -rm -f ./$(DEPDIR)/libcommonpth_a-percent.Po @@ -3283,6 +3356,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libcommon_a-b64dec.Po -rm -f ./$(DEPDIR)/libcommon_a-b64enc.Po -rm -f ./$(DEPDIR)/libcommon_a-ccparray.Po + -rm -f ./$(DEPDIR)/libcommon_a-comopt.Po -rm -f ./$(DEPDIR)/libcommon_a-compliance.Po -rm -f ./$(DEPDIR)/libcommon_a-convert.Po -rm -f ./$(DEPDIR)/libcommon_a-dotlock.Po @@ -3306,6 +3380,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libcommon_a-mischelp.Po -rm -f ./$(DEPDIR)/libcommon_a-mkdir_p.Po -rm -f ./$(DEPDIR)/libcommon_a-name-value.Po + -rm -f ./$(DEPDIR)/libcommon_a-openpgp-fpr.Po -rm -f ./$(DEPDIR)/libcommon_a-openpgp-oid.Po -rm -f ./$(DEPDIR)/libcommon_a-openpgp-s2k.Po -rm -f ./$(DEPDIR)/libcommon_a-percent.Po @@ -3339,6 +3414,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libcommonpth_a-b64enc.Po -rm -f ./$(DEPDIR)/libcommonpth_a-call-gpg.Po -rm -f ./$(DEPDIR)/libcommonpth_a-ccparray.Po + -rm -f ./$(DEPDIR)/libcommonpth_a-comopt.Po -rm -f ./$(DEPDIR)/libcommonpth_a-compliance.Po -rm -f ./$(DEPDIR)/libcommonpth_a-convert.Po -rm -f ./$(DEPDIR)/libcommonpth_a-dotlock.Po @@ -3361,6 +3437,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libcommonpth_a-mischelp.Po -rm -f ./$(DEPDIR)/libcommonpth_a-mkdir_p.Po -rm -f ./$(DEPDIR)/libcommonpth_a-name-value.Po + -rm -f ./$(DEPDIR)/libcommonpth_a-openpgp-fpr.Po -rm -f ./$(DEPDIR)/libcommonpth_a-openpgp-oid.Po -rm -f ./$(DEPDIR)/libcommonpth_a-openpgp-s2k.Po -rm -f ./$(DEPDIR)/libcommonpth_a-percent.Po diff --git a/common/comopt.c b/common/comopt.c new file mode 100644 index 0000000..764df57 --- /dev/null +++ b/common/comopt.c @@ -0,0 +1,131 @@ +/* comopt.c - Common options for GnUPG (common.conf) + * Copyright (C) 2021 g10 Code GmbH + * + * This file is part of GnuPG. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either + * + * - the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * or + * + * - the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * or both in parallel, as here. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: (LGPL-3.0-or-later OR GPL-2.0-or-later) + */ + +#include <config.h> +#include <stdlib.h> +#include <errno.h> +#include <ctype.h> + +#include "util.h" +#include "i18n.h" +#include "comopt.h" + + +enum opt_values + { + aNull = 0, + + oLogFile = 500, + oUseKeyboxd, + oKeyboxdProgram, + + oNoop + }; + +static gpgrt_opt_t opts[] = { + ARGPARSE_s_s (oLogFile, "log-file", "@"), + ARGPARSE_s_n (oUseKeyboxd, "use-keyboxd", "@"), + ARGPARSE_s_s (oKeyboxdProgram, "keyboxd-program", "@"), + + ARGPARSE_end () +}; + + + +/* Parse the common options in the homedir and etc. This needs to be + * called after the gpgrt config directories are. MODULE_ID is one of + * the GNUPG_MODULE_NAME_ constants. If verbose is true info about + * the parsing is printed. Note that this function is not + * thread-safe. */ +gpg_error_t +parse_comopt (int module_id, int verbose) +{ + gpg_error_t err = 0; + gpgrt_argparse_t pargs; + int argc = 0; + char **argv = NULL; + + /* Reset all options in case we are called a second time. */ + xfree (comopt.logfile); + xfree (comopt.keyboxd_program); + memset (&comopt, 0, sizeof comopt); + + /* Start the parser. */ + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags = (ARGPARSE_FLAG_NOVERSION + | ARGPARSE_FLAG_SYS + | ARGPARSE_FLAG_USER + ); + while (gpgrt_argparser (&pargs, opts, "common" EXTSEP_S "conf" )) + { + switch (pargs.r_opt) + { + case ARGPARSE_CONFFILE: + if (verbose) + log_info (_("reading options from '%s'\n"), + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + break; + + case oLogFile: + comopt.logfile = pargs.r.ret_str; + break; + + case oUseKeyboxd: + comopt.use_keyboxd = 1; + break; + + case oKeyboxdProgram: + comopt.keyboxd_program = pargs.r.ret_str; + break; + + default: + pargs.err = ARGPARSE_PRINT_WARNING; + err = gpg_error (GPG_ERR_GENERAL); + break; + } + } + + gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */ + + if (comopt.logfile && !(!strncmp (comopt.logfile, "socket:", 7) + || !strncmp (comopt.logfile, "tcp:", 4)) ) + { + /* Letting all modules write to the same log file is not a good + * idea. Append the module name. */ + char *p; + + p = xstrconcat (comopt.logfile, "-", gnupg_module_name (module_id), NULL); + xfree (comopt.logfile); + comopt.logfile = p; + } + + return err; +} diff --git a/common/comopt.h b/common/comopt.h new file mode 100644 index 0000000..1cdf25f --- /dev/null +++ b/common/comopt.h @@ -0,0 +1,50 @@ +/* comopt.h - Common options for GnuPG (common.conf) + * Copyright (C) 2021 g10 Code GmbH + * + * This file is part of GnuPG. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either + * + * - the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * or + * + * - the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * or both in parallel, as here. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: (LGPL-3.0-or-later OR GPL-2.0-or-later) + */ + +#ifndef GNUPG_COMOPT_H +#define GNUPG_COMOPT_H + +#include "../common/util.h" + + +/* Common options for all GnuPG components. */ +EXTERN_UNLESS_MAIN_MODULE +struct +{ + char *logfile; /* Socket used by daemons for logging. */ + int use_keyboxd; /* Use the keyboxd as storage backend. */ + char *keyboxd_program; /* Use this as keyboxd program. */ +} comopt; + + +gpg_error_t parse_comopt (int module_id, int verbose); + + +#endif /*GNUPG_COMOPT_H*/ diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c index b144108..77182cb 100644 --- a/common/exechelp-posix.c +++ b/common/exechelp-posix.c @@ -732,8 +732,13 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count, { int status = -1; + /* Skip invalid PID. */ if (pids[i] == (pid_t)(-1)) - return my_error (GPG_ERR_INV_VALUE); + { + r_exitcodes[i] = -1; + left -= 1; + continue; + } /* See if there was a previously stored result for this pid. */ if (get_result (pids[i], &status)) diff --git a/common/name-value.c b/common/name-value.c index f663ecf..0bd205b 100644 --- a/common/name-value.c +++ b/common/name-value.c @@ -777,9 +777,13 @@ do_nvc_parse (nvc_t *result, int *errlinep, estream_t stream, /* Add the final entry. */ if (raw_value) - err = _nvc_add (*result, name, NULL, raw_value, 1); + { + err = _nvc_add (*result, name, NULL, raw_value, 1); + name = NULL; + } leave: + xfree (name); gpgrt_free (buf); if (err) { diff --git a/common/openpgp-fpr.c b/common/openpgp-fpr.c new file mode 100644 index 0000000..de28c25 --- /dev/null +++ b/common/openpgp-fpr.c @@ -0,0 +1,283 @@ +/* openpgp-fpr.c - OpenPGP Fingerprint computation + * Copyright (C) 2021 g10 Code GmbH + * + * This file is part of GnuPG. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either + * + * - the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * or + * + * - the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * or both in parallel, as here. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: (LGPL-3.0-or-later OR GPL-2.0-or-later) + */ + +#include <config.h> +#include <stdlib.h> +#include <errno.h> +#include <ctype.h> + +#include "util.h" +#include "openpgpdefs.h" + +/* Count the number of bits, assuming the A represents an unsigned big + * integer of length LEN bytes. */ +static unsigned int +count_bits (const unsigned char *a, size_t len) +{ + unsigned int n = len * 8; + int i; + + for (; len && !*a; len--, a++, n -=8) + ; + if (len) + { + for (i=7; i && !(*a & (1<<i)); i--) + n--; + } + return n; +} + +/* Variant of count_bits for simple octet strings. */ +static unsigned int +count_sos_bits (const unsigned char *a, size_t len) +{ + unsigned int n = len * 8; + int i; + + if (len == 0 || *a == 0) + return n; + + for (i=7; i && !(*a & (1<<i)); i--) + n--; + + return n; +} + + +gpg_error_t +compute_openpgp_fpr (int keyversion, int pgpalgo, unsigned long timestamp, + gcry_buffer_t *iov, int iovcnt, + unsigned char *result, unsigned int *r_resultlen) +{ + gpg_error_t err; + int hashalgo; + unsigned char prefix[15]; + size_t n; + int i; + + if (r_resultlen) + *r_resultlen = 0; + + if (iovcnt < 2) + return gpg_error (GPG_ERR_INV_ARG); + + /* Note that iov[0] is reserved. */ + for (n=0, i=1; i < iovcnt; i++) + n += iov[i].len; + + i = 0; + if (keyversion == 5) + { + hashalgo = GCRY_MD_SHA256; + n += 10; /* Add the prefix length. */ + prefix[i++] = 0x9a; + prefix[i++] = (n >> 24); + prefix[i++] = (n >> 16); + } + else if (keyversion == 4) + { + hashalgo = GCRY_MD_SHA1; + n += 6; /* Add the prefix length. */ + prefix[i++] = 0x99; + } + else + return gpg_error (GPG_ERR_UNKNOWN_VERSION); + + prefix[i++] = (n >> 8); + prefix[i++] = n; + prefix[i++] = keyversion; + prefix[i++] = (timestamp >> 24); + prefix[i++] = (timestamp >> 16); + prefix[i++] = (timestamp >> 8); + prefix[i++] = (timestamp); + prefix[i++] = pgpalgo; + if (keyversion == 5) + { + prefix[i++] = ((n-10) >> 24); + prefix[i++] = ((n-10) >> 16); + prefix[i++] = ((n-10) >> 8); + prefix[i++] = (n-10); + } + log_assert (i <= sizeof prefix); + /* The first element is reserved for our use; set it. */ + iov[0].size = 0; + iov[0].off = 0; + iov[0].len = i; + iov[0].data = prefix; + + /* for (i=0; i < iovcnt; i++) */ + /* log_printhex (iov[i].data, iov[i].len, "cmpfpr i=%d: ", i); */ + + err = gcry_md_hash_buffers (hashalgo, 0, result, iov, iovcnt); + /* log_printhex (result, 20, "fingerpint: "); */ + + /* Better clear the first element because it was set by us. */ + iov[0].size = 0; + iov[0].off = 0; + iov[0].len = 0; + iov[0].data = NULL; + + if (!err && r_resultlen) + *r_resultlen = (hashalgo == GCRY_MD_SHA1)? 20 : 32; + + return err; +} + + +gpg_error_t +compute_openpgp_fpr_rsa (int keyversion, unsigned long timestamp, + const unsigned char *m, unsigned int mlen, + const unsigned char *e, unsigned int elen, + unsigned char *result, unsigned int *r_resultlen) +{ + gcry_buffer_t iov[5] = { {0} }; + unsigned char nbits_m[2], nbits_e[2]; + unsigned int n; + + /* Strip leading zeroes. */ + for (; mlen && !*m; mlen--, m++) + ; + for (; elen && !*e; elen--, e++) + ; + + /* Count bits. */ + n = count_bits (m, mlen); + nbits_m[0] = n >> 8; + nbits_m[1] = n; + + n = count_bits (e, elen); + nbits_e[0] = n >> 8; + nbits_e[1] = n; + + /* Put parms into the array. Note that iov[0] is reserved. */ + iov[1].len = 2; + iov[1].data = nbits_m; + iov[2].len = mlen; + iov[2].data = (void*)m; + iov[3].len = 2; + iov[3].data = nbits_e; + iov[4].len = elen; + iov[4].data = (void*)e; + + return compute_openpgp_fpr (keyversion, PUBKEY_ALGO_RSA, timestamp, + iov, 5, result, r_resultlen); +} + + +/* Determine KDF hash algorithm and KEK encryption algorithm by CURVE. + * The returned buffer has a length of 4. + * Note: This needs to be kept in sync with the table in g10/ecdh.c */ +static const unsigned char* +default_ecdh_params (unsigned int nbits) +{ + /* See RFC-6637 for those constants. + 0x03: Number of bytes + 0x01: Version for this parameter format + KEK digest algorithm + KEK cipher algorithm + */ + if (nbits <= 256) + return (const unsigned char*)"\x03\x01\x08\x07"; + else if (nbits <= 384) + return (const unsigned char*)"\x03\x01\x09\x09"; + else + return (const unsigned char*)"\x03\x01\x0a\x09"; +} + + +gpg_error_t +compute_openpgp_fpr_ecc (int keyversion, unsigned long timestamp, + const char *curvename, int for_encryption, + const unsigned char *q, unsigned int qlen, + const unsigned char *kdf, unsigned int kdflen, + unsigned char *result, unsigned int *r_resultlen) +{ + gpg_error_t err; + const char *curveoidstr; + gcry_mpi_t curveoid = NULL; + unsigned int curvebits; + int pgpalgo; + const unsigned char *oidraw; + size_t oidrawlen; + gcry_buffer_t iov[5] = { {0} }; + unsigned int iovlen; + unsigned char nbits_q[2]; + unsigned int n; + + curveoidstr = openpgp_curve_to_oid (curvename, &curvebits, &pgpalgo); + err = openpgp_oid_from_str (curveoidstr, &curveoid); + if (err) + goto leave; + oidraw = gcry_mpi_get_opaque (curveoid, &n); + if (!oidraw) + { + err = gpg_error_from_syserror (); + goto leave; + } + oidrawlen = (n+7)/8; + + /* If the curve does not enforce a certain algorithm, we use the + * for_encryption flag to decide which algo to use. */ + if (!pgpalgo) + pgpalgo = for_encryption? PUBKEY_ALGO_ECDH : PUBKEY_ALGO_ECDSA; + + /* Count bits. */ + n = count_sos_bits (q, qlen); + nbits_q[0] = n >> 8; + nbits_q[1] = n; + + /* Put parms into the array. Note that iov[0] is reserved. */ + iov[1].len = oidrawlen; + iov[1].data = (void*)oidraw; + iov[2].len = 2; + iov[2].data = nbits_q; + iov[3].len = qlen; + iov[3].data = (void*)q; + iovlen = 4; + if (pgpalgo == PUBKEY_ALGO_ECDH) + { + if (!kdf || !kdflen || !kdf[0]) + { + /* No KDF givem - use the default. */ + kdflen = 4; + kdf = default_ecdh_params (curvebits); + } + iov[4].len = kdflen; + iov[4].data = (void*)kdf; + iovlen++; + } + + err = compute_openpgp_fpr (keyversion, pgpalgo, timestamp, + iov, iovlen, result, r_resultlen); + + leave: + gcry_mpi_release (curveoid); + return err; +} diff --git a/common/openpgpdefs.h b/common/openpgpdefs.h index 5ab45de..6257479 100644 --- a/common/openpgpdefs.h +++ b/common/openpgpdefs.h @@ -213,6 +213,26 @@ compress_algo_t; /*-- openpgp-s2k.c --*/ unsigned char encode_s2k_iterations (int iterations); +/*-- openpgp-fpr.c --*/ +gpg_error_t compute_openpgp_fpr (int keyversion, int pgpalgo, + unsigned long timestamp, + gcry_buffer_t *iov, int iovcnt, + unsigned char *result, + unsigned int *r_resultlen); +gpg_error_t compute_openpgp_fpr_rsa (int keyversion, + unsigned long timestamp, + const unsigned char *m, unsigned int mlen, + const unsigned char *e, unsigned int elen, + unsigned char *result, + unsigned int *r_resultlen); +gpg_error_t compute_openpgp_fpr_ecc (int keyversion, + unsigned long timestamp, + const char *curvename, int for_encryption, + const unsigned char *q, unsigned int qlen, + const unsigned char *kdf, + unsigned int kdflen, + unsigned char *result, + unsigned int *r_resultlen); /*-- openpgp-oid.c --*/ pubkey_algo_t map_gcry_pk_to_openpgp (enum gcry_pk_algos algo); diff --git a/common/recsel.c b/common/recsel.c index b2b302b..95c104f 100644 --- a/common/recsel.c +++ b/common/recsel.c @@ -249,7 +249,13 @@ recsel_parse_expr (recsel_expr_t *selector, const char *expression) se = xtrymalloc (sizeof *se + strlen (expr)); if (!se) - return my_error_from_syserror (); + { + gpg_error_t err = my_error_from_syserror (); + + recsel_release (se_head); + xfree (expr_buffer); + return err; + } strcpy (se->name, expr); se->next = NULL; se->not = 0; |