mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-16 22:38:38 +00:00
add sofia-sip 1.12.4 (plus some patches through 12/21/2006) to in tree libs
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3774 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
0cdfa4fe13
commit
2ecac238f3
719 files changed
+311340
-2
No files matched your search
@@ -0,0 +1,24 @@
|
||||
2005-11-08 Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
|
||||
* Renamed auth_digest_test.c as test_auth_digest.c.
|
||||
|
||||
2005-10-21 Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
|
||||
* Generate opaque only if opaque parameter has value "*".
|
||||
|
||||
M ./libsofia-sip-ua/iptsec/auth_module.c -14 +20
|
||||
|
||||
2005-09-06 Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
|
||||
* auth_digest_test.c: Using opaque to match credentials (as per
|
||||
auth_digest_credentials()).
|
||||
|
||||
* auth_plugin.h, auth_module.c: Added auth_digest_credentials.
|
||||
|
||||
2005-08-10 Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
|
||||
* auth_module.c: Using unsigned as type of hash!
|
||||
|
||||
2005-07-18 Kai Vehmanen <kai.vehmanen@nokia.com>
|
||||
|
||||
* Initial import of the module to Sofia-SIP tree.
|
||||
@@ -0,0 +1,20 @@
|
||||
PROJECT_NAME = "iptsec"
|
||||
OUTPUT_DIRECTORY = ../docs/html/iptsec
|
||||
|
||||
INPUT = iptsec.docs sofia-sip .
|
||||
|
||||
@INCLUDE = ../docs/Doxyfile.conf
|
||||
|
||||
TAGFILES += ../docs/su.doxytags=../su
|
||||
TAGFILES += ../docs/ipt.doxytags=../ipt
|
||||
TAGFILES += ../docs/bnf.doxytags=../bnf
|
||||
TAGFILES += ../docs/url.doxytags=../url
|
||||
TAGFILES += ../docs/msg.doxytags=../msg
|
||||
TAGFILES += ../docs/sip.doxytags=../sip
|
||||
TAGFILES += ../docs/sresolv.doxytags=../sresolv
|
||||
TAGFILES += ../docs/tport.doxytags=../tport
|
||||
TAGFILES += ../docs/nta.doxytags=../nta
|
||||
|
||||
GENERATE_TAGFILE = ../docs/iptsec.doxytags
|
||||
|
||||
ALIASES +=
|
||||
@@ -0,0 +1,80 @@
|
||||
#
|
||||
# Makefile.am for iptsec module
|
||||
#
|
||||
# Copyright (C) 2005,2006 Nokia Corporation
|
||||
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
# Licensed under LGPL. See file COPYING.
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Header paths
|
||||
|
||||
INCLUDES = -I$(srcdir)/../bnf -I../bnf \
|
||||
-I$(srcdir)/../ipt -I../ipt \
|
||||
-I$(srcdir)/../http -I../http \
|
||||
-I$(srcdir)/../msg -I../msg \
|
||||
-I$(srcdir)/../nta -I../nta \
|
||||
-I$(srcdir)/../sip -I../sip \
|
||||
-I$(srcdir)/../url -I../url \
|
||||
-I$(srcdir)/../su -I../su
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Build targets
|
||||
|
||||
noinst_LTLIBRARIES = libiptsec.la
|
||||
|
||||
check_PROGRAMS = test_auth_digest
|
||||
|
||||
TESTS = test_auth_digest
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Rules for building the targets
|
||||
|
||||
BUILT_SOURCES = auth_tag_ref.c
|
||||
|
||||
nobase_include_sofia_HEADERS = \
|
||||
sofia-sip/auth_common.h \
|
||||
sofia-sip/auth_client.h sofia-sip/auth_digest.h \
|
||||
sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
|
||||
sofia-sip/auth_client_plugin.h \
|
||||
$(NTLM_HEADER)
|
||||
|
||||
libiptsec_la_SOURCES = iptsec_debug.h \
|
||||
auth_client.c auth_common.c auth_digest.c \
|
||||
auth_module.c auth_tag.c auth_tag_ref.c \
|
||||
auth_plugin.c auth_plugin_delayed.c \
|
||||
auth_module_http.c auth_module_sip.c \
|
||||
$(NTLM_SOURCE) \
|
||||
iptsec_debug.c
|
||||
|
||||
NTLM_HEADER = sofia-sip/auth_ntlm.h
|
||||
if HAVE_NTLM
|
||||
NTLM_SOURCE = auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
|
||||
endif
|
||||
|
||||
EXTRA_libiptsec_la_SOURCES = \
|
||||
auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
|
||||
|
||||
COVERAGE_INPUT = $(libiptsec_la_SOURCES) $(include_sofia_HEADERS)
|
||||
|
||||
LDADD = libiptsec.la \
|
||||
../http/libhttp.la \
|
||||
../nta/libnta.la \
|
||||
../sip/libsip.la \
|
||||
../msg/libmsg.la \
|
||||
../url/liburl.la \
|
||||
../bnf/libbnf.la \
|
||||
../ipt/libipt.la \
|
||||
../su/libsu.la
|
||||
|
||||
test_auth_digest_LDFLAGS = -static
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Install and distribution rules
|
||||
|
||||
EXTRA_DIST = Doxyfile iptsec.docs testpasswd \
|
||||
auth_module_sip.c auth_module_http.c $(BUILT_SOURCES)
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Sofia specific rules
|
||||
|
||||
include ../sofia.am
|
||||
@@ -0,0 +1,752 @@
|
||||
# Makefile.in generated by automake 1.9.2 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
#
|
||||
# Makefile.am for iptsec module
|
||||
#
|
||||
# Copyright (C) 2005,2006 Nokia Corporation
|
||||
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
# Licensed under LGPL. See file COPYING.
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Header paths
|
||||
|
||||
# common Makefile targets for libsofia-sip-ua modules
|
||||
# ---------------------------------------------------
|
||||
|
||||
|
||||
SOURCES = $(libiptsec_la_SOURCES) $(EXTRA_libiptsec_la_SOURCES) test_auth_digest.c
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ../..
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
check_PROGRAMS = test_auth_digest$(EXEEXT)
|
||||
DIST_COMMON = $(nobase_include_sofia_HEADERS) $(srcdir)/../sofia.am \
|
||||
$(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
|
||||
subdir = libsofia-sip-ua/iptsec
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/sac-general.m4 \
|
||||
$(top_srcdir)/m4/sac-openssl.m4 $(top_srcdir)/m4/sac-su.m4 \
|
||||
$(top_srcdir)/m4/sac-su2.m4 $(top_srcdir)/m4/sac-tport.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h \
|
||||
$(top_builddir)/libsofia-sip-ua/su/sofia-sip/su_configure.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libiptsec_la_LIBADD =
|
||||
am__libiptsec_la_SOURCES_DIST = iptsec_debug.h auth_client.c \
|
||||
auth_common.c auth_digest.c auth_module.c auth_tag.c \
|
||||
auth_tag_ref.c auth_plugin.c auth_plugin_delayed.c \
|
||||
auth_module_http.c auth_module_sip.c auth_ntlm.c \
|
||||
auth_client_ntlm.c auth_plugin_ntlm.c iptsec_debug.c
|
||||
@HAVE_NTLM_TRUE@am__objects_1 = auth_ntlm.lo auth_client_ntlm.lo \
|
||||
@HAVE_NTLM_TRUE@ auth_plugin_ntlm.lo
|
||||
am_libiptsec_la_OBJECTS = auth_client.lo auth_common.lo auth_digest.lo \
|
||||
auth_module.lo auth_tag.lo auth_tag_ref.lo auth_plugin.lo \
|
||||
auth_plugin_delayed.lo auth_module_http.lo auth_module_sip.lo \
|
||||
$(am__objects_1) iptsec_debug.lo
|
||||
libiptsec_la_OBJECTS = $(am_libiptsec_la_OBJECTS)
|
||||
test_auth_digest_SOURCES = test_auth_digest.c
|
||||
test_auth_digest_OBJECTS = test_auth_digest.$(OBJEXT)
|
||||
test_auth_digest_LDADD = $(LDADD)
|
||||
test_auth_digest_DEPENDENCIES = libiptsec.la ../http/libhttp.la \
|
||||
../nta/libnta.la ../sip/libsip.la ../msg/libmsg.la \
|
||||
../url/liburl.la ../bnf/libbnf.la ../ipt/libipt.la \
|
||||
../su/libsu.la
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/libsofia-sip-ua/su/sofia-sip
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(libiptsec_la_SOURCES) $(EXTRA_libiptsec_la_SOURCES) \
|
||||
test_auth_digest.c
|
||||
DIST_SOURCES = $(am__libiptsec_la_SOURCES_DIST) \
|
||||
$(EXTRA_libiptsec_la_SOURCES) test_auth_digest.c
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
|
||||
am__installdirs = "$(DESTDIR)$(include_sofiadir)"
|
||||
nobase_include_sofiaHEADERS_INSTALL = $(install_sh_DATA)
|
||||
HEADERS = $(nobase_include_sofia_HEADERS)
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
|
||||
AMDEP_FALSE = @AMDEP_FALSE@
|
||||
AMDEP_TRUE = @AMDEP_TRUE@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
COREFOUNDATION_FALSE = @COREFOUNDATION_FALSE@
|
||||
COREFOUNDATION_TRUE = @COREFOUNDATION_TRUE@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CWFLAG = @CWFLAG@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DOXYGEN = @DOXYGEN@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ENABLE_COVERAGE_FALSE = @ENABLE_COVERAGE_FALSE@
|
||||
ENABLE_COVERAGE_TRUE = @ENABLE_COVERAGE_TRUE@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXPENSIVE_CHECKS_FALSE = @EXPENSIVE_CHECKS_FALSE@
|
||||
EXPENSIVE_CHECKS_TRUE = @EXPENSIVE_CHECKS_TRUE@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GLIB_CFLAGS = @GLIB_CFLAGS@
|
||||
GLIB_LIBS = @GLIB_LIBS@
|
||||
GLIB_VERSION = @GLIB_VERSION@
|
||||
HAVE_DOXYGEN_FALSE = @HAVE_DOXYGEN_FALSE@
|
||||
HAVE_DOXYGEN_TRUE = @HAVE_DOXYGEN_TRUE@
|
||||
HAVE_GLIB_FALSE = @HAVE_GLIB_FALSE@
|
||||
HAVE_GLIB_TRUE = @HAVE_GLIB_TRUE@
|
||||
HAVE_MINGW32_FALSE = @HAVE_MINGW32_FALSE@
|
||||
HAVE_MINGW32_TRUE = @HAVE_MINGW32_TRUE@
|
||||
HAVE_NTLM_FALSE = @HAVE_NTLM_FALSE@
|
||||
HAVE_NTLM_TRUE = @HAVE_NTLM_TRUE@
|
||||
HAVE_TLS_FALSE = @HAVE_TLS_FALSE@
|
||||
HAVE_TLS_TRUE = @HAVE_TLS_TRUE@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBVER_SOFIA_SIP_UA_AGE = @LIBVER_SOFIA_SIP_UA_AGE@
|
||||
LIBVER_SOFIA_SIP_UA_CUR = @LIBVER_SOFIA_SIP_UA_CUR@
|
||||
LIBVER_SOFIA_SIP_UA_GLIB_AGE = @LIBVER_SOFIA_SIP_UA_GLIB_AGE@
|
||||
LIBVER_SOFIA_SIP_UA_GLIB_CUR = @LIBVER_SOFIA_SIP_UA_GLIB_CUR@
|
||||
LIBVER_SOFIA_SIP_UA_GLIB_REV = @LIBVER_SOFIA_SIP_UA_GLIB_REV@
|
||||
LIBVER_SOFIA_SIP_UA_GLIB_SOVER = @LIBVER_SOFIA_SIP_UA_GLIB_SOVER@
|
||||
LIBVER_SOFIA_SIP_UA_REV = @LIBVER_SOFIA_SIP_UA_REV@
|
||||
LIBVER_SOFIA_SIP_UA_SOVER = @LIBVER_SOFIA_SIP_UA_SOVER@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MINGW_ENVIRONMENT = @MINGW_ENVIRONMENT@
|
||||
MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
|
||||
NDEBUG_FALSE = @NDEBUG_FALSE@
|
||||
NDEBUG_TRUE = @NDEBUG_TRUE@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
RANLIB = @RANLIB@
|
||||
REPLACE_LIBADD = @REPLACE_LIBADD@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SOFIA_CFLAGS = @SOFIA_CFLAGS@
|
||||
SOFIA_GLIB_PKG_REQUIRES = @SOFIA_GLIB_PKG_REQUIRES@
|
||||
STRIP = @STRIP@
|
||||
TESTS_ENVIRONMENT = @TESTS_ENVIRONMENT@
|
||||
VERSION = @VERSION@
|
||||
VER_LIBSOFIA_SIP_UA_MAJOR_MINOR = @VER_LIBSOFIA_SIP_UA_MAJOR_MINOR@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
ac_ct_LD = @ac_ct_LD@
|
||||
ac_ct_RANLIB = @ac_ct_RANLIB@
|
||||
ac_ct_STRIP = @ac_ct_STRIP@
|
||||
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
|
||||
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
|
||||
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
|
||||
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
datadir = @datadir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
include_sofiadir = @include_sofiadir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
INCLUDES = -I$(srcdir)/../bnf -I../bnf \
|
||||
-I$(srcdir)/../ipt -I../ipt \
|
||||
-I$(srcdir)/../http -I../http \
|
||||
-I$(srcdir)/../msg -I../msg \
|
||||
-I$(srcdir)/../nta -I../nta \
|
||||
-I$(srcdir)/../sip -I../sip \
|
||||
-I$(srcdir)/../url -I../url \
|
||||
-I$(srcdir)/../su -I../su
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Build targets
|
||||
noinst_LTLIBRARIES = libiptsec.la
|
||||
TESTS = test_auth_digest
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Rules for building the targets
|
||||
BUILT_SOURCES = auth_tag_ref.c
|
||||
nobase_include_sofia_HEADERS = \
|
||||
sofia-sip/auth_common.h \
|
||||
sofia-sip/auth_client.h sofia-sip/auth_digest.h \
|
||||
sofia-sip/auth_module.h sofia-sip/auth_plugin.h \
|
||||
sofia-sip/auth_client_plugin.h \
|
||||
$(NTLM_HEADER)
|
||||
|
||||
libiptsec_la_SOURCES = iptsec_debug.h \
|
||||
auth_client.c auth_common.c auth_digest.c \
|
||||
auth_module.c auth_tag.c auth_tag_ref.c \
|
||||
auth_plugin.c auth_plugin_delayed.c \
|
||||
auth_module_http.c auth_module_sip.c \
|
||||
$(NTLM_SOURCE) \
|
||||
iptsec_debug.c
|
||||
|
||||
NTLM_HEADER = sofia-sip/auth_ntlm.h
|
||||
@HAVE_NTLM_TRUE@NTLM_SOURCE = auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
|
||||
EXTRA_libiptsec_la_SOURCES = \
|
||||
auth_ntlm.c auth_client_ntlm.c auth_plugin_ntlm.c
|
||||
|
||||
COVERAGE_INPUT = $(libiptsec_la_SOURCES) $(include_sofia_HEADERS)
|
||||
LDADD = libiptsec.la \
|
||||
../http/libhttp.la \
|
||||
../nta/libnta.la \
|
||||
../sip/libsip.la \
|
||||
../msg/libmsg.la \
|
||||
../url/liburl.la \
|
||||
../bnf/libbnf.la \
|
||||
../ipt/libipt.la \
|
||||
../su/libsu.la
|
||||
|
||||
test_auth_digest_LDFLAGS = -static
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Install and distribution rules
|
||||
EXTRA_DIST = Doxyfile iptsec.docs testpasswd \
|
||||
auth_module_sip.c auth_module_http.c $(BUILT_SOURCES)
|
||||
|
||||
AM_CFLAGS = $(CWFLAG) $(SOFIA_CFLAGS)
|
||||
DISTCLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
# rules for building tag files
|
||||
TAG_AWK = $(top_srcdir)/libsofia-sip-ua/su/tag_dll.awk
|
||||
INTERNAL_INCLUDES = \
|
||||
-I$(srcdir)/../features -I../features \
|
||||
-I$(srcdir)/../ipt -I../ipt \
|
||||
-I$(srcdir)/../iptsec -I../iptsec \
|
||||
-I$(srcdir)/../bnf -I../bnf \
|
||||
-I$(srcdir)/../http -I../http \
|
||||
-I$(srcdir)/../msg -I../msg \
|
||||
-I$(srcdir)/../nth -I../nth \
|
||||
-I$(srcdir)/../nta -I../nta \
|
||||
-I$(srcdir)/../nea -I../nea \
|
||||
-I$(srcdir)/../nua -I../nua \
|
||||
-I$(srcdir)/../soa -I../soa \
|
||||
-I$(srcdir)/../sdp -I../sdp \
|
||||
-I$(srcdir)/../sip -I../sip \
|
||||
-I$(srcdir)/../soa -I../soa \
|
||||
-I$(srcdir)/../sresolv -I../sresolv \
|
||||
-I$(srcdir)/../tport -I../tport \
|
||||
-I$(srcdir)/../stun -I../stun \
|
||||
-I$(srcdir)/../url -I../url \
|
||||
-I$(srcdir)/../su -I../su
|
||||
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../sofia.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libsofia-sip-ua/iptsec/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu libsofia-sip-ua/iptsec/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_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
|
||||
libiptsec.la: $(libiptsec_la_OBJECTS) $(libiptsec_la_DEPENDENCIES)
|
||||
$(LINK) $(libiptsec_la_LDFLAGS) $(libiptsec_la_OBJECTS) $(libiptsec_la_LIBADD) $(LIBS)
|
||||
|
||||
clean-checkPROGRAMS:
|
||||
@list='$(check_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f $$p $$f"; \
|
||||
rm -f $$p $$f ; \
|
||||
done
|
||||
test_auth_digest$(EXEEXT): $(test_auth_digest_OBJECTS) $(test_auth_digest_DEPENDENCIES)
|
||||
@rm -f test_auth_digest$(EXEEXT)
|
||||
$(LINK) $(test_auth_digest_LDFLAGS) $(test_auth_digest_OBJECTS) $(test_auth_digest_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_client.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_client_ntlm.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_common.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_digest.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_module.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_module_http.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_module_sip.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_ntlm.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_plugin.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_plugin_delayed.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_plugin_ntlm.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_tag.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/auth_tag_ref.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iptsec_debug.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_auth_digest.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool
|
||||
uninstall-info-am:
|
||||
install-nobase_include_sofiaHEADERS: $(nobase_include_sofia_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(include_sofiadir)" || $(mkdir_p) "$(DESTDIR)$(include_sofiadir)"
|
||||
@$(am__vpath_adj_setup) \
|
||||
list='$(nobase_include_sofia_HEADERS)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
$(am__vpath_adj) \
|
||||
echo " $(nobase_include_sofiaHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(include_sofiadir)/$$f'"; \
|
||||
$(nobase_include_sofiaHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(include_sofiadir)/$$f"; \
|
||||
done
|
||||
|
||||
uninstall-nobase_include_sofiaHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@$(am__vpath_adj_setup) \
|
||||
list='$(nobase_include_sofia_HEADERS)'; for p in $$list; do \
|
||||
$(am__vpath_adj) \
|
||||
echo " rm -f '$(DESTDIR)$(include_sofiadir)/$$f'"; \
|
||||
rm -f "$(DESTDIR)$(include_sofiadir)/$$f"; \
|
||||
done
|
||||
|
||||
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; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
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; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
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; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
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)'; \
|
||||
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`; \
|
||||
echo "XPASS: $$tst"; \
|
||||
;; \
|
||||
*) \
|
||||
echo "PASS: $$tst"; \
|
||||
;; \
|
||||
esac; \
|
||||
elif test $$? -ne 77; then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*" $$tst "*) \
|
||||
xfail=`expr $$xfail + 1`; \
|
||||
echo "XFAIL: $$tst"; \
|
||||
;; \
|
||||
*) \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "FAIL: $$tst"; \
|
||||
;; \
|
||||
esac; \
|
||||
else \
|
||||
skip=`expr $$skip + 1`; \
|
||||
echo "SKIP: $$tst"; \
|
||||
fi; \
|
||||
done; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
if test "$$xfail" -eq 0; then \
|
||||
banner="All $$all tests passed"; \
|
||||
else \
|
||||
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
|
||||
fi; \
|
||||
else \
|
||||
if test "$$xpass" -eq 0; then \
|
||||
banner="$$failed of $$all tests failed"; \
|
||||
else \
|
||||
banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dashes="$$banner"; \
|
||||
skipped=""; \
|
||||
if test "$$skip" -ne 0; then \
|
||||
skipped="($$skip tests were not run)"; \
|
||||
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`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
test -z "$$skipped" || echo "$$skipped"; \
|
||||
test -z "$$report" || echo "$$report"; \
|
||||
echo "$$dashes"; \
|
||||
test "$$failed" -eq 0; \
|
||||
else :; fi
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(mkdir_p) $(distdir)/.. $(distdir)/sofia-sip
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
|
||||
list='$(DISTFILES)'; for file in $$list; do \
|
||||
case $$file in \
|
||||
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
esac; \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
dir="/$$dir"; \
|
||||
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(include_sofiadir)"; do \
|
||||
test -z "$$dir" || $(mkdir_p) "$$dir"; \
|
||||
done
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(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
|
||||
mostlyclean-generic:
|
||||
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
|
||||
clean-noinstLTLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-nobase_include_sofiaHEADERS
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am uninstall-nobase_include_sofiaHEADERS
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
|
||||
clean-checkPROGRAMS clean-generic clean-libtool \
|
||||
clean-noinstLTLIBRARIES ctags 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-exec install-exec-am \
|
||||
install-info install-info-am install-man \
|
||||
install-nobase_include_sofiaHEADERS 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-info-am \
|
||||
uninstall-nobase_include_sofiaHEADERS
|
||||
|
||||
|
||||
built-sources: $(BUILT_SOURCES)
|
||||
|
||||
clean-built-sources:
|
||||
-rm -rf $(BUILT_SOURCES) $(BUILT_SOURCES:%=$(srcdir)/%)
|
||||
|
||||
*_tag_ref.c: $(TAG_AWK)
|
||||
|
||||
%_tag_ref.c: %_tag.c
|
||||
$(AWK) -f $(TAG_AWK) NODLL=1 $(TAG_DLL_FLAGS) $<
|
||||
|
||||
@ENABLE_COVERAGE_TRUE@coverage:
|
||||
@ENABLE_COVERAGE_TRUE@ @$(top_srcdir)/scripts/coverage $(COVERAGE_FLAGS) $(COVERAGE_INPUT)
|
||||
|
||||
../bnf/libbnf.la ../http/libhttp.la ../ipt/libipt.la ../iptsec/libiptsec.la \
|
||||
../msg/libmsg.la ../nea/libnea.la ../nta/libnta.la ../nth/libnth.la \
|
||||
../nua/libnua.la ../sdp/libsdp.la ../sip/libsip.la ../soa/libsoa.la \
|
||||
../sresolv/libsresolv.la ../stun/libstun.la ../su/libsu.la \
|
||||
../tport/libtport.la ../url/liburl.la:
|
||||
$(MAKE) -C $(@D) $(@F)
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Sofia specific rules
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_client_ntlm.c NTLM authenticator for SIP client
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Wed May 24 21:44:39 EEST 2006
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sofia-sip/su.h>
|
||||
#include <sofia-sip/su_md5.h>
|
||||
|
||||
#include "sofia-sip/auth_ntlm.h"
|
||||
#include "sofia-sip/auth_client.h"
|
||||
#include "sofia-sip/auth_client_plugin.h"
|
||||
|
||||
#include <sofia-sip/msg_header.h>
|
||||
|
||||
#include <sofia-sip/auth_digest.h>
|
||||
|
||||
#include <sofia-sip/base64.h>
|
||||
#include <sofia-sip/su_uniqueid.h>
|
||||
#include <sofia-sip/string0.h>
|
||||
|
||||
#include <sofia-sip/su_debug.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct auth_ntlm_client_s
|
||||
{
|
||||
auth_client_t ntlm_client;
|
||||
|
||||
int ntlm_ncount;
|
||||
char const *ntlm_cnonce;
|
||||
auth_challenge_t ntlm_ac[1];
|
||||
} auth_ntlm_client_t;
|
||||
|
||||
static int auc_ntlm_challenge(auth_client_t *ca,
|
||||
msg_auth_t const *ch);
|
||||
static int auc_ntlm_authorization(auth_client_t *ca,
|
||||
su_home_t *h,
|
||||
char const *method,
|
||||
url_t const *url,
|
||||
msg_payload_t const *body,
|
||||
msg_header_t **);
|
||||
|
||||
auth_client_plugin_t const _ntlm_client_plugin =
|
||||
{
|
||||
sizeof ca_ntlm_plugin,
|
||||
sizeof (auth_ntlm_client_t),
|
||||
"NTLM",
|
||||
auc_ntlm_challenge,
|
||||
auc_ntlm_authorization
|
||||
};
|
||||
|
||||
auth_client_plugin_t const * const ntlm_client_plugin = _ntlm_client_plugin;
|
||||
|
||||
/** Store a ntlm authorization challenge.
|
||||
*/
|
||||
static int auc_ntlm_challenge(auth_client_t *ca, msg_auth_t const *ch)
|
||||
{
|
||||
su_home_t *home = ca->ca_home;
|
||||
auth_ntlm_client_t *ntlm = (auth_ntlm_client_t *)ca;
|
||||
auth_challenge_t ac[1] = {{ sizeof ac }};
|
||||
int stale;
|
||||
|
||||
if (auth_ntlm_challenge_get(home, ac, ch->au_params) < 0)
|
||||
goto error;
|
||||
|
||||
/* Check that we can handle the challenge */
|
||||
if (!ac->ac_md5 && !ac->ac_md5sess)
|
||||
goto error;
|
||||
if (ac->ac_qop && !ac->ac_auth && !ac->ac_auth_int)
|
||||
goto error;
|
||||
|
||||
stale = ac->ac_stale || str0cmp(ac->ac_nonce, ntlm->ntlm_ac->ac_nonce);
|
||||
|
||||
if (ac->ac_qop && (ntlm->ntlm_cnonce == NULL || ac->ac_stale)) {
|
||||
su_guid_t guid[1];
|
||||
char *cnonce;
|
||||
if (ntlm->ntlm_cnonce != NULL)
|
||||
/* Free the old one if we are updating after stale=true */
|
||||
su_free(home, (void *)ntlm->ntlm_cnonce);
|
||||
su_guid_generate(guid);
|
||||
ntlm->ntlm_cnonce = cnonce = su_alloc(home, BASE64_SIZE(sizeof(guid)) + 1);
|
||||
base64_e(cnonce, BASE64_SIZE(sizeof(guid)) + 1, guid, sizeof(guid));
|
||||
ntlm->ntlm_ncount = 0;
|
||||
}
|
||||
|
||||
auth_ntlm_challenge_free_params(home, ntlm->ntlm_ac);
|
||||
|
||||
*ntlm->ntlm_ac = *ac;
|
||||
|
||||
return stale ? 2 : 1;
|
||||
|
||||
error:
|
||||
auth_ntlm_challenge_free_params(home, ac);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**Create a NTLM authorization header.
|
||||
*
|
||||
* Creates a ntlm authorization header from username @a user and password
|
||||
* @a pass, client nonce @a cnonce, client nonce count @a nc, request method
|
||||
* @a method, request URI @a uri and message body @a data. The authorization
|
||||
* header type is determined by @a hc - it can be either
|
||||
* sip_authorization_class or sip_proxy_authorization_class, as well as
|
||||
* http_authorization_class or http_proxy_authorization_class.
|
||||
*
|
||||
* @param home memory home used to allocate memory for the new header
|
||||
* @param hc header class for the header to be created
|
||||
* @param user user name
|
||||
* @param pass password
|
||||
* @param ac challenge structure
|
||||
* @param cnonce client nonce
|
||||
* @param nc client nonce count
|
||||
* @param method request method
|
||||
* @param uri request uri
|
||||
* @param data message body
|
||||
* @param dlen length of message body
|
||||
*
|
||||
* @return
|
||||
* Returns a pointer to newly created authorization header, or NULL upon an
|
||||
* error.
|
||||
*/
|
||||
int auc_ntlm_authorization(auth_client_t *ca,
|
||||
su_home_t *home,
|
||||
char const *method,
|
||||
url_t const *url,
|
||||
msg_payload_t const *body,
|
||||
msg_header_t **return_headers)
|
||||
{
|
||||
auth_ntlm_client_t *ntlm = (auth_ntlm_client_t *)ca;
|
||||
msg_hclass_t *hc = ca->ca_credential_class;
|
||||
char const *user = ca->ca_user;
|
||||
char const *pass = ca->ca_pass;
|
||||
auth_challenge_t const *ac = ntlm->ntlm_ac;
|
||||
char const *cnonce = ntlm->ntlm_cnonce;
|
||||
unsigned nc = ++ntlm->ntlm_ncount;
|
||||
char *uri = url_as_string(home, url);
|
||||
void const *data = body ? body->pl_data : "";
|
||||
int dlen = body ? body->pl_len : 0;
|
||||
|
||||
msg_header_t *h;
|
||||
auth_hexmd5_t sessionkey, response;
|
||||
auth_response_t ar[1] = {{ 0 }};
|
||||
char ncount[17];
|
||||
|
||||
ar->ar_size = sizeof(ar);
|
||||
ar->ar_username = user;
|
||||
ar->ar_realm = ac->ac_realm;
|
||||
ar->ar_nonce = ac->ac_nonce;
|
||||
ar->ar_algorithm = NULL;
|
||||
ar->ar_md5 = ac->ac_md5;
|
||||
ar->ar_md5sess = ac->ac_md5sess;
|
||||
ar->ar_opaque = ac->ac_opaque;
|
||||
ar->ar_qop = NULL;
|
||||
ar->ar_auth = ac->ac_auth;
|
||||
ar->ar_auth_int = ac->ac_auth_int;
|
||||
ar->ar_uri = uri;
|
||||
|
||||
/* If there is no qop, we MUST NOT include cnonce or nc */
|
||||
if (!ar->ar_auth && !ar->ar_auth_int)
|
||||
cnonce = NULL;
|
||||
|
||||
if (cnonce) {
|
||||
snprintf(ncount, sizeof(ncount), "%08x", nc);
|
||||
ar->ar_cnonce = cnonce;
|
||||
ar->ar_nc = ncount;
|
||||
}
|
||||
|
||||
auth_ntlm_sessionkey(ar, sessionkey, pass);
|
||||
auth_ntlm_response(ar, response, sessionkey, method, data, dlen);
|
||||
|
||||
h = msg_header_format(home, hc,
|
||||
"NTLM "
|
||||
"username=\"%s\", "
|
||||
"realm=\"%s\", "
|
||||
"nonce=\"%s"
|
||||
"%s%s"
|
||||
"%s%s"
|
||||
"%s%s, "
|
||||
"uri=\"%s\", "
|
||||
"response=\"%s\""
|
||||
"%s%s"
|
||||
"%s%s",
|
||||
ar->ar_username,
|
||||
ar->ar_realm,
|
||||
ar->ar_nonce,
|
||||
cnonce ? "\", cnonce=\"" : "",
|
||||
cnonce ? cnonce : "",
|
||||
ar->ar_opaque ? "\", opaque=\"" : "",
|
||||
ar->ar_opaque ? ar->ar_opaque : "",
|
||||
ar->ar_algorithm ? "\", algorithm=" : "",
|
||||
ar->ar_algorithm ? ar->ar_algorithm : "",
|
||||
ar->ar_uri,
|
||||
response,
|
||||
ar->ar_auth || ar->ar_auth_int ? ", qop=" : "",
|
||||
ar->ar_auth_int ? "auth-int" :
|
||||
(ar->ar_auth ? "auth" : ""),
|
||||
cnonce ? ", nc=" : "",
|
||||
cnonce ? ncount : "");
|
||||
|
||||
su_free(home, uri);
|
||||
|
||||
if (!h)
|
||||
return -1;
|
||||
*return_headers = h;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_common.c
|
||||
*
|
||||
* Functions common to both client and server authentication.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Original Created: Thu Feb 22 12:10:37 2001 ppessi
|
||||
* @date Created: Wed May 17 13:37:50 EEST 2006 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sofia-sip/auth_common.h"
|
||||
#include "sofia-sip/msg_header.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if !HAVE_STRCASESTR
|
||||
char *strcasestr(char const *haystack, char const *needle);
|
||||
#endif
|
||||
|
||||
static inline int has_token(char const *qstring, char const *token);
|
||||
|
||||
/**
|
||||
* Parse authentication parameters.
|
||||
*
|
||||
* The function auth_get_params() searches for the authentication parameters
|
||||
* in @a params. The parameter list @a params is seached for each parameter
|
||||
* given in in vararg section, and if it is found, its value is assigned to
|
||||
* the given address.
|
||||
*
|
||||
* @note The field name should contain the equal ("=") sign.
|
||||
*
|
||||
* @return
|
||||
* The function auth_get_params() returns number of parameters found in
|
||||
* params, or -1 upon an error.
|
||||
*/
|
||||
issize_t auth_get_params(su_home_t *home,
|
||||
char const * const params[], ...
|
||||
/* char const *fmt, char const **return_value */)
|
||||
{
|
||||
int n, j;
|
||||
size_t len, namelen;
|
||||
char const *fmt, *expected;
|
||||
char const *value, *p, **return_value;
|
||||
va_list(ap);
|
||||
|
||||
assert(params);
|
||||
|
||||
if (!params) return -1;
|
||||
|
||||
va_start(ap, params);
|
||||
|
||||
for (n = 0; (fmt = va_arg(ap, char const *));) {
|
||||
return_value = va_arg(ap, char const **);
|
||||
len = strlen(fmt);
|
||||
if (!len)
|
||||
continue;
|
||||
namelen = strcspn(fmt, "=");
|
||||
expected = fmt + namelen + 1;
|
||||
value = NULL;
|
||||
|
||||
if (expected[0]) {
|
||||
/* value match: format is name=expected,
|
||||
if expected is found in parameter value,
|
||||
return non-NULL pointer in *return_value */
|
||||
for (j = 0; (p = params[j++]);) {
|
||||
if (strcasecmp(p, fmt) == 0) {
|
||||
/* Matched the whole parameter with fmt name=expected */
|
||||
value = p;
|
||||
break;
|
||||
}
|
||||
else if (strncasecmp(p, fmt, namelen) ||
|
||||
p[namelen] != '=')
|
||||
continue;
|
||||
|
||||
p = p + namelen + 1;
|
||||
|
||||
if (p[0] == '"' && has_token(p, expected)) {
|
||||
/* Quoted parameter value has expected value,
|
||||
* e.g., qop=auth matches qop="auth,auth-int" */
|
||||
value = p;
|
||||
break;
|
||||
}
|
||||
else if (strcasecmp(p, expected) == 0) {
|
||||
/* Parameter value matches with extected value
|
||||
* e.g., qop=auth matches qop=auth */
|
||||
value = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* format is name= , return unquoted parameter value after = */
|
||||
for (j = 0; (p = params[j++]);) {
|
||||
if (strncasecmp(p, fmt, len))
|
||||
continue;
|
||||
|
||||
if (p[len] == '"')
|
||||
value = msg_unquote_dup(home, p + len);
|
||||
else
|
||||
value = su_strdup(home, p + len);
|
||||
|
||||
if (value == NULL)
|
||||
return -1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (value) {
|
||||
*return_value = value;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int auth_struct_copy(void *dst, void const *src, isize_t s_size)
|
||||
{
|
||||
int d_size = *(int *)dst;
|
||||
|
||||
if (d_size < 0)
|
||||
return -1;
|
||||
|
||||
if ((size_t)d_size > s_size) {
|
||||
memcpy(dst, src, s_size);
|
||||
memset((char *)dst + s_size, 0, d_size - s_size);
|
||||
}
|
||||
else {
|
||||
memcpy(dst, src, d_size);
|
||||
*(int *)dst = d_size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int has_token(char const *qstring, char const *token)
|
||||
{
|
||||
size_t n = strlen(token);
|
||||
char const *q;
|
||||
|
||||
q = strcasestr(qstring, token);
|
||||
return (q &&
|
||||
(q[n] == 0 || strchr("\", \t", q[n])) &&
|
||||
(q == qstring || strchr("\", \t", q[-1])));
|
||||
}
|
||||
|
||||
|
||||
/** Compare two strings, even if they are quoted */
|
||||
int auth_strcmp(char const *quoted, char const *unquoted)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
if (quoted[0] != '"')
|
||||
return strcmp(quoted, unquoted);
|
||||
|
||||
/* Compare quoted with unquoted */
|
||||
|
||||
for (i = 1, j = 0; ; i++, j++) {
|
||||
char q = quoted[i], u = unquoted[j];
|
||||
|
||||
if (q == '"')
|
||||
q = '\0';
|
||||
else if (q == '\\' && u != '\0')
|
||||
q = quoted[i++];
|
||||
|
||||
if (q - u)
|
||||
return q - u;
|
||||
|
||||
if (q == '\0')
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_digest.c
|
||||
*
|
||||
* Implementation for digest authentication.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Feb 22 12:10:37 2001 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sofia-sip/su_md5.h>
|
||||
#include "sofia-sip/auth_common.h"
|
||||
#include "sofia-sip/auth_digest.h"
|
||||
#include "sofia-sip/msg_header.h"
|
||||
#include "sofia-sip/auth_common.h"
|
||||
|
||||
#include "iptsec_debug.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
|
||||
/**Get digest-challenge parameters.
|
||||
*
|
||||
* The function digest_challenge_get() searches for the digest authentication
|
||||
* parameters in @a params. The parameters are assigned to the appropriate
|
||||
* fields in @a ac structure.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The function digest_challenge_get() returns number of parameters
|
||||
* found, or -1 upon an error.
|
||||
*/
|
||||
issize_t auth_digest_challenge_get(su_home_t *home,
|
||||
auth_challenge_t *ac0,
|
||||
char const * const params[])
|
||||
{
|
||||
ssize_t n;
|
||||
auth_challenge_t ac[1] = {{ 0 }};
|
||||
char const *md5 = NULL, *md5sess = NULL, *sha1 = NULL,
|
||||
*stale = NULL,
|
||||
*qop_auth = NULL, *qop_auth_int = NULL;
|
||||
|
||||
ac->ac_size = sizeof(ac);
|
||||
|
||||
assert(ac0);
|
||||
assert(ac0->ac_size >= (int) sizeof(*ac));
|
||||
|
||||
if (ac0 == NULL || params == NULL)
|
||||
return -1;
|
||||
|
||||
n = auth_get_params(home, params,
|
||||
"realm=", &ac->ac_realm,
|
||||
"domain=", &ac->ac_domain,
|
||||
"nonce=", &ac->ac_nonce,
|
||||
"opaque=", &ac->ac_opaque,
|
||||
"algorithm=", &ac->ac_algorithm,
|
||||
"qop=", &ac->ac_qop,
|
||||
"algorithm=md5", &md5,
|
||||
"algorithm=md5-sess", &md5sess,
|
||||
"algorithm=sha1", &sha1,
|
||||
"stale=true", &stale,
|
||||
"qop=auth", &qop_auth,
|
||||
"qop=auth-int", &qop_auth_int,
|
||||
NULL);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
ac->ac_stale = stale != NULL;
|
||||
ac->ac_md5 = md5 != NULL || ac->ac_algorithm == NULL;
|
||||
ac->ac_md5sess = md5sess != NULL;
|
||||
ac->ac_sha1 = sha1 != NULL;
|
||||
ac->ac_auth = qop_auth != NULL;
|
||||
ac->ac_auth_int = qop_auth_int != NULL;
|
||||
|
||||
auth_struct_copy(ac0, ac, sizeof(ac));
|
||||
|
||||
SU_DEBUG_5(("%s(): got "MOD_ZD"\n", "auth_digest_challenge_get", n));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/** Free challenge parameters */
|
||||
void auth_digest_challenge_free_params(su_home_t *home, auth_challenge_t *ac)
|
||||
{
|
||||
if (ac->ac_realm)
|
||||
su_free(home, (void *)ac->ac_realm), ac->ac_realm = NULL;
|
||||
if (ac->ac_domain)
|
||||
su_free(home, (void *)ac->ac_domain), ac->ac_domain = NULL;
|
||||
if (ac->ac_nonce)
|
||||
su_free(home, (void *)ac->ac_nonce), ac->ac_nonce = NULL;
|
||||
if (ac->ac_opaque)
|
||||
su_free(home, (void *)ac->ac_opaque), ac->ac_opaque = NULL;
|
||||
if (ac->ac_algorithm)
|
||||
su_free(home, (void *)ac->ac_algorithm), ac->ac_algorithm = NULL;
|
||||
if (ac->ac_qop)
|
||||
su_free(home, (void *)ac->ac_qop), ac->ac_qop = NULL;
|
||||
}
|
||||
|
||||
/**Get digest-response parameters.
|
||||
*
|
||||
* The function auth_response_get() searches for the digest authentication
|
||||
* parameters in @a params. The parameters are assigned to the appropriate
|
||||
* fields in @a ar structure.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The function auth_response_get() returns number of parameters
|
||||
* found, or -1 upon an error.
|
||||
*/
|
||||
issize_t auth_digest_response_get(su_home_t *home,
|
||||
auth_response_t *ar0,
|
||||
char const *const params[])
|
||||
{
|
||||
ssize_t n;
|
||||
auth_response_t ar[1] = {{ 0 }};
|
||||
char const *md5 = NULL, *md5sess = NULL, *sha1 = NULL,
|
||||
*qop_auth = NULL, *qop_auth_int = NULL;
|
||||
|
||||
ar->ar_size = sizeof(ar);
|
||||
|
||||
assert(ar0); assert(params); assert(ar0->ar_size >= (int) sizeof(ar));
|
||||
|
||||
if (ar0 == NULL || params == NULL)
|
||||
return -1;
|
||||
|
||||
n = auth_get_params(home, params,
|
||||
"username=", &ar->ar_username,
|
||||
"realm=", &ar->ar_realm,
|
||||
"nonce=", &ar->ar_nonce,
|
||||
"uri=", &ar->ar_uri,
|
||||
"response=", &ar->ar_response,
|
||||
"algorithm=", &ar->ar_algorithm,
|
||||
"opaque=", &ar->ar_opaque,
|
||||
"cnonce=", &ar->ar_cnonce,
|
||||
"qop=", &ar->ar_qop,
|
||||
"nc=", &ar->ar_nc,
|
||||
"algorithm=md5", &md5,
|
||||
"algorithm=md5-sess", &md5sess,
|
||||
"algorithm=sha1", &sha1,
|
||||
"qop=auth", &qop_auth,
|
||||
"qop=auth-int", &qop_auth_int,
|
||||
NULL);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
ar->ar_md5 = md5 != NULL || ar->ar_algorithm == NULL;
|
||||
ar->ar_md5sess = md5sess != NULL;
|
||||
ar->ar_sha1 = sha1 != NULL;
|
||||
ar->ar_auth = qop_auth != NULL;
|
||||
ar->ar_auth_int = qop_auth_int != NULL;
|
||||
|
||||
auth_struct_copy(ar0, ar, sizeof(ar));
|
||||
|
||||
SU_DEBUG_7(("%s: "MOD_ZD"\n", "auth_digest_response_get", n));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void unquote_update(su_md5_t md5[1], char const *quoted)
|
||||
{
|
||||
if (!quoted)
|
||||
/*xyzzy*/;
|
||||
else if (quoted[0] == '"') {
|
||||
char const *q;
|
||||
size_t n;
|
||||
|
||||
for (q = quoted + 1; *q; q += n + 2) {
|
||||
n = strcspn(q, "\"\\");
|
||||
su_md5_update(md5, q, n);
|
||||
if (q[n] == '"' || q[n] == '\0')
|
||||
break;
|
||||
su_md5_update(md5, q + n + 1, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
su_md5_strupdate(md5, quoted);
|
||||
}
|
||||
|
||||
/** Generate A1 hash for digest authentication.
|
||||
*/
|
||||
int auth_digest_a1(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1,
|
||||
char const *secret)
|
||||
{
|
||||
su_md5_t md5[1];
|
||||
|
||||
/* Calculate A1 */
|
||||
su_md5_init(md5);
|
||||
su_md5_strupdate(md5, ar->ar_username);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_realm);
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_strupdate(md5, secret);
|
||||
|
||||
su_md5_hexdigest(md5, ha1);
|
||||
|
||||
SU_DEBUG_5(("auth_digest_a1() has A1 = MD5(%s:%s:%s) = %s\n",
|
||||
ar->ar_username, ar->ar_realm, secret, ha1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int auth_digest_a1sess(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1sess,
|
||||
char const *ha1)
|
||||
{
|
||||
su_md5_t md5[1];
|
||||
|
||||
su_md5_init(md5);
|
||||
su_md5_strupdate(md5, ha1);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_nonce);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_cnonce);
|
||||
|
||||
su_md5_hexdigest(md5, ha1sess);
|
||||
|
||||
SU_DEBUG_5(("auth_sessionkey has A1' = MD5(%s:%s:%s) = %s\n",
|
||||
ha1, ar->ar_nonce, ar->ar_cnonce, ha1sess));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Generate MD5 session key for digest authentication.
|
||||
*/
|
||||
int auth_digest_sessionkey(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1,
|
||||
char const *secret)
|
||||
{
|
||||
if (ar->ar_md5sess)
|
||||
ar->ar_algorithm = "MD5-sess";
|
||||
else if (ar->ar_md5)
|
||||
ar->ar_algorithm = "MD5";
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (ar->ar_md5sess) {
|
||||
auth_hexmd5_t base_ha1;
|
||||
auth_digest_a1(ar, base_ha1, secret);
|
||||
auth_digest_a1sess(ar, ha1, base_ha1);
|
||||
} else {
|
||||
auth_digest_a1(ar, ha1, secret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Generate response for digest authentication.
|
||||
*
|
||||
*/
|
||||
int auth_digest_response(auth_response_t *ar,
|
||||
auth_hexmd5_t response,
|
||||
auth_hexmd5_t const ha1,
|
||||
char const *method_name,
|
||||
void const *data, isize_t dlen)
|
||||
{
|
||||
su_md5_t md5[1];
|
||||
auth_hexmd5_t Hentity, HA2;
|
||||
|
||||
if (ar->ar_auth_int)
|
||||
ar->ar_qop = "auth-int";
|
||||
else if (ar->ar_auth)
|
||||
ar->ar_qop = "auth";
|
||||
else
|
||||
ar->ar_qop = NULL;
|
||||
|
||||
/* Calculate Hentity */
|
||||
if (ar->ar_auth_int) {
|
||||
if (data && dlen) {
|
||||
su_md5_init(md5);
|
||||
su_md5_update(md5, data, dlen);
|
||||
su_md5_hexdigest(md5, Hentity);
|
||||
} else {
|
||||
strcpy(Hentity, "d41d8cd98f00b204e9800998ecf8427e");
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate A2 */
|
||||
su_md5_init(md5);
|
||||
su_md5_strupdate(md5, method_name);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_uri);
|
||||
if (ar->ar_auth_int) {
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_update(md5, Hentity, sizeof(Hentity) - 1);
|
||||
}
|
||||
su_md5_hexdigest(md5, HA2);
|
||||
|
||||
SU_DEBUG_5(("A2 = MD5(%s:%s%s%s)\n", method_name, ar->ar_uri,
|
||||
ar->ar_auth_int ? ":" : "", ar->ar_auth_int ? Hentity : ""));
|
||||
|
||||
/* Calculate response */
|
||||
su_md5_init(md5);
|
||||
su_md5_update(md5, ha1, 32);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_nonce);
|
||||
|
||||
if (ar->ar_auth || ar->ar_auth_int) {
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_strupdate(md5, ar->ar_nc);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_cnonce);
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_strupdate(md5, ar->ar_qop);
|
||||
}
|
||||
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_update(md5, HA2, 32);
|
||||
su_md5_hexdigest(md5, response);
|
||||
|
||||
SU_DEBUG_5(("auth_response: %s = MD5(%s:%s%s%s%s%s%s%s:%s) (qop=%s)\n",
|
||||
response, ha1, ar->ar_nonce,
|
||||
ar->ar_auth || ar->ar_auth_int ? ":" : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ar->ar_nc : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ":" : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ar->ar_cnonce : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ":" : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ar->ar_qop : "",
|
||||
HA2,
|
||||
ar->ar_qop ? ar->ar_qop : "NONE"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file auth_module_http.c
|
||||
* @brief Authenticate HTTP request
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
* @author Jari Urpalainen <Jari.Urpalainen@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Jan 15 17:23:21 2004 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sofia-sip/http.h>
|
||||
#include <sofia-sip/http_header.h>
|
||||
#include <sofia-sip/http_status.h>
|
||||
|
||||
#include <sofia-sip/auth_module.h>
|
||||
|
||||
static auth_challenger_t http_server_challenger[] =
|
||||
{{ HTTP_401_UNAUTHORIZED, http_www_authenticate_class }};
|
||||
|
||||
static auth_challenger_t http_proxy_challenger[] =
|
||||
{{ HTTP_407_PROXY_AUTH, http_proxy_authenticate_class }};
|
||||
|
||||
const char *auth_mod_check_http(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
http_t const *http,
|
||||
auth_kind_t proxy)
|
||||
{
|
||||
msg_auth_t *credentials =
|
||||
proxy ? http->http_proxy_authorization : http->http_authorization;
|
||||
auth_challenger_t const *challenger =
|
||||
proxy ? http_proxy_challenger : http_server_challenger;
|
||||
|
||||
if (http->http_request) {
|
||||
if (!as->as_method)
|
||||
as->as_method = http->http_request->rq_method_name;
|
||||
#if 0
|
||||
if (!as->as_uri)
|
||||
as->as_uri = http->http_request->rq_url;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (http->http_payload && !as->as_body)
|
||||
as->as_body = http->http_payload->pl_data,
|
||||
as->as_bodylen = http->http_payload->pl_len;
|
||||
|
||||
/* Call real authentication method */
|
||||
auth_mod_check_client(am, as, credentials, challenger);
|
||||
|
||||
if (as->as_status)
|
||||
return NULL;
|
||||
else
|
||||
return as->as_user;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file auth_module_sip.c
|
||||
* @brief Authenticate SIP request
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
* @author Jari Urpalainen <Jari.Urpalainen@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Jan 15 17:23:21 2004 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sofia-sip/sip.h>
|
||||
#include <sofia-sip/sip_header.h>
|
||||
#include <sofia-sip/sip_status.h>
|
||||
|
||||
#include <sofia-sip/nta.h>
|
||||
|
||||
#include <sofia-sip/auth_module.h>
|
||||
|
||||
static auth_challenger_t sip_server_challenger[] =
|
||||
{{ SIP_401_UNAUTHORIZED, sip_www_authenticate_class,
|
||||
sip_authentication_info_class
|
||||
}};
|
||||
|
||||
static auth_challenger_t sip_proxy_challenger[] =
|
||||
{{ SIP_407_PROXY_AUTH_REQUIRED, sip_proxy_authenticate_class }};
|
||||
|
||||
/** Authenticate an incoming SIP request.
|
||||
*
|
||||
* The function auth_mod_check() completes the @a as structure and calls the
|
||||
* scheme-specific authentication method performing the actual
|
||||
* authentication.
|
||||
*
|
||||
* A successful authentication is indicated by setting @a as->as_status to
|
||||
* 0. The authentication module sets @a as->as_match as the matching
|
||||
* credential header.
|
||||
*/
|
||||
void auth_mod_check(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
sip_t const *sip,
|
||||
auth_kind_t proxy)
|
||||
{
|
||||
msg_auth_t *credentials;
|
||||
auth_challenger_t const *challenger;
|
||||
|
||||
if (as == NULL || sip == NULL)
|
||||
return;
|
||||
|
||||
if (am == NULL) {
|
||||
as->as_status = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
credentials = proxy ? sip->sip_proxy_authorization : sip->sip_authorization;
|
||||
challenger = proxy ? sip_proxy_challenger : sip_server_challenger;
|
||||
|
||||
if (sip->sip_request)
|
||||
as->as_method = sip->sip_request->rq_method_name;
|
||||
|
||||
if (sip->sip_payload)
|
||||
as->as_body = sip->sip_payload->pl_data,
|
||||
as->as_bodylen = sip->sip_payload->pl_len;
|
||||
|
||||
auth_mod_method(am, as, credentials, challenger);
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_ntlm.c
|
||||
*
|
||||
* Implementation for digest authentication.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Feb 22 12:10:37 2001 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sofia-sip/su_md5.h>
|
||||
#include "sofia-sip/auth_digest.h"
|
||||
#include "sofia-sip/auth_ntlm.h"
|
||||
|
||||
#include "iptsec_debug.h"
|
||||
|
||||
static inline int has_token(char const *qstring, char const *token);
|
||||
|
||||
|
||||
/**Get ntlm-challenge parameters.
|
||||
*
|
||||
* The function ntlm_challenge_get() searches for the ntlm authentication
|
||||
* parameters in @a params. The parameters are assigned to the appropriate
|
||||
* fields in @a ac structure.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The function ntlm_challenge_get() returns number of parameters
|
||||
* found, or -1 upon an error.
|
||||
*/
|
||||
issize_t auth_ntlm_challenge_get(su_home_t *home,
|
||||
auth_challenge_t *ac0,
|
||||
char const * const params[])
|
||||
{
|
||||
ssize_t n;
|
||||
auth_challenge_t ac[1] = {{ 0 }};
|
||||
char const *md5 = NULL, *md5sess = NULL, *sha1 = NULL,
|
||||
*qop_auth = NULL, *qop_auth_int = NULL;
|
||||
|
||||
ac->ac_size = sizeof(ac);
|
||||
|
||||
assert(ac0);
|
||||
assert(ac0->ac_size >= sizeof(*ac));
|
||||
|
||||
if (ac0 == NULL || params == NULL)
|
||||
return -1;
|
||||
|
||||
n = auth_get_params(home, params,
|
||||
"realm=", &ac->ac_realm,
|
||||
"domain=", &ac->ac_domain,
|
||||
"nonce=", &ac->ac_nonce,
|
||||
"opaque=", &ac->ac_opaque,
|
||||
"stale=", &ac->ac_stale,
|
||||
"algorithm=", &ac->ac_algorithm,
|
||||
"qop=", &ac->ac_qop,
|
||||
"algorithm=md5", &md5,
|
||||
"algorithm=md5-sess", &md5sess,
|
||||
"algorithm=sha1", &sha1,
|
||||
"qop=auth", &qop_auth,
|
||||
"qop=auth-int", &qop_auth_int,
|
||||
NULL);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
if (ac->ac_stale && strcasecmp(ac->ac_stale, "true") != 0)
|
||||
ac->ac_stale = NULL;
|
||||
|
||||
ac->ac_md5 = md5 != NULL || ac->ac_algorithm == NULL;
|
||||
ac->ac_md5sess = md5sess != NULL;
|
||||
ac->ac_sha1 = sha1 != NULL;
|
||||
ac->ac_auth = qop_auth != NULL;
|
||||
ac->ac_auth_int = qop_auth_int != NULL;
|
||||
|
||||
auth_struct_copy(ac0, ac, sizeof(ac));
|
||||
|
||||
SU_DEBUG_5(("%s(): got %d\n", "auth_ntlm_challenge_get", n));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/**Get ntlm-response parameters.
|
||||
*
|
||||
* The function auth_response_get() searches for the ntlm authentication
|
||||
* parameters in @a params. The parameters are assigned to the appropriate
|
||||
* fields in @a ar structure.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The function auth_response_get() returns number of parameters
|
||||
* found, or -1 upon an error.
|
||||
*/
|
||||
issize_t auth_ntlm_response_get(su_home_t *home,
|
||||
auth_response_t *ar0,
|
||||
char const *const params[])
|
||||
{
|
||||
ssize_t n;
|
||||
auth_response_t ar[1] = {{ 0 }};
|
||||
char const *md5 = NULL, *md5sess = NULL, *sha1 = NULL,
|
||||
*qop_auth = NULL, *qop_auth_int = NULL;
|
||||
|
||||
ar->ar_size = sizeof(ar);
|
||||
|
||||
assert(ar0); assert(params); assert(ar0->ar_size >= sizeof(ar));
|
||||
|
||||
if (ar0 == NULL || params == NULL)
|
||||
return -1;
|
||||
|
||||
n = auth_get_params(home, params,
|
||||
"username=", &ar->ar_username,
|
||||
"realm=", &ar->ar_realm,
|
||||
"nonce=", &ar->ar_nonce,
|
||||
"uri=", &ar->ar_uri,
|
||||
"response=", &ar->ar_response,
|
||||
"algorithm=", &ar->ar_algorithm,
|
||||
"opaque=", &ar->ar_opaque,
|
||||
"cnonce=", &ar->ar_cnonce,
|
||||
"qop=", &ar->ar_qop,
|
||||
"nc=", &ar->ar_nc,
|
||||
"algorithm=md5", &md5,
|
||||
"algorithm=md5-sess", &md5sess,
|
||||
"algorithm=sha1", &sha1,
|
||||
"qop=auth", &qop_auth,
|
||||
"qop=auth-int", &qop_auth_int,
|
||||
NULL);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
ar->ar_md5 = md5 != NULL || ar->ar_algorithm == NULL;
|
||||
ar->ar_md5sess = md5sess != NULL;
|
||||
ar->ar_sha1 = sha1 != NULL;
|
||||
ar->ar_auth = qop_auth != NULL;
|
||||
ar->ar_auth_int = qop_auth_int != NULL;
|
||||
|
||||
auth_struct_copy(ar0, ar, sizeof(ar));
|
||||
|
||||
SU_DEBUG_7(("%s: %d\n", "auth_ntlm_response_get", n));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/** Generate A1 hash for digest authentication.
|
||||
*/
|
||||
int auth_digest_a1(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1,
|
||||
char const *secret)
|
||||
{
|
||||
su_md5_t md5[1];
|
||||
|
||||
/* Calculate A1 */
|
||||
su_md5_init(md5);
|
||||
su_md5_strupdate(md5, ar->ar_username);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_realm);
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_strupdate(md5, secret);
|
||||
|
||||
su_md5_hexdigest(md5, ha1);
|
||||
|
||||
SU_DEBUG_5(("auth_digest_a1() has A1 = MD5(%s:%s:%s) = %s\n",
|
||||
ar->ar_username, ar->ar_realm, secret, ha1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int auth_digest_a1sess(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1sess,
|
||||
char const *ha1)
|
||||
{
|
||||
su_md5_t md5[1];
|
||||
|
||||
su_md5_init(md5);
|
||||
su_md5_strupdate(md5, ha1);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_nonce);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_cnonce);
|
||||
|
||||
su_md5_hexdigest(md5, ha1sess);
|
||||
|
||||
SU_DEBUG_5(("auth_sessionkey has A1' = MD5(%s:%s:%s) = %s\n",
|
||||
ha1, ar->ar_nonce, ar->ar_cnonce, ha1sess));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Generate MD5 session key for digest authentication.
|
||||
*/
|
||||
int auth_digest_sessionkey(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1,
|
||||
char const *secret)
|
||||
{
|
||||
if (ar->ar_md5sess)
|
||||
ar->ar_algorithm = "MD5-sess";
|
||||
else if (ar->ar_md5)
|
||||
ar->ar_algorithm = "MD5";
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (ar->ar_md5sess) {
|
||||
auth_hexmd5_t base_ha1;
|
||||
auth_digest_a1(ar, base_ha1, secret);
|
||||
auth_digest_a1sess(ar, ha1, base_ha1);
|
||||
} else {
|
||||
auth_digest_a1(ar, ha1, secret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/** Generate response for digest authentication.
|
||||
*
|
||||
*/
|
||||
int auth_digest_response(auth_response_t *ar,
|
||||
auth_hexmd5_t response,
|
||||
auth_hexmd5_t const ha1,
|
||||
char const *method_name,
|
||||
void const *data, issize_t dlen)
|
||||
{
|
||||
su_md5_t md5[1];
|
||||
auth_hexmd5_t Hentity, HA2;
|
||||
|
||||
if (ar->ar_auth_int)
|
||||
ar->ar_qop = "auth-int";
|
||||
else if (ar->ar_auth)
|
||||
ar->ar_qop = "auth";
|
||||
else
|
||||
ar->ar_qop = NULL;
|
||||
|
||||
/* Calculate Hentity */
|
||||
if (ar->ar_auth_int) {
|
||||
if (data && dlen) {
|
||||
su_md5_init(md5);
|
||||
su_md5_update(md5, data, dlen);
|
||||
su_md5_hexdigest(md5, Hentity);
|
||||
} else {
|
||||
strcpy(Hentity, "d41d8cd98f00b204e9800998ecf8427e");
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate A2 */
|
||||
su_md5_init(md5);
|
||||
su_md5_strupdate(md5, method_name);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_uri);
|
||||
if (ar->ar_auth_int) {
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_update(md5, Hentity, sizeof(Hentity) - 1);
|
||||
}
|
||||
su_md5_hexdigest(md5, HA2);
|
||||
|
||||
SU_DEBUG_5(("A2 = MD5(%s:%s%s%s)\n", method_name, ar->ar_uri,
|
||||
ar->ar_auth_int ? ":" : "", ar->ar_auth_int ? Hentity : ""));
|
||||
|
||||
/* Calculate response */
|
||||
su_md5_init(md5);
|
||||
su_md5_update(md5, ha1, 32);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_nonce);
|
||||
|
||||
if (ar->ar_auth || ar->ar_auth_int) {
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_strupdate(md5, ar->ar_nc);
|
||||
su_md5_update(md5, ":", 1);
|
||||
unquote_update(md5, ar->ar_cnonce);
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_strupdate(md5, ar->ar_qop);
|
||||
}
|
||||
|
||||
su_md5_update(md5, ":", 1);
|
||||
su_md5_update(md5, HA2, 32);
|
||||
su_md5_hexdigest(md5, response);
|
||||
|
||||
SU_DEBUG_5(("auth_response: %s = MD5(%s:%s%s%s%s%s%s%s:%s) (qop=%s)\n",
|
||||
response, ha1, ar->ar_nonce,
|
||||
ar->ar_auth || ar->ar_auth_int ? ":" : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ar->ar_nc : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ":" : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ar->ar_cnonce : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ":" : "",
|
||||
ar->ar_auth || ar->ar_auth_int ? ar->ar_qop : "",
|
||||
HA2,
|
||||
ar->ar_qop ? ar->ar_qop : "NONE"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file auth_plugin.c
|
||||
* @brief Plugin interface for authentication verification modules.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Tue Apr 27 15:23:31 2004 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sofia-sip/auth_digest.h>
|
||||
|
||||
#if HAVE_FUNC
|
||||
#elif HAVE_FUNCTION
|
||||
#define __func__ __FUNCTION__
|
||||
#else
|
||||
static char const __func__[] = "auth_plugin";
|
||||
#endif
|
||||
|
||||
#include <sofia-sip/su_debug.h>
|
||||
|
||||
#include <sofia-sip/su_wait.h>
|
||||
#include <sofia-sip/su_alloc.h>
|
||||
#include <sofia-sip/su_tagarg.h>
|
||||
|
||||
#include "sofia-sip/auth_module.h"
|
||||
#include "sofia-sip/auth_plugin.h"
|
||||
|
||||
extern auth_scheme_t auth_scheme_basic[];
|
||||
extern auth_scheme_t auth_scheme_digest[];
|
||||
extern auth_scheme_t auth_scheme_delayed[];
|
||||
|
||||
enum { N = 32 };
|
||||
|
||||
static auth_scheme_t *schemes[N] = {
|
||||
auth_scheme_basic,
|
||||
auth_scheme_digest,
|
||||
auth_scheme_delayed
|
||||
};
|
||||
|
||||
/** Register an authentication plugin.
|
||||
*
|
||||
* @retval 0 when successful
|
||||
* @retval -1 upon an error
|
||||
*/
|
||||
int auth_mod_register_plugin(auth_scheme_t *asch)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; schemes[i]; i++) {
|
||||
if (i == N)
|
||||
return -1;
|
||||
}
|
||||
|
||||
schemes[i] = asch;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Create an authentication plugin module.
|
||||
*
|
||||
* The function auth_mod_create() creates a module used to authenticate the
|
||||
* requests.
|
||||
*
|
||||
* @param root pointer to a su_root_t object
|
||||
* @param tag,value,... tagged argument list
|
||||
*
|
||||
* @TAGS
|
||||
* AUTHTAG_METHOD(), AUTHTAG_REALM(), AUTHTAG_DB(), AUTHTAG_ALLOW(),
|
||||
* AUTHTAG_QOP(), AUTHTAG_ALGORITHM(), AUTHTAG_EXPIRES(),
|
||||
* AUTHTAG_BLACKLIST(), AUTHTAG_FORBIDDEN(), AUTHTAG_ANONYMOUS(),
|
||||
* AUTHTAG_REMOTE().
|
||||
*/
|
||||
auth_mod_t *auth_mod_create(su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...)
|
||||
{
|
||||
auth_mod_t *am = NULL;
|
||||
|
||||
ta_list ta;
|
||||
|
||||
char const *method = NULL;
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
|
||||
tl_gets(ta_args(ta),
|
||||
AUTHTAG_METHOD_REF(method),
|
||||
TAG_NULL());
|
||||
|
||||
if (method) {
|
||||
auth_scheme_t *bscheme = NULL;
|
||||
char const *base;
|
||||
size_t len;
|
||||
|
||||
base = strrchr(method, '+');
|
||||
if (base)
|
||||
len = base++ - method;
|
||||
else
|
||||
len = strlen(method);
|
||||
|
||||
if (base == NULL)
|
||||
;
|
||||
else if (strcasecmp(base, "Basic") == 0)
|
||||
bscheme = auth_scheme_basic;
|
||||
else if (strcasecmp(base, "Digest") == 0)
|
||||
bscheme = auth_scheme_digest;
|
||||
|
||||
if (base == NULL || bscheme) {
|
||||
int i;
|
||||
|
||||
for (i = 0; schemes[i] && i < N; i++) {
|
||||
if (strncasecmp(schemes[i]->asch_method, method, len) == 0 &&
|
||||
schemes[i]->asch_method[len] == 0) {
|
||||
am = auth_mod_alloc(schemes[i], ta_tags(ta));
|
||||
if (schemes[i]->asch_init(am, bscheme, root, ta_tags(ta)) == -1) {
|
||||
auth_mod_destroy(am), am = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ta_end(ta);
|
||||
|
||||
return am;
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_plugin_delayed.c
|
||||
*
|
||||
* @brief Plugin for delayed authentication.
|
||||
*
|
||||
* This authentication plugin provides authentication operation that is
|
||||
* intentionally delayed. It serves as an example of server-side
|
||||
* authentication plugins.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>.
|
||||
*
|
||||
* @date Created: Wed Apr 11 15:14:03 2001 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define SU_MSG_ARG_T struct auth_splugin_t
|
||||
|
||||
#if HAVE_FUNC
|
||||
#elif HAVE_FUNCTION
|
||||
#define __func__ __FUNCTION__
|
||||
#else
|
||||
static char const __func__[] = "auth_plugin_delayed";
|
||||
#endif
|
||||
|
||||
#include <sofia-sip/su_debug.h>
|
||||
#include <sofia-sip/su_wait.h>
|
||||
|
||||
#include <sofia-sip/su_alloc.h>
|
||||
#include <sofia-sip/su_tagarg.h>
|
||||
|
||||
#include "sofia-sip/auth_module.h"
|
||||
#include "sofia-sip/auth_plugin.h"
|
||||
|
||||
struct auth_plugin_t
|
||||
{
|
||||
su_root_t *ap_root;
|
||||
auth_scheme_t *ap_base;
|
||||
auth_splugin_t *ap_list;
|
||||
auth_splugin_t**ap_tail;
|
||||
};
|
||||
|
||||
/* Digest (or Basic) with delay */
|
||||
|
||||
static int delayed_auth_init(auth_mod_t *am,
|
||||
auth_scheme_t *base,
|
||||
su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
static void delayed_auth_method(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *auth,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
static void delayed_auth_challenge(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
static void delayed_auth_cancel(auth_mod_t *am, auth_status_t *as);
|
||||
|
||||
static void delayed_auth_destroy(auth_mod_t *am);
|
||||
|
||||
auth_scheme_t auth_scheme_delayed[1] =
|
||||
{{
|
||||
"Delayed",
|
||||
sizeof (struct { auth_mod_t mod[1]; auth_plugin_t plug[1]; }),
|
||||
delayed_auth_init,
|
||||
delayed_auth_method,
|
||||
delayed_auth_challenge,
|
||||
delayed_auth_cancel,
|
||||
delayed_auth_destroy
|
||||
}};
|
||||
|
||||
static int delayed_auth_init(auth_mod_t *am,
|
||||
auth_scheme_t *base,
|
||||
su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...)
|
||||
{
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
int retval = -1;
|
||||
ta_list ta;
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
|
||||
if (root && base && auth_init_default(am, base, root, ta_tags(ta)) != -1) {
|
||||
ap->ap_root = root;
|
||||
ap->ap_base = base;
|
||||
ap->ap_tail = &ap->ap_list;
|
||||
|
||||
retval = 0;
|
||||
}
|
||||
|
||||
ta_end(ta);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
struct auth_splugin_t
|
||||
{
|
||||
void const *asp_tag;
|
||||
auth_splugin_t *asp_next;
|
||||
auth_splugin_t **asp_prev;
|
||||
auth_mod_t *asp_am;
|
||||
auth_status_t *asp_as;
|
||||
msg_auth_t *asp_header;
|
||||
auth_challenger_t const *asp_ach;
|
||||
int asp_canceled;
|
||||
};
|
||||
|
||||
|
||||
static void delayed_auth_method_recv(su_root_magic_t *rm,
|
||||
su_msg_r msg,
|
||||
auth_splugin_t *u);
|
||||
|
||||
static void delayed_auth_method(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *auth,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
su_msg_r mamc = SU_MSG_R_INIT;
|
||||
auth_splugin_t *asp;
|
||||
|
||||
if (su_msg_create(mamc,
|
||||
su_root_task(ap->ap_root),
|
||||
su_root_task(ap->ap_root),
|
||||
delayed_auth_method_recv,
|
||||
sizeof *asp) == SU_FAILURE) {
|
||||
as->as_status = 500;
|
||||
as->as_phrase = "Asynchronous authentication failure";
|
||||
return;
|
||||
}
|
||||
|
||||
asp = su_msg_data(mamc); assert(asp);
|
||||
|
||||
asp->asp_tag = delayed_auth_cancel;
|
||||
asp->asp_am = am;
|
||||
asp->asp_as = as;
|
||||
asp->asp_header = auth;
|
||||
asp->asp_ach = ach;
|
||||
asp->asp_canceled = 0;
|
||||
|
||||
if (su_msg_send(mamc) == SU_FAILURE) {
|
||||
su_msg_destroy(mamc);
|
||||
as->as_status = 500;
|
||||
as->as_phrase = "Asynchronous authentication failure";
|
||||
return;
|
||||
}
|
||||
|
||||
as->as_plugin = asp;
|
||||
|
||||
as->as_status = 100;
|
||||
as->as_phrase = "Trying";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void delayed_auth_method_recv(su_root_magic_t *rm,
|
||||
su_msg_r msg,
|
||||
auth_splugin_t *asp)
|
||||
{
|
||||
auth_mod_t *am = asp->asp_am;
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
|
||||
if (asp->asp_canceled)
|
||||
return;
|
||||
|
||||
ap->ap_base->asch_check(am, asp->asp_as, asp->asp_header, asp->asp_ach);
|
||||
|
||||
if (asp->asp_as->as_callback)
|
||||
asp->asp_as->as_callback(asp->asp_as->as_magic, asp->asp_as);
|
||||
}
|
||||
|
||||
static void delayed_auth_challenge(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
|
||||
/* Invoke member function of base scheme */
|
||||
ap->ap_base->asch_challenge(am, as, ach);
|
||||
}
|
||||
|
||||
static void delayed_auth_cancel(auth_mod_t *am, auth_status_t *as)
|
||||
{
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
|
||||
(void)ap; /* xyzzy */
|
||||
|
||||
if (as->as_plugin && as->as_plugin->asp_tag == delayed_auth_cancel)
|
||||
as->as_plugin->asp_canceled = 1;
|
||||
|
||||
as->as_status = 500, as->as_phrase = "Authentication canceled";
|
||||
}
|
||||
|
||||
static void delayed_auth_destroy(auth_mod_t *am)
|
||||
{
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
|
||||
/* Invoke member function of base scheme */
|
||||
ap->ap_base->asch_destroy(am);
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_plugin_ntlm.c
|
||||
*
|
||||
* @brief Plugin for delayed authentication.
|
||||
*
|
||||
* This authentication plugin provides authentication operation that is
|
||||
* intentionally delayed. It serves as an example of server-side
|
||||
* authentication plugins.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>.
|
||||
*
|
||||
* @date Created: Wed Apr 11 15:14:03 2001 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sofia-sip/su_debug.h>
|
||||
#include <sofia-sip/su_wait.h>
|
||||
|
||||
#include <sofia-sip/su_alloc.h>
|
||||
#include <sofia-sip/su_tagarg.h>
|
||||
|
||||
#include "sofia-sip/auth_module.h"
|
||||
#include "sofia-sip/auth_plugin.h"
|
||||
#include "sofia-sip/auth_ntlm.h"
|
||||
|
||||
#if HAVE_FUNC
|
||||
#elif HAVE_FUNCTION
|
||||
#define __func__ __FUNCTION__
|
||||
#else
|
||||
static char const __func__[] = "auth_plugin_ntml";
|
||||
#endif
|
||||
|
||||
/* ====================================================================== */
|
||||
/* NTLM authentication scheme */
|
||||
|
||||
static int auth_init_ntlm(auth_mod_t *am,
|
||||
auth_scheme_t *base,
|
||||
su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
static void auth_method_ntlm_x(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *au,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
auth_scheme_t auth_scheme_ntlm[1] =
|
||||
{{
|
||||
"NTLM", /* asch_method */
|
||||
sizeof (auth_mod_t), /* asch_size */
|
||||
auth_init_default, /* asch_init */
|
||||
auth_method_ntlm_x, /* asch_check */
|
||||
auth_challenge_ntlm, /* asch_challenge */
|
||||
auth_cancel_default, /* asch_cancel */
|
||||
auth_destroy_default /* asch_destroy */
|
||||
}};
|
||||
|
||||
#define AUTH_NTLM_NONCE_LEN (BASE64_SIZE(sizeof (struct nonce)) + 1)
|
||||
|
||||
static int auth_init_ntlm(auth_mod_t *am,
|
||||
auth_scheme_t *base,
|
||||
su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...)
|
||||
{
|
||||
auth_plugin_t *ap = AUTH_PLUGIN(am);
|
||||
int retval = -1;
|
||||
ta_list ta;
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
|
||||
if (auth_init_default(am, NULL, root, ta_tags(ta)) != -1) {
|
||||
retval = 0;
|
||||
}
|
||||
|
||||
ta_end(ta);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/** Authenticate a request with @b NTLM authentication scheme.
|
||||
*
|
||||
* This function reads user database before authentication, if needed.
|
||||
*/
|
||||
static
|
||||
void auth_method_ntlm_x(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *au,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
if (am) {
|
||||
auth_readdb_if_needed(am);
|
||||
auth_method_ntlm(am, as, au, ach);
|
||||
}
|
||||
}
|
||||
|
||||
/** Authenticate a request with @b Ntlm authentication scheme.
|
||||
*/
|
||||
void auth_method_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *au,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
as->as_allow = as->as_allow || auth_allow_check(am, as) == 0;
|
||||
|
||||
if (as->as_realm)
|
||||
au = auth_ntlm_credentials(au, as->as_realm, am->am_opaque,
|
||||
am->am_gssapi_data, am->am_targetname);
|
||||
|
||||
else
|
||||
au = NULL;
|
||||
|
||||
if (as->as_allow) {
|
||||
SU_DEBUG_5(("%s: allow unauthenticated %s\n", __func__, as->as_method));
|
||||
as->as_status = 0, as->as_phrase = NULL;
|
||||
as->as_match = (msg_header_t *)au;
|
||||
return;
|
||||
}
|
||||
|
||||
if (au) {
|
||||
auth_response_t ar[1] = {{ sizeof(ar) }};
|
||||
auth_ntlm_response_get(as->as_home, ar, au->au_params);
|
||||
as->as_match = (msg_header_t *)au;
|
||||
auth_check_ntlm(am, as, ar, ach);
|
||||
}
|
||||
else {
|
||||
/* There was no matching credentials, send challenge */
|
||||
SU_DEBUG_5(("%s: no credentials matched\n", __func__));
|
||||
auth_challenge_ntlm(am, as, ach);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Find a NTLM credential header with matching realm and opaque. */
|
||||
msg_auth_t *auth_ntlm_credentials(msg_auth_t *auth,
|
||||
char const *realm,
|
||||
char const *opaque,
|
||||
char const *gssapidata,
|
||||
char const *targetname)
|
||||
{
|
||||
char const *agssapidata, *atargetname;
|
||||
|
||||
for (;auth; auth = auth_mod_credentials(auth->au_next)) {
|
||||
if (strcasecmp(auth->au_scheme, "NTLM"))
|
||||
continue;
|
||||
|
||||
if (gssapidata) {
|
||||
agssapidata = msg_header_find_param(auth->au_common, "gssapi-data=");
|
||||
if (!agssapidata || auth_strcmp(agssapidata, gssapidata))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetname) {
|
||||
atargetname = msg_header_find_param(auth->au_common, "targetname=");
|
||||
if (!atargetname || auth_strcmp(atargetname, targetname))
|
||||
continue;
|
||||
}
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/** Check ntlm authentication */
|
||||
void auth_check_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_response_t *ar,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
char const *a1;
|
||||
auth_hexmd5_t a1buf, response;
|
||||
auth_passwd_t *apw;
|
||||
char const *phrase;
|
||||
msg_time_t now = msg_now();
|
||||
|
||||
if (am == NULL || as == NULL || ar == NULL || ach == NULL) {
|
||||
if (as) {
|
||||
as->as_status = 500, as->as_phrase = "Internal Server Error";
|
||||
as->as_response = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
phrase = "Bad authorization";
|
||||
|
||||
#define PA "Authorization missing "
|
||||
|
||||
if ((!ar->ar_username && (phrase = PA "username")) ||
|
||||
(!ar->ar_nonce && (phrase = PA "nonce")) ||
|
||||
(!ar->ar_uri && (phrase = PA "URI")) ||
|
||||
(!ar->ar_response && (phrase = PA "response")) ||
|
||||
/* (!ar->ar_opaque && (phrase = PA "opaque")) || */
|
||||
/* Check for qop */
|
||||
(ar->ar_qop &&
|
||||
((ar->ar_auth &&
|
||||
strcasecmp(ar->ar_qop, "auth") &&
|
||||
strcasecmp(ar->ar_qop, "\"auth\"")) ||
|
||||
(ar->ar_auth_int &&
|
||||
strcasecmp(ar->ar_qop, "auth-int") &&
|
||||
strcasecmp(ar->ar_qop, "\"auth-int\"")))
|
||||
&& (phrase = PA "has invalid qop"))) {
|
||||
assert(phrase);
|
||||
SU_DEBUG_5(("auth_method_ntlm: 400 %s\n", phrase));
|
||||
as->as_status = 400, as->as_phrase = phrase;
|
||||
as->as_response = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX - replace */
|
||||
#if 0
|
||||
if (as->as_nonce_issued == 0 /* Already validated nonce */ &&
|
||||
auth_validate_ntlm_nonce(am, as, ar, now) < 0) {
|
||||
#else
|
||||
if (as->as_nonce_issued == 0 /* Already validated nonce */ &&
|
||||
auth_validate_digest_nonce(am, as, ar, now) < 0) {
|
||||
#endif
|
||||
as->as_blacklist = am->am_blacklist;
|
||||
auth_challenge_ntlm(am, as, ach);
|
||||
return;
|
||||
}
|
||||
|
||||
if (as->as_stale) {
|
||||
auth_challenge_ntlm(am, as, ach);
|
||||
return;
|
||||
}
|
||||
|
||||
apw = auth_mod_getpass(am, ar->ar_username, ar->ar_realm);
|
||||
|
||||
#if 0
|
||||
if (apw && apw->apw_hash)
|
||||
a1 = apw->apw_hash;
|
||||
else if (apw && apw->apw_pass)
|
||||
auth_ntlm_a1(ar, a1buf, apw->apw_pass), a1 = a1buf;
|
||||
else
|
||||
auth_ntlm_a1(ar, a1buf, "xyzzy"), a1 = a1buf, apw = NULL;
|
||||
|
||||
if (ar->ar_md5sess)
|
||||
auth_ntlm_a1sess(ar, a1buf, a1), a1 = a1buf;
|
||||
#else
|
||||
if (apw && apw->apw_hash)
|
||||
a1 = apw->apw_hash;
|
||||
else if (apw && apw->apw_pass)
|
||||
auth_digest_a1(ar, a1buf, apw->apw_pass), a1 = a1buf;
|
||||
else
|
||||
auth_digest_a1(ar, a1buf, "xyzzy"), a1 = a1buf, apw = NULL;
|
||||
|
||||
if (ar->ar_md5sess)
|
||||
auth_digest_a1sess(ar, a1buf, a1), a1 = a1buf;
|
||||
#endif
|
||||
|
||||
/* XXX - replace with auth_ntlm_response */
|
||||
#if 0
|
||||
auth_ntlm_response(ar, response, a1,
|
||||
as->as_method, as->as_body, as->as_bodylen);
|
||||
#else
|
||||
auth_digest_response(ar, response, a1,
|
||||
as->as_method, as->as_body, as->as_bodylen);
|
||||
#endif
|
||||
|
||||
if (!apw || strcmp(response, ar->ar_response)) {
|
||||
if (am->am_forbidden) {
|
||||
as->as_status = 403, as->as_phrase = "Forbidden";
|
||||
as->as_blacklist = am->am_blacklist;
|
||||
as->as_response = NULL;
|
||||
}
|
||||
else {
|
||||
auth_challenge_ntlm(am, as, ach);
|
||||
as->as_blacklist = am->am_blacklist;
|
||||
}
|
||||
SU_DEBUG_5(("auth_method_ntlm: response did not match\n"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
assert(apw);
|
||||
|
||||
as->as_user = apw->apw_user;
|
||||
as->as_anonymous = apw == am->am_anon_user;
|
||||
|
||||
if (am->am_nextnonce || am->am_mutual)
|
||||
auth_info_ntlm(am, as, ach);
|
||||
|
||||
if (am->am_challenge)
|
||||
auth_challenge_ntlm(am, as, ach);
|
||||
|
||||
SU_DEBUG_7(("auth_method_ntlm: successful authentication\n"));
|
||||
|
||||
as->as_status = 0; /* Successful authentication! */
|
||||
as->as_phrase = "";
|
||||
}
|
||||
|
||||
/** Construct a challenge header for @b Ntlm authentication scheme. */
|
||||
void auth_challenge_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
char const *u, *d;
|
||||
char nonce[AUTH_NTLM_NONCE_LEN];
|
||||
|
||||
#if 0
|
||||
auth_generate_ntlm_nonce(am, nonce, sizeof nonce, 0, msg_now());
|
||||
#else
|
||||
auth_generate_digest_nonce(am, nonce, sizeof nonce, 0, msg_now());
|
||||
#endif
|
||||
|
||||
u = as->as_uri;
|
||||
d = as->as_pdomain;
|
||||
|
||||
as->as_response =
|
||||
msg_header_format(as->as_home, ach->ach_header,
|
||||
"Ntlm"
|
||||
" realm=\"%s\","
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" nonce=\"%s\","
|
||||
"%s%s%s"
|
||||
"%s" /* stale */
|
||||
" algorithm=%s"
|
||||
"%s%s%s",
|
||||
as->as_realm,
|
||||
u ? " uri=\"" : "", u ? u : "", u ? "\"," : "",
|
||||
d ? " domain=\"" : "", d ? d : "", d ? "\"," : "",
|
||||
nonce,
|
||||
am->am_opaque ? " opaque=\"" : "",
|
||||
am->am_opaque ? am->am_opaque : "",
|
||||
am->am_opaque ? "\"," : "",
|
||||
as->as_stale ? " stale=true," : "",
|
||||
am->am_algorithm,
|
||||
am->am_qop ? ", qop=\"" : "",
|
||||
am->am_qop ? am->am_qop : "",
|
||||
am->am_qop ? "\"" : "");
|
||||
|
||||
if (!as->as_response)
|
||||
as->as_status = 500, as->as_phrase = auth_internal_server_error;
|
||||
else
|
||||
as->as_status = ach->ach_status, as->as_phrase = ach->ach_phrase;
|
||||
}
|
||||
|
||||
/** Construct a info header for @b Ntlm authentication scheme. */
|
||||
void auth_info_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach)
|
||||
{
|
||||
if (!ach->ach_info)
|
||||
return;
|
||||
|
||||
if (am->am_nextnonce) {
|
||||
char nonce[AUTH_NTLM_NONCE_LEN];
|
||||
|
||||
/* XXX - replace */
|
||||
#if 0
|
||||
auth_generate_ntlm_nonce(am, nonce, sizeof nonce, 1, msg_now());
|
||||
#else
|
||||
auth_generate_digest_nonce(am, nonce, sizeof nonce, 1, msg_now());
|
||||
#endif
|
||||
|
||||
as->as_info =
|
||||
msg_header_format(as->as_home, ach->ach_info, "nextnonce=\"%s\"", nonce);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE auth_tag.c
|
||||
* @brief Tags for authentication verification module for NTA servers.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>.
|
||||
*
|
||||
* @date Created: Wed Apr 11 15:14:03 2001 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define TAG_NAMESPACE "auth"
|
||||
|
||||
#include "sofia-sip/auth_module.h"
|
||||
|
||||
#include <sofia-sip/su_tag_class.h>
|
||||
#include <sofia-sip/url_tag_class.h>
|
||||
|
||||
/**@def AUTHTAG_ANY()
|
||||
*
|
||||
* Filter tag matching any AUTHTAG_*().
|
||||
*/
|
||||
tag_typedef_t authtag_any = NSTAG_TYPEDEF(*);
|
||||
|
||||
/**@def AUTHTAG_MODULE()
|
||||
*
|
||||
* Pointer to an authentication server module (auth_mod_t).
|
||||
*
|
||||
* The tag item AUTHTAG_MODULE() contains pointer to an authentication server
|
||||
* module. It is used to pass an already initialized authentication module
|
||||
* to a server object (like web server or registrar object).
|
||||
*/
|
||||
tag_typedef_t authtag_module = PTRTAG_TYPEDEF(module);
|
||||
|
||||
/**@def AUTHTAG_METHOD()
|
||||
*
|
||||
* Name of the authentication scheme.
|
||||
*
|
||||
* The tag AUTHTAG_METHOD() specifies the authentication module and scheme
|
||||
* to be used by the auth_module. The name can specify a basic
|
||||
* authentication module, like "Digest" or "Basic", or an plugin module,
|
||||
* like "SGMF+Digest".
|
||||
*
|
||||
* @sa See <auth_plugin.h> for plugin interface.
|
||||
*/
|
||||
tag_typedef_t authtag_method = STRTAG_TYPEDEF(method);
|
||||
|
||||
/**@def AUTHTAG_REALM()
|
||||
*
|
||||
* Authentication realm used by authentication server.
|
||||
*
|
||||
* The tag authtag_method specifies the authentication realm used by the @b
|
||||
* auth_module. For servers, the domain name in the request URI is inserted
|
||||
* in the realm returned to the client if the realm string contains an
|
||||
* asterisk @c "*". Only the first asterisk is replaced by request domain
|
||||
* name.
|
||||
*
|
||||
* @p Default Value
|
||||
* "*".
|
||||
*/
|
||||
tag_typedef_t authtag_realm = STRTAG_TYPEDEF(realm);
|
||||
|
||||
/**@def AUTHTAG_OPAQUE()
|
||||
*
|
||||
* Opaque data used by authentication server.
|
||||
*
|
||||
* The tag authtag_opaque is used to pass opaque data to the @b auth_module.
|
||||
* The opaque data will be included in all the challenges (however, the data
|
||||
* is prefixed with a "." and other opaque data used by the algorithms.
|
||||
*
|
||||
* @p Default Value
|
||||
* "".
|
||||
*/
|
||||
tag_typedef_t authtag_opaque = STRTAG_TYPEDEF(opaque);
|
||||
|
||||
/**@def AUTHTAG_DB()
|
||||
*
|
||||
* Name of authentication database used by authentication server.
|
||||
*
|
||||
* The tag AUTHTAG_DB() specifies the file name used to store the
|
||||
* authentication data. The file contains triplets as follows:
|
||||
*
|
||||
* @code
|
||||
* user:password:realm
|
||||
* @endcode
|
||||
*
|
||||
* @note
|
||||
* Currently, the passwords are stored as plaintext.
|
||||
*/
|
||||
tag_typedef_t authtag_db = STRTAG_TYPEDEF(db);
|
||||
|
||||
/**@def AUTHTAG_QOP()
|
||||
*
|
||||
* Quality-of-protection used by Digest authentication.
|
||||
*
|
||||
* The tag AUTHTAG_QOP() specifies the qop scheme to be used by the
|
||||
* digest authentication.
|
||||
*/
|
||||
tag_typedef_t authtag_qop = STRTAG_TYPEDEF(qop);
|
||||
|
||||
/**@def AUTHTAG_ALGORITHM()
|
||||
*
|
||||
* Authentication algorithm used by Digest authentication.
|
||||
*
|
||||
* The tag AUTHTAG_ALGORITHM() specifies the qop scheme to be used by the
|
||||
* digest authentication.
|
||||
*/
|
||||
tag_typedef_t authtag_algorithm = STRTAG_TYPEDEF(algorithm);
|
||||
|
||||
/**@def AUTHTAG_EXPIRES()
|
||||
*
|
||||
* Nonce expiration time for Digest authentication.
|
||||
*
|
||||
* The tag AUTHTAG_EXPIRES() specifies the time in seconds that a nonce is
|
||||
* considered valid. If 0, the nonce lifetime unbounded. The default time is
|
||||
* 3600 seconds.
|
||||
*/
|
||||
tag_typedef_t authtag_expires = UINTTAG_TYPEDEF(expires);
|
||||
|
||||
/**@def AUTHTAG_NEXT_EXPIRES()
|
||||
*
|
||||
* Next nonce expiration time for Digest authentication.
|
||||
*
|
||||
* The tag AUTHTAG_NEXT_EXPIRES() specifies the time in seconds that a
|
||||
* nextnonce sent in Authentication-Info header is considered valid. If 0,
|
||||
* the nonce lifetime is unbounded. The default time is 3600 seconds.
|
||||
*/
|
||||
tag_typedef_t authtag_next_expires = UINTTAG_TYPEDEF(next_expires);
|
||||
|
||||
/**@def AUTHTAG_BLACKLIST()
|
||||
*
|
||||
* Blacklist time.
|
||||
*
|
||||
* The tag AUTHTAG_BLACKLIST() specifies the time the server delays its
|
||||
* response if it is given bad credentials or malformed nonce. The default
|
||||
* time is 5 seconds.
|
||||
*
|
||||
* @todo Implement delayed response.
|
||||
*/
|
||||
tag_typedef_t authtag_blacklist = UINTTAG_TYPEDEF(blacklist);
|
||||
|
||||
/**@def AUTHTAG_FORBIDDEN()
|
||||
*
|
||||
* Respond with 403 Forbidden.
|
||||
*
|
||||
* When given a true argument, the tag AUTHTAG_FORBIDDEN() specifies that the
|
||||
* server responds with 403 Forbidden (instead of 401/407) when it receives
|
||||
* bad credentials.
|
||||
*/
|
||||
tag_typedef_t authtag_forbidden = BOOLTAG_TYPEDEF(forbidden);
|
||||
|
||||
/**@def AUTHTAG_ANONYMOUS()
|
||||
*
|
||||
* Allow anonymous access.
|
||||
*
|
||||
* When given a true argument, the tag AUTHTAG_ANONYMOUS() allows
|
||||
* authentication module to accept the account "anonymous" with an empty
|
||||
* password. The auth_status_t::as_anonymous flag is set in auth_status_t
|
||||
* structure after anonymous authentication.
|
||||
*/
|
||||
tag_typedef_t authtag_anonymous = BOOLTAG_TYPEDEF(anonymous);
|
||||
|
||||
/**@def AUTHTAG_FAKE()
|
||||
*
|
||||
* Fake authentication process.
|
||||
*
|
||||
* When given a true argument, the tag AUTHTAG_FAKE() causes authentication
|
||||
* module to allow access with any password when the username is valid. The
|
||||
* auth_status_t::as_fake flag is set in auth_status_t structure after a
|
||||
* fake authentication.
|
||||
*/
|
||||
tag_typedef_t authtag_fake = BOOLTAG_TYPEDEF(fake);
|
||||
|
||||
/**@def AUTHTAG_REMOTE()
|
||||
*
|
||||
* Remote authenticator URL.
|
||||
*
|
||||
* The tag AUTHTAG_REMOTE() is used to specify URL for remote authenticator.
|
||||
* The meaning of the URL is specific to the authentication module. The
|
||||
* authentication module is selected by AUTHTAG_METHOD().
|
||||
*/
|
||||
tag_typedef_t authtag_remote = URLTAG_TYPEDEF(remote);
|
||||
|
||||
/**@def AUTHTAG_ALLOW()
|
||||
*
|
||||
* Comma-separated list of methods that are not challenged.
|
||||
*
|
||||
* The tag AUTHTAG_ALLOW() takes its argument a string containing a
|
||||
* comma-separated list of methods, for example,
|
||||
* @code
|
||||
* AUTHTAG_ALLOW("ACK, BYE, CANCEL").
|
||||
* @endcode
|
||||
*
|
||||
* The specified methods are not challenged by the authentication module.
|
||||
* For example, this may include SIP ACK method or SIP methods only used
|
||||
* within an already established dialog.
|
||||
*/
|
||||
tag_typedef_t authtag_allow = STRTAG_TYPEDEF(allow);
|
||||
|
||||
/**@def AUTHTAG_MASTER_KEY()
|
||||
*
|
||||
* Private master key for the authentication module.
|
||||
*
|
||||
* The tag AUTHTAG_MASTER_KEY() specifies a private master key that can be
|
||||
* used by the authentication module for various purposes (for instance,
|
||||
* validating that nonces are really generated by it).
|
||||
*/
|
||||
tag_typedef_t authtag_master_key = STRTAG_TYPEDEF(master_key);
|
||||
|
||||
/**@def AUTHTAG_CACHE_USERS()
|
||||
*
|
||||
* Time to cache user data.
|
||||
*
|
||||
* The tag AUTHTAG_CACHE_USERS() specifies how many seconds the user data is
|
||||
* cached locally. Default value is typically 30 minutes.
|
||||
*/
|
||||
tag_typedef_t authtag_cache_users = UINTTAG_TYPEDEF(cache_users);
|
||||
|
||||
/**@def AUTHTAG_CACHE_ERRORS()
|
||||
*
|
||||
* Time to cache errors.
|
||||
*
|
||||
* The tag AUTHTAG_CACHE_ERRORS() specifies the lifetime in seconds for
|
||||
* errors in the local authentication data cache. Note that the errors
|
||||
* generated locally (e.g., because of connectivity problem with
|
||||
* authentication server) have maximum lifetime of 2 minutes.
|
||||
*/
|
||||
tag_typedef_t authtag_cache_errors = UINTTAG_TYPEDEF(cache_errors);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* -*- C -*- */
|
||||
|
||||
/**@MODULEPAGE "iptsec" - Authentication Module
|
||||
*
|
||||
* @section iptsec_meta Module Meta Information
|
||||
*
|
||||
* The iptsec module currently provides interfaces to HTTP
|
||||
* Basic and Digest authentication, used by HTTP and SIP protocol elements.
|
||||
* There are both
|
||||
* @ref auth_client "client-side" and
|
||||
* @ref auth_module "server-side"
|
||||
* (authentication verification) functionality available.
|
||||
*
|
||||
* @CONTACT Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @STATUS @SofiaSIP Core library
|
||||
*
|
||||
* @LICENSE LGPL
|
||||
*
|
||||
* @section auth_module Server Verifying Authentication
|
||||
*
|
||||
* The file <auth_module.h> defines the interface used by a server verifying
|
||||
* the authentication from client. After the server has created an @ref
|
||||
* auth_mod_t "authentication module", the usual authentication operation is
|
||||
* simple enough:
|
||||
|
||||
* -# server initializes an #auth_status_t structure with information from
|
||||
* the request
|
||||
* -# server calls auth_mod_method()
|
||||
* -# server checks the status from auth_status_t structure, sends an error
|
||||
* response to the client if authentication fails
|
||||
* -# server proceeds serving the authenticated request.
|
||||
*
|
||||
* If the operation is asynchronous, only a preliminary result is stored in
|
||||
* the auth_status_t structure when the call to auth_mod_method() returns.
|
||||
* In that case, the application can assign a callback function to the
|
||||
* structure. The callback function is invoked when the authentication
|
||||
* operation is completed. An asynchronous authentication operation can be
|
||||
* terminated before its completion by calling auth_mod_cancel().
|
||||
*
|
||||
* @subsection auth_module_tags Server-Side Authentication Parameters
|
||||
*
|
||||
* When the server creates the authentication module with auth_mod_create(),
|
||||
* it can specify numerous parameters affecting the authentication protocol
|
||||
* and algorithms. The parameter tags are defined in <auth_module.h>. The
|
||||
* most important parameters include:
|
||||
*
|
||||
* - AUTHTAG_METHOD(),
|
||||
* - AUTHTAG_ALGORITHM(),
|
||||
* - AUTHTAG_QOP(), and
|
||||
* - AUTHTAG_REMOTE().
|
||||
*
|
||||
* @section auth_client Client Authenticating User
|
||||
*
|
||||
* The file <auth_client.h> defines the interface used by a client
|
||||
* authenticating a user with a server. Because there may be multiple
|
||||
* servers or proxies requiring authentication, the client-side
|
||||
* authentication information is represented using a list of #auth_client_t
|
||||
* objects. The client-side operation is as follows:
|
||||
*
|
||||
* -# send a request
|
||||
* -# get a response with specific response code (401 or 407) and challenge
|
||||
* -# store the challenge to a list with auc_challenge()
|
||||
* -# prompt user and feed credentials (username and password) to the list
|
||||
* with auc_credentials() or auc_all_credentials()
|
||||
* -# authorize a request (add credential headers to it) with
|
||||
* auc_authorization() and resend the request
|
||||
*
|
||||
* If there are several username/password pairs for multiple authentication
|
||||
* realms required, the application must provide the corresponding realm as
|
||||
* an argument to auc_all_credentials().
|
||||
*/
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file iptsec_debug.c
|
||||
* @brief Debug log for IPTSEC module.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Dec 19 15:55:30 2002 ppessi
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "iptsec_debug.h"
|
||||
|
||||
/**@var IPTSEC_DEBUG
|
||||
*
|
||||
* Environment variable determining the debug log level for @b iptsec
|
||||
* module.
|
||||
*
|
||||
* The IPTSEC_DEBUG environment variable is used to determine the debug
|
||||
* logging level for @b iptsec module. The default level is 3.
|
||||
*
|
||||
* @sa <su_debug.h>, iptsec_log, SOFIA_DEBUG
|
||||
*/
|
||||
extern char const IPTSEC_DEBUG[];
|
||||
|
||||
#ifndef SU_DEBUG
|
||||
#define SU_DEBUG 3
|
||||
#endif
|
||||
|
||||
/**Debug log for @b iptsec module.
|
||||
*
|
||||
* The iptsec_log is the log object used by @b iptsec module. The level of
|
||||
* #iptsec_log is set using #IPTSEC_DEBUG environment variable.
|
||||
*/
|
||||
su_log_t iptsec_log[] = { SU_LOG_INIT("iptsec", "IPTSEC_DEBUG", SU_DEBUG) };
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef IPTSEC_DEBUG_H
|
||||
/** Defined when <iptsec_debug.h> has been included. */
|
||||
#define IPTSEC_DEBUG_H
|
||||
|
||||
/**@file iptsec_debug.h
|
||||
* @brief Debug log for IPTSEC module.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Dec 19 15:56:35 2002 ppessi
|
||||
*/
|
||||
|
||||
#include <sofia-sip/su_log.h>
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
/** Common log for application and srvlib components. */
|
||||
SOFIAPUBVAR su_log_t iptsec_log[];
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#define SU_LOG (iptsec_log)
|
||||
|
||||
#include <sofia-sip/su_debug.h>
|
||||
|
||||
#endif /* !defined IPTSEC_DEBUG_H */
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_CLIENT_H
|
||||
/** Defined when <sofia-sip/auth_client.h> has been included. */
|
||||
#define AUTH_CLIENT_H
|
||||
|
||||
/**@file sofia-sip/auth_client.h
|
||||
*
|
||||
* @brief Client-side authenticator library.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Wed Feb 14 17:09:44 2001 ppessi
|
||||
*/
|
||||
|
||||
#ifndef MSG_TYPES_H
|
||||
#include <sofia-sip/msg_types.h>
|
||||
#endif
|
||||
|
||||
#ifndef URL_H
|
||||
#include <sofia-sip/url.h>
|
||||
#endif
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
/** Authenticator object. */
|
||||
typedef struct auth_client_s auth_client_t;
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_challenge(auth_client_t **auc, su_home_t *home,
|
||||
msg_auth_t const *auth,
|
||||
msg_hclass_t *crcl);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_credentials(auth_client_t **auc, su_home_t *home, char const *data);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_info(auth_client_t **auc_list,
|
||||
msg_auth_info_t const *ai,
|
||||
msg_hclass_t *credential_class);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_all_credentials(auth_client_t **auc_list,
|
||||
char const *scheme,
|
||||
char const *realm,
|
||||
char const *user,
|
||||
char const *pass);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_clear_credentials(auth_client_t **auc_list,
|
||||
char const *scheme,
|
||||
char const *realm);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_copy_credentials(auth_client_t **dst, auth_client_t const *src);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_has_authorization(auth_client_t **auc_list);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_authorization(auth_client_t **auc_list, msg_t *msg, msg_pub_t *pub,
|
||||
char const *method,
|
||||
url_t const *url,
|
||||
msg_payload_t const *body);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_authorization_headers(auth_client_t **auc_list,
|
||||
su_home_t *home,
|
||||
char const *method,
|
||||
url_t const *url,
|
||||
msg_payload_t const *body,
|
||||
msg_header_t **return_headers);
|
||||
|
||||
struct sip_s;
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_authorize(auth_client_t **auc, msg_t *msg, struct sip_s *sip);
|
||||
|
||||
typedef struct auth_client_plugin auth_client_plugin_t;
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auc_register_plugin(auth_client_plugin_t const *plugin);
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_CLIENT_PLUGIN_H
|
||||
/** Defined when <sofia-sip/auth_client_plugin.h> has been included. */
|
||||
#define AUTH_CLIENT_PLUGIN_H
|
||||
|
||||
/**@file sofia-sip/auth_client_plugin.h
|
||||
* @brief Client-side plugin interface for authentication
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Fri May 19 16:18:21 EEST 2006
|
||||
*/
|
||||
|
||||
#ifndef AUTH_CLIENT_H
|
||||
#include "sofia-sip/auth_client.h"
|
||||
#endif
|
||||
|
||||
#ifndef MSG_HEADER_H
|
||||
#include <sofia-sip/msg_header.h>
|
||||
#endif
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
struct auth_client_s {
|
||||
su_home_t ca_home[1];
|
||||
auth_client_plugin_t const *ca_auc;
|
||||
|
||||
auth_client_t *ca_next;
|
||||
|
||||
char const *ca_scheme;
|
||||
char const *ca_realm;
|
||||
char *ca_user;
|
||||
char *ca_pass;
|
||||
|
||||
msg_hclass_t *ca_credential_class;
|
||||
};
|
||||
|
||||
struct auth_client_plugin
|
||||
{
|
||||
int auc_plugin_size; /* Size of this structure */
|
||||
int auc_size; /* Size of the client structure */
|
||||
|
||||
char const *auc_name; /* Name of the autentication scheme */
|
||||
|
||||
/** Store challenge */
|
||||
int (*auc_challenge)(auth_client_t *ca,
|
||||
msg_auth_t const *ch);
|
||||
|
||||
/** Authorize request. */
|
||||
int (*auc_authorize)(auth_client_t *ca,
|
||||
su_home_t *h,
|
||||
char const *method,
|
||||
url_t const *url,
|
||||
msg_payload_t const *body,
|
||||
msg_header_t **return_headers);
|
||||
|
||||
/** Store nextnonce from Authentication-Info or Proxy-Authentication-Info. */
|
||||
int (*auc_info)(auth_client_t *ca, msg_auth_info_t const *ai);
|
||||
};
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif /* !defined AUTH_CLIENT_PLUGIN_H */
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_COMMON_H
|
||||
/** Defined when <sofia-sip/auth_common.h> has been included. */
|
||||
#define AUTH_COMMON_H
|
||||
|
||||
/**@file sofia-sip/auth_common.h
|
||||
*
|
||||
* Functions common for client/server.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Fri May 19 15:54:08 EEST 2006 ppessi
|
||||
*/
|
||||
|
||||
#ifndef SU_ALLOC_H
|
||||
#include <sofia-sip/su_alloc.h>
|
||||
#endif
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
SOFIAPUBFUN issize_t auth_get_params(su_home_t *home,
|
||||
char const * const params[], ...
|
||||
/* char const * name,
|
||||
char const **return_value */);
|
||||
|
||||
SOFIAPUBFUN int auth_struct_copy(void *dst, void const *src, isize_t s_size);
|
||||
|
||||
SOFIAPUBFUN int auth_strcmp(char const *quoted, char const *unquoted);
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_DIGEST_H
|
||||
/** Defined when <sofia-sip/auth_digest.h> has been included. */
|
||||
#define AUTH_DIGEST_H
|
||||
|
||||
/**@file sofia-sip/auth_digest.h
|
||||
* Datatypes and functions for Digest authentication.
|
||||
*
|
||||
* The structures and functions here follow the RFC 2617.
|
||||
*
|
||||
* @sa @RFC2617,
|
||||
* <i>"HTTP Authentication: Basic and Digest Access Authentication"</i>,
|
||||
* J. Franks et al,
|
||||
* June 1999.
|
||||
*
|
||||
* @sa @RFC3261 section 22
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Feb 22 12:25:55 2001 ppessi
|
||||
*/
|
||||
|
||||
#ifndef SU_ALLOC_H
|
||||
#include <sofia-sip/su_alloc.h>
|
||||
#endif
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
/** Parameters for digest-challenge.
|
||||
*
|
||||
* The digest-challenge is sent by server or proxy to client. It can be
|
||||
* included in, e.g, WWW-Authenticate or Proxy-Authenticate headers.
|
||||
*
|
||||
* @code
|
||||
* challenge = "Digest" digest-challenge
|
||||
* digest-challenge = 1#( realm | [domain] | nonce |
|
||||
* [opaque] | [stale] | [algorithm] |
|
||||
* [qop-options] | [auth-param] )
|
||||
* domain = "domain" "=" <"> URI ( 1*SP URI ) <">
|
||||
* URI = absoluteURI | abs_path
|
||||
* nonce = "nonce" "=" nonce-value
|
||||
* nonce-value = quoted-string
|
||||
* opaque = "opaque" "=" quoted-string
|
||||
* stale = "stale" "=" ( "true" | "false" )
|
||||
* algorithm = "algorithm" "=" ( "MD5" | "MD5-sess" | token )
|
||||
* qop-options = "qop" "=" <"> 1#qop-value <">
|
||||
* qop-value = "auth" | "auth-int" | token
|
||||
* @endcode
|
||||
*
|
||||
* @sa @RFC2617
|
||||
*/
|
||||
typedef struct {
|
||||
int ac_size;
|
||||
char const *ac_realm; /**< realm */
|
||||
char const *ac_domain; /**< domain */
|
||||
char const *ac_nonce; /**< nonce */
|
||||
char const *ac_opaque; /**< opaque */
|
||||
char const *ac_algorithm; /**< algorithm */
|
||||
char const *ac_qop; /**< qop */
|
||||
unsigned ac_stale : 1; /**< stale=true */
|
||||
unsigned ac_md5 : 1; /**< algorithm=MS5 (or missing) */
|
||||
unsigned ac_md5sess : 1; /**< algorithm=MD5-sess */
|
||||
unsigned ac_sha1 : 1; /**< algorithm=sha1 (SSA Hash) */
|
||||
unsigned ac_auth : 1; /**< qop=auth */
|
||||
unsigned ac_auth_int : 1; /**< qop=auth-int */
|
||||
unsigned : 0;
|
||||
} auth_challenge_t;
|
||||
|
||||
/** Digest parameters for digest-response in Authorize.
|
||||
*
|
||||
* The digest-response is sent by the client to a server or a proxy. It can
|
||||
* be included in, e.g., Authorization or Proxy-Authorization headers.
|
||||
*
|
||||
* @code
|
||||
* credentials = "Digest" digest-response
|
||||
* digest-response = 1#( username | realm | nonce | digest-uri |
|
||||
* response | [ algorithm ] | [cnonce] | [opaque] |
|
||||
* [message-qop] | [nonce-count] | [auth-param] )
|
||||
* username = "username" "=" username-value
|
||||
* username-value = quoted-string
|
||||
* digest-uri = "uri" "=" digest-uri-value
|
||||
* digest-uri-value = request-uri ; As specified by HTTP/1.1
|
||||
* message-qop = "qop" "=" qop-value
|
||||
* cnonce = "cnonce" "=" cnonce-value
|
||||
* cnonce-value = nonce-value
|
||||
* nonce-count = "nc" "=" nc-value
|
||||
* nc-value = 8LHEX
|
||||
* response = "response" "=" request-digest
|
||||
* request-digest = <"> 32LHEX <">
|
||||
* LHEX = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
|
||||
* "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f"
|
||||
* @endcode
|
||||
*/
|
||||
typedef struct {
|
||||
int ar_size;
|
||||
char const *ar_username;
|
||||
char const *ar_realm; /**< realm */
|
||||
char const *ar_nonce; /**< nonce */
|
||||
char const *ar_uri; /**< uri */
|
||||
char const *ar_response; /**< response */
|
||||
char const *ar_algorithm; /**< algorithm */
|
||||
char const *ar_cnonce; /**< cnonce */
|
||||
char const *ar_opaque; /**< opaque */
|
||||
char const *ar_qop; /**< qop */
|
||||
char const *ar_nc; /**< nonce count */
|
||||
unsigned ar_md5 : 1; /**< MS5 algorithm */
|
||||
unsigned ar_md5sess : 1; /**< MD5-sess algorithm */
|
||||
unsigned ar_sha1 : 1; /**< SHA1 algorithm */
|
||||
unsigned ar_auth : 1; /**< qop=auth */
|
||||
unsigned ar_auth_int : 1; /**< qop=auth-int */
|
||||
unsigned : 0;
|
||||
} auth_response_t;
|
||||
|
||||
typedef char auth_hexmd5_t[33];
|
||||
|
||||
SOFIAPUBFUN issize_t auth_digest_challenge_get(su_home_t *, auth_challenge_t *,
|
||||
char const * const params[]);
|
||||
SOFIAPUBFUN void auth_digest_challenge_free_params(su_home_t *home,
|
||||
auth_challenge_t *ac);
|
||||
SOFIAPUBFUN issize_t auth_digest_response_get(su_home_t *, auth_response_t *,
|
||||
char const * const params[]);
|
||||
|
||||
SOFIAPUBFUN int auth_digest_a1(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1,
|
||||
char const *secret);
|
||||
|
||||
SOFIAPUBFUN int auth_digest_a1sess(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1sess,
|
||||
char const *ha1);
|
||||
|
||||
SOFIAPUBFUN int auth_digest_sessionkey(auth_response_t *, auth_hexmd5_t ha1,
|
||||
char const *secret);
|
||||
SOFIAPUBFUN int auth_digest_response(auth_response_t *, auth_hexmd5_t response,
|
||||
auth_hexmd5_t const ha1,
|
||||
char const *method_name,
|
||||
void const *data, isize_t dlen);
|
||||
|
||||
SOFIAPUBFUN int auth_struct_copy(void *dst, void const *src, isize_t s_size);
|
||||
|
||||
SOFIAPUBFUN int auth_strcmp(char const *quoted, char const *unquoted);
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_MODULE_H
|
||||
/** Defined when <sofia-sip/auth_module.h> has been included. */
|
||||
#define AUTH_MODULE_H
|
||||
|
||||
/**@file sofia-sip/auth_module.h
|
||||
* @brief Authentication verification interface.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>.
|
||||
*
|
||||
* @date Created: Mon Jul 23 19:21:24 2001 ppessi
|
||||
*/
|
||||
|
||||
#ifndef SU_TAG_H
|
||||
#include <sofia-sip/su_tag.h>
|
||||
#endif
|
||||
#ifndef SU_WAIT_H
|
||||
#include <sofia-sip/su_wait.h>
|
||||
#endif
|
||||
#ifndef MSG_TYPES_H
|
||||
#include <sofia-sip/msg_types.h>
|
||||
#endif
|
||||
#ifndef URL_H
|
||||
#include <sofia-sip/url.h>
|
||||
#endif
|
||||
#ifndef URL_TAG_H
|
||||
#include <sofia-sip/url_tag.h>
|
||||
#endif
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
typedef struct auth_mod_t auth_mod_t;
|
||||
/** Authentication operation. */
|
||||
typedef struct auth_status_t auth_status_t;
|
||||
|
||||
#ifdef AUTH_MAGIC_T
|
||||
typedef AUTH_MAGIC_T auth_magic_t;
|
||||
#else
|
||||
typedef void auth_magic_t;
|
||||
#endif
|
||||
|
||||
/** Virtual table for authentication plugin. */
|
||||
typedef struct auth_scheme const auth_scheme_t;
|
||||
|
||||
/** Opaque data used by authentication plugin module. */
|
||||
typedef struct auth_plugin_t auth_plugin_t;
|
||||
/** Opaque user data used by plugin module. */
|
||||
typedef struct auth_splugin_t auth_splugin_t;
|
||||
/** Opaque authentication operation data used by plugin module. */
|
||||
typedef struct auth_uplugin_t auth_uplugin_t;
|
||||
|
||||
/** Callback from completeted asynchronous authentication operation. */
|
||||
typedef void auth_callback_t(auth_magic_t *, auth_status_t *);
|
||||
|
||||
/**Authentication operation result.
|
||||
*
|
||||
* The auth_status_t structure is used to store the status of the
|
||||
* authentication operation and all the related data. The application
|
||||
* verifying the authentication fills the auth_status_t structure, then
|
||||
* calls auth_mod_method() (or auth_mod_challenge()). The operation result
|
||||
* is stored in the structure.
|
||||
*
|
||||
* If the operation is asynchronous, only a preliminary result is stored in
|
||||
* the auth_status_t structure when the call to auth_mod_method() returns.
|
||||
* In that case, the application @b must assign a callback function to the
|
||||
* structure. The callback function is invoked when the authentication
|
||||
* operation is completed.
|
||||
*
|
||||
* It is recommended that the auth_status_t structure is allocated with
|
||||
* auth_status_new() or initialized with auth_status_init() or
|
||||
* auth_status_init_with() functions.
|
||||
*/
|
||||
struct auth_status_t
|
||||
{
|
||||
su_home_t as_home[1]; /**< Memory home for authentication */
|
||||
|
||||
int as_status; /**< Return authorization status [out] */
|
||||
char const *as_phrase; /**< Return response phrase [out] */
|
||||
char const *as_user; /**< Authenticated username [in/out] */
|
||||
char const *as_display; /**< Return user's real name [in/out] */
|
||||
|
||||
url_t const *as_user_uri; /* Return user's identity [in/out] */
|
||||
char const *as_ident; /**< Identities [out] */
|
||||
unsigned as_profile; /**< User profile (group) [out] */
|
||||
|
||||
su_addrinfo_t *as_source; /**< Source address [in] */
|
||||
|
||||
char const *as_realm; /**< Authentication realm [in] */
|
||||
char const *as_domain; /**< Hostname [in] */
|
||||
char const *as_uri; /**< Request-URI [in] */
|
||||
char const *as_pdomain; /**< Domain parameter [in] (ignored). */
|
||||
char const *as_method; /**< Method name to authenticate [in] */
|
||||
|
||||
void const *as_body; /**< Message body to protect [in] */
|
||||
isize_t as_bodylen; /**< Length of message body [in] */
|
||||
|
||||
msg_time_t as_nonce_issued; /**< Nonce issue time [out] */
|
||||
unsigned as_blacklist; /**< Blacklist time [out] */
|
||||
unsigned as_anonymous:1;/**< Return true if user is anonymous [out] */
|
||||
unsigned as_stale:1; /**< Credentials were stale [out] */
|
||||
unsigned as_allow:1; /**< Method cannot be challenged [out] */
|
||||
unsigned as_nextnonce:1; /**< Client used nextnonce [out] */
|
||||
unsigned :0;
|
||||
|
||||
msg_header_t *as_response; /**< Authentication challenge [out] */
|
||||
msg_header_t *as_info; /**< Authentication-Info [out] */
|
||||
msg_header_t *as_match; /**< Used authentication header [out] */
|
||||
|
||||
/** @defgroup Callback information for asynchronous operation. */
|
||||
/** @{ */
|
||||
auth_magic_t *as_magic; /**< Application data [in] */
|
||||
auth_callback_t*as_callback; /**< Completion callback [in] */
|
||||
/** @} */
|
||||
|
||||
/** Pointer to extended state, used exclusively by plugin modules. */
|
||||
auth_splugin_t *as_plugin;
|
||||
};
|
||||
|
||||
/** Authentication challenge.
|
||||
*
|
||||
* This structure defines what kind of response and challenge header is
|
||||
* returned to the user. For example, a server authentication is implemented
|
||||
* with 401 response code and phrase along with header class for
|
||||
* @b WWW-Authenticate header in the @a ach structure.
|
||||
*/
|
||||
typedef struct auth_challenger
|
||||
{
|
||||
int ach_status; /**< Response status for challenge response */
|
||||
char const *ach_phrase; /**< Response phrase for challenge response */
|
||||
msg_hclass_t *ach_header; /**< Header class for challenge header */
|
||||
msg_hclass_t *ach_info;
|
||||
} auth_challenger_t;
|
||||
|
||||
SOFIAPUBVAR char const auth_internal_server_error[];
|
||||
|
||||
#define AUTH_STATUS_INIT \
|
||||
{{ SU_HOME_INIT(auth_status_t) }, 500, auth_internal_server_error, NULL }
|
||||
|
||||
#define AUTH_STATUS_DEINIT(as) \
|
||||
su_home_deinit(as->as_home)
|
||||
|
||||
#define AUTH_RESPONSE_INIT(as) AUTH_STATUS_INIT
|
||||
#define AUTH_RESPONSE_DEINIT(as) AUTH_STATUS_DEINIT(as)
|
||||
|
||||
SOFIAPUBFUN int auth_mod_register_plugin(auth_scheme_t *asch);
|
||||
|
||||
SOFIAPUBFUN auth_mod_t *auth_mod_create(su_root_t *root,
|
||||
tag_type_t, tag_value_t, ...);
|
||||
SOFIAPUBFUN void auth_mod_destroy(auth_mod_t *);
|
||||
|
||||
SOFIAPUBFUN auth_mod_t *auth_mod_ref(auth_mod_t *am);
|
||||
SOFIAPUBFUN void auth_mod_unref(auth_mod_t *am);
|
||||
|
||||
SOFIAPUBFUN char const *auth_mod_name(auth_mod_t *am);
|
||||
|
||||
SOFIAPUBFUN auth_status_t *auth_status_init(void *, isize_t size);
|
||||
SOFIAPUBFUN auth_status_t *auth_status_init_with(void *, isize_t size,
|
||||
int status,
|
||||
char const *phrase);
|
||||
|
||||
SOFIAPUBFUN auth_status_t *auth_status_new(su_home_t *);
|
||||
|
||||
SOFIAPUBFUN auth_status_t *auth_status_ref(auth_status_t *as);
|
||||
|
||||
SOFIAPUBFUN void auth_status_unref(auth_status_t *as);
|
||||
|
||||
SOFIAPUBFUN void auth_mod_verify(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *credentials,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN void auth_mod_challenge(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN void auth_mod_authorize(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN void auth_mod_cancel(auth_mod_t *am, auth_status_t *as);
|
||||
|
||||
/* ====================================================================== */
|
||||
/* Deprecated functions */
|
||||
|
||||
typedef enum {
|
||||
auth_server,
|
||||
auth_proxy,
|
||||
auth_proxy_consume,
|
||||
auth_consume
|
||||
} auth_kind_t;
|
||||
|
||||
SOFIAPUBFUN void auth_mod_method(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *credentials,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN void auth_mod_check_client(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *credentials,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN void auth_mod_challenge_client(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
#ifdef SIP_H
|
||||
SOFIAPUBFUN void auth_mod_check(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
sip_t const *sip,
|
||||
auth_kind_t proxy);
|
||||
#endif
|
||||
|
||||
#ifdef HTTP_H
|
||||
SOFIAPUBFUN const char *auth_mod_check_http(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
http_t const *http,
|
||||
auth_kind_t proxy);
|
||||
#endif
|
||||
|
||||
/* ====================================================================== */
|
||||
/* Tags */
|
||||
|
||||
#define AUTHTAG_ANY() authtag_any, ((tag_value_t)0)
|
||||
SOFIAPUBVAR tag_typedef_t authtag_any;
|
||||
|
||||
/** Pointer to an authentication server (auth_mod_t). */
|
||||
#define AUTHTAG_MODULE(x) authtag_module, authtag_module_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_module;
|
||||
|
||||
#define AUTHTAG_MODULE_REF(x) authtag_module_ref, authtag_module_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_module_ref;
|
||||
|
||||
#if SU_HAVE_INLINE
|
||||
static inline tag_value_t authtag_module_v(auth_mod_t *v) {
|
||||
return (tag_value_t)v;
|
||||
}
|
||||
static inline tag_value_t authtag_module_vr(auth_mod_t **vp) {
|
||||
return (tag_value_t)vp;
|
||||
}
|
||||
#else
|
||||
#define authtag_module_v(v) ((tag_value_t)(v))
|
||||
#define authtag_module_vr(v) ((tag_value_t)(v))
|
||||
#endif
|
||||
|
||||
/** Authentication scheme used by authentication module. */
|
||||
#define AUTHTAG_METHOD(x) authtag_method, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_method;
|
||||
|
||||
#define AUTHTAG_METHOD_REF(x) authtag_method_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_method_ref;
|
||||
|
||||
/** Authentication realm used by authentication server. */
|
||||
#define AUTHTAG_REALM(x) authtag_realm, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_realm;
|
||||
|
||||
#define AUTHTAG_REALM_REF(x) authtag_realm_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_realm_ref;
|
||||
|
||||
/** Opaque authentication data always included in challenge. */
|
||||
#define AUTHTAG_OPAQUE(x) authtag_opaque, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_opaque;
|
||||
|
||||
#define AUTHTAG_OPAQUE_REF(x) authtag_opaque_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_opaque_ref;
|
||||
|
||||
/** Name of authentication database used by authentication server. */
|
||||
#define AUTHTAG_DB(x) authtag_db, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_db;
|
||||
|
||||
#define AUTHTAG_DB_REF(x) authtag_db_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_db_ref;
|
||||
|
||||
/** Quality-of-protection used by digest authentication. */
|
||||
#define AUTHTAG_QOP(x) authtag_qop, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_qop;
|
||||
|
||||
#define AUTHTAG_QOP_REF(x) authtag_qop_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_qop_ref;
|
||||
|
||||
/** Algorithm used by digest authentication. */
|
||||
#define AUTHTAG_ALGORITHM(x) authtag_algorithm, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_algorithm;
|
||||
|
||||
#define AUTHTAG_ALGORITHM_REF(x) authtag_algorithm_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_algorithm_ref;
|
||||
|
||||
/** Nonce lifetime. */
|
||||
#define AUTHTAG_EXPIRES(x) authtag_expires, tag_uint_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_expires;
|
||||
|
||||
#define AUTHTAG_EXPIRES_REF(x) authtag_expires_ref, tag_uint_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_expires_ref;
|
||||
|
||||
/** Lifetime for nextnonce, 0 disables nextnonce. */
|
||||
#define AUTHTAG_NEXT_EXPIRES(x) authtag_next_expires, tag_uint_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_next_expires;
|
||||
|
||||
#define AUTHTAG_NEXT_EXPIRES_REF(x) \
|
||||
authtag_next_expires_ref, tag_uint_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_next_expires_ref;
|
||||
|
||||
/** Extra delay when responding if provided invalid credentials or nonce. */
|
||||
#define AUTHTAG_BLACKLIST(x) authtag_blacklist, tag_uint_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_blacklist;
|
||||
|
||||
#define AUTHTAG_BLACKLIST_REF(x) authtag_blacklist_ref, tag_uint_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_blacklist_ref;
|
||||
|
||||
/** Respond with 403 Forbidden if given invalid credentials. */
|
||||
#define AUTHTAG_FORBIDDEN(x) authtag_forbidden, tag_bool_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_forbidden;
|
||||
|
||||
#define AUTHTAG_FORBIDDEN_REF(x) authtag_forbidden_ref, tag_bool_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_forbidden_ref;
|
||||
|
||||
/** Allow anonymous access. */
|
||||
#define AUTHTAG_ANONYMOUS(x) authtag_anonymous, tag_bool_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_anonymous;
|
||||
|
||||
#define AUTHTAG_ANONYMOUS_REF(x) authtag_anonymous_ref, tag_bool_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_anonymous_ref;
|
||||
|
||||
/** Fake authentication procedure - do not check result. */
|
||||
#define AUTHTAG_FAKE(x) authtag_fake, tag_bool_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_fake;
|
||||
|
||||
#define AUTHTAG_FAKE_REF(x) authtag_fake_ref, tag_bool_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_fake_ref;
|
||||
|
||||
/** HSS client structure. */
|
||||
#define AUTHTAG_HSS(x) authtag_hss, tag_ptr_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_hss;
|
||||
|
||||
#define AUTHTAG_HSS_REF(x) authtag_hss_ref, tag_ptr_vr((&x), (x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_hss_ref;
|
||||
|
||||
/** Remote authenticator URL. */
|
||||
#define AUTHTAG_REMOTE(x) authtag_remote, urltag_url_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_remote;
|
||||
|
||||
#define AUTHTAG_REMOTE_REF(x) authtag_remote_ref, urltag_url_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_remote_ref;
|
||||
|
||||
/** Comma-separated list of methods never challenged. */
|
||||
#define AUTHTAG_ALLOW(x) authtag_allow, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_allow;
|
||||
|
||||
#define AUTHTAG_ALLOW_REF(x) authtag_allow_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_allow_ref;
|
||||
|
||||
/** Check that user exists, don't do authentication. */
|
||||
#define AUTHTAG_FAKE(x) authtag_fake, tag_bool_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_fake;
|
||||
|
||||
#define AUTHTAG_FAKE_REF(x) authtag_fake_ref, tag_bool_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_fake_ref;
|
||||
|
||||
/** Master key in base64 for the authentication module. */
|
||||
#define AUTHTAG_MASTER_KEY(x) authtag_master_key, tag_str_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_master_key;
|
||||
|
||||
#define AUTHTAG_MASTER_KEY_REF(x) authtag_master_key_ref, tag_str_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_master_key_ref;
|
||||
|
||||
/** Cache time for authentication data. */
|
||||
#define AUTHTAG_CACHE_USERS(x) authtag_cache_users, tag_uint_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_cache_users;
|
||||
|
||||
#define AUTHTAG_CACHE_USERS_REF(x) authtag_cache_users_ref, tag_uint_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_cache_users_ref;
|
||||
|
||||
/** Cache time for errors. */
|
||||
#define AUTHTAG_CACHE_ERRORS(x) authtag_cache_errors, tag_uint_v((x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_cache_errors;
|
||||
|
||||
#define AUTHTAG_CACHE_ERRORS_REF(x) authtag_cache_errors_ref, tag_uint_vr((&x))
|
||||
SOFIAPUBVAR tag_typedef_t authtag_cache_errors_ref;
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_NTLM_H
|
||||
/** Defined when <sofia-sip/auth_ntlm.h> has been included. */
|
||||
#define AUTH_NTLM_H
|
||||
|
||||
/**@file sofia-sip/auth_ntlm.h
|
||||
* Datatypes and functions for Ntlm authentication.
|
||||
*
|
||||
* The structures and functions here follow the RFC 2617.
|
||||
*
|
||||
* @sa
|
||||
* <a href="ftp://ftp.ietf.org/rfc/rfc2617.txt">RFC 2617</a>,
|
||||
* <i>"HTTP Authentication: Basic and Ntlm Access Authentication"</i>,
|
||||
* J. Franks et al,
|
||||
* June 1999.
|
||||
*
|
||||
* @sa Section 19 from
|
||||
* <a href="ftp://ftp.ietf.org/internet-drafts/draft-ietf-sip-rfc2543bis-04.txt>draft-ietf-sip-rfc2543bis-04</a>.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Thu Feb 22 12:25:55 2001 ppessi
|
||||
*/
|
||||
|
||||
#ifndef SU_ALLOC_H
|
||||
#include <sofia-sip/su_alloc.h>
|
||||
#endif
|
||||
|
||||
#ifndef AUTH_PLUGIN_H
|
||||
#include <sofia-sip/auth_plugin.h>
|
||||
#endif
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
issize_t auth_ntlm_challenge_get(su_home_t *, auth_challenge_t *,
|
||||
char const * const params[]);
|
||||
issize_t auth_ntlm_response_get(su_home_t *, auth_response_t *,
|
||||
char const * const params[]);
|
||||
|
||||
int auth_ntlm_a1(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1,
|
||||
char const *secret);
|
||||
|
||||
int auth_ntlm_a1sess(auth_response_t *ar,
|
||||
auth_hexmd5_t ha1sess,
|
||||
char const *ha1);
|
||||
|
||||
int auth_ntlm_sessionkey(auth_response_t *, auth_hexmd5_t ha1,
|
||||
char const *secret);
|
||||
int auth_ntlm_response(auth_response_t *, auth_hexmd5_t response,
|
||||
auth_hexmd5_t const ha1,
|
||||
char const *method_name, void const *data, issize_t dlen);
|
||||
|
||||
/** NTLM scheme */
|
||||
msg_auth_t *auth_ntlm_credentials(msg_auth_t *auth,
|
||||
char const *realm,
|
||||
char const *opaque,
|
||||
char const *gssapidata,
|
||||
char const *targetname);
|
||||
|
||||
void auth_challenge_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
|
||||
void auth_method_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *au,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
|
||||
void auth_check_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_response_t *ar,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
int auth_generate_ntlm_nonce(auth_mod_t *am,
|
||||
char buffer[],
|
||||
size_t buffer_len,
|
||||
int nextnonce,
|
||||
msg_time_t now);
|
||||
|
||||
int auth_validate_ntlm_nonce(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_response_t *ar,
|
||||
msg_time_t now);
|
||||
|
||||
void auth_info_ntlm(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2005 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTH_PLUGIN_H
|
||||
/** Defined when <sofia-sip/auth_plugin.h> has been included. */
|
||||
#define AUTH_PLUGIN_H
|
||||
|
||||
/**@file sofia-sip/auth_plugin.h
|
||||
* @brief Plugin interface for authentication verification modules.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
*
|
||||
* @date Created: Tue Apr 27 15:22:07 2004 ppessi
|
||||
*/
|
||||
|
||||
#ifndef AUTH_MODULE_H
|
||||
#include "sofia-sip/auth_module.h"
|
||||
#endif
|
||||
|
||||
#ifndef AUTH_DIGEST_H
|
||||
#include "sofia-sip/auth_digest.h"
|
||||
#endif
|
||||
|
||||
#ifndef AUTH_COMMON_H
|
||||
#include "sofia-sip/auth_common.h"
|
||||
#endif
|
||||
|
||||
#ifndef MSG_DATE_H
|
||||
#include <sofia-sip/msg_date.h>
|
||||
#endif
|
||||
|
||||
#ifndef SU_MD5_H
|
||||
#include <sofia-sip/su_md5.h>
|
||||
#endif
|
||||
|
||||
#include <sofia-sip/htable.h>
|
||||
|
||||
SOFIA_BEGIN_DECLS
|
||||
|
||||
/* ====================================================================== */
|
||||
/* Plugin interface for authentication */
|
||||
|
||||
/** Authentication scheme */
|
||||
struct auth_scheme
|
||||
{
|
||||
/** Name */
|
||||
char const *asch_method;
|
||||
|
||||
/** Size of module object */
|
||||
usize_t asch_size;
|
||||
|
||||
/** Initialize module. Invoked by auth_mod_create(). */
|
||||
int (*asch_init)(auth_mod_t *am,
|
||||
auth_scheme_t *base,
|
||||
su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
/** Check authentication. Invoked by auth_mod_method(). */
|
||||
void (*asch_check)(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *auth,
|
||||
auth_challenger_t const *ch);
|
||||
|
||||
/** Create a challenge. Invoked by auth_mod_challenge(). */
|
||||
void (*asch_challenge)(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ch);
|
||||
|
||||
/** Cancel an asynchronous authentication request.
|
||||
* Invoked by auth_mod_cancel().
|
||||
*/
|
||||
void (*asch_cancel)(auth_mod_t *am,
|
||||
auth_status_t *as);
|
||||
|
||||
/** Reclaim resources an authentication module.
|
||||
*
|
||||
* Invoked by auth_mod_destroy()/auth_mod_unref().
|
||||
*/
|
||||
void (*asch_destroy)(auth_mod_t *am);
|
||||
|
||||
};
|
||||
|
||||
/** User data structure */
|
||||
typedef struct
|
||||
{
|
||||
unsigned apw_index; /**< Key to hash table */
|
||||
void const *apw_type; /**< Magic pointer */
|
||||
|
||||
char const *apw_user; /**< Username */
|
||||
char const *apw_realm; /**< Realm */
|
||||
char const *apw_pass; /**< Password */
|
||||
char const *apw_hash; /**< MD5 of the username, realm and pass */
|
||||
char const *apw_ident; /**< Identity information */
|
||||
auth_uplugin_t *apw_extended; /**< Method-specific extension */
|
||||
} auth_passwd_t;
|
||||
|
||||
|
||||
HTABLE_DECLARE_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
|
||||
|
||||
struct stat;
|
||||
|
||||
/** Common data for authentication module */
|
||||
struct auth_mod_t
|
||||
{
|
||||
su_home_t am_home[1];
|
||||
unsigned am_refcount; /**< Number of references to this module */
|
||||
|
||||
/* User database / cache */
|
||||
char const *am_db; /**< User database file name */
|
||||
struct stat *am_stat; /**< State of user file when read */
|
||||
auth_htable_t am_users[1]; /**< Table of users */
|
||||
|
||||
void *am_buffer; /**< Buffer for database */
|
||||
auth_passwd_t *am_locals; /**< Entries from local user file */
|
||||
size_t am_local_count; /**< Number of entries from local user file */
|
||||
|
||||
auth_passwd_t *am_anon_user; /**< Special entry for anonymous user */
|
||||
|
||||
/* Attributes */
|
||||
url_t *am_remote; /**< Remote authenticator */
|
||||
char const *am_realm; /**< Our realm */
|
||||
char const *am_opaque; /**< Opaque identification data */
|
||||
char const *am_gssapi_data; /**< NTLM data */
|
||||
char const *am_targetname; /**< NTLM target name */
|
||||
auth_scheme_t *am_scheme; /**< Authentication scheme (Digest, Basic). */
|
||||
char const **am_allow; /**< Methods to allow without authentication */
|
||||
msg_param_t am_algorithm; /**< Defauilt algorithm */
|
||||
msg_param_t am_qop; /**< Default qop (quality-of-protection) */
|
||||
unsigned am_expires; /**< Nonce lifetime */
|
||||
unsigned am_next_exp; /**< Next nonce lifetime */
|
||||
unsigned am_blacklist; /**< Extra delay if bad credentials. */
|
||||
unsigned am_forbidden:1;/**< Respond with 403 if bad credentials */
|
||||
unsigned am_anonymous:1;/**< Allow anonymous access */
|
||||
unsigned am_challenge:1;/**< Challenge even if successful */
|
||||
unsigned am_nextnonce:1;/**< Send next nonce in responses */
|
||||
unsigned am_mutual:1; /**< Mutual authentication */
|
||||
unsigned am_fake:1; /**< Fake authentication */
|
||||
|
||||
unsigned :0; /**< Pad */
|
||||
unsigned am_count; /**< Nonce counter */
|
||||
|
||||
uint8_t am_master_key[16]; /**< Private master key */
|
||||
|
||||
su_md5_t am_hmac_ipad; /**< MD5 with inner pad */
|
||||
su_md5_t am_hmac_opad; /**< MD5 with outer pad */
|
||||
};
|
||||
|
||||
SOFIAPUBFUN
|
||||
auth_passwd_t *auth_mod_getpass(auth_mod_t *am,
|
||||
char const *user,
|
||||
char const *realm);
|
||||
|
||||
SOFIAPUBFUN
|
||||
auth_passwd_t *auth_mod_addpass(auth_mod_t *am,
|
||||
char const *user,
|
||||
char const *realm);
|
||||
|
||||
SOFIAPUBFUN int auth_readdb_if_needed(auth_mod_t *am);
|
||||
|
||||
SOFIAPUBFUN int auth_readdb(auth_mod_t *am);
|
||||
|
||||
SOFIAPUBFUN msg_auth_t *auth_mod_credentials(msg_auth_t *auth,
|
||||
char const *scheme,
|
||||
char const *realm);
|
||||
|
||||
SOFIAPUBFUN auth_mod_t *auth_mod_alloc(auth_scheme_t *scheme,
|
||||
tag_type_t, tag_value_t, ...);
|
||||
|
||||
#define AUTH_PLUGIN(am) (auth_plugin_t *)((am) + 1)
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auth_init_default(auth_mod_t *am,
|
||||
auth_scheme_t *base,
|
||||
su_root_t *root,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
/** Default cancel method */
|
||||
SOFIAPUBFUN void auth_cancel_default(auth_mod_t *am, auth_status_t *as);
|
||||
|
||||
/** Default destroy method */
|
||||
SOFIAPUBFUN void auth_destroy_default(auth_mod_t *am);
|
||||
|
||||
/** Basic scheme */
|
||||
SOFIAPUBFUN
|
||||
void auth_method_basic(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *auth,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN
|
||||
void auth_challenge_basic(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
/** Digest scheme */
|
||||
SOFIAPUBFUN
|
||||
msg_auth_t *auth_digest_credentials(msg_auth_t *auth,
|
||||
char const *realm,
|
||||
char const *opaque);
|
||||
|
||||
SOFIAPUBFUN
|
||||
void auth_method_digest(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
msg_auth_t *au,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN
|
||||
void auth_info_digest(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN
|
||||
void auth_check_digest(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_response_t *ar,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN
|
||||
void auth_challenge_digest(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_challenger_t const *ach);
|
||||
|
||||
SOFIAPUBFUN
|
||||
isize_t auth_generate_digest_nonce(auth_mod_t *am,
|
||||
char buffer[],
|
||||
size_t buffer_len,
|
||||
int nextnonce,
|
||||
msg_time_t now);
|
||||
|
||||
SOFIAPUBFUN
|
||||
int auth_validate_digest_nonce(auth_mod_t *am,
|
||||
auth_status_t *as,
|
||||
auth_response_t *ar,
|
||||
msg_time_t now);
|
||||
|
||||
SOFIAPUBFUN int auth_allow_check(auth_mod_t *am, auth_status_t *as);
|
||||
|
||||
/** Init md5 for MD5-based HMAC */
|
||||
SOFIAPUBFUN void auth_md5_hmac_init(auth_mod_t *am, su_md5_t *md5);
|
||||
SOFIAPUBFUN void auth_md5_hmac_digest(auth_mod_t *am, su_md5_t *md5,
|
||||
void *hmac, size_t size);
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif /* !defined AUTH_PLUGIN_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,3 @@
|
||||
user1:secret:
|
||||
user2:fish:
|
||||
very-long-user-name-that-surely-exceeds-the-static-buffer:at-least-when-used-with-the-even-longer-password:
|
||||
Reference in new issue
Block a user