diff options
Diffstat (limited to 'lib/ntlm')
-rw-r--r-- | lib/ntlm/Makefile.am | 7 | ||||
-rw-r--r-- | lib/ntlm/Makefile.in | 868 | ||||
-rw-r--r-- | lib/ntlm/NTMakefile | 2 | ||||
-rw-r--r-- | lib/ntlm/heimntlm-protos.h | 267 | ||||
-rw-r--r-- | lib/ntlm/heimntlm.h | 13 | ||||
-rw-r--r-- | lib/ntlm/ntlm.c | 508 | ||||
-rw-r--r-- | lib/ntlm/ntlm_err.et | 38 | ||||
-rw-r--r-- | lib/ntlm/test_ntlm.c | 261 |
8 files changed, 1566 insertions, 398 deletions
diff --git a/lib/ntlm/Makefile.am b/lib/ntlm/Makefile.am index 8b36bbc14e48..d33efd2b679a 100644 --- a/lib/ntlm/Makefile.am +++ b/lib/ntlm/Makefile.am @@ -2,11 +2,9 @@ include $(top_srcdir)/Makefile.am.common -AM_CPPFLAGS += $(INCLUDE_hcrypto) - lib_LTLIBRARIES = libheimntlm.la -dist_include_HEADERS = heimntlm.h heimntlm-protos.h +dist_include_HEADERS = heimntlm.h $(srcdir)/heimntlm-protos.h nodist_include_HEADERS = ntlm_err.h @@ -23,10 +21,11 @@ $(libheimntlm_la_OBJECTS): $(srcdir)/version-script.map libheimntlm_la_LIBADD = \ ../krb5/libkrb5.la \ + $(top_builddir)/lib/wind/libwind.la \ $(LIB_hcrypto) \ $(LIBADD_roken) -$(srcdir)/heimntlm-protos.h: +$(srcdir)/heimntlm-protos.h: $(dist_libheimntlm_la_SOURCES) cd $(srcdir) && perl ../../cf/make-proto.pl -q -P comment -o heimntlm-protos.h $(dist_libheimntlm_la_SOURCES) || rm -f heimntlm-protos.h $(libheimntlm_la_OBJECTS): $(srcdir)/heimntlm-protos.h ntlm_err.h diff --git a/lib/ntlm/Makefile.in b/lib/ntlm/Makefile.in index f033c982259f..28cebe5ca621 100644 --- a/lib/ntlm/Makefile.in +++ b/lib/ntlm/Makefile.in @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2017 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. @@ -23,6 +22,61 @@ VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +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@ @@ -41,9 +95,6 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -DIST_COMMON = $(dist_include_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/Makefile.am.common \ - $(top_srcdir)/cf/Makefile.am.common ChangeLog @versionscript_TRUE@am__append_1 = $(LDFLAGS_VERSION_SCRIPT)$(srcdir)/version-script.map TESTS = test_ntlm$(EXEEXT) check_PROGRAMS = test_ntlm$(EXEEXT) @@ -62,8 +113,7 @@ am__aclocal_m4_deps = $(top_srcdir)/cf/aix.m4 \ $(top_srcdir)/cf/check-man.m4 \ $(top_srcdir)/cf/check-netinet-ip-and-tcp.m4 \ $(top_srcdir)/cf/check-type-extra.m4 \ - $(top_srcdir)/cf/check-var.m4 $(top_srcdir)/cf/check-x.m4 \ - $(top_srcdir)/cf/check-xau.m4 $(top_srcdir)/cf/crypto.m4 \ + $(top_srcdir)/cf/check-var.m4 $(top_srcdir)/cf/crypto.m4 \ $(top_srcdir)/cf/db.m4 $(top_srcdir)/cf/destdirs.m4 \ $(top_srcdir)/cf/dispatch.m4 $(top_srcdir)/cf/dlopen.m4 \ $(top_srcdir)/cf/find-func-no-libs.m4 \ @@ -76,6 +126,7 @@ am__aclocal_m4_deps = $(top_srcdir)/cf/aix.m4 \ $(top_srcdir)/cf/krb-bigendian.m4 \ $(top_srcdir)/cf/krb-func-getlogin.m4 \ $(top_srcdir)/cf/krb-ipv6.m4 $(top_srcdir)/cf/krb-prog-ln-s.m4 \ + $(top_srcdir)/cf/krb-prog-perl.m4 \ $(top_srcdir)/cf/krb-readline.m4 \ $(top_srcdir)/cf/krb-struct-spwd.m4 \ $(top_srcdir)/cf/krb-struct-winsize.m4 \ @@ -95,6 +146,8 @@ am__aclocal_m4_deps = $(top_srcdir)/cf/aix.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_include_HEADERS) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = @@ -120,48 +173,284 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" \ "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = -libheimntlm_la_DEPENDENCIES = ../krb5/libkrb5.la $(am__DEPENDENCIES_1) \ +libheimntlm_la_DEPENDENCIES = ../krb5/libkrb5.la \ + $(top_builddir)/lib/wind/libwind.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) dist_libheimntlm_la_OBJECTS = ntlm.lo nodist_libheimntlm_la_OBJECTS = ntlm_err.lo libheimntlm_la_OBJECTS = $(dist_libheimntlm_la_OBJECTS) \ $(nodist_libheimntlm_la_OBJECTS) -libheimntlm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libheimntlm_la_LDFLAGS) $(LDFLAGS) -o $@ +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 = +libheimntlm_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(libheimntlm_la_LDFLAGS) $(LDFLAGS) -o \ + $@ test_ntlm_SOURCES = test_ntlm.c test_ntlm_OBJECTS = test_ntlm.$(OBJEXT) test_ntlm_LDADD = $(LDADD) test_ntlm_DEPENDENCIES = libheimntlm.la $(am__DEPENDENCIES_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 = 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) +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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ +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 = $(dist_libheimntlm_la_SOURCES) \ $(nodist_libheimntlm_la_SOURCES) test_ntlm.c DIST_SOURCES = $(dist_libheimntlm_la_SOURCES) test_ntlm.c +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac HEADERS = $(dist_include_HEADERS) $(nodist_include_HEADERS) +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 -am__tty_colors = \ -red=; grn=; lgn=; blu=; std= +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.am.common \ + $(top_srcdir)/cf/Makefile.am.common $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver ChangeLog DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ +AS = @AS@ ASN1_COMPILE = @ASN1_COMPILE@ ASN1_COMPILE_DEP = @ASN1_COMPILE_DEP@ AUTOCONF = @AUTOCONF@ @@ -180,12 +469,12 @@ COMPILE_ET = @COMPILE_ET@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ +DB1LIB = @DB1LIB@ +DB3LIB = @DB3LIB@ DBHEADER = @DBHEADER@ -DBLIB = @DBLIB@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIR_com_err = @DIR_com_err@ -DIR_hcrypto = @DIR_hcrypto@ DIR_hdbdir = @DIR_hdbdir@ DIR_roken = @DIR_roken@ DLLTOOL = @DLLTOOL@ @@ -195,17 +484,17 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +ENABLE_AFS_STRING_TO_KEY = @ENABLE_AFS_STRING_TO_KEY@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GCD_MIG = @GCD_MIG@ GREP = @GREP@ GROFF = @GROFF@ INCLUDES_roken = @INCLUDES_roken@ -INCLUDE_hcrypto = @INCLUDE_hcrypto@ -INCLUDE_hesiod = @INCLUDE_hesiod@ -INCLUDE_krb4 = @INCLUDE_krb4@ INCLUDE_libedit = @INCLUDE_libedit@ INCLUDE_libintl = @INCLUDE_libintl@ INCLUDE_openldap = @INCLUDE_openldap@ +INCLUDE_openssl_crypto = @INCLUDE_openssl_crypto@ INCLUDE_readline = @INCLUDE_readline@ INCLUDE_sqlite3 = @INCLUDE_sqlite3@ INSTALL = @INSTALL@ @@ -224,12 +513,9 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@ -LIB_NDBM = @LIB_NDBM@ -LIB_XauFileName = @LIB_XauFileName@ -LIB_XauReadAuth = @LIB_XauReadAuth@ -LIB_XauWriteAuth = @LIB_XauWriteAuth@ LIB_bswap16 = @LIB_bswap16@ LIB_bswap32 = @LIB_bswap32@ +LIB_bswap64 = @LIB_bswap64@ LIB_com_err = @LIB_com_err@ LIB_com_err_a = @LIB_com_err_a@ LIB_com_err_so = @LIB_com_err_so@ @@ -238,6 +524,7 @@ LIB_db_create = @LIB_db_create@ LIB_dbm_firstkey = @LIB_dbm_firstkey@ LIB_dbopen = @LIB_dbopen@ LIB_dispatch_async_f = @LIB_dispatch_async_f@ +LIB_dladdr = @LIB_dladdr@ LIB_dlopen = @LIB_dlopen@ LIB_dn_expand = @LIB_dn_expand@ LIB_dns_search = @LIB_dns_search@ @@ -254,10 +541,8 @@ LIB_hcrypto = @LIB_hcrypto@ LIB_hcrypto_a = @LIB_hcrypto_a@ LIB_hcrypto_appl = @LIB_hcrypto_appl@ LIB_hcrypto_so = @LIB_hcrypto_so@ -LIB_hesiod = @LIB_hesiod@ LIB_hstrerror = @LIB_hstrerror@ LIB_kdb = @LIB_kdb@ -LIB_krb4 = @LIB_krb4@ LIB_libedit = @LIB_libedit@ LIB_libintl = @LIB_libintl@ LIB_loadquery = @LIB_loadquery@ @@ -265,6 +550,7 @@ LIB_logout = @LIB_logout@ LIB_logwtmp = @LIB_logwtmp@ LIB_openldap = @LIB_openldap@ LIB_openpty = @LIB_openpty@ +LIB_openssl_crypto = @LIB_openssl_crypto@ LIB_otp = @LIB_otp@ LIB_pidfile = @LIB_pidfile@ LIB_readline = @LIB_readline@ @@ -279,12 +565,15 @@ LIB_sqlite3 = @LIB_sqlite3@ LIB_syslog = @LIB_syslog@ LIB_tgetent = @LIB_tgetent@ LIPO = @LIPO@ +LMDBLIB = @LMDBLIB@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +NDBMLIB = @NDBMLIB@ NM = @NM@ NMEDIT = @NMEDIT@ NO_AFS = @NO_AFS@ @@ -301,6 +590,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LDADD = @PTHREAD_LDADD@ @@ -315,13 +605,7 @@ STRIP = @STRIP@ VERSION = @VERSION@ VERSIONING = @VERSIONING@ WFLAGS = @WFLAGS@ -WFLAGS_NOIMPLICITINT = @WFLAGS_NOIMPLICITINT@ -WFLAGS_NOUNUSED = @WFLAGS_NOUNUSED@ -XMKMF = @XMKMF@ -X_CFLAGS = @X_CFLAGS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_LIBS = @X_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ +WFLAGS_LITE = @WFLAGS_LITE@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ @@ -345,6 +629,8 @@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ +db_type = @db_type@ +db_type_preference = @db_type_preference@ docdir = @docdir@ dpagaix_cflags = @dpagaix_cflags@ dpagaix_ldadd = @dpagaix_ldadd@ @@ -380,37 +666,46 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUFFIXES = .et .h .x .z .hx .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 +SUFFIXES = .et .h .pc.in .pc .x .z .hx .1 .3 .5 .7 .8 .cat1 .cat3 \ + .cat5 .cat7 .cat8 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -AM_CPPFLAGS = $(INCLUDES_roken) $(INCLUDE_hcrypto) +AM_CPPFLAGS = $(INCLUDES_roken) @do_roken_rename_TRUE@ROKEN_RENAME = -DROKEN_RENAME AM_CFLAGS = $(WFLAGS) CP = cp buildinclude = $(top_builddir)/include +LIB_XauReadAuth = @LIB_XauReadAuth@ LIB_el_init = @LIB_el_init@ LIB_getattr = @LIB_getattr@ LIB_getpwent_r = @LIB_getpwent_r@ LIB_odm_initialize = @LIB_odm_initialize@ LIB_setpcred = @LIB_setpcred@ -HESIODLIB = @HESIODLIB@ -HESIODINCLUDE = @HESIODINCLUDE@ +INCLUDE_krb4 = @INCLUDE_krb4@ +LIB_krb4 = @LIB_krb4@ libexec_heimdaldir = $(libexecdir)/heimdal NROFF_MAN = groff -mandoc -Tascii -LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) +@NO_AFS_FALSE@LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) +@NO_AFS_TRUE@LIB_kafs = @KRB5_TRUE@LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la \ @KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la @KRB5_TRUE@LIB_gssapi = $(top_builddir)/lib/gssapi/libgssapi.la -LIB_heimbase = $(top_builddir)/base/libheimbase.la +LIB_heimbase = $(top_builddir)/lib/base/libheimbase.la @DCE_TRUE@LIB_kdfs = $(top_builddir)/lib/kdfs/libkdfs.la + +#silent-rules +heim_verbose = $(heim_verbose_$(V)) +heim_verbose_ = $(heim_verbose_$(AM_DEFAULT_VERBOSITY)) +heim_verbose_0 = @echo " GEN "$@; lib_LTLIBRARIES = libheimntlm.la -dist_include_HEADERS = heimntlm.h heimntlm-protos.h +dist_include_HEADERS = heimntlm.h $(srcdir)/heimntlm-protos.h nodist_include_HEADERS = ntlm_err.h dist_libheimntlm_la_SOURCES = ntlm.c heimntlm.h nodist_libheimntlm_la_SOURCES = ntlm_err.c libheimntlm_la_LDFLAGS = -version-info 1:0:1 $(am__append_1) libheimntlm_la_LIBADD = \ ../krb5/libkrb5.la \ + $(top_builddir)/lib/wind/libwind.la \ $(LIB_hcrypto) \ $(LIBADD_roken) @@ -428,7 +723,7 @@ CLEANFILES = \ all: all-am .SUFFIXES: -.SUFFIXES: .et .h .x .z .hx .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .c .lo .o .obj +.SUFFIXES: .et .h .pc.in .pc .x .z .hx .1 .3 .5 .7 .8 .cat1 .cat3 .cat5 .cat7 .cat8 .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -441,7 +736,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/ntlm/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign lib/ntlm/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -450,6 +744,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; +$(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh @@ -459,9 +754,9 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): + install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ @@ -469,6 +764,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) else :; fi; \ done; \ test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } @@ -484,14 +781,17 @@ uninstall-libLTLIBRARIES: clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libheimntlm.la: $(libheimntlm_la_OBJECTS) $(libheimntlm_la_DEPENDENCIES) - $(libheimntlm_la_LINK) -rpath $(libdir) $(libheimntlm_la_OBJECTS) $(libheimntlm_la_LIBADD) $(LIBS) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libheimntlm.la: $(libheimntlm_la_OBJECTS) $(libheimntlm_la_DEPENDENCIES) $(EXTRA_libheimntlm_la_DEPENDENCIES) + $(AM_V_CCLD)$(libheimntlm_la_LINK) -rpath $(libdir) $(libheimntlm_la_OBJECTS) $(libheimntlm_la_LIBADD) $(LIBS) clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -501,9 +801,10 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -test_ntlm$(EXEEXT): $(test_ntlm_OBJECTS) $(test_ntlm_DEPENDENCIES) + +test_ntlm$(EXEEXT): $(test_ntlm_OBJECTS) $(test_ntlm_DEPENDENCIES) $(EXTRA_test_ntlm_DEPENDENCIES) @rm -f test_ntlm$(EXEEXT) - $(LINK) $(test_ntlm_OBJECTS) $(test_ntlm_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(test_ntlm_OBJECTS) $(test_ntlm_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -516,25 +817,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_ntlm.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@ +@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@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .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@ +@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@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(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@ +@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@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -543,8 +844,11 @@ clean-libtool: -rm -rf .libs _libs install-dist_includeHEADERS: $(dist_include_HEADERS) @$(NORMAL_INSTALL) - test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(dist_include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -558,13 +862,14 @@ uninstall-dist_includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(dist_include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(includedir)" && rm -f $$files + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) install-nodist_includeHEADERS: $(nodist_include_HEADERS) @$(NORMAL_INSTALL) - test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -578,30 +883,17 @@ uninstall-nodist_includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(includedir)" && rm -f $$files - -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) + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +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`; \ - 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; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -613,15 +905,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $$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; }; }'`; \ +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 @@ -630,101 +918,187 @@ 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 -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; skip=0; \ - srcdir=$(srcdir); export srcdir; \ - list=' $(TESTS) '; \ - $(am__tty_colors); \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - col=$$red; res=XPASS; \ - ;; \ - *) \ - col=$$grn; res=PASS; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xfail=`expr $$xfail + 1`; \ - col=$$lgn; res=XFAIL; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - col=$$red; res=FAIL; \ - ;; \ - esac; \ - else \ - skip=`expr $$skip + 1`; \ - col=$$blu; res=SKIP; \ - fi; \ - echo "$${col}$$res$${std}: $$tst"; \ - done; \ - if test "$$all" -eq 1; then \ - tests="test"; \ - All=""; \ - else \ - tests="tests"; \ - All="All "; \ +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="$$All$$all $$tests passed"; \ - else \ - if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ - banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ - fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all $$tests failed"; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ else \ - if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ - banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ - fi; \ - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - if test "$$skip" -eq 1; then \ - skipped="($$skip test was not run)"; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ else \ - skipped="($$skip tests were not run)"; \ + color_start= color_end=; \ fi; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ - fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ - fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ - else \ - echo "$$red$$dashes"; \ - fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ - test "$$failed" -eq 0; \ - else :; fi + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +test_ntlm.log: test_ntlm$(EXEEXT) + @p='test_ntlm$(EXEEXT)'; \ + b='test_ntlm'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -778,11 +1152,19 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + 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: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) @@ -825,9 +1207,8 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-libLTLIBRARIES - @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-exec-am: install-exec-local install-libLTLIBRARIES + install-html: install-html-am install-html-am: @@ -870,43 +1251,57 @@ uninstall-am: uninstall-dist_includeHEADERS uninstall-libLTLIBRARIES \ uninstall-nodist_includeHEADERS @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook -.MAKE: check-am install-am install-data-am install-exec-am \ - install-strip uninstall-am - -.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \ - check-local clean clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags dist-hook 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-data-hook install-dist_includeHEADERS install-dvi \ - install-dvi-am install-exec install-exec-am install-exec-hook \ - install-html install-html-am install-info install-info-am \ +.MAKE: check-am install-am install-data-am install-strip uninstall-am + +.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-TESTS \ + check-am check-local clean clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ + ctags-am dist-hook 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-data-hook \ + install-dist_includeHEADERS install-dvi install-dvi-am \ + install-exec install-exec-am install-exec-local install-html \ + install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man \ install-nodist_includeHEADERS 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-dist_includeHEADERS \ - uninstall-hook uninstall-libLTLIBRARIES \ - uninstall-nodist_includeHEADERS + recheck tags tags-am uninstall uninstall-am \ + uninstall-dist_includeHEADERS uninstall-hook \ + uninstall-libLTLIBRARIES uninstall-nodist_includeHEADERS + +.PRECIOUS: Makefile install-suid-programs: @foo='$(bin_SUIDS)'; \ for file in $$foo; do \ - x=$(DESTDIR)$(bindir)/$$file; \ - if chown 0:0 $$x && chmod u+s $$x; then :; else \ - echo "*"; \ - echo "* Failed to install $$x setuid root"; \ - echo "*"; \ - fi; done + x=$(DESTDIR)$(bindir)/$$file; \ + if chown 0:0 $$x && chmod u+s $$x; then :; else \ + echo "*"; \ + echo "* Failed to install $$x setuid root"; \ + echo "*"; \ + fi; \ + done + +install-exec-local: install-suid-programs + +codesign-all: + @if [ X"$$CODE_SIGN_IDENTITY" != X ] ; then \ + foo='$(bin_PROGRAMS) $(sbin_PROGRAMS) $(libexec_PROGRAMS)' ; \ + for file in $$foo ; do \ + echo "CODESIGN $$file" ; \ + codesign -f -s "$$CODE_SIGN_IDENTITY" $$file || exit 1 ; \ + done ; \ + fi -install-exec-hook: install-suid-programs +all-local: codesign-all -install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(nobase_include_HEADERS) - @foo='$(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ)'; \ +install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(nobase_include_HEADERS) $(noinst_HEADERS) + @foo='$(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(noinst_HEADERS)'; \ for f in $$foo; do \ f=`basename $$f`; \ if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \ @@ -914,7 +1309,7 @@ install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_incl if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \ : ; else \ echo " $(CP) $$file $(buildinclude)/$$f"; \ - $(CP) $$file $(buildinclude)/$$f; \ + $(CP) $$file $(buildinclude)/$$f || true; \ fi ; \ done ; \ foo='$(nobase_include_HEADERS)'; \ @@ -971,6 +1366,8 @@ check-local:: $(NROFF_MAN) $< > $@ .5.cat5: $(NROFF_MAN) $< > $@ +.7.cat7: + $(NROFF_MAN) $< > $@ .8.cat8: $(NROFF_MAN) $< > $@ @@ -1013,6 +1410,19 @@ dist-cat5-mans: $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ done +dist-cat7-mans: + @foo='$(man7_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.7) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat7/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + dist-cat8-mans: @foo='$(man8_MANS)'; \ bar='$(man_MANS)'; \ @@ -1026,13 +1436,13 @@ dist-cat8-mans: $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ done -dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans +dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat7-mans dist-cat8-mans install-cat-mans: - $(SHELL) $(top_srcdir)/cf/install-catman.sh install "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS) + $(SHELL) $(top_srcdir)/cf/install-catman.sh install "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man7_MANS) $(man8_MANS) uninstall-cat-mans: - $(SHELL) $(top_srcdir)/cf/install-catman.sh uninstall "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS) + $(SHELL) $(top_srcdir)/cf/install-catman.sh uninstall "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man7_MANS) $(man8_MANS) install-data-hook: install-cat-mans uninstall-hook: uninstall-cat-mans @@ -1064,7 +1474,7 @@ distdir-in-tree: $(DISTFILES) $(INFO_DEPS) done $(libheimntlm_la_OBJECTS): $(srcdir)/version-script.map -$(srcdir)/heimntlm-protos.h: +$(srcdir)/heimntlm-protos.h: $(dist_libheimntlm_la_SOURCES) cd $(srcdir) && perl ../../cf/make-proto.pl -q -P comment -o heimntlm-protos.h $(dist_libheimntlm_la_SOURCES) || rm -f heimntlm-protos.h $(libheimntlm_la_OBJECTS): $(srcdir)/heimntlm-protos.h ntlm_err.h diff --git a/lib/ntlm/NTMakefile b/lib/ntlm/NTMakefile index 40ed64449572..527fc891266d 100644 --- a/lib/ntlm/NTMakefile +++ b/lib/ntlm/NTMakefile @@ -75,7 +75,7 @@ test-binaries: $(OBJ)\test_ntlm.exe test-run: cd $(OBJ) - test_ntlm.exe + -test_ntlm.exe cd $(SRCDIR) $(OBJ)\test_ntlm.exe: $(OBJ)\test_ntlm.obj $(LIBHEIMNTLM) $(LIBHEIMDAL) $(LIBVERS) $(LIBROKEN) diff --git a/lib/ntlm/heimntlm-protos.h b/lib/ntlm/heimntlm-protos.h index 5f56536ffc3b..b44dbc312527 100644 --- a/lib/ntlm/heimntlm-protos.h +++ b/lib/ntlm/heimntlm-protos.h @@ -1,6 +1,7 @@ /* This is a generated file */ #ifndef __heimntlm_protos_h__ #define __heimntlm_protos_h__ +#ifndef DOXY #include <stdarg.h> @@ -8,6 +9,20 @@ extern "C" { #endif +/** + * Generates an NTLMv1 session random with assosited session master key. + * + * @param key the ntlm v1 key + * @param len length of key + * @param session generated session nonce, should be freed with heim_ntlm_free_buf(). + * @param master calculated session master key, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_build_ntlm1_master ( void */*key*/, @@ -15,6 +30,21 @@ heim_ntlm_build_ntlm1_master ( struct ntlm_buf */*session*/, struct ntlm_buf */*master*/); +/** + * Generates an NTLMv2 session random with associated session master key. + * + * @param key the NTLMv2 key + * @param len length of key + * @param blob the NTLMv2 "blob" + * @param session generated session nonce, should be freed with heim_ntlm_free_buf(). + * @param master calculated session master key, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_build_ntlm2_master ( void */*key*/, @@ -23,6 +53,23 @@ heim_ntlm_build_ntlm2_master ( struct ntlm_buf */*session*/, struct ntlm_buf */*master*/); +/** + * Calculate LMv2 response + * + * @param key the ntlm key + * @param len length of key + * @param username name of the user, as sent in the message, assumed to be in UTF8. + * @param target the name of the target, assumed to be in UTF8. + * @param serverchallenge challenge as sent by the server in the type2 message. + * @param ntlmv2 calculated session key + * @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_calculate_lm2 ( const void */*key*/, @@ -33,6 +80,20 @@ heim_ntlm_calculate_lm2 ( unsigned char ntlmv2[16], struct ntlm_buf */*answer*/); +/** + * Calculate NTLMv1 response hash + * + * @param key the ntlm v1 key + * @param len length of key + * @param challenge sent by the server + * @param answer calculated answer, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_calculate_ntlm1 ( void */*key*/, @@ -40,6 +101,24 @@ heim_ntlm_calculate_ntlm1 ( unsigned char challenge[8], struct ntlm_buf */*answer*/); +/** + * Calculate NTLMv2 response + * + * @param key the ntlm key + * @param len length of key + * @param username name of the user, as sent in the message, assumed to be in UTF8. + * @param target the name of the target, assumed to be in UTF8. + * @param serverchallenge challenge as sent by the server in the type2 message. + * @param infotarget infotarget as sent by the server in the type2 message. + * @param ntlmv2 calculated session key + * @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_calculate_ntlm2 ( const void */*key*/, @@ -51,6 +130,10 @@ heim_ntlm_calculate_ntlm2 ( unsigned char ntlmv2[16], struct ntlm_buf */*answer*/); +/** + * Third check with empty domain. + */ + int heim_ntlm_calculate_ntlm2_sess ( const unsigned char clnt_nonce[8], @@ -65,6 +148,19 @@ heim_ntlm_calculate_ntlm2_sess_hash ( const unsigned char svr_chal[8], unsigned char verifier[8]); +/** + * Decodes an NTLM targetinfo message + * + * @param data input data buffer with the encode NTLM targetinfo message + * @param ucs2 if the strings should be encoded with ucs2 (selected by flag in message). + * @param ti the decoded target info, should be freed with heim_ntlm_free_targetinfo(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_decode_targetinfo ( const struct ntlm_buf */*data*/, @@ -95,42 +191,150 @@ heim_ntlm_derive_ntlm2_sess ( const unsigned char svr_chal[8], unsigned char derivedkey[16]); +/** + * Encodes a ntlm_targetinfo message. + * + * @param ti the ntlm_targetinfo message to encode. + * @param ucs2 ignored + * @param data is the return buffer with the encoded message, should be + * freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_encode_targetinfo ( const struct ntlm_targetinfo */*ti*/, int /*ucs2*/, struct ntlm_buf */*data*/); +/** + * Encodes an ntlm_type1 message. + * + * @param type1 the ntlm_type1 message to encode. + * @param data is the return buffer with the encoded message, should be + * freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_encode_type1 ( const struct ntlm_type1 */*type1*/, struct ntlm_buf */*data*/); +/** + * Encodes an ntlm_type2 message. + * + * @param type2 the ntlm_type2 message to encode. + * @param data is the return buffer with the encoded message, should be + * freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_encode_type2 ( const struct ntlm_type2 */*type2*/, struct ntlm_buf */*data*/); +/** + * Encodes an ntlm_type3 message. + * + * @param type3 the ntlm_type3 message to encode. + * @param data is the return buffer with the encoded message, should be + * @param[out] mic_offset offset of message integrity code + * freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_encode_type3 ( const struct ntlm_type3 */*type3*/, - struct ntlm_buf */*data*/); + struct ntlm_buf */*data*/, + size_t */*mic_offset*/); + +/** + * heim_ntlm_free_buf frees the ntlm buffer + * + * @param p buffer to be freed + * + * @ingroup ntlm_core + */ void heim_ntlm_free_buf (struct ntlm_buf */*p*/); +/** + * Frees the ntlm_targetinfo message + * + * @param ti targetinfo to be freed + * + * @ingroup ntlm_core + */ + void heim_ntlm_free_targetinfo (struct ntlm_targetinfo */*ti*/); +/** + * Frees the ntlm_type1 message + * + * @param data message to be freed + * + * @ingroup ntlm_core + */ + void heim_ntlm_free_type1 (struct ntlm_type1 */*data*/); +/** + * Frees the ntlm_type2 message + * + * @param data message to be freed + * + * @ingroup ntlm_core + */ + void heim_ntlm_free_type2 (struct ntlm_type2 */*data*/); +/** + * Frees the ntlm_type3 message + * + * @param data message to be freed + * + * @ingroup ntlm_core + */ + void heim_ntlm_free_type3 (struct ntlm_type3 */*data*/); +/** + * Given a key and encrypted session, unwrap the session key + * + * @param baseKey the sessionBaseKey + * @param encryptedSession encrypted session, type3.session field. + * @param session generated session nonce, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_keyex_unwrap ( struct ntlm_buf */*baseKey*/, @@ -143,19 +347,60 @@ heim_ntlm_keyex_wrap ( struct ntlm_buf */*session*/, struct ntlm_buf */*encryptedSession*/); +/** + * Calculate the NTLM key, the password is assumed to be in UTF8. + * + * @param password password to calcute the key for. + * @param key calcuted key, should be freed with heim_ntlm_free_buf(). + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_nt_key ( const char */*password*/, struct ntlm_buf */*key*/); +/** + * Generates an NTLMv2 session key. + * + * @param key the ntlm key + * @param len length of key + * @param username name of the user, as sent in the message, assumed to be in UTF8. + * @param target the name of the target, assumed to be in UTF8. + * @param upper_case_target upper case the target, should not be used only for legacy systems + * @param ntlmv2 the ntlmv2 session key + * + * @return 0 on success, or an error code on failure. + * + * @ingroup ntlm_core + */ + int heim_ntlm_ntlmv2_key ( const void */*key*/, size_t /*len*/, const char */*username*/, const char */*target*/, + int /*upper_case_target*/, unsigned char ntlmv2[16]); +time_t +heim_ntlm_ts2unixtime (uint64_t /*t*/); + +uint64_t +heim_ntlm_unix2ts_time (time_t /*unix_time*/); + +/** + @defgroup ntlm_core Heimdal NTLM library * + * The NTLM core functions implement the string2key generation + * function, message encode and decode function, and the hash function + * functions. + */ + size_t heim_ntlm_unparse_flags ( uint32_t /*flags*/, @@ -175,6 +420,25 @@ heim_ntlm_v2_base_session ( struct ntlm_buf */*ntlmResponse*/, struct ntlm_buf */*session*/); +/** + * Verify NTLMv2 response. + * + * @param key the ntlm key + * @param len length of key + * @param username name of the user, as sent in the message, assumed to be in UTF8. + * @param target the name of the target, assumed to be in UTF8. + * @param now the time now (0 if the library should pick it up itself) + * @param serverchallenge challenge as sent by the server in the type2 message. + * @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). + * @param infotarget infotarget as sent by the server in the type2 message. + * @param ntlmv2 calculated session key + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + int heim_ntlm_verify_ntlm2 ( const void */*key*/, @@ -191,4 +455,5 @@ heim_ntlm_verify_ntlm2 ( } #endif +#endif /* DOXY */ #endif /* __heimntlm_protos_h__ */ diff --git a/lib/ntlm/heimntlm.h b/lib/ntlm/heimntlm.h index 22e2142df88f..6b24649df849 100644 --- a/lib/ntlm/heimntlm.h +++ b/lib/ntlm/heimntlm.h @@ -70,8 +70,8 @@ struct ntlm_buf { #define NTLM_TARGET_DOMAIN 0x00010000 #define NTLM_TARGET_SERVER 0x00020000 -#define NTLM_TARGET_SHARE 0x00040000 -#define NTLM_NEG_NTLM2_SESSION 0x00080000 +#define NTLM_TARGET_SHARE 0x00040000 /* mbz */ +#define NTLM_NEG_NTLM2_SESSION 0x00080000 /* EXTENDED_SESSIONSECURITY */ #define NTLM_NEG_NTLM2 0x00080000 #define NTLM_NEG_IDENTIFY 0x00100000 @@ -95,7 +95,9 @@ struct ntlm_buf { * heim_ntlm_free_targetinfo(). */ +/* avflags */ #define NTLM_TI_AV_FLAG_GUEST 0x00000001 +#define NTLM_TI_AV_FLAG_MIC 0x00000002 struct ntlm_targetinfo { char *servername; /**< */ @@ -104,6 +106,9 @@ struct ntlm_targetinfo { char *dnsservername; /**< */ char *dnstreename; /**< */ uint32_t avflags; /**< */ + char *targetname; + struct ntlm_buf channel_bindings; + uint64_t timestamp; }; /** @@ -149,8 +154,12 @@ struct ntlm_type3 { struct ntlm_buf sessionkey; /**< */ char *ws; /**< */ uint32_t os[2]; /**< */ + size_t mic_offset; + uint8_t mic[16]; }; +extern time_t heim_ntlm_time_skew; + #include <ntlm_err.h> #include <heimntlm-protos.h> diff --git a/lib/ntlm/ntlm.c b/lib/ntlm/ntlm.c index 7aafc8c0aa7a..7ec0181ff419 100644 --- a/lib/ntlm/ntlm.c +++ b/lib/ntlm/ntlm.c @@ -44,9 +44,12 @@ #include <limits.h> #include <roken.h> + +#include <wind.h> #include <parse_units.h> #include <krb5.h> + #define HC_DEPRECATED_CRYPTO #include "krb5-types.h" @@ -103,6 +106,8 @@ struct sec_buffer { static const unsigned char ntlmsigature[8] = "NTLMSSP\x00"; +time_t heim_ntlm_time_skew = 300; + /* * */ @@ -116,6 +121,25 @@ static const unsigned char ntlmsigature[8] = "NTLMSSP\x00"; } \ } while(/*CONSTCOND*/0) +#define CHECK_SIZE(f, e) \ + do { \ + ssize_t sret = f; \ + if (sret != (ssize_t)(e)) { \ + ret = HNTLM_ERR_DECODE; \ + goto out; \ + } \ + } while(/*CONSTCOND*/0) + +#define CHECK_OFFSET(f, e) \ + do { \ + off_t sret = f; \ + if (sret != (e)) { \ + ret = HNTLM_ERR_DECODE; \ + goto out; \ + } \ + } while(/*CONSTCOND*/0) + + static struct units ntlm_flag_units[] = { #define ntlm_flag(x) { #x, NTLM_##x } ntlm_flag(ENC_56), @@ -182,36 +206,68 @@ heim_ntlm_free_buf(struct ntlm_buf *p) static int ascii2ucs2le(const char *string, int up, struct ntlm_buf *buf) { - unsigned char *p; - size_t len, i; + uint16_t *data; + size_t len, n; + uint8_t *p; + int ret; - len = strlen(string); - if (len / 2 > UINT_MAX) + ret = wind_utf8ucs2_length(string, &len); + if (ret) + return ret; + if (len > UINT_MAX / sizeof(data[0])) return ERANGE; + data = malloc(len * sizeof(data[0])); + if (data == NULL) + return ENOMEM; + + ret = wind_utf8ucs2(string, data, &len); + if (ret) { + free(data); + return ret; + } + + if (len == 0) { + free(data); + buf->data = NULL; + buf->length = 0; + return 0; + } + + /* uppercase string, only handle ascii right now */ + if (up) { + for (n = 0; n < len ; n++) { + if (data[n] < 128) + data[n] = toupper((int)data[n]); + } + } + buf->length = len * 2; - buf->data = malloc(buf->length); + p = buf->data = malloc(buf->length); if (buf->data == NULL && len != 0) { + free(data); heim_ntlm_free_buf(buf); return ENOMEM; } - p = buf->data; - for (i = 0; i < len; i++) { - unsigned char t = (unsigned char)string[i]; - if (t & 0x80) { - heim_ntlm_free_buf(buf); - return EINVAL; - } - if (up) - t = toupper(t); - p[(i * 2) + 0] = t; - p[(i * 2) + 1] = 0; + for (n = 0; n < len ; n++) { + p[(n * 2) + 0] = (data[n] ) & 0xff; + p[(n * 2) + 1] = (data[n] >> 8) & 0xff; } + memset(data, 0, sizeof(data[0]) * len); + free(data); + return 0; } /* + * Sizes in bytes + */ + +#define SIZE_SEC_BUFFER (2+2+4) +#define SIZE_OS_VERSION (8) + +/* * */ @@ -242,13 +298,20 @@ out: * wire, but using utf8 in memory. */ -static krb5_error_code +static size_t len_string(int ucs2, const char *s) { - size_t len = strlen(s); - if (ucs2) - len *= 2; - return len; + if (ucs2) { + size_t len; + int ret; + + ret = wind_utf8ucs2_length(s, &len); + if (ret == 0) + return len * 2; + return strlen(s) * 5 * 2; + } else { + return strlen(s); + } } /* @@ -259,28 +322,50 @@ static krb5_error_code ret_string(krb5_storage *sp, int ucs2, size_t len, char **s) { krb5_error_code ret; + uint16_t *data = NULL; *s = malloc(len + 1); if (*s == NULL) return ENOMEM; - CHECK(krb5_storage_read(sp, *s, len), len); + CHECK_SIZE(krb5_storage_read(sp, *s, len), len); (*s)[len] = '\0'; if (ucs2) { - size_t i; - for (i = 0; i < len / 2; i++) { - (*s)[i] = (*s)[i * 2]; - if ((*s)[i * 2 + 1]) { - free(*s); - *s = NULL; - return EINVAL; - } + unsigned int flags = WIND_RW_LE; + size_t utf16len = len / 2; + size_t utf8len; + + data = malloc(utf16len * sizeof(data[0])); + if (data == NULL) { + free(*s); *s = NULL; + ret = ENOMEM; + goto out; + } + + ret = wind_ucs2read(*s, len, &flags, data, &utf16len); + free(*s); *s = NULL; + if (ret) { + goto out; } - (*s)[i] = '\0'; + + CHECK(wind_ucs2utf8_length(data, utf16len, &utf8len), 0); + + utf8len += 1; + + *s = malloc(utf8len); + if (s == NULL) { + ret = ENOMEM; + goto out; + } + + CHECK(wind_ucs2utf8(data, utf16len, *s, &utf8len), 0); } ret = 0; out: + if (data) + free(data); + return ret; } @@ -290,10 +375,10 @@ static krb5_error_code ret_sec_string(krb5_storage *sp, int ucs2, struct sec_buffer *desc, char **s) { krb5_error_code ret = 0; - CHECK(krb5_storage_seek(sp, desc->offset, SEEK_SET), desc->offset); + CHECK_OFFSET(krb5_storage_seek(sp, desc->offset, SEEK_SET), desc->offset); CHECK(ret_string(sp, ucs2, desc->length, s), 0); out: - return ret; + return ret; } static krb5_error_code @@ -311,7 +396,7 @@ put_string(krb5_storage *sp, int ucs2, const char *s) buf.length = strlen(s); } - CHECK(krb5_storage_write(sp, buf.data, buf.length), buf.length); + CHECK_SIZE(krb5_storage_write(sp, buf.data, buf.length), buf.length); if (ucs2) heim_ntlm_free_buf(&buf); ret = 0; @@ -330,8 +415,8 @@ ret_buf(krb5_storage *sp, struct sec_buffer *desc, struct ntlm_buf *buf) buf->data = malloc(desc->length); buf->length = desc->length; - CHECK(krb5_storage_seek(sp, desc->offset, SEEK_SET), desc->offset); - CHECK(krb5_storage_read(sp, buf->data, buf->length), buf->length); + CHECK_OFFSET(krb5_storage_seek(sp, desc->offset, SEEK_SET), desc->offset); + CHECK_SIZE(krb5_storage_read(sp, buf->data, buf->length), buf->length); ret = 0; out: return ret; @@ -341,7 +426,7 @@ static krb5_error_code put_buf(krb5_storage *sp, const struct ntlm_buf *buf) { krb5_error_code ret; - CHECK(krb5_storage_write(sp, buf->data, buf->length), buf->length); + CHECK_SIZE(krb5_storage_write(sp, buf->data, buf->length), buf->length); ret = 0; out: return ret; @@ -363,6 +448,8 @@ heim_ntlm_free_targetinfo(struct ntlm_targetinfo *ti) free(ti->dnsdomainname); free(ti->dnsservername); free(ti->dnstreename); + free(ti->targetname); + heim_ntlm_free_buf(&ti->channel_bindings); memset(ti, 0, sizeof(*ti)); } @@ -423,6 +510,20 @@ heim_ntlm_encode_targetinfo(const struct ntlm_targetinfo *ti, CHECK(krb5_store_uint16(out, 4), 0); CHECK(krb5_store_uint32(out, ti->avflags), 0); } + if (ti->timestamp) { + CHECK(krb5_store_uint16(out, 7), 0); + CHECK(krb5_store_uint16(out, 8), 0); + CHECK(krb5_store_uint32(out, ti->timestamp & 0xffffffff), 0); + CHECK(krb5_store_uint32(out, (ti->timestamp >> 32) & 0xffffffff), 0); + } + if (ti->targetname) { + CHECK(encode_ti_string(out, 9, ucs2, ti->targetname), 0); + } + if (ti->channel_bindings.length) { + CHECK(krb5_store_uint16(out, 10), 0); + CHECK(krb5_store_uint16(out, ti->channel_bindings.length), 0); + CHECK_SIZE(krb5_storage_write(out, ti->channel_bindings.data, ti->channel_bindings.length), ti->channel_bindings.length); + } /* end tag */ CHECK(krb5_store_int16(out, 0), 0); @@ -497,6 +598,26 @@ heim_ntlm_decode_targetinfo(const struct ntlm_buf *data, case 6: CHECK(krb5_ret_uint32(in, &ti->avflags), 0); break; + case 7: { + uint32_t tmp; + CHECK(krb5_ret_uint32(in, &tmp), 0); + ti->timestamp = tmp; + CHECK(krb5_ret_uint32(in, &tmp), 0); + ti->timestamp |= ((uint64_t)tmp) << 32; + break; + } + case 9: + CHECK(ret_string(in, 1, len, &ti->targetname), 0); + break; + case 10: + ti->channel_bindings.data = malloc(len); + if (ti->channel_bindings.data == NULL) { + ret = ENOMEM; + goto out; + } + ti->channel_bindings.length = len; + CHECK_SIZE(krb5_storage_read(in, ti->channel_bindings.data, len), len); + break; default: krb5_storage_seek(in, len, SEEK_CUR); break; @@ -508,6 +629,21 @@ heim_ntlm_decode_targetinfo(const struct ntlm_buf *data, return ret; } +static krb5_error_code +encode_os_version(krb5_storage *out) +{ + krb5_error_code ret; + CHECK(krb5_store_uint8(out, 0x06), 0); + CHECK(krb5_store_uint8(out, 0x01), 0); + CHECK(krb5_store_uint16(out, 0x1db0), 0); + CHECK(krb5_store_uint8(out, 0x0f), 0); /* ntlm version 15 */ + CHECK(krb5_store_uint8(out, 0x00), 0); + CHECK(krb5_store_uint8(out, 0x00), 0); + CHECK(krb5_store_uint8(out, 0x00), 0); + out: + return ret; +} + /** * Frees the ntlm_type1 message * @@ -534,6 +670,7 @@ heim_ntlm_decode_type1(const struct ntlm_buf *buf, struct ntlm_type1 *data) uint32_t type; struct sec_buffer domain, hostname; krb5_storage *in; + int ucs2; memset(data, 0, sizeof(*data)); @@ -544,25 +681,30 @@ heim_ntlm_decode_type1(const struct ntlm_buf *buf, struct ntlm_type1 *data) } krb5_storage_set_byteorder(in, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_read(in, sig, sizeof(sig)), sizeof(sig)); + CHECK_SIZE(krb5_storage_read(in, sig, sizeof(sig)), sizeof(sig)); CHECK(memcmp(ntlmsigature, sig, sizeof(ntlmsigature)), 0); CHECK(krb5_ret_uint32(in, &type), 0); CHECK(type, 1); CHECK(krb5_ret_uint32(in, &data->flags), 0); - if (data->flags & NTLM_OEM_SUPPLIED_DOMAIN) - CHECK(ret_sec_buffer(in, &domain), 0); - if (data->flags & NTLM_OEM_SUPPLIED_WORKSTATION) - CHECK(ret_sec_buffer(in, &hostname), 0); -#if 0 - if (domain.offset > 32) { + + ucs2 = !!(data->flags & NTLM_NEG_UNICODE); + + /* + * domain and hostname are unconditionally encoded regardless of + * NTLMSSP_NEGOTIATE_OEM_{HOSTNAME,WORKSTATION}_SUPPLIED flag + */ + CHECK(ret_sec_buffer(in, &domain), 0); + CHECK(ret_sec_buffer(in, &hostname), 0); + + if (data->flags & NTLM_NEG_VERSION) { CHECK(krb5_ret_uint32(in, &data->os[0]), 0); CHECK(krb5_ret_uint32(in, &data->os[1]), 0); } -#endif + if (data->flags & NTLM_OEM_SUPPLIED_DOMAIN) - CHECK(ret_sec_string(in, 0, &domain, &data->domain), 0); + CHECK(ret_sec_string(in, ucs2, &domain, &data->domain), 0); if (data->flags & NTLM_OEM_SUPPLIED_WORKSTATION) - CHECK(ret_sec_string(in, 0, &hostname, &data->hostname), 0); + CHECK(ret_sec_string(in, ucs2, &hostname, &data->hostname), 0); out: if (in) @@ -593,35 +735,41 @@ heim_ntlm_encode_type1(const struct ntlm_type1 *type1, struct ntlm_buf *data) struct sec_buffer domain, hostname; krb5_storage *out; uint32_t base, flags; + int ucs2 = 0; flags = type1->flags; base = 16; + if (flags & NTLM_NEG_UNICODE) + ucs2 = 1; + if (type1->domain) { - base += 8; + base += SIZE_SEC_BUFFER; flags |= NTLM_OEM_SUPPLIED_DOMAIN; } if (type1->hostname) { - base += 8; + base += SIZE_SEC_BUFFER; flags |= NTLM_OEM_SUPPLIED_WORKSTATION; } - if (type1->os[0]) - base += 8; + if (flags & NTLM_NEG_VERSION) + base += SIZE_OS_VERSION; /* os */ - domain.offset = base; if (type1->domain) { - domain.length = len_string(0, type1->domain); + domain.offset = base; + domain.length = len_string(ucs2, type1->domain); domain.allocated = domain.length; } else { + domain.offset = 0; domain.length = 0; domain.allocated = 0; } - hostname.offset = domain.allocated + domain.offset; if (type1->hostname) { - hostname.length = len_string(0, type1->hostname); + hostname.offset = domain.allocated + domain.offset; + hostname.length = len_string(ucs2, type1->hostname); hostname.allocated = hostname.length; } else { + hostname.offset = 0; hostname.length = 0; hostname.allocated = 0; } @@ -631,21 +779,21 @@ heim_ntlm_encode_type1(const struct ntlm_type1 *type1, struct ntlm_buf *data) return ENOMEM; krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), + CHECK_SIZE(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), sizeof(ntlmsigature)); CHECK(krb5_store_uint32(out, 1), 0); CHECK(krb5_store_uint32(out, flags), 0); CHECK(store_sec_buffer(out, &domain), 0); CHECK(store_sec_buffer(out, &hostname), 0); -#if 0 - CHECK(krb5_store_uint32(out, type1->os[0]), 0); - CHECK(krb5_store_uint32(out, type1->os[1]), 0); -#endif + + if (flags & NTLM_NEG_VERSION) { + CHECK(encode_os_version(out), 0); + } if (type1->domain) - CHECK(put_string(out, 0, type1->domain), 0); + CHECK(put_string(out, ucs2, type1->domain), 0); if (type1->hostname) - CHECK(put_string(out, 0, type1->hostname), 0); + CHECK(put_string(out, ucs2, type1->hostname), 0); { krb5_data d; @@ -695,7 +843,7 @@ heim_ntlm_decode_type2(const struct ntlm_buf *buf, struct ntlm_type2 *type2) } krb5_storage_set_byteorder(in, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_read(in, sig, sizeof(sig)), sizeof(sig)); + CHECK_SIZE(krb5_storage_read(in, sig, sizeof(sig)), sizeof(sig)); CHECK(memcmp(ntlmsigature, sig, sizeof(ntlmsigature)), 0); CHECK(krb5_ret_uint32(in, &type), 0); CHECK(type, 2); @@ -704,7 +852,7 @@ heim_ntlm_decode_type2(const struct ntlm_buf *buf, struct ntlm_type2 *type2) CHECK(krb5_ret_uint32(in, &type2->flags), 0); if (type2->flags & NTLM_NEG_UNICODE) ucs2 = 1; - CHECK(krb5_storage_read(in, type2->challenge, sizeof(type2->challenge)), + CHECK_SIZE(krb5_storage_read(in, type2->challenge, sizeof(type2->challenge)), sizeof(type2->challenge)); CHECK(krb5_ret_uint32(in, &ctx[0]), 0); /* context */ CHECK(krb5_ret_uint32(in, &ctx[1]), 0); @@ -753,7 +901,7 @@ heim_ntlm_encode_type2(const struct ntlm_type2 *type2, struct ntlm_buf *data) base = 48; if (type2->flags & NTLM_NEG_VERSION) - base += 8; + base += SIZE_OS_VERSION; if (type2->flags & NTLM_NEG_UNICODE) ucs2 = 1; @@ -771,23 +919,22 @@ heim_ntlm_encode_type2(const struct ntlm_type2 *type2, struct ntlm_buf *data) return ENOMEM; krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), + CHECK_SIZE(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), sizeof(ntlmsigature)); CHECK(krb5_store_uint32(out, 2), 0); CHECK(store_sec_buffer(out, &targetname), 0); CHECK(krb5_store_uint32(out, type2->flags), 0); - CHECK(krb5_storage_write(out, type2->challenge, sizeof(type2->challenge)), + CHECK_SIZE(krb5_storage_write(out, type2->challenge, sizeof(type2->challenge)), sizeof(type2->challenge)); CHECK(krb5_store_uint32(out, 0), 0); /* context */ CHECK(krb5_store_uint32(out, 0), 0); CHECK(store_sec_buffer(out, &targetinfo), 0); /* os version */ if (type2->flags & NTLM_NEG_VERSION) { - CHECK(krb5_store_uint32(out, type2->os[0]), 0); - CHECK(krb5_store_uint32(out, type2->os[1]), 0); + CHECK(encode_os_version(out), 0); } CHECK(put_string(out, ucs2, type2->targetname), 0); - CHECK(krb5_storage_write(out, type2->targetinfo.data, + CHECK_SIZE(krb5_storage_write(out, type2->targetinfo.data, type2->targetinfo.length), type2->targetinfo.length); @@ -841,7 +988,7 @@ heim_ntlm_decode_type3(const struct ntlm_buf *buf, uint32_t type; krb5_storage *in; struct sec_buffer lm, ntlm, target, username, sessionkey, ws; - uint32_t min_offset = 72; + uint32_t min_offset = 0xffffffff; memset(type3, 0, sizeof(*type3)); memset(&sessionkey, 0, sizeof(sessionkey)); @@ -853,7 +1000,7 @@ heim_ntlm_decode_type3(const struct ntlm_buf *buf, } krb5_storage_set_byteorder(in, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_read(in, sig, sizeof(sig)), sizeof(sig)); + CHECK_SIZE(krb5_storage_read(in, sig, sizeof(sig)), sizeof(sig)); CHECK(memcmp(ntlmsigature, sig, sizeof(ntlmsigature)), 0); CHECK(krb5_ret_uint32(in, &type), 0); CHECK(type, 3); @@ -864,24 +1011,27 @@ heim_ntlm_decode_type3(const struct ntlm_buf *buf, if (ntlm.allocated) min_offset = min(min_offset, ntlm.offset); CHECK(ret_sec_buffer(in, &target), 0); - if (target.allocated) - min_offset = min(min_offset, target.offset); + min_offset = min(min_offset, target.offset); CHECK(ret_sec_buffer(in, &username), 0); - if (username.allocated) - min_offset = min(min_offset, username.offset); + min_offset = min(min_offset, username.offset); CHECK(ret_sec_buffer(in, &ws), 0); if (ws.allocated) min_offset = min(min_offset, ws.offset); - if (min_offset > 52) { + if (min_offset >= 52) { CHECK(ret_sec_buffer(in, &sessionkey), 0); - min_offset = max(min_offset, sessionkey.offset); + min_offset = min(min_offset, sessionkey.offset); CHECK(krb5_ret_uint32(in, &type3->flags), 0); } - if (min_offset > 52 + 8 + 4 + 8) { + if (min_offset >= 52 + SIZE_SEC_BUFFER + 4 + SIZE_OS_VERSION) { CHECK(krb5_ret_uint32(in, &type3->os[0]), 0); CHECK(krb5_ret_uint32(in, &type3->os[1]), 0); } + if (min_offset >= 52 + SIZE_SEC_BUFFER + 4 + SIZE_OS_VERSION + 16) { + type3->mic_offset = 52 + SIZE_SEC_BUFFER + 4 + SIZE_OS_VERSION; + CHECK_SIZE(krb5_storage_read(in, type3->mic, sizeof(type3->mic)), sizeof(type3->mic)); + } else + type3->mic_offset = 0; CHECK(ret_buf(in, &lm, &type3->lm), 0); CHECK(ret_buf(in, &ntlm, &type3->ntlm), 0); CHECK(ret_sec_string(in, ucs2, &target, &type3->targetname), 0); @@ -904,6 +1054,7 @@ out: * * @param type3 the ntlm_type3 message to encode. * @param data is the return buffer with the encoded message, should be + * @param[out] mic_offset offset of message integrity code * freed with heim_ntlm_free_buf(). * * @return In case of success 0 is return, an errors, a errno in what @@ -913,7 +1064,7 @@ out: */ int -heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data) +heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data, size_t *mic_offset) { struct sec_buffer lm, ntlm, target, username, sessionkey, ws; krb5_error_code ret; @@ -932,9 +1083,12 @@ heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data) base += 8; /* sessionkey sec buf */ base += 4; /* flags */ + if (type3->flags & NTLM_NEG_VERSION) + base += SIZE_OS_VERSION; /* os flags */ - if (type3->os[0]) { - base += 8; + if (mic_offset) { + *mic_offset = base; + base += 16; } if (type3->flags & NTLM_NEG_UNICODE) @@ -969,7 +1123,7 @@ heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data) return ENOMEM; krb5_storage_set_byteorder(out, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), + CHECK_SIZE(krb5_storage_write(out, ntlmsigature, sizeof(ntlmsigature)), sizeof(ntlmsigature)); CHECK(krb5_store_uint32(out, 3), 0); @@ -981,10 +1135,15 @@ heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data) CHECK(store_sec_buffer(out, &sessionkey), 0); CHECK(krb5_store_uint32(out, type3->flags), 0); -#if 0 - CHECK(krb5_store_uint32(out, 0), 0); /* os0 */ - CHECK(krb5_store_uint32(out, 0), 0); /* os1 */ -#endif + /* os version */ + if (type3->flags & NTLM_NEG_VERSION) { + CHECK(encode_os_version(out), 0); + } + + if (mic_offset) { + static const uint8_t buf[16] = { 0 }; + CHECK_SIZE(krb5_storage_write(out, buf, sizeof(buf)), sizeof(buf)); + } CHECK(put_string(out, ucs2, type3->targetname), 0); CHECK(put_string(out, ucs2, type3->username), 0); @@ -1055,10 +1214,10 @@ heim_ntlm_nt_key(const char *password, struct ntlm_buf *key) EVP_MD_CTX *m; int ret; - key->data = malloc(MD5_DIGEST_LENGTH); + key->data = malloc(MD4_DIGEST_LENGTH); if (key->data == NULL) return ENOMEM; - key->length = MD5_DIGEST_LENGTH; + key->length = MD4_DIGEST_LENGTH; ret = ascii2ucs2le(password, 0, &buf); if (ret) { @@ -1133,7 +1292,7 @@ heim_ntlm_v1_base_session(void *key, size_t len, session->length = 0; return ENOMEM; } - + m = EVP_MD_CTX_create(); if (m == NULL) { heim_ntlm_free_buf(session); @@ -1182,6 +1341,9 @@ heim_ntlm_keyex_wrap(struct ntlm_buf *base_session, EVP_CIPHER_CTX c; int ret; + if (base_session->length != MD4_DIGEST_LENGTH) + return HNTLM_ERR_INVALID_LENGTH; + session->length = MD4_DIGEST_LENGTH; session->data = malloc(session->length); if (session->data == NULL) { @@ -1222,8 +1384,6 @@ heim_ntlm_keyex_wrap(struct ntlm_buf *base_session, } - - /** * Generates an NTLMv1 session random with assosited session master key. * @@ -1313,6 +1473,8 @@ heim_ntlm_keyex_unwrap(struct ntlm_buf *baseKey, memset(session, 0, sizeof(*session)); + if (encryptedSession->length != MD4_DIGEST_LENGTH) + return HNTLM_ERR_INVALID_LENGTH; if (baseKey->length != MD4_DIGEST_LENGTH) return HNTLM_ERR_INVALID_LENGTH; @@ -1344,6 +1506,7 @@ heim_ntlm_keyex_unwrap(struct ntlm_buf *baseKey, * @param len length of key * @param username name of the user, as sent in the message, assumed to be in UTF8. * @param target the name of the target, assumed to be in UTF8. + * @param upper_case_target upper case the target, should not be used only for legacy systems * @param ntlmv2 the ntlmv2 session key * * @return 0 on success, or an error code on failure. @@ -1355,6 +1518,7 @@ int heim_ntlm_ntlmv2_key(const void *key, size_t len, const char *username, const char *target, + int upper_case_target, unsigned char ntlmv2[16]) { int ret; @@ -1371,8 +1535,8 @@ heim_ntlm_ntlmv2_key(const void *key, size_t len, goto out; HMAC_Update(&c, buf.data, buf.length); free(buf.data); - /* uppercase target and turn into ucs2-le */ - ret = ascii2ucs2le(target, 1, &buf); + /* turn target into ucs2-le */ + ret = ascii2ucs2le(target, upper_case_target, &buf); if (ret) goto out; HMAC_Update(&c, buf.data, buf.length); @@ -1381,6 +1545,7 @@ heim_ntlm_ntlmv2_key(const void *key, size_t len, HMAC_Final(&c, ntlmv2, &hmaclen); out: HMAC_CTX_cleanup(&c); + memset(&c, 0, sizeof(c)); return ret; } @@ -1391,16 +1556,16 @@ heim_ntlm_ntlmv2_key(const void *key, size_t len, #define NTTIME_EPOCH 0x019DB1DED53E8000LL -static uint64_t -unix2nttime(time_t unix_time) +uint64_t +heim_ntlm_unix2ts_time(time_t unix_time) { long long wt; wt = unix_time * (uint64_t)10000000 + (uint64_t)NTTIME_EPOCH; return wt; } -static time_t -nt2unixtime(uint64_t t) +time_t +heim_ntlm_ts2unixtime(uint64_t t) { t = ((t - (uint64_t)NTTIME_EPOCH) / (uint64_t)10000000); if (t > (((uint64_t)(time_t)(~(uint64_t)0)) >> 1)) @@ -1440,7 +1605,7 @@ heim_ntlm_calculate_lm2(const void *key, size_t len, /* calculate ntlmv2 key */ - heim_ntlm_ntlmv2_key(key, len, username, target, ntlmv2); + heim_ntlm_ntlmv2_key(key, len, username, target, 0, ntlmv2); answer->data = malloc(24); if (answer->data == NULL) @@ -1450,7 +1615,7 @@ heim_ntlm_calculate_lm2(const void *key, size_t len, heim_ntlm_derive_ntlm2_sess(ntlmv2, clientchallenge, 8, serverchallenge, answer->data); - memcpy(((uint8_t *)answer->data) + 16, clientchallenge, 8); + memcpy(((unsigned char *)answer->data) + 16, clientchallenge, 8); return 0; } @@ -1490,14 +1655,14 @@ heim_ntlm_calculate_ntlm2(const void *key, size_t len, unsigned char clientchallenge[8]; uint64_t t; - t = unix2nttime(time(NULL)); + t = heim_ntlm_unix2ts_time(time(NULL)); if (RAND_bytes(clientchallenge, sizeof(clientchallenge)) != 1) return HNTLM_ERR_RAND; /* calculate ntlmv2 key */ - heim_ntlm_ntlmv2_key(key, len, username, target, ntlmv2); + heim_ntlm_ntlmv2_key(key, len, username, target, 0, ntlmv2); /* calculate and build ntlmv2 answer */ @@ -1512,12 +1677,19 @@ heim_ntlm_calculate_ntlm2(const void *key, size_t len, CHECK(krb5_store_uint32(sp, t & 0xffffffff), 0); CHECK(krb5_store_uint32(sp, t >> 32), 0); - CHECK(krb5_storage_write(sp, clientchallenge, 8), 8); + CHECK_SIZE(krb5_storage_write(sp, clientchallenge, 8), 8); - CHECK(krb5_store_uint32(sp, 0), 0); /* unknown but zero will work */ - CHECK(krb5_storage_write(sp, infotarget->data, infotarget->length), + CHECK(krb5_store_uint32(sp, 0), 0); /* Z(4) */ + CHECK_SIZE(krb5_storage_write(sp, infotarget->data, infotarget->length), infotarget->length); - CHECK(krb5_store_uint32(sp, 0), 0); /* unknown but zero will work */ + + /* + * These last 4 bytes(Z(4)) are not documented by MicroSoft and + * SnowLeopard doesn't send them, Lion expected them to be there, + * so we have to continue to send them. That is ok, since everyone + * else (except Snow) seems to do that too. + */ + CHECK(krb5_store_uint32(sp, 0), 0); /* Z(4) */ CHECK(krb5_storage_to_data(sp, &data), 0); krb5_storage_free(sp); @@ -1531,8 +1703,8 @@ heim_ntlm_calculate_ntlm2(const void *key, size_t len, return ENOMEM; } - CHECK(krb5_storage_write(sp, ntlmv2answer, 16), 16); - CHECK(krb5_storage_write(sp, data.data, data.length), data.length); + CHECK_SIZE(krb5_storage_write(sp, ntlmv2answer, 16), 16); + CHECK_SIZE(krb5_storage_write(sp, data.data, data.length), data.length); krb5_data_free(&data); CHECK(krb5_storage_to_data(sp, &data), 0); @@ -1551,43 +1723,25 @@ out: static const int authtimediff = 3600 * 2; /* 2 hours */ -/** - * Verify NTLMv2 response. - * - * @param key the ntlm key - * @param len length of key - * @param username name of the user, as sent in the message, assumed to be in UTF8. - * @param target the name of the target, assumed to be in UTF8. - * @param now the time now (0 if the library should pick it up itself) - * @param serverchallenge challenge as sent by the server in the type2 message. - * @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). - * @param infotarget infotarget as sent by the server in the type2 message. - * @param ntlmv2 calculated session key - * - * @return In case of success 0 is return, an errors, a errno in what - * went wrong. - * - * @ingroup ntlm_core - */ - -int -heim_ntlm_verify_ntlm2(const void *key, size_t len, - const char *username, - const char *target, - time_t now, - const unsigned char serverchallenge[8], - const struct ntlm_buf *answer, - struct ntlm_buf *infotarget, - unsigned char ntlmv2[16]) +static int +verify_ntlm2(const void *key, size_t len, + const char *username, + const char *target, + int upper_case_target, + time_t now, + const unsigned char serverchallenge[8], + const struct ntlm_buf *answer, + struct ntlm_buf *infotarget, + unsigned char ntlmv2[16]) { krb5_error_code ret; unsigned char clientanswer[16]; unsigned char clientnonce[8]; unsigned char serveranswer[16]; krb5_storage *sp; + uint64_t t; time_t authtime; uint32_t temp; - uint64_t t; infotarget->length = 0; infotarget->data = NULL; @@ -1600,7 +1754,7 @@ heim_ntlm_verify_ntlm2(const void *key, size_t len, /* calculate ntlmv2 key */ - heim_ntlm_ntlmv2_key(key, len, username, target, ntlmv2); + heim_ntlm_ntlmv2_key(key, len, username, target, upper_case_target, ntlmv2); /* calculate and build ntlmv2 answer */ @@ -1609,7 +1763,7 @@ heim_ntlm_verify_ntlm2(const void *key, size_t len, return ENOMEM; krb5_storage_set_flags(sp, KRB5_STORAGE_BYTEORDER_LE); - CHECK(krb5_storage_read(sp, clientanswer, 16), 16); + CHECK_SIZE(krb5_storage_read(sp, clientanswer, 16), 16); CHECK(krb5_ret_uint32(sp, &temp), 0); CHECK(temp, 0x00000101); @@ -1621,28 +1775,32 @@ heim_ntlm_verify_ntlm2(const void *key, size_t len, CHECK(krb5_ret_uint32(sp, &temp), 0); t |= ((uint64_t)temp)<< 32; - authtime = nt2unixtime(t); + authtime = heim_ntlm_ts2unixtime(t); - if (abs((int)(authtime - now)) > authtimediff) { + if (labs((int)(authtime - now)) > authtimediff) { ret = HNTLM_ERR_TIME_SKEW; goto out; } /* client challenge */ - CHECK(krb5_storage_read(sp, clientnonce, 8), 8); + CHECK_SIZE(krb5_storage_read(sp, clientnonce, 8), 8); - CHECK(krb5_ret_uint32(sp, &temp), 0); /* unknown */ + CHECK(krb5_ret_uint32(sp, &temp), 0); /* Z(4) */ - /* should really unparse the infotarget, but lets pick up everything */ - infotarget->length = answer->length - krb5_storage_seek(sp, 0, SEEK_CUR); + /* let pick up targetinfo */ + infotarget->length = answer->length - (size_t)krb5_storage_seek(sp, 0, SEEK_CUR); + if (infotarget->length < 4) { + ret = HNTLM_ERR_INVALID_LENGTH; + goto out; + } infotarget->data = malloc(infotarget->length); if (infotarget->data == NULL) { ret = ENOMEM; goto out; } - CHECK(krb5_storage_read(sp, infotarget->data, infotarget->length), + CHECK_SIZE(krb5_storage_read(sp, infotarget->data, infotarget->length), infotarget->length); - /* XXX remove the unknown ?? */ + krb5_storage_free(sp); sp = NULL; @@ -1669,6 +1827,60 @@ out: return ret; } +/** + * Verify NTLMv2 response. + * + * @param key the ntlm key + * @param len length of key + * @param username name of the user, as sent in the message, assumed to be in UTF8. + * @param target the name of the target, assumed to be in UTF8. + * @param now the time now (0 if the library should pick it up itself) + * @param serverchallenge challenge as sent by the server in the type2 message. + * @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). + * @param infotarget infotarget as sent by the server in the type2 message. + * @param ntlmv2 calculated session key + * + * @return In case of success 0 is return, an errors, a errno in what + * went wrong. + * + * @ingroup ntlm_core + */ + +int +heim_ntlm_verify_ntlm2(const void *key, size_t len, + const char *username, + const char *target, + time_t now, + const unsigned char serverchallenge[8], + const struct ntlm_buf *answer, + struct ntlm_buf *infotarget, + unsigned char ntlmv2[16]) +{ + int ret; + + /** + * First check with the domain as the client passed it to the function. + */ + + ret = verify_ntlm2(key, len, username, target, 0, now, + serverchallenge, answer, infotarget, ntlmv2); + + /** + * Second check with domain uppercased. + */ + + if (ret) + ret = verify_ntlm2(key, len, username, target, 1, now, + serverchallenge, answer, infotarget, ntlmv2); + + /** + * Third check with empty domain. + */ + if (ret) + ret = verify_ntlm2(key, len, username, "", 0, now, + serverchallenge, answer, infotarget, ntlmv2); + return ret; +} /* * Calculate the NTLM2 Session Response @@ -1799,5 +2011,5 @@ heim_ntlm_derive_ntlm2_sess(const unsigned char sessionkey[16], HMAC_Update(&c, clnt_nonce, clnt_nonce_length); HMAC_Final(&c, derivedkey, &hmaclen); HMAC_CTX_cleanup(&c); + memset(&c, 0, sizeof(c)); } - diff --git a/lib/ntlm/ntlm_err.et b/lib/ntlm/ntlm_err.et index 0fd6e00a21c7..fd39aa31fb2d 100644 --- a/lib/ntlm/ntlm_err.et +++ b/lib/ntlm/ntlm_err.et @@ -14,11 +14,47 @@ error_code RAND, "Random generator failed" error_code AUTH, "NTLM authentication failed" error_code TIME_SKEW, "Client time skewed to server" error_code OEM, "Client set OEM string" -error_code MISSING_NAME_SEPARATOR, "missing @ or \ in name" +error_code MISSING_NAME_SEPARATOR, "missing @ or \\\\ in name" error_code MISSING_BUFFER, "missing expected buffer" error_code INVALID_APOP, "Invalid APOP response" error_code INVALID_CRAM_MD5, "Invalid CRAM-MD5 response" error_code INVALID_DIGEST_MD5, "Invalid DIGEST-MD5 response" error_code INVALID_DIGEST_MD5_RSPAUTH, "Invalid DIGEST-MD5 rspauth" +error_code INVALID_CHANNEL_BINDINGS, "Invalid channel bindings" +error_code INVALID_MIC, "Invalid MIC" +error_code INVALID_SESSIONKEY, "Invalid session key" + + +# +# NTLM/GSS error codes +# +index 64 +error_code NOT_CONFIGURED, "NTLM not configured" + +error_code INVALID_CHALLANGE, "Invalid client challenge" +error_code INVALID_LMv1_RESPONSE, "Invalid client LMv1 response" +error_code INVALID_NT_RESPONSE, "Invalid client NT response" +error_code INVALID_LMv2_RESPONSE, "Invalid client LMv2 response" +error_code INVALID_NTv1_RESPONSE, "Invalid client NTv1 response" +error_code INVALID_NTv2_RESPONSE, "Invalid client NTv2 response" +error_code INVALID_NTv1_ANSWER, "Invalid client NTv1 answer" +error_code INVALID_NTv2_ANSWER, "Invalid client NTv2 answer" +error_code INVALID_SESSION_KEY, "Invalid session key" + +error_code INVALID_NO_GUEST, "Invalid guest login request" + +error_code NO_NETR_CONFIGURED, "No NETR configured" + + +# +# Scram errors +# +prefix HSCRAM_ERR +index 128 + +error_code INVALID_MESSAGE, "Invalid SCRAM message" +error_code INVALID_PROOF, "Invalid SCRAM proof" +error_code INVALID_ROLE, "Invalid SCRAM role" + end diff --git a/lib/ntlm/test_ntlm.c b/lib/ntlm/test_ntlm.c index 5a995adae48b..e7d723727e58 100644 --- a/lib/ntlm/test_ntlm.c +++ b/lib/ntlm/test_ntlm.c @@ -41,11 +41,14 @@ #include <krb5-types.h> /* or <inttypes.h> */ #include <heimntlm.h> +static int dumpdata_flag; + static int test_parse(void) { const char *user = "foo", *domain = "mydomain", + *hostname = "myhostname", *password = "digestpassword", *target = "DOMAIN"; struct ntlm_type1 type1; @@ -56,9 +59,9 @@ test_parse(void) memset(&type1, 0, sizeof(type1)); - type1.flags = NTLM_NEG_UNICODE|NTLM_NEG_TARGET|NTLM_NEG_NTLM; + type1.flags = NTLM_NEG_UNICODE|NTLM_NEG_TARGET|NTLM_NEG_NTLM|NTLM_NEG_VERSION; type1.domain = rk_UNCONST(domain); - type1.hostname = NULL; + type1.hostname = rk_UNCONST(hostname); type1.os[0] = 0; type1.os[1] = 0; @@ -68,11 +71,20 @@ test_parse(void) memset(&type1, 0, sizeof(type1)); + if (dumpdata_flag) + rk_dumpdata("ntlm-type1", data.data, data.length); + ret = heim_ntlm_decode_type1(&data, &type1); free(data.data); if (ret) errx(1, "heim_ntlm_encode_type1"); + if (strcmp(type1.domain, domain) != 0) + errx(1, "parser got domain wrong: %s", type1.domain); + + if (strcmp(type1.hostname, hostname) != 0) + errx(1, "parser got hostname wrong: %s", type1.hostname); + heim_ntlm_free_type1(&type1); /* @@ -95,6 +107,9 @@ test_parse(void) memset(&type2, 0, sizeof(type2)); + if (dumpdata_flag) + rk_dumpdata("ntlm-type2", data.data, data.length); + ret = heim_ntlm_decode_type2(&data, &type2); free(data.data); if (ret) @@ -123,7 +138,7 @@ test_parse(void) free(key.data); } - ret = heim_ntlm_encode_type3(&type3, &data); + ret = heim_ntlm_encode_type3(&type3, &data, NULL); if (ret) errx(1, "heim_ntlm_encode_type3"); @@ -131,6 +146,9 @@ test_parse(void) memset(&type3, 0, sizeof(type3)); + if (dumpdata_flag) + rk_dumpdata("ntlm-type3", data.data, data.length); + ret = heim_ntlm_decode_type3(&data, 1, &type3); free(data.data); if (ret) @@ -289,17 +307,106 @@ test_ntlm2_session_resp(void) } static int +test_ntlmv2(void) +{ + unsigned char type3[413] = + "\x4e\x54\x4c\x4d\x53\x53\x50\x00\x03\x00\x00\x00\x18\x00\x18\x00" + "\x80\x00\x00\x00\x9e\x00\x9e\x00\x98\x00\x00\x00\x14\x00\x14\x00" + "\x48\x00\x00\x00\x10\x00\x10\x00\x5c\x00\x00\x00\x14\x00\x14\x00" + "\x6c\x00\x00\x00\x00\x00\x00\x00\x36\x01\x00\x00\x05\x82\x88\xa2" + "\x05\x01\x28\x0a\x00\x00\x00\x0f\x43\x00\x4f\x00\x4c\x00\x4c\x00" + "\x45\x00\x59\x00\x2d\x00\x58\x00\x50\x00\x34\x00\x54\x00\x45\x00" + "\x53\x00\x54\x00\x55\x00\x53\x00\x45\x00\x52\x00\x43\x00\x4f\x00" + "\x4c\x00\x4c\x00\x45\x00\x59\x00\x2d\x00\x58\x00\x50\x00\x34\x00" + "\x2f\x96\xec\x0a\xf7\x9f\x2e\x24\xba\x09\x48\x10\xa5\x22\xd4\xe1" + "\x16\x6a\xca\x58\x74\x9a\xc1\x4f\x54\x6f\xee\x40\x96\xce\x43\x6e" + "\xdf\x99\x20\x71\x6c\x9a\xda\x2a\x01\x01\x00\x00\x00\x00\x00\x00" + "\x8d\xc0\x57\xc9\x79\x5e\xcb\x01\x16\x6a\xca\x58\x74\x9a\xc1\x4f" + "\x00\x00\x00\x00\x02\x00\x14\x00\x4e\x00\x55\x00\x54\x00\x43\x00" + "\x52\x00\x41\x00\x43\x00\x4b\x00\x45\x00\x52\x00\x01\x00\x14\x00" + "\x4e\x00\x55\x00\x54\x00\x43\x00\x52\x00\x41\x00\x43\x00\x4b\x00" + "\x45\x00\x52\x00\x04\x00\x12\x00\x61\x00\x70\x00\x70\x00\x6c\x00" + "\x65\x00\x2e\x00\x63\x00\x6f\x00\x6d\x00\x03\x00\x20\x00\x68\x00" + "\x75\x00\x6d\x00\x6d\x00\x65\x00\x6c\x00\x2e\x00\x61\x00\x70\x00" + "\x70\x00\x6c\x00\x65\x00\x2e\x00\x63\x00\x6f\x00\x6d\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x57\x00\x69\x00\x6e\x00\x64\x00\x6f" + "\x00\x77\x00\x73\x00\x20\x00\x32\x00\x30\x00\x30\x00\x32\x00\x20" + "\x00\x53\x00\x65\x00\x72\x00\x76\x00\x69\x00\x63\x00\x65\x00\x20" + "\x00\x50\x00\x61\x00\x63\x00\x6b\x00\x20\x00\x33\x00\x20\x00\x32" + "\x00\x36\x00\x30\x00\x30\x00\x00\x00\x57\x00\x69\x00\x6e\x00\x64" + "\x00\x6f\x00\x77\x00\x73\x00\x20\x00\x32\x00\x30\x00\x30\x00\x32" + "\x00\x20\x00\x35\x00\x2e\x00\x31\x00\x00\x00\x00\x00"; + const unsigned char challenge[8] = + "\xe4\x9c\x6a\x12\xe1\xbd\xde\x6a"; + unsigned char sessionkey[16]; + + const char key[16] = "\xD1\x83\x98\x3E\xAE\xA7\xBE\x99\x59\xC8\xF4\xC1\x98\xED\x0E\x68"; + + struct ntlm_buf data; + struct ntlm_type3 t3; + int ret; + + struct ntlm_targetinfo ti; + + unsigned char timsg[114] = + "\002\000\024\000N\000U\000T\000C\000R\000A\000C\000K\000E\000R\000\001\000\024\000N\000U\000T\000C\000R\000A\000C\000K\000E\000R\000\004\000\022\000a\000p\000p\000l\000e\000.\000c\000o\000m\000\003\000 \000h\000u\000m\000m\000e\000l\000.\000a\000p\000p\000l\000e\000.\000c\000o\000m\000\000\000\000\000\000\000\000"; + + + data.data = type3; + data.length = sizeof(type3); + + ret = heim_ntlm_decode_type3(&data, 1, &t3); + if (ret) + errx(1, "heim_ntlm_decode_type3"); + + memset(&ti, 0, sizeof(ti)); + + data.data = timsg; + data.length = sizeof(timsg); + + ret = heim_ntlm_decode_targetinfo(&data, 1, &ti); + if (ret) + return ret; + + ret = heim_ntlm_verify_ntlm2(key, sizeof(key), + t3.username, + t3.targetname, + 1285615547, + challenge, + &t3.ntlm, + &data, + sessionkey); + if (ret) + errx(1, "verify_ntlmv2"); + + if (sizeof(timsg) != data.length || memcmp(timsg, data.data, sizeof(timsg)) != 0) + errx(1, "target info wrong: %d != %d", + (int)sizeof(timsg), (int)data.length); + + heim_ntlm_free_type3(&t3); + heim_ntlm_free_targetinfo(&ti); + + return 0; +} + +static int test_targetinfo(void) { struct ntlm_targetinfo ti; struct ntlm_buf buf; const char *dnsservername = "dnsservername"; + const char *targetname = "targetname"; + const char z16[16] = { 0 }; int ret; memset(&ti, 0, sizeof(ti)); ti.dnsservername = rk_UNCONST(dnsservername); ti.avflags = 1; + ti.targetname = rk_UNCONST(targetname); + ti.channel_bindings.data = rk_UNCONST(z16); + ti.channel_bindings.length = sizeof(z16); + ret = heim_ntlm_encode_targetinfo(&ti, 1, &buf); if (ret) return ret; @@ -315,12 +422,133 @@ test_targetinfo(void) errx(1, "ti.dnshostname != %s", dnsservername); if (ti.avflags != 1) errx(1, "ti.avflags != 1"); + if (ti.targetname == NULL || + strcmp(ti.targetname, targetname) != 0) + errx(1, "ti.targetname != %s", targetname); + + if (ti.channel_bindings.length != sizeof(z16) || + memcmp(ti.channel_bindings.data, z16, sizeof(z16)) != 0) + errx(1, "ti.channel_bindings != Z(16)"); heim_ntlm_free_targetinfo(&ti); return 0; } +static int +test_string2key(void) +{ + const char *pw = "山田"; + struct ntlm_buf buf; + + unsigned char key[16] = { + 0xc6, 0x5d, 0xc7, 0x61, 0xa1, 0x34, 0x17, 0xa1, + 0x17, 0x08, 0x9c, 0x1b, 0xb0, 0x0d, 0x0f, 0x19 + }; + + if (heim_ntlm_nt_key(pw, &buf) != 0) + errx(1, "heim_ntlmv_nt_key(jp)"); + + if (buf.length != 16 || memcmp(buf.data, key, 16) != 0) + errx(1, "compare failed"); + + heim_ntlm_free_buf(&buf); + + return 0; +} + +static int +test_jp(void) +{ + char buf2[220] = + "\x4e\x54\x4c\x4d\x53\x53\x50\x00\x02\x00\x00\x00\x06\x00\x06\x00" + "\x38\x00\x00\x00\x05\x02\x89\x62\x62\x94\xb1\xf3\x56\x80\xb0\xf9" + "\x00\x00\x00\x00\x00\x00\x00\x00\x9e\x00\x9e\x00\x3e\x00\x00\x00" + "\x06\x01\xb0\x1d\x00\x00\x00\x0f\x43\x00\x4f\x00\x53\x00\x02\x00" + "\x06\x00\x43\x00\x4f\x00\x53\x00\x01\x00\x12\x00\x43\x00\x4f\x00" + "\x53\x00\x57\x00\x49\x00\x4e\x00\x37\x00\x4a\x00\x50\x00\x04\x00" + "\x1a\x00\x63\x00\x6f\x00\x73\x00\x2e\x00\x61\x00\x70\x00\x70\x00" + "\x6c\x00\x65\x00\x2e\x00\x63\x00\x6f\x00\x6d\x00\x03\x00\x2e\x00" + "\x63\x00\x6f\x00\x73\x00\x77\x00\x69\x00\x6e\x00\x37\x00\x6a\x00" + "\x70\x00\x2e\x00\x63\x00\x6f\x00\x73\x00\x2e\x00\x61\x00\x70\x00" + "\x70\x00\x6c\x00\x65\x00\x2e\x00\x63\x00\x6f\x00\x6d\x00\x05\x00" + "\x1a\x00\x63\x00\x6f\x00\x73\x00\x2e\x00\x61\x00\x70\x00\x70\x00" + "\x6c\x00\x65\x00\x2e\x00\x63\x00\x6f\x00\x6d\x00\x07\x00\x08\x00" + "\x94\x51\xf0\xbd\xdc\x61\xcb\x01\x00\x00\x00\x00"; + + char buf3[362] = + "\x4e\x54\x4c\x4d\x53\x53\x50\x00\x03\x00\x00\x00\x18\x00\x18\x00" + "\x74\x00\x00\x00\xce\x00\xce\x00\x8c\x00\x00\x00\x1a\x00\x1a\x00" + "\x40\x00\x00\x00\x04\x00\x04\x00\x5a\x00\x00\x00\x16\x00\x16\x00" + "\x5e\x00\x00\x00\x10\x00\x10\x00\x5a\x01\x00\x00\x05\x02\x89\x62" + "\x31\x00\x37\x00\x2e\x00\x32\x00\x30\x00\x31\x00\x2e\x00\x35\x00" + "\x37\x00\x2e\x00\x31\x00\x32\x00\x31\x00\x71\x5c\x30\x75\x77\x00" + "\x6f\x00\x72\x00\x6b\x00\x73\x00\x74\x00\x61\x00\x74\x00\x69\x00" + "\x6f\x00\x6e\x00\xab\xad\xeb\x72\x01\xd4\x5f\xdf\x59\x07\x5f\xa9" + "\xfd\x54\x98\x2d\xfa\x17\xbb\xf1\x3c\x8f\xf5\x20\xe6\x8f\xd7\x0a" + "\xc9\x19\x3e\x94\x61\x31\xdb\x0f\x55\xe8\xe2\x53\x01\x01\x00\x00" + "\x00\x00\x00\x00\x00\x06\x3e\x30\xe4\x61\xcb\x01\x71\x98\x10\x6b" + "\x4c\x82\xec\xb3\x00\x00\x00\x00\x02\x00\x06\x00\x43\x00\x4f\x00" + "\x53\x00\x01\x00\x12\x00\x43\x00\x4f\x00\x53\x00\x57\x00\x49\x00" + "\x4e\x00\x37\x00\x4a\x00\x50\x00\x04\x00\x1a\x00\x63\x00\x6f\x00" + "\x73\x00\x2e\x00\x61\x00\x70\x00\x70\x00\x6c\x00\x65\x00\x2e\x00" + "\x63\x00\x6f\x00\x6d\x00\x03\x00\x2e\x00\x63\x00\x6f\x00\x73\x00" + "\x77\x00\x69\x00\x6e\x00\x37\x00\x6a\x00\x70\x00\x2e\x00\x63\x00" + "\x6f\x00\x73\x00\x2e\x00\x61\x00\x70\x00\x70\x00\x6c\x00\x65\x00" + "\x2e\x00\x63\x00\x6f\x00\x6d\x00\x05\x00\x1a\x00\x63\x00\x6f\x00" + "\x73\x00\x2e\x00\x61\x00\x70\x00\x70\x00\x6c\x00\x65\x00\x2e\x00" + "\x63\x00\x6f\x00\x6d\x00\x07\x00\x08\x00\xab\xec\xcc\x30\xe4\x61" + "\xcb\x01\x00\x00\x00\x00\x00\x00\x00\x00\xbc\x2e\xba\x3f\xd1\xb1" + "\xa7\x70\x00\x9d\x55\xa0\x59\x74\x2b\x78"; + + + struct ntlm_type2 type2; + struct ntlm_type3 type3; + struct ntlm_buf data; + int ret; + + data.length = sizeof(buf2); + data.data = buf2; + + memset(&type2, 0, sizeof(type2)); + + ret = heim_ntlm_decode_type2(&data, &type2); + if (ret) + errx(1, "heim_ntlm_decode_type2(jp): %d", ret); + + data.data = NULL; + data.length = 0; + + ret = heim_ntlm_encode_type2(&type2, &data); + if (ret) + errx(1, "heim_ntlm_encode_type2(jp): %d", ret); + + heim_ntlm_free_type2(&type2); + heim_ntlm_free_buf(&data); + + data.length = sizeof(buf3); + data.data = buf3; + + memset(&type3, 0, sizeof(type3)); + + ret = heim_ntlm_decode_type3(&data, 1, &type3); + if (ret) + errx(1, "heim_ntlm_decode_type2(jp): %d", ret); + + data.data = NULL; + data.length = 0; + + ret = heim_ntlm_encode_type3(&type3, &data, NULL); + if (ret) + errx(1, "heim_ntlm_decode_type2(jp): %d", ret); + + heim_ntlm_free_type3(&type3); + heim_ntlm_free_buf(&data); + + return 0; +} + + static int verbose_flag = 0; static int version_flag = 0; static int help_flag = 0; @@ -342,11 +570,11 @@ usage (int ret) int main(int argc, char **argv) { - int ret = 0, optind = 0; + int ret = 0, optidx = 0; setprogname(argv[0]); - if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind)) + if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx)) usage(1); if (help_flag) @@ -357,24 +585,33 @@ main(int argc, char **argv) exit(0); } - argc -= optind; - argv += optind; - if (verbose_flag) printf("test_parse\n"); + ret |= test_parse(); - ret += test_parse(); if (verbose_flag) printf("test_keys\n"); + ret |= test_keys(); - ret += test_keys(); if (verbose_flag) printf("test_ntlm2_session_resp\n"); - ret += test_ntlm2_session_resp(); + ret |= test_ntlm2_session_resp(); if (verbose_flag) printf("test_targetinfo\n"); - ret += test_targetinfo(); + ret |= test_targetinfo(); + + if (verbose_flag) + printf("test_ntlmv2\n"); + ret |= test_ntlmv2(); + + if (verbose_flag) + printf("test_string2key\n"); + ret |= test_string2key(); + + if (verbose_flag) + printf("test_jp\n"); + ret |= test_jp(); return ret; } |