From 0e752a6e215aee21dc73da097c3225495d54a5b6 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 9 Apr 2021 07:19:03 -0300 Subject: Add libotr/etc sources --- .../tests/regression/client/Makefile.am | 16 + .../tests/regression/client/Makefile.in | 584 ++++++++++ .../libotr-4.1.1/tests/regression/client/client.c | 1158 ++++++++++++++++++++ .../libotr-4.1.1/tests/regression/client/otr.key | 41 + 4 files changed, 1799 insertions(+) create mode 100644 libotr/libotr-4.1.1/tests/regression/client/Makefile.am create mode 100644 libotr/libotr-4.1.1/tests/regression/client/Makefile.in create mode 100644 libotr/libotr-4.1.1/tests/regression/client/client.c create mode 100644 libotr/libotr-4.1.1/tests/regression/client/otr.key (limited to 'libotr/libotr-4.1.1/tests/regression/client') diff --git a/libotr/libotr-4.1.1/tests/regression/client/Makefile.am b/libotr/libotr-4.1.1/tests/regression/client/Makefile.am new file mode 100644 index 0000000..d2b11be --- /dev/null +++ b/libotr/libotr-4.1.1/tests/regression/client/Makefile.am @@ -0,0 +1,16 @@ +AM_CFLAGS = -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/tests/utils/ \ + -I$(srcdir) \ + @LIBGCRYPT_CFLAGS@ + +LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la + +LIBOTR=$(top_builddir)/src/libotr.la + +noinst_PROGRAMS = client + +client_SOURCES = client.c +client_LDADD = $(LIBTAP) $(LIBOTR) -lpthread @LIBGCRYPT_LIBS@ + +EXTRA_DIST = otr.key diff --git a/libotr/libotr-4.1.1/tests/regression/client/Makefile.in b/libotr/libotr-4.1.1/tests/regression/client/Makefile.in new file mode 100644 index 0000000..de3aa90 --- /dev/null +++ b/libotr/libotr-4.1.1/tests/regression/client/Makefile.in @@ -0,0 +1,584 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = client$(EXEEXT) +subdir = tests/regression/client +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/config/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \ + $(top_srcdir)/config/ltoptions.m4 \ + $(top_srcdir)/config/ltsugar.m4 \ + $(top_srcdir)/config/ltversion.m4 \ + $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_client_OBJECTS = client.$(OBJEXT) +client_OBJECTS = $(am_client_OBJECTS) +client_DEPENDENCIES = $(LIBTAP) $(LIBOTR) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(client_SOURCES) +DIST_SOURCES = $(client_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBOTR_LIBTOOL_VERSION = @LIBOTR_LIBTOOL_VERSION@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CFLAGS = -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/tests/utils/ \ + -I$(srcdir) \ + @LIBGCRYPT_CFLAGS@ + +LIBTAP = $(top_builddir)/tests/utils/tap/libtap.la +LIBOTR = $(top_builddir)/src/libotr.la +client_SOURCES = client.c +client_LDADD = $(LIBTAP) $(LIBOTR) -lpthread @LIBGCRYPT_LIBS@ +EXTRA_DIST = otr.key +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/regression/client/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/regression/client/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) $(EXTRA_client_DEPENDENCIES) + @rm -f client$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(client_OBJECTS) $(client_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libotr/libotr-4.1.1/tests/regression/client/client.c b/libotr/libotr-4.1.1/tests/regression/client/client.c new file mode 100644 index 0000000..e72b661 --- /dev/null +++ b/libotr/libotr-4.1.1/tests/regression/client/client.c @@ -0,0 +1,1158 @@ +/* + * Copyright (C) 2014 - David Goulet + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program 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, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#define zmalloc(x) calloc(1, x) + +GCRY_THREAD_OPTION_PTHREAD_IMPL; + +/* Global OTR user state. */ +static OtrlUserState user_state; + +/* Getopt options. */ +static struct option long_opts[] = { + { "load-instag", 1, NULL, 'i' }, + { "load-key", 1, NULL, 'k' }, + { "load-fp", 1, NULL, 'f' }, + { "timeout", 1, NULL, 't' }, + { "max-msg", 1, NULL, 'm' }, + { "disconnect", 0, NULL, 'd' }, + { "auth", 0, NULL, 'a' }, + { "fragment", 0, NULL, 'F' }, + + /* Closure. */ + { NULL, 0, NULL, 0 } +}; + +static char *opt_instag_path; +static char *opt_key_path; +static char *opt_key_fp_path; +static unsigned int opt_max_num_msg; +static int opt_disconnect; +static int opt_auth; +static int opt_fragment; + +/* Currently, the message size sent is between 1 and 600 len so 100 is a good + * middle ground. */ +static const int fragment_size = 100; +/* By default, don't send frag. */ +static OtrlFragmentPolicy fragPolicy = OTRL_FRAGMENT_SEND_SKIP; + +static const char *protocol = "otr-test"; +static const char *alice_name = "alice"; +static const char *bob_name = "bob"; + +static const char *unix_sock_bob_path = "/tmp/otr-test-bob.sock"; +static const char *unix_sock_alice_path = "/tmp/otr-test-alice.sock"; + +static const char *auth_question = "What is NSA?"; +static const char *auth_secret = "No Sugar Added"; + +/* Alice and Bob thread's socket. */ +static int alice_sock; +static int bob_sock; +/* Declare it global because we use it multiple times. */ +static struct sockaddr_un alice_sun; +static struct sockaddr_un bob_sun; + +static int timeout_max = 1000; +static unsigned int num_recv_msg; +static unsigned int session_disconnected; + +static int quit_pipe[2] = { -1, -1 }; + +/* + * For now not really do much more but if we want to use the OK condition at + * some point to do something else, that will ease our life :). + */ +#define OK(cond, fmt, args...) \ + do { \ + ok(cond, fmt, ## args); \ + } while (0) + +/* + * Used to pass OTR message between threads. This contains the cipher and + * plaintext so we are able to validate what's expected in both threads. + */ +struct otr_msg { + size_t plaintext_len; + size_t ciphertext_len; + char *plaintext; + char *ciphertext; +}; + +struct otr_info { + const char *user; + int sock; + unsigned int gone_secure; + unsigned int auth_done; +}; + +/* Stub */ +static int send_otr_msg(int sock, const char *to, const char *from, + struct otr_info *oinfo, const char *message); + +static OtrlPolicy ops_policy(void *opdata, ConnContext *context) +{ + return OTRL_POLICY_DEFAULT; +} + +static void ops_inject_msg(void *opdata, const char *accountname, + const char *protocol, const char *recipient, const char *message) +{ + ssize_t ret; + struct otr_info *oinfo = opdata; + struct otr_msg *msg; + + msg = zmalloc(sizeof(*msg)); + if (!msg) { + perror("zmalloc inject"); + return; + } + + msg->ciphertext = strdup(message); + msg->ciphertext_len = strlen(message); + + ret = send(oinfo->sock, &msg, sizeof(msg), 0); + if (ret < 0) { + perror("send msg"); + } +} + +static void ops_gone_secure(void *opdata, ConnContext *context) +{ + struct otr_info *oinfo = opdata; + + session_disconnected = 0; + oinfo->gone_secure = 1; + /* XXX: gone_insecure is never called ref bug #40 so this will always be + * true. */ + OK(oinfo->gone_secure, "Gone secure for %s", + oinfo->user); +} + +static void ops_gone_insecure(void *opdata, ConnContext *context) +{ + struct otr_info *oinfo = opdata; + + OK(oinfo->gone_secure, "Gone insecure for %s", + oinfo->user); + oinfo->gone_secure = 0; +} + +static int ops_max_message_size(void *opdata, ConnContext *context) +{ + if (opt_fragment) { + return fragment_size; + } + return 0; +} + +static const char *ops_otr_error_message(void *opdata, ConnContext *context, + OtrlErrorCode code) +{ + char *msg = NULL; + + switch (code) { + case OTRL_ERRCODE_NONE: + break; + case OTRL_ERRCODE_ENCRYPTION_ERROR: + msg = strdup("OTRL_ERRCODE_ENCRYPTION_ERROR"); + break; + case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE: + msg = strdup("OTRL_ERRCODE_MSG_NOT_IN_PRIVATE"); + break; + case OTRL_ERRCODE_MSG_UNREADABLE: + msg = strdup("OTRL_ERRCODE_MSG_UNREADABLE"); + break; + case OTRL_ERRCODE_MSG_MALFORMED: + msg = strdup("OTRL_ERRCODE_MSG_MALFORMED"); + break; + } + + return msg; +} + +static void ops_otr_error_message_free(void *opdata, const char *err_msg) +{ + free((char *) err_msg); +} + +static void ops_handle_msg_event(void *opdata, OtrlMessageEvent msg_event, + ConnContext *context, const char *message, gcry_error_t err) +{ + //char* msg = ""; + struct otr_info *oinfo = opdata; + + switch(msg_event) { + case OTRL_MSGEVENT_NONE: + //msg = "OTRL_MSGEVENT_NONE"; + break; + case OTRL_MSGEVENT_ENCRYPTION_REQUIRED: + //msg = "OTRL_MSGEVENT_ENCRYPTION_REQUIRED"; + break; + case OTRL_MSGEVENT_ENCRYPTION_ERROR: + //msg = "OTRL_MSGEVENT_ENCRYPTION_ERROR"; + break; + case OTRL_MSGEVENT_CONNECTION_ENDED: + //msg = "OTRL_MSGEVENT_CONNECTION_ENDED"; + oinfo->gone_secure = 0; + break; + case OTRL_MSGEVENT_SETUP_ERROR: + //msg = "OTRL_MSGEVENT_SETUP_ERROR"; + break; + case OTRL_MSGEVENT_MSG_REFLECTED: + //msg = "OTRL_MSGEVENT_MSG_REFLECTED"; + break; + case OTRL_MSGEVENT_MSG_RESENT: + //msg = "OTRL_MSGEVENT_MSG_RESENT"; + break; + case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE: + //msg = "OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE"; + break; + case OTRL_MSGEVENT_RCVDMSG_UNREADABLE: + //msg = "OTRL_MSGEVENT_RCVDMSG_UNREADABLE"; + break; + case OTRL_MSGEVENT_RCVDMSG_MALFORMED: + //msg = "OTRL_MSGEVENT_RCVDMSG_MALFORMED"; + break; + case OTRL_MSGEVENT_LOG_HEARTBEAT_RCVD: + //msg = "OTRL_MSGEVENT_LOG_HEARTBEAT_RCVD"; + break; + case OTRL_MSGEVENT_LOG_HEARTBEAT_SENT: + //msg = "OTRL_MSGEVENT_LOG_HEARTBEAT_SENT"; + break; + case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR: + //msg = "OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR"; + break; + case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED: + //msg = "OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED"; + break; + case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED: + //msg = "OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED"; + break; + case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE: + //msg = "OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE"; + break; + default: + //msg = "Unknown OTRL message event"; + break; + } +} + +static void ops_create_instag(void *opdata, const char *accountname, + const char *protocol) +{ + otrl_instag_generate(user_state, "/dev/null", accountname, + protocol); +} + +static int ops_is_logged_in(void *opdata, const char *accountname, + const char *protocol, const char *recipient) +{ + /* Always logged in or else we don't receive a disconnected TLV. */ + return 1; +} + +static void ops_create_privkey(void *opdata, const char *accountname, + const char *protocol) +{ + /* XXX: We should gen. our own key each time at some point? */ + return; +} + +static void ops_update_context_list(void *opdata) +{ + return; +} + +static void ops_new_fingerprint(void *opdata, OtrlUserState us, + const char *accountname, const char *protocol, + const char *username, unsigned char fingerprint[20]) +{ + return; +} + +static void ops_write_fingerprints(void *opdata) +{ + return; +} + +static void ops_still_secure(void *opdata, ConnContext *context, int is_reply) +{ + struct otr_info *oinfo = opdata; + + OK(oinfo->gone_secure, "OP still secure"); +} + +static void ops_received_symkey(void *opdata, ConnContext *context, + unsigned int use, const unsigned char *usedata, + size_t usedatalen, const unsigned char *symkey) +{ + return; +} + +static const char *ops_resent_msg_prefix(void *opdata, ConnContext *context) +{ + /* Just so we can test resent_msg_prefix_free */ + char *prefix = zmalloc(32); + strncpy(prefix, "[such resent]", 32); + + return prefix; +} + +static void ops_resent_msg_prefix_free(void *opdata, const char *prefix) +{ + free((char *) prefix); +} + +static void ops_convert_msg(void *opdata, ConnContext *context, + OtrlConvertType convert_type, char ** dest, const char *src) +{ + switch (convert_type) { + case OTRL_CONVERT_SENDING: + case OTRL_CONVERT_RECEIVING: + break; + default: + OK(0, "OP convert_msg, got a unknown type %d", convert_type); + break; + } + + *dest = NULL; +} + +static void ops_convert_free(void *opdata, ConnContext *context, char *dest) +{ + return; +} + +/* Stub */ +static void ops_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, + ConnContext *context, unsigned short progress_percent, char *question); +static void ops_timer_control(void *opdata, unsigned int interval); + +/* OTR message operations. */ +static OtrlMessageAppOps ops = { + ops_policy, + ops_create_privkey, + ops_is_logged_in, + ops_inject_msg, + ops_update_context_list, + ops_new_fingerprint, + ops_write_fingerprints, + ops_gone_secure, + ops_gone_insecure, + ops_still_secure, + ops_max_message_size, + NULL, /* account_name - NOT USED */ + NULL, /* account_name_free - NOT USED */ + ops_received_symkey, + ops_otr_error_message, + ops_otr_error_message_free, + ops_resent_msg_prefix, + ops_resent_msg_prefix_free, + ops_handle_smp_event, + ops_handle_msg_event, + ops_create_instag, + ops_convert_msg, + ops_convert_free, + ops_timer_control, +}; + + +static void ops_timer_control(void *opdata, unsigned int interval) +{ + otrl_message_poll(user_state, &ops, NULL); +} + +static void ops_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, + ConnContext *context, unsigned short progress_percent, char *question) +{ + struct otr_info *oinfo = opdata; + + switch (smp_event) { + case OTRL_SMPEVENT_ASK_FOR_SECRET: + OK(!oinfo->auth_done && + !strncmp(oinfo->user, alice_name, strlen(alice_name)), + "SMP Event, %s asking for secret", alice_name); + break; + case OTRL_SMPEVENT_ASK_FOR_ANSWER: + OK(!oinfo->auth_done && + !strncmp(oinfo->user, bob_name, strlen(bob_name)) && + !strncmp(auth_question, question, strlen(auth_question)), + "SMP Event, %s asking for answer", bob_name); + /* + * Directly respond to the SMP auth here. Much more easy instead of in + * bob's thread. + */ + otrl_message_respond_smp(user_state, &ops, opdata, context, + (unsigned char *) auth_secret, strlen(auth_secret)); + break; + case OTRL_SMPEVENT_IN_PROGRESS: + OK(!oinfo->auth_done && + !strncmp(oinfo->user, alice_name, strlen(alice_name)), + "SMP Event, %s asking for secret", alice_name); + break; + case OTRL_SMPEVENT_SUCCESS: + oinfo->auth_done = 1; + OK(oinfo->auth_done, "SMP authentication success for %s", oinfo->user); + break; + case OTRL_SMPEVENT_ABORT: + case OTRL_SMPEVENT_FAILURE: + case OTRL_SMPEVENT_CHEATED: + case OTRL_SMPEVENT_ERROR: + default: + OK(0, "SMP auth failed with event %d", smp_event); + break; + } +} + +static void cleanup(void) +{ + ssize_t ret; + + /* Wake up threads. */ + ret = write(quit_pipe[1], "42", 2); + if (ret < 0) { + perror("write quit pipe"); + } + + /* Cleanup residual Unix socket path. */ + unlink(alice_sun.sun_path); + unlink(bob_sun.sun_path); +} + +static void update_msg_counter(void) +{ + num_recv_msg++; + if (num_recv_msg == opt_max_num_msg) { + cleanup(); + } +} + +/* + * Generate random string and stores it in out of size len. + */ +static void gen_random_string(char *out, size_t len) +{ + size_t i; + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + for (i = 0; i < len; i++) { + out[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; + } + out[len - 1] = '\0'; +} + +static int send_otr_msg(int sock, const char *to, const char *from, + struct otr_info *oinfo, const char *message) +{ + char *new_msg = NULL; + ssize_t ret; + gcry_error_t err; + struct otr_msg *omsg; + + omsg = zmalloc(sizeof(*omsg)); + if (!omsg) { + perror("zmalloc send otr msg"); + goto error; + } + + if (!message) { + size_t len = rand() % 600; + char *msg = zmalloc(len); + if (!msg) { + perror("random msg"); + goto error; + } + gen_random_string(msg, len); + omsg->plaintext = msg; + omsg->plaintext_len = strlen(msg); + } else { + omsg->plaintext = strdup(message); + omsg->plaintext_len = strlen(message); + } + + err = otrl_message_sending(user_state, &ops, oinfo, from, protocol, to, + OTRL_INSTAG_BEST, omsg->plaintext, NULL, &new_msg, + fragPolicy, NULL, NULL, NULL); + if (err) { + goto error; + } + if (new_msg) { + free(omsg->ciphertext); + omsg->ciphertext = strdup(new_msg); + omsg->ciphertext_len = strlen(omsg->ciphertext); + otrl_message_free(new_msg); + } + + ret = send(sock, &omsg, sizeof(omsg), 0); + if (ret < 0) { + perror("send OTR msg"); + goto error; + } + + return 0; + +error: + if(omsg){ + free(omsg->plaintext); + free(omsg->ciphertext); + free(omsg); + } + return -1; +} + +static int recv_otr_msg(int sock, const char *to, const char *from, + struct otr_info *oinfo) +{ + int err; + ssize_t ret; + char *new_msg = NULL; + struct otr_msg *omsg; + OtrlTLV *tlvs = NULL; + + ret = recv(sock, &omsg, sizeof(omsg), 0); + if (ret < 0) { + goto error; + } + + err = otrl_message_receiving(user_state, &ops, oinfo, to, protocol, from, + omsg->ciphertext, &new_msg, &tlvs, NULL, NULL, NULL); + if (!err) { + if (new_msg) { + OK(strncmp(omsg->plaintext, new_msg, omsg->plaintext_len) == 0, + "Message exchanged is valid"); + update_msg_counter(); + } + } else { + OK(err == 1, "Internal OTR message valid"); + } + + free(omsg->plaintext); + free(omsg->ciphertext); + free(omsg); + + OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); + /* + * XXX: Somehow you can end up with a disconnected TLV in a gone secure + * session (see #54). This is probably a bug but since the gone_insecure is + * never called (see bug #48) we have no reliable way of knowing the state + * of the session at this point. + */ + if (tlv && !oinfo->gone_secure) { + OK(session_disconnected, "Disconnected TLV confirmed"); + } + + otrl_tlv_free(tlvs); + + return 0; + +error: + return -1; +} + +static int add_sock_to_pollset(int epfd, int sock, uint32_t req_ev) +{ + int ret; + struct epoll_event ev; + + memset(&ev, 0, sizeof(ev)); + ev.events = req_ev; + ev.data.fd = sock; + + ret = epoll_ctl(epfd, EPOLL_CTL_ADD, sock, &ev); + if (ret < 0) { + perror("epoll_ctl add"); + } + return ret; +} + +static void *alice_thread(void *data) +{ + int sock_to_bob, sock_from_bob = 0, epfd, ret; + unsigned int auth_started = 0; + struct otr_info oinfo; + + memset(&oinfo, 0, sizeof(oinfo)); + + /* Poll size is ignored since 2.6.8 */ + epfd = epoll_create(42); + if (epfd < 0) { + perror("epoll_create Bob"); + goto error; + } + + sock_to_bob = socket(PF_UNIX, SOCK_STREAM, 0); + if (sock_to_bob < 0) { + perror("Bob socket to Alice"); + goto sock_error; + } + oinfo.sock = sock_to_bob; + oinfo.user = alice_name; + if (!opt_auth) { + /* We are not going to SMP auth for this session so indicate it's + * completed so we can go forward with random disconnect. + */ + oinfo.auth_done = 1; + } + + ret = connect(sock_to_bob, (struct sockaddr *) &bob_sun, + sizeof(bob_sun)); + if (ret < 0) { + perror("connect to Alice"); + goto end; + } + + /* Add quit pipe to pollset trigger by a cleanup. */ + ret = add_sock_to_pollset(epfd, quit_pipe[0], EPOLLIN); + if (ret < 0) { + goto end; + } + + /* Add our socket to epoll set. */ + ret = add_sock_to_pollset(epfd, alice_sock, + EPOLLIN | EPOLLRDHUP); + if (ret < 0) { + goto end; + } + + while (1) { + int i, nb_fd, timeout; + struct epoll_event ev[3]; + memset(ev, 0, sizeof(ev)); + + /* + * Set random timeout and when we do timeout, use that to send message + * to Alice. + */ + timeout = (rand() % (timeout_max - 1)); + + ret = epoll_wait(epfd, ev, sizeof(ev), timeout); + if (ret < 0) { + perror("epoll_wait Alice"); + goto end; + } + nb_fd = ret; + + /* Each timeout to 10 finishes the OTR session. */ + if (!(timeout % 3) && opt_disconnect && oinfo.auth_done) { + session_disconnected = 1; + oinfo.gone_secure = 0; + otrl_message_disconnect(user_state, &ops, &oinfo, + alice_name, protocol, bob_name, OTRL_INSTAG_BEST); + OK(!oinfo.gone_secure, "OTR message disconnect"); + } + + /* Start authentication with Bob. */ + if (opt_auth && !auth_started && oinfo.gone_secure) { + ConnContext *ctx; + + /* We have to find our context before auth. */ + ctx = otrl_context_find(user_state, bob_name, alice_name, + protocol, OTRL_INSTAG_BEST, 0, NULL, NULL, &oinfo); + OK(ctx, "Alice context found for SMP auth"); + + otrl_message_initiate_smp_q(user_state, &ops, &oinfo, ctx, + auth_question, (unsigned char *) auth_secret, + strlen(auth_secret)); + auth_started = 1; + } + + /* No event thus timeout, send message to Alice. */ + if (nb_fd == 0) { + (void) send_otr_msg(sock_to_bob, bob_name, alice_name, &oinfo, + NULL); + continue; + } + + for (i = 0; i < nb_fd; i++) { + int fd; + uint32_t event; + + fd = ev[i].data.fd; + event = ev[i].events; + + if (fd == quit_pipe[0]) { + /* Time to leave. */ + goto end; + } else if (fd == alice_sock) { + if (event & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) { + goto end; + } else if (event & EPOLLIN) { + socklen_t len; + struct sockaddr_un sun; + + /* Connection from Bob, accept it so we can handle it. */ + sock_from_bob = accept(fd, (struct sockaddr *) &sun, + &len); + ret = add_sock_to_pollset(epfd, sock_from_bob, + EPOLLIN | EPOLLERR | EPOLLHUP); + if (ret < 0) { + goto end; + } + } + continue; + } else if (fd == sock_from_bob) { + if (event & (EPOLLERR | EPOLLHUP)) { + /* Stop since Bob's thread just shut us down. */ + goto end; + } else if (event & EPOLLIN) { + (void) recv_otr_msg(sock_from_bob, alice_name, bob_name, + &oinfo); + } + continue; + } else { + goto end; + } + } + } + +end: + if (sock_from_bob) { + (void) close(sock_from_bob); + } + (void) close(sock_to_bob); +sock_error: + (void) close(epfd); +error: + (void) close(alice_sock); + + return NULL; +} + +static void *bob_thread(void *data) +{ + int sock_to_alice, sock_from_alice = 0, epfd, ret; + struct otr_info oinfo; + + memset(&oinfo, 0, sizeof(oinfo)); + + /* Poll size is ignored since 2.6.8 */ + epfd = epoll_create(42); + if (epfd < 0) { + perror("epoll_create Bob"); + goto error; + } + + sock_to_alice = socket(PF_UNIX, SOCK_STREAM, 0); + if (sock_to_alice < 0) { + perror("Bob socket to Alice"); + goto sock_error; + } + oinfo.sock = sock_to_alice; + oinfo.user = bob_name; + + ret = connect(sock_to_alice, (struct sockaddr *) &alice_sun, + sizeof(alice_sun)); + if (ret < 0) { + perror("connect to Alice"); + goto end; + } + + /* Add quit pipe to pollset trigger by a cleanup. */ + ret = add_sock_to_pollset(epfd, quit_pipe[0], EPOLLIN); + if (ret < 0) { + goto end; + } + + /* Add our socket to epoll set. */ + ret = add_sock_to_pollset(epfd, bob_sock, + EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLRDHUP); + if (ret < 0) { + goto end; + } + + while (1) { + int i, timeout = 500, nb_fd; + struct epoll_event ev[3]; + memset(ev, 0, sizeof(ev)); + + /* + * Set random timeout and when we do timeout, use that to send message + * to Alice. + */ + timeout = (rand() % (timeout_max - 1)); + + ret = epoll_wait(epfd, ev, sizeof(ev), timeout); + if (ret < 0) { + perror("epoll_wait Bob"); + goto end; + } + nb_fd = ret; + + /* No event thus timeout, send message to Alice. */ + if (nb_fd == 0) { + (void) send_otr_msg(sock_to_alice, alice_name, bob_name, &oinfo, + NULL); + continue; + } + + for (i = 0; i < nb_fd; i++) { + int fd; + uint32_t event; + + fd = ev[i].data.fd; + event = ev[i].events; + + if (fd == quit_pipe[0]) { + /* Time to leave. */ + goto end; + } else if (fd == bob_sock) { + if (event & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) { + goto end; + } else if (event & (EPOLLIN | EPOLLHUP)) { + socklen_t len; + struct sockaddr_un sun; + + /* Connection from Alice, accept it so we can handle it. */ + sock_from_alice = accept(fd, (struct sockaddr *) &sun, + &len); + ret = add_sock_to_pollset(epfd, sock_from_alice, + EPOLLIN | EPOLLERR | EPOLLHUP); + if (ret < 0) { + goto end; + } + } + continue; + } else if (fd == sock_from_alice) { + if (event & (EPOLLERR | EPOLLHUP)) { + goto end; + } else if (event & EPOLLIN) { + (void) recv_otr_msg(sock_from_alice, bob_name, + alice_name, &oinfo); + } + continue; + } else { + goto end; + } + } + } + +end: + if (sock_from_alice) { + (void) close(sock_from_alice); + } + (void) close(sock_to_alice); +sock_error: + (void) close(epfd); +error: + (void) close(bob_sock); + return NULL; +} + +static void run(void) +{ + int ret; + void *status; + pthread_t alice_th, bob_th; + + /* Init quit pipe. */ + ret = pipe(quit_pipe); + if (ret < 0) { + perror("pipe quit pipe"); + goto end; + } + + ret = pthread_create(&alice_th, NULL, alice_thread, NULL); + if (ret) { + fail("pthread_create sender thread failed (errno: %d)", errno); + goto end; + } + + ret = pthread_create(&bob_th, NULL, bob_thread, NULL); + if (ret) { + fail("pthread_create receiver thread failed (errno: %d)", errno); + goto exit_receiver; + } + + (void) pthread_join(bob_th, &status); + +exit_receiver: + (void) pthread_join(alice_th, &status); +end: + /* Get rid of the quit pipe. */ + close(quit_pipe[0]); + close(quit_pipe[1]); + return; +} + +/* + * Load OTR instag using the given opt argument. + */ +static void load_instag(void) +{ + int ret; + gcry_error_t err; + + ret = access(opt_instag_path, R_OK); + if (ret < 0) { + fail("Instag file %s is not readable", opt_instag_path); + return; + } + + err = otrl_instag_read(user_state, opt_instag_path); + OK(err == GPG_ERR_NO_ERROR, "Loading instag from given file"); +} + +/* + * Load private key file using the given opt argument. + */ +static void load_key(void) +{ + int ret; + gcry_error_t err; + + ret = access(opt_key_path, R_OK); + if (ret < 0) { + fail("Key file %s is not readable", opt_key_path); + return; + } + + err = otrl_privkey_read(user_state, opt_key_path); + OK(err == GPG_ERR_NO_ERROR, "Loading key from given file"); +} + +/* + * Load private key fingerprint file using the given opt argument. + */ +static void load_key_fp(void) +{ + int ret; + gcry_error_t err; + + ret = access(opt_key_fp_path, R_OK); + if (ret < 0) { + fail("Key fingerprints file %s is not readable", opt_key_fp_path); + return; + } + + err = otrl_privkey_read_fingerprints(user_state, opt_key_fp_path, NULL, + NULL); + OK(err == GPG_ERR_NO_ERROR, "Loading key fingerprints from given file"); +} + +static int create_unix_socket(const char *pathname, + struct sockaddr_un *sun) +{ + int sock, ret; + + /* Create both Unix socket. */ + if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { + ret = -errno; + perror("Unix socket"); + goto error; + } + + memset(sun, 0, sizeof(struct sockaddr_un)); + sun->sun_family = AF_UNIX; + strncpy(sun->sun_path, pathname, sizeof(sun->sun_path)); + sun->sun_path[sizeof(sun->sun_path) - 1] = '\0'; + + ret = bind(sock, (struct sockaddr *) sun, sizeof(struct sockaddr_un)); + if (ret < 0) { + perror("bind unix sock"); + goto error; + } + + ret = listen(sock, 10); + if (ret < 0) { + perror("listen unix sock"); + goto error; + } + + return sock; +error: + return ret; +} + +/* + * Bootstrap client by initializing the OTR library and creating an OTR user + * state. + * + * Return 0 on success else a negative value on error. + */ +static int init_client(void) +{ + int ret; + + /* Init libgcrypt threading system. */ + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); + + /* Init OTR library. */ + OTRL_INIT; + OK(1, "OTR library initialization done."); + + user_state = otrl_userstate_create(); + OK(user_state, "OTR userstate creation done."); + if (!user_state) { + fail("Out of memory on userstate create"); + ret = -ENOMEM; + goto error; + } + + /* Seed the prng. */ + srand(time(NULL)); + + /* Cleanup Unix socket file before creating them. */ + unlink(unix_sock_alice_path); + unlink(unix_sock_bob_path); + + alice_sock = create_unix_socket(unix_sock_alice_path, &alice_sun); + bob_sock = create_unix_socket(unix_sock_bob_path, &bob_sun); + if (alice_sock < 0 || bob_sock < 0) { + ret = -EINVAL; + goto error; + } + + if (opt_fragment) { + fragPolicy = OTRL_FRAGMENT_SEND_ALL; + } + + return 0; + +error: + return ret; +} + +static void sighandler(int sig) +{ + switch (sig) { + case SIGPIPE: + case SIGINT: + case SIGTERM: + cleanup(); + break; + default: + break; + } +} + +/* + * main entry point. + */ +int main(int argc, char **argv) +{ + int ret, opt; + struct sigaction sa; + sigset_t sigset; + + plan_no_plan(); + + if ((ret = sigemptyset(&sigset)) < 0) { + perror("sigemptyset"); + goto error; + } + + sa.sa_handler = sighandler; + sa.sa_mask = sigset; + sa.sa_flags = 0; + + if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) { + perror("sigaction"); + goto error; + } + if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) { + perror("sigaction"); + goto error; + } + if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) { + perror("sigaction"); + goto error; + } + + while ((opt = getopt_long(argc, argv, "+i:k:f:t:m:daF", long_opts, NULL)) != -1) { + switch (opt) { + case 'i': + opt_instag_path = strdup(optarg); + break; + case 'k': + opt_key_path = strdup(optarg); + break; + case 'f': + opt_key_fp_path = strdup(optarg); + break; + case 't': + timeout_max = atoi(optarg); + break; + case 'm': + opt_max_num_msg = atoi(optarg); + break; + case 'd': + opt_disconnect = 1; + break; + case 'a': + opt_auth = 1; + break; + case 'F': + opt_fragment = 1; + break; + default: + goto error; + } + } + + if (!opt_key_path) { + fail("No key file, failing"); + goto error; + } + + /* Running OTR tests. */ + ret = init_client(); + if (ret < 0) { + goto error; + } + + if (opt_instag_path) { + load_instag(); + } + if (opt_key_fp_path) { + load_key_fp(); + } + load_key(); + + run(); + + return exit_status(); + +error: + return -1; +} diff --git a/libotr/libotr-4.1.1/tests/regression/client/otr.key b/libotr/libotr-4.1.1/tests/regression/client/otr.key new file mode 100644 index 0000000..ee8767d --- /dev/null +++ b/libotr/libotr-4.1.1/tests/regression/client/otr.key @@ -0,0 +1,41 @@ +(privkeys + (account +(name alice) +(protocol otr-test) +(private-key + (dsa + (p #00E4240AE9740D5FB1DF076A3270143BBD5B66DEB9BFD601CF3C3DC3E8D76BF1EA0D1A66E209516600E915B79552887EE9810D613C63EA6D2B6E69321C3C81F71F533F02430D20AF65C05C15BA46EF10C78EFF3BE687C33A4F6EA90877AB30E6423070AAFD3F22B5939D0DC8FBE5145A68F38EBA98ADCA7E06EFBC5E345E9AEDEF#) + (q "\x00§Õ»Ç*ÂÝi#ûb§U~õ{U©öq") + (g #00D3A15721AEF3A49DF26E875EC8C5FF4096B0B1717AF89485A015245176FD4AE3065D9F7B2D185B1E02CEAFB53E6984B1D341E62EBB4A5C189EB40959CFED0C48DAE73F3391C5E1482372E9DE539CD6911C54583DC0A3179547A38E19549F81A6DBFA8036C471C2A358D4B3AB86C7424556DFD61C35CC1EC08304B0102A0EEE08#) + (y #6E3996E07B6CB54DC443BD83033293956E5B7CCC511D19DCAC8735496B061D6EB6DF3D5540548D3C97201393E669EF9066BCA6A72E3AC68710188BEDF06FDF22548D8709BD4E9E1AD02DB0E193399BEB39DE5218D70C999D9856D3205DB79BA8DFC188726E646A1BE1722843F5E56A51C499C5BE5F63FACE7802ECD565E99F39#) + (x #2C5887BA7EC5F426B6BE4438E2FAE4589DBF2CB6#) + ) + ) + ) + (account +(name bob) +(protocol otr-test) +(private-key + (dsa + (p #00BD114F05B275A8A94954047983C5CD96ED95C782D2ED65A18E78C98E8EAFBAF58BBD046BE9895AD55FD0FF95907E7EBD6ACA2688D24779BDE9F0AAB13924CE65F597F9C9B9953DDBACF51DA7113FBAB9BE1DF6C6EA836DEB48983CCDCFC4125B5013D0CE52F890D0C391A035D30BCD5169A3451FD7023685274576DCB5F8FA47#) + (q #00D1DA3915346A704EB2D2F2A48CD48F3DCC4CF25D#) + (g #501BCFB989AD2C346BBD7782CA0230551F976B1A07EE3AEE27E4B63B7B00B1ACA712AD85784986411278163156D4DBA9DF75C8560F9C2E02C02AEC830EC403A56B6F64432869D6CA9314A648076511343507629BF4FC96F8FDBB9797258DDF11F437B1450BA23F1AA7E885EC6A33D37B7D7EC384A004420DB238E140B94AAAFE#) + (y #7C9CB7732164787DD1931BB58257665EB60D6AA72B8D64D634530A61BE93D5AF01427962646542F18401B73032B12B9CBCAE8E3CF080DAD55C6612A97D6D8776CF2CBDD3AAC75D302B60E6956E5B3C60B39E171A2D5F150A924C6E22981EFDF052D5C6507B2DEC15E96CB6CAF7B260D5386BBDD7D7F69B4BF14451D64D847AEB#) + (x #00AB1E941176D94505911118AC799A504ADCCE88F8#) + ) + ) + ) + (account +(name otrtest3) +(protocol otr-test) +(private-key + (dsa + (p #00BB4C57669E50E4C35F8E4CA84855CF2C83EE75C4F44B4BB4A7E88590D394D7A738E82EE97892E5051CE45E200741E18D423137AA8E6679B1CFAB4FF11D45D8C9CBDE388D30FC800B4879713E3C57BA48A92FE135BB9AF265F770B706FB9A04802244D12CBFFD97ACE5C73FCE88C2B716B4B22B994CD6429A7E16D9B6D1874137#) + (q #00C40DA63B679A80FC31BF49A68503BB39754D0A45#) + (g #6C0A48BEA859587D6677306D1777A2A0635470F149A86EB64EA62EAAA4C21ECE4375ACD016B776E3AD3411C18BB3FF37F963FCEBB8820FF8838AFA6FCD1B39558DAB78450AE2ED9457DEDBDCE13DF5A6B20A738D2973D375D360C044AF7F0204CCC372098F0B6460963274B1EA0B5FEC93571A15F5C03DCDF54EE83BB198F363#) + (y #00AB2C8A82F020DB99EF5B7A8330EC43E0D5EBD623FEB67D1B046D88FACA01D8E31E4D7865DC62D4DA58CF8BC7FF4B57C203A9F7F5C85DAB1B63D63299EF13AD89AAA7E6638C9DBC42D096408936C9F0382224CFB5C1528DCC8C7F2554CB4CA2FF3C3239BC921F1C690295DD9AE69C8EF5BBD8E58A8FAA8BB9D5F88463CAECEE7B#) + (x #7824B713A4E5FA6D6C69172196648CD4657A1ED1#) + ) + ) + ) +) -- cgit 1.4.1