diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2012-10-27 21:02:32 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2012-10-27 21:02:32 +0000 |
commit | 70f1558a2eca8295e30bb1e381d948056333634d (patch) | |
tree | 3051cb6afbc7d5ebae4381e54c70d9cbe54005a4 /tools | |
parent | 4f1edcf052857117fd51e878c362f878961c4dc9 (diff) |
- Second time's the charm? Moving svnroot/ircd-hybrid-8 to
svnroot/ircd-hybrid/trunk
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1592 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 8 | ||||
-rw-r--r-- | tools/Makefile.in | 588 | ||||
-rw-r--r-- | tools/README | 10 | ||||
-rw-r--r-- | tools/README.mkpasswd | 50 | ||||
-rw-r--r-- | tools/README.respond | 36 | ||||
-rwxr-xr-x | tools/mkkeypair | 54 | ||||
-rw-r--r-- | tools/mkpasswd.c | 533 | ||||
-rw-r--r-- | tools/respond.c | 166 |
8 files changed, 1445 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am new file mode 100644 index 0000000..d1272e7 --- /dev/null +++ b/tools/Makefile.am @@ -0,0 +1,8 @@ +AUTOMAKE_OPTIONS = foreign + +bin_PROGRAMS = mkpasswd +if ENABLE_SSL +bin_PROGRAMS += respond +respond_SOURCES = respond.c +endif +mkpasswd_SOURCES = mkpasswd.c diff --git a/tools/Makefile.in b/tools/Makefile.in new file mode 100644 index 0000000..6146275 --- /dev/null +++ b/tools/Makefile.in @@ -0,0 +1,588 @@ +# Makefile.in generated by automake 1.12.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 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__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +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@ +bin_PROGRAMS = mkpasswd$(EXEEXT) $(am__EXEEXT_1) +@ENABLE_SSL_TRUE@am__append_1 = respond +subdir = tools +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.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 = +@ENABLE_SSL_TRUE@am__EXEEXT_1 = respond$(EXEEXT) +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_mkpasswd_OBJECTS = mkpasswd.$(OBJEXT) +mkpasswd_OBJECTS = $(am_mkpasswd_OBJECTS) +mkpasswd_LDADD = $(LDADD) +am__respond_SOURCES_DIST = respond.c +@ENABLE_SSL_TRUE@am_respond_OBJECTS = respond.$(OBJEXT) +respond_OBJECTS = $(am_respond_OBJECTS) +respond_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(mkpasswd_SOURCES) $(respond_SOURCES) +DIST_SOURCES = $(mkpasswd_SOURCES) $(am__respond_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +ARGZ_H = @ARGZ_H@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +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@ +INCLTDL = @INCLTDL@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBADD_DL = @LIBADD_DL@ +LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ +LIBADD_DLOPEN = @LIBADD_DLOPEN@ +LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ +LIBDIR = @LIBDIR@ +LIBLTDL = @LIBLTDL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOCALSTATEDIR = @LOCALSTATEDIR@ +LTDLDEPS = @LTDLDEPS@ +LTDLINCL = @LTDLINCL@ +LTDLOPEN = @LTDLOPEN@ +LTLIBOBJS = @LTLIBOBJS@ +LT_CONFIG_H = @LT_CONFIG_H@ +LT_DLLOADERS = @LT_DLLOADERS@ +LT_DLPREOPEN = @LT_DLPREOPEN@ +MAINT = @MAINT@ +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@ +PREFIX = @PREFIX@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +VERSION = @VERSION@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +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@ +ltdl_LIBOBJS = @ltdl_LIBOBJS@ +ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ +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@ +sys_symbol_underscore = @sys_symbol_underscore@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign +@ENABLE_SSL_TRUE@respond_SOURCES = respond.c +mkpasswd_SOURCES = mkpasswd.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --foreign tools/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign tools/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_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 +mkpasswd$(EXEEXT): $(mkpasswd_OBJECTS) $(mkpasswd_DEPENDENCIES) $(EXTRA_mkpasswd_DEPENDENCIES) + @rm -f mkpasswd$(EXEEXT) + $(LINK) $(mkpasswd_OBJECTS) $(mkpasswd_LDADD) $(LIBS) +respond$(EXEEXT): $(respond_OBJECTS) $(respond_DEPENDENCIES) $(EXTRA_respond_DEPENDENCIES) + @rm -f respond$(EXEEXT) + $(LINK) $(respond_OBJECTS) $(respond_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkpasswd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/respond.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + 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 +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + 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: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + 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: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +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-binPROGRAMS clean-generic clean-libtool 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-binPROGRAMS + +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: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool cscopelist ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS 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 uninstall uninstall-am uninstall-binPROGRAMS + + +# 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/tools/README b/tools/README new file mode 100644 index 0000000..a90b098 --- /dev/null +++ b/tools/README @@ -0,0 +1,10 @@ +$Id$ + +A directory of support programs for ircd. + +mkkeypair - a small program used for generating a public and private + key pair +mkpasswd.c - makes password for operator{} blocks +respond.c - a tool to generate an RSA response to the challenge asked + by the server, and a tool to generate a keypair for the + C/R system diff --git a/tools/README.mkpasswd b/tools/README.mkpasswd new file mode 100644 index 0000000..3c179da --- /dev/null +++ b/tools/README.mkpasswd @@ -0,0 +1,50 @@ +$Id$ + +This is documentation for the mkpasswd.c included in ircd-hybrid-8. + +This version of mkpasswd can create both DES and MD5 passwords, with +either randomly generated or user provided salts. + +Options: +-6 - Create a SHA-512 password +-5 - Create a SHA-256 password +-m - Create an MD5 password +-b - Create a BlowFish password +-d - Create a DES password +-e - Create an Extended DES password +-l - Specify the length of a random MD5 salt +-r - Specify a number of rounds for a BlowFish or Extended DES password +-p - Specify the plaintext password at the command line +-s - Specify the salt at the command line +-R - Specify a raw salt passed directly to crypt() +-h - Get help + +Without the presence of any parameters, it'll behave like the old mkpasswd, +creating a DES password with a randomly generated salt and prompting for +the password (without echo). + +A DES salt is a pair of alphanumeric characters ('.' and '/' are permitted +as well), such as 'a4' or 'Td'. + +An MD5 salt consists of up to 16 (though most implementations limit you to +8) alphanumeric characters (plus '.' and '/'), +such as 'tGd' or 'J6d4dfG'. + +Known bugs: +Blowfish (on OpenBSD) is not yet supported +The encryption algorithms supported depend on your system's crypt() + implementation. +The maximum length of an MD5 salt is limited to your systems crypt() + implementation, typically 8. + +Supported Platforms (Known and tested): +Linux glibc (SHA since glibc 2.7, DES and MD5) +FreeBSD 3.x (DES (MD5 maybe)) +FreeBSD 4.x (DES and MD5) +Solaris 2.5-2.6 (DES only) +Cygwin 1.1.4 (DES only) +Prior Cygwin with the MD5 libcrypt (MD5 only) +OpenBSD 2.7 (don't link with -lcrypt) (DES and MD5, no Blowfish support) +Mac OS-X (Darwin) (don't link with -lcrypt) (DES only) + +Other systems probably work, but they haven't been amply tested. diff --git a/tools/README.respond b/tools/README.respond new file mode 100644 index 0000000..898bf85 --- /dev/null +++ b/tools/README.respond @@ -0,0 +1,36 @@ + rsa_respond + +respond: + +respond takes the challenge from the server and creates a valid response +to pass back to the server. + +Syntax: +$ ./respond <private key> <challenge> [passphrase] + +Notes: + +The private key file is protected by a passphrase, entered when the key is +created. The passphrase is prompted for whenever respond is called. + +Do not use mkkeypair to create a RSA key. The shell script will create it +without a passphrase. + +If the passphrase is passed on the command line (insecure mode), the +program will not prompt for a passphrase. This is primarily for running +rsa_respond from a script. + +Compiling: + +Untar the distribution +Read this document +Run 'configure' (not so foolproof, tweak the Makefile if necessary) +...and 'make' + +libcrypto from OpenSSL must be available in order to use this program. + +System support: +respond compiles properly, and have been tested on FreeBSD 4.x, Linux glibc, +Solaris 8, and Cygwin 1.2 or higher. + +# $Id: README 33 2005-10-02 20:50:00Z knight $ diff --git a/tools/mkkeypair b/tools/mkkeypair new file mode 100755 index 0000000..7393a10 --- /dev/null +++ b/tools/mkkeypair @@ -0,0 +1,54 @@ +#!/bin/sh +# $Id$ +# +# mkkeypair - short shell script to generate a OpenSSL RSA key suitable +# for use with cryptlinks. +# +# (C) 2003 Joshua Kwan and the IRCD-Hybrid team +# See LICENSE for the terms of copying. + +if test -f rsa.key; then + echo Moving old key out of the way to rsa.key.old + mv rsa.key rsa.key.old +fi + +if test -f rsa.pub; then + echo Moving old public key out of the way to rsa.pub.old + mv rsa.pub rsa.pub.old +fi + +echo Generating random bytes + +if test -c /dev/urandom; then + RANDGEN=/dev/urandom +elif test -c /dev/random; then + RANDGEN=/dev/random +else + RANDGEN=input +fi + +if test "$RANDGEN" = input; then + echo "Your system doesn't have a suitable random data generator," + echo "so type 150 characters of gibberish here to simulate it." + read -n 150 randomdata + echo + echo "$randomdata" > randdata + sort < randdata >> randdata.1 + cat randdata.1 >> randdata + rm -f randdata.1 +else + dd if=$RANDGEN of=randdata count=1 bs=2048 +fi + +echo Creating the private key. +openssl genrsa -rand randdata -out rsa.key 2048 || exit 1 +chmod 600 rsa.key +echo Creating the public key from the private key. +openssl rsa -in rsa.key -out rsa.pub -pubout || exit 1 +chmod 644 rsa.pub + +echo +echo Private key now exists as rsa.key +echo Public key now exists as rsa.pub + +rm -f randdata diff --git a/tools/mkpasswd.c b/tools/mkpasswd.c new file mode 100644 index 0000000..c4234d5 --- /dev/null +++ b/tools/mkpasswd.c @@ -0,0 +1,533 @@ +/* simple password generator by Nelson Minar (minar@reed.edu) +** copyright 1991, all rights reserved. +** You can use this code as long as my name stays with it. +** +** md5 patch by W. Campbell <wcampbel@botbay.net> +** Modernization, getopt, etc for the Hybrid IRCD team +** by W. Campbell +** +** /dev/random for salt generation added by +** Aaron Sethman <androsyn@ratbox.org> +** +** $Id$ +*/ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <time.h> +#include <unistd.h> +#include <fcntl.h> + +#define FLAG_MD5 0x00000001 +#define FLAG_DES 0x00000002 +#define FLAG_SALT 0x00000004 +#define FLAG_PASS 0x00000008 +#define FLAG_LENGTH 0x00000010 +#define FLAG_BLOWFISH 0x00000020 +#define FLAG_ROUNDS 0x00000040 +#define FLAG_EXT 0x00000080 +#define FLAG_RAW 0x00000100 +#define FLAG_SHA256 0x00000200 +#define FLAG_SHA512 0x00000400 + + +extern char *crypt(); + + +static char *make_sha256_salt(int); +static char *make_sha256_salt_para(const char *); +static char *make_sha512_salt(int); +static char *make_sha512_salt_para(const char *); +static char *make_des_salt(void); +static char *make_ext_salt(int); +static char *make_ext_salt_para(int, const char *); +static char *make_md5_salt(int); +static char *make_md5_salt_para(const char *); +static char *make_bf_salt(int, int); +static char *make_bf_salt_para(int, const char *); +static char *int_to_base64(int); +static char *generate_random_salt(char *, int); +static char *generate_poor_salt(char *, int); +static void full_usage(void); +static void brief_usage(void); + +static const char saltChars[] = + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + /* 0 .. 63, ascii - 64 */ + +int +main(int argc, char *argv[]) +{ + const char *plaintext = NULL; + int c; + char *saltpara = NULL; + char *salt; + int flag = 0; + int length = 0; /* Not Set */ + int rounds = 0; /* Not set, since extended DES needs 25 and blowfish needs + ** 4 by default, a side effect of this being the encryption + ** type parameter must be specified before the rounds + ** parameter. + */ + + while ((c = getopt(argc, argv, "56mdber:h?l:s:p:R:")) != -1) + { + switch (c) + { + case '5': + flag |= FLAG_SHA256; + break; + case '6': + flag |= FLAG_SHA512; + break; + case 'm': + flag |= FLAG_MD5; + break; + case 'd': + flag |= FLAG_DES; + break; + case 'b': + flag |= FLAG_BLOWFISH; + rounds = 4; + break; + case 'e': + flag |= FLAG_EXT; + rounds = 25; + break; + case 'l': + flag |= FLAG_LENGTH; + length = atoi(optarg); + break; + case 'r': + flag |= FLAG_ROUNDS; + rounds = atoi(optarg); + break; + case 's': + flag |= FLAG_SALT; + saltpara = optarg; + break; + case 'p': + flag |= FLAG_PASS; + plaintext = optarg; + break; + case 'R': + flag |= FLAG_RAW; + saltpara = optarg; + break; + case 'h': + full_usage(); + /* NOT REACHED */ + break; + case '?': + brief_usage(); + /* NOT REACHED */ + break; + default: + printf("Invalid Option: -%c\n", c); + break; + } + } + + if (flag & FLAG_MD5) + { + if (length == 0) + length = 8; + if (flag & FLAG_SALT) + salt = make_md5_salt_para(saltpara); + else + salt = make_md5_salt(length); + } + else if (flag & FLAG_SHA256) + { + if (length == 0) + length = 16; + if (flag & FLAG_SALT) + salt = make_sha256_salt_para(saltpara); + else + salt = make_sha256_salt(length); + } + else if (flag & FLAG_SHA512) + { + if (length == 0) + length = 16; + if (flag & FLAG_SALT) + salt = make_sha512_salt_para(saltpara); + else + salt = make_sha512_salt(length); + } + else if (flag & FLAG_BLOWFISH) + { + if (length == 0) + length = 22; + if (flag & FLAG_SALT) + salt = make_bf_salt_para(rounds, saltpara); + else + salt = make_bf_salt(rounds, length); + } + else if (flag & FLAG_EXT) + { + /* XXX - rounds needs to be done */ + if (flag & FLAG_SALT) + { + if ((strlen(saltpara) == 4)) + { + salt = make_ext_salt_para(rounds, saltpara); + } + else + { + printf("Invalid salt, please enter 4 alphanumeric characters\n"); + exit(1); + } + } + else + { + salt = make_ext_salt(rounds); + } + } + else if (flag & FLAG_RAW) + { + salt = saltpara; + } + else /* Default to DES */ + { + if (flag & FLAG_SALT) + { + if ((strlen(saltpara) == 2)) + { + salt = saltpara; + } + else + { + printf("Invalid salt, please enter 2 alphanumeric characters\n"); + exit(1); + } + } + else + { + salt = make_des_salt(); + } + } + + if (flag & FLAG_PASS) + { + if (!plaintext) + printf("Please enter a valid password\n"); + } + else + plaintext = getpass("plaintext: "); + + printf("%s\n", crypt(plaintext, salt)); + return 0; +} + +static char * +make_des_salt(void) +{ + static char salt[3]; + + generate_random_salt(salt, 2); + salt[2] = '\0'; + return salt; +} + +static char * +int_to_base64(int value) +{ + static char buf[5]; + int i; + + for (i = 0; i < 4; i++) + { + buf[i] = saltChars[value & 63]; + value >>= 6; /* Right shifting 6 places is the same as dividing by 64 */ + } + + buf[i] = '\0'; /* not REALLY needed as it's static, and thus initialized + ** to \0. + */ + return buf; +} + +static char * +make_ext_salt(int rounds) +{ + static char salt[10]; + + sprintf(salt, "_%s", int_to_base64(rounds)); + generate_random_salt(&salt[5], 4); + salt[9] = '\0'; + + return salt; +} + +static char * +make_ext_salt_para(int rounds, const char *saltpara) +{ + static char salt[10]; + + sprintf(salt, "_%s%s", int_to_base64(rounds), saltpara); + return salt; +} + +static char * +make_sha256_salt_para(const char *saltpara) +{ + static char salt[21]; + + if (saltpara && (strlen(saltpara) <= 16)) + { + /* + * sprintf used because of portability requirements, the length + * is checked above, so it should not be too much of a concern + */ + sprintf(salt, "$5$%s$", saltpara); + return salt; + } + + printf("Invalid Salt, please use up to 16 random alphanumeric characters\n"); + exit(1); + + /* NOT REACHED */ + return NULL; +} + +static char * +make_sha256_salt(int length) +{ + static char salt[21]; + + if (length > 16) + { + printf("SHA256 salt length too long\n"); + exit(0); + } + + salt[0] = '$'; + salt[1] = '5'; + salt[2] = '$'; + + generate_random_salt(&salt[3], length); + + salt[length + 3] = '$'; + salt[length + 4] = '\0'; + + return salt; +} + +static char * +make_sha512_salt_para(const char *saltpara) +{ + static char salt[21]; + + if (saltpara && (strlen(saltpara) <= 16)) + { + /* + * sprintf used because of portability requirements, the length + * is checked above, so it should not be too much of a concern + */ + sprintf(salt, "$6$%s$", saltpara); + return salt; + } + + printf("Invalid Salt, please use up to 16 random alphanumeric characters\n"); + exit(1); + + /* NOT REACHED */ + return NULL; +} + +static char * +make_sha512_salt(int length) +{ + static char salt[21]; + + if (length > 16) + { + printf("SHA512 salt length too long\n"); + exit(0); + } + + salt[0] = '$'; + salt[1] = '6'; + salt[2] = '$'; + + generate_random_salt(&salt[3], length); + + salt[length + 3] = '$'; + salt[length + 4] = '\0'; + + return salt; +} + +static char * +make_md5_salt_para(const char *saltpara) +{ + static char salt[21]; + + if (saltpara && (strlen(saltpara) <= 16)) + { + /* + * sprintf used because of portability requirements, the length + * is checked above, so it should not be too much of a concern + */ + sprintf(salt, "$1$%s$", saltpara); + return salt; + } + + printf("Invalid Salt, please use up to 16 random alphanumeric characters\n"); + exit(1); + + /* NOT REACHED */ + return NULL; +} + +static char * +make_md5_salt(int length) +{ + static char salt[21]; + + if (length > 16) + { + printf("MD5 salt length too long\n"); + exit(0); + } + + salt[0] = '$'; + salt[1] = '1'; + salt[2] = '$'; + + generate_random_salt(&salt[3], length); + + salt[length + 3] = '$'; + salt[length + 4] = '\0'; + + return salt; +} + +static char * +make_bf_salt_para(int rounds, const char *saltpara) +{ + static char salt[31]; + char tbuf[3]; + + if (saltpara && (strlen(saltpara) <= 22)) + { + /* + * sprintf used because of portability requirements, the length + * is checked above, so it should not be too much of a concern + */ + sprintf(tbuf, "%02d", rounds); + sprintf(salt, "$2a$%s$%s$", tbuf, saltpara); + return salt; + } + + printf("Invalid Salt, please use up to 22 random alphanumeric characters\n"); + exit(1); + + /* NOT REACHED */ + return NULL; +} + +static char * +make_bf_salt(int rounds, int length) +{ + static char salt[31]; + char tbuf[3]; + + if (length > 22) + { + printf("BlowFish salt length too long\n"); + exit(0); + } + + sprintf(tbuf, "%02d", rounds); + sprintf(salt, "$2a$%s$", tbuf); + + generate_random_salt(&salt[7], length); + + salt[length + 7] = '$'; + salt[length + 8] = '\0'; + + return salt; +} + +static char * +generate_poor_salt(char *salt, int length) +{ + int i; + + srandom(time(NULL)); + + for (i = 0; i < length; i++) + salt[i] = saltChars[random() % 64]; + + return salt; +} + +static char * +generate_random_salt(char *salt, int length) +{ + char *buf; + int fd, i; + + if ((fd = open("/dev/random", O_RDONLY)) < 0) + return generate_poor_salt(salt, length); + + buf = calloc(1, length); + + if (read(fd, buf, length) != length) + { + close(fd); + free(buf); + + return generate_poor_salt(salt, length); + } + + for (i = 0; i < length; i++) + salt[i] = saltChars[abs(buf[i]) % 64]; + + close(fd); + free(buf); + + return salt; +} + +static void +full_usage(void) +{ + printf("mkpasswd [-5|-6|-m|-d|-b|-e] [-l saltlength] [-r rounds] [-s salt] [-p plaintext]\n"); + printf(" [-R rawsalt]\n"); + printf("-5 Generate a SHA-256 password\n"); + printf("-6 Generate a SHA-512 password\n"); + printf("-m Generate an MD5 password\n"); + printf("-d Generate a DES password\n"); + printf("-b Generate a BlowFish password\n"); + printf("-e Generate an Extended DES password\n"); + printf("-l Specify a length for a random MD5 or BlowFish salt\n"); + printf("-r Specify a number of rounds for a BlowFish or Extended DES password\n"); + printf(" BlowFish: default 4, no more than 6 recommended\n"); + printf(" Extended DES: default 25\n"); + printf("-s Specify a salt, 2 alphanumeric characters for DES, up to 16 for SHA/MD5,\n"); + printf(" up to 22 for BlowFish, and 4 for Extended DES\n"); + printf("-R Specify a raw salt passed directly to crypt()\n"); + printf("-p Specify a plaintext password to use\n"); + printf("Example: mkpasswd -m -s 3dr -p test\n"); + exit(0); +} + +static void +brief_usage(void) +{ + printf("mkpasswd - password hash generator\n"); + printf("Standard DES: mkpasswd [-d] [-s salt] [-p plaintext]\n"); + printf("Extended DES: mkpasswd -e [-r rounds] [-s salt] [-p plaintext]\n"); + printf(" SHA-256: mkpasswd -5 [-l saltlength] [-s salt] [-p plaintext]\n"); + printf(" SHA-512: mkpasswd -6 [-l saltlength] [-s salt] [-p plaintext]\n"); + printf(" MD5: mkpasswd -m [-l saltlength] [-s salt] [-p plaintext]\n"); + printf(" BlowFish: mkpasswd -b [-r rounds] [-l saltlength] [-s salt]\n"); + printf(" [-p plaintext]\n"); + printf(" Raw: mkpasswd -R <rawsalt> [-p plaintext]\n"); + printf("Use -h for full usage\n"); + exit(0); +} diff --git a/tools/respond.c b/tools/respond.c new file mode 100644 index 0000000..9a2169c --- /dev/null +++ b/tools/respond.c @@ -0,0 +1,166 @@ +/* + * tools/rsa_respond/respond.c + * A simple RSA authentification challenge response generator for the + * ircd-hybrid CHALLENGE command. + * This code is Copyright(C)2001 by the past and present ircd-hybrid + * developers. + * This program is free software; you can redistribute it and/or modify + * it under the terms of 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. + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * $Id: respond.c 33 2005-10-02 20:50:00Z knight $ + */ +#include <stdio.h> +#include <string.h> +#include <openssl/err.h> +#include <openssl/rsa.h> +#include <openssl/pem.h> +#include <openssl/md5.h> +#include <unistd.h> + +static int insecure_mode = 0; +static char *pass_param = NULL; + +static int pass_cb(char *buf, int size, int rwflag, void *u) +{ + int len; + char *tmp; + + if (insecure_mode != 0) + { + if (pass_param == NULL) + return 0; + len = strlen(pass_param); + if (len <= 0) /* This SHOULDN'T happen */ + return 0; + if (len > size) + len = size; + memcpy(buf, pass_param, len); + return len; + } + + tmp = getpass("Enter passphrase for challenge: "); + if (!tmp) + { + puts("Couldn't read passphrase from stdin!"); + exit(-1); + } + len = strlen(tmp); + if (len <= 0) + return 0; + if (len > size) + len = size; + memcpy(buf, tmp, len); + return len; +} + +static void +binary_to_hex( unsigned char * bin, char * hex, int length ) +{ + static const char trans[] = "0123456789ABCDEF"; + int i; + + for( i = 0; i < length; i++ ) + { + hex[i<<1] = trans[bin[i] >> 4]; + hex[(i<<1)+1] = trans[bin[i] & 0xf]; + } + hex[i<<1] = '\0'; +} + +static int +hex_to_binary(const char *from, char *to, int len) +{ + char a, b=1; + int p=0; + const char *ptr = from; + while (-1) + { + a = *ptr++; + if (!a) + break; + b = *ptr++; + + /* If this happens, we got bad input. */ + if (!b) + break; + if (p >= len) + break; + if (!((a >= '0' && a <= '9') || (a >= 'A' && a <= 'F'))) + break; + if (!((b >= '0' && b <= '9') || (b >= 'A' && b <= 'F'))) + break; + to[p++] = ((a <= '9') ? (a - '0') : (a - 'A' + 0xA))<<4 | + ((b <= '9') ? (b - '0') : (b - 'A' + 0xA)); + } + return p; +} + +int +main(int argc, char **argv) +{ + FILE *kfile; + RSA *rsa = NULL; + char ndata[257], ddata[257]; + /* respond privatefile challenge */ + if (argc < 3) + { + puts("Usage: respond privatefile challenge [passphrase]"); + return 0; + } + + if (argc == 4) + { + /* This is TOTALLY insecure and not recommended, but for + ** interfacing with irc client scripts, it's either this + ** or don't use a passphrase. + ** + ** The likelihood of a passphrase leaking isn't TOO great, + ** only ps auxww will show it, and even then, only at the + ** precise moment this is called. + */ + insecure_mode = 1; + pass_param = argv[3]; + } + + if (!(kfile = fopen(argv[1], "r"))) + { + puts("Could not open the private keyfile."); + return 0; + } + + SSLeay_add_all_ciphers(); + rsa = PEM_read_RSAPrivateKey(kfile, NULL,pass_cb, NULL); + + if(!rsa) + { + puts("Unable to read your private key, is the passphrase wrong?"); + return 0; + } + + fclose(kfile); + if (hex_to_binary(argv[2], ndata, 128) != 128) + { + puts("Bad challenge."); + return -1; + } + + if (RSA_private_decrypt(128, (unsigned char*)ndata, + (unsigned char*)ddata, rsa, RSA_PKCS1_PADDING) == -1) + { + puts("Decryption error."); + return -1; + } + binary_to_hex((unsigned char*)ddata, ndata, 32); + puts(ndata); + return 0; +} |