1 --- misc/xmlsec1-1.2.6/apps/Makefile.in 2004-08-26 08:00:30.000000000 +0200
2 +++ misc/build/xmlsec1-1.2.6/apps/Makefile.in 2008-06-29 23:44:19.000000000 +0200
11 .SUFFIXES: .c .lo .o .obj
12 --- misc/xmlsec1-1.2.6/configure 2004-08-26 08:00:34.000000000 +0200
13 +++ misc/build/xmlsec1-1.2.6/configure 2008-06-29 23:44:19.000000000 +0200
18 -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os XMLSEC_VERSION XMLSEC_PACKAGE XMLSEC_VERSION_SAFE XMLSEC_VERSION_MAJOR XMLSEC_VERSION_MINOR XMLSEC_VERSION_SUBMINOR XMLSEC_VERSION_INFO INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL RM CP MV TAR HELP2MAN MAN2HTML U ANSI2KNR INSTALL_LTDL_TRUE INSTALL_LTDL_FALSE CONVENIENCE_LTDL_TRUE CONVENIENCE_LTDL_FALSE LIBADD_DL PKG_CONFIG_ENABLED PKG_CONFIG LIBXML_CFLAGS LIBXML_LIBS LIBXML262_CFLAGS LIBXML262_LIBS LIBXML_CONFIG LIBXML_MIN_VERSION LIBXSLT_CFLAGS LIBXSLT_LIBS XMLSEC_NO_LIBXSLT LIBXSLT_CONFIG LIBXSLT_MIN_VERSION OPENSSL_CFLAGS OPENSSL_LIBS OPENSSL097_CFLAGS OPENSSL097_LIBS XMLSEC_NO_OPENSSL_TRUE XMLSEC_NO_OPENSSL_FALSE XMLSEC_NO_OPENSSL OPENSSL_CRYPTO_LIB OPENSSL_MIN_VERSION GNUTLS_CFLAGS GNUTLS_LIBS XMLSEC_NO_GNUTLS_TRUE XMLSEC_NO_GNUTLS_FALSE XMLSEC_NO_GNUTLS GNUTLS_CRYPTO_LIB GNUTLS_MIN_VERSION NSS_CFLAGS NSS_LIBS XMLSEC_NO_NSS_TRUE XMLSEC_NO_NSS_FALSE XMLSEC_NO_NSS NSS_CRYPTO_LIB NSS_MIN_VERSION NSPR_MIN_VERSION MOZILLA_MIN_VERSION XMLSEC_NO_SHA1_TRUE XMLSEC_NO_SHA1_FALSE XMLSEC_NO_SHA1 XMLSEC_NO_RIPEMD160_TRUE XMLSEC_NO_RIPEMD160_FALSE XMLSEC_NO_RIPEMD160 XMLSEC_NO_HMAC_TRUE XMLSEC_NO_HMAC_FALSE XMLSEC_NO_HMAC XMLSEC_NO_DSA_TRUE XMLSEC_NO_DSA_FALSE XMLSEC_NO_DSA XMLSEC_NO_RSA_TRUE XMLSEC_NO_RSA_FALSE XMLSEC_NO_RSA XMLSEC_NO_X509_TRUE XMLSEC_NO_X509_FALSE XMLSEC_NO_X509 XMLSEC_NO_DES_TRUE XMLSEC_NO_DES_FALSE XMLSEC_NO_DES XMLSEC_NO_AES_TRUE XMLSEC_NO_AES_FALSE XMLSEC_NO_AES XMLSEC_NO_XMLDSIG_TRUE XMLSEC_NO_XMLDSIG_FALSE XMLSEC_NO_XMLDSIG XMLSEC_NO_XMLENC_TRUE XMLSEC_NO_XMLENC_FALSE XMLSEC_NO_XMLENC XMLSEC_NO_XKMS_TRUE XMLSEC_NO_XKMS_FALSE XMLSEC_NO_XKMS XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_TRUE XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_FALSE XMLSEC_NO_CRYPTO_DYNAMIC_LOADING XMLSEC_DL_INCLUDES XMLSEC_DL_LIBS XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_TRUE XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_FALSE XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING XMLSEC_DOCDIR XMLSEC_STATIC_BINARIES XMLSEC_CORE_CFLAGS XMLSEC_CORE_LIBS XMLSEC_LIBDIR XMLSEC_OPENSSL_CFLAGS XMLSEC_OPENSSL_LIBS XMLSEC_GNUTLS_CFLAGS XMLSEC_GNUTLS_LIBS XMLSEC_NSS_CFLAGS XMLSEC_NSS_LIBS XMLSEC_CFLAGS XMLSEC_LIBS XMLSEC_DEFINES XMLSEC_APP_DEFINES XMLSEC_CRYPTO XMLSEC_CRYPTO_LIST XMLSEC_CRYPTO_DISABLED_LIST XMLSEC_CRYPTO_LIB XMLSEC_CRYPTO_CFLAGS XMLSEC_CRYPTO_LIBS XMLSEC_CRYPTO_PC_FILES_LIST LIBOBJS LTLIBOBJS'
19 +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os XMLSEC_VERSION XMLSEC_PACKAGE XMLSEC_VERSION_SAFE XMLSEC_VERSION_MAJOR XMLSEC_VERSION_MINOR XMLSEC_VERSION_SUBMINOR XMLSEC_VERSION_INFO INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL RM CP MV TAR HELP2MAN MAN2HTML U ANSI2KNR INSTALL_LTDL_TRUE INSTALL_LTDL_FALSE CONVENIENCE_LTDL_TRUE CONVENIENCE_LTDL_FALSE LIBADD_DL PKG_CONFIG_ENABLED PKG_CONFIG LIBXML_CFLAGS LIBXML_LIBS LIBXML262_CFLAGS LIBXML262_LIBS LIBXML_CONFIG LIBXML_MIN_VERSION LIBXSLT_CFLAGS LIBXSLT_LIBS XMLSEC_NO_LIBXSLT LIBXSLT_CONFIG LIBXSLT_MIN_VERSION OPENSSL_CFLAGS OPENSSL_LIBS OPENSSL097_CFLAGS OPENSSL097_LIBS XMLSEC_NO_OPENSSL_TRUE XMLSEC_NO_OPENSSL_FALSE XMLSEC_NO_OPENSSL OPENSSL_CRYPTO_LIB OPENSSL_MIN_VERSION GNUTLS_CFLAGS GNUTLS_LIBS XMLSEC_NO_GNUTLS_TRUE XMLSEC_NO_GNUTLS_FALSE XMLSEC_NO_GNUTLS GNUTLS_CRYPTO_LIB GNUTLS_MIN_VERSION NSS_CFLAGS NSS_LIBS XMLSEC_NO_NSS_TRUE XMLSEC_NO_NSS_FALSE XMLSEC_NO_NSS NSS_CRYPTO_LIB NSS_MIN_VERSION NSPR_MIN_VERSION MOZILLA_MIN_VERSION MSCRYPTO_CFLAGS MSCRYPTO_LIBS XMLSEC_NO_SHA1_TRUE XMLSEC_NO_SHA1_FALSE XMLSEC_NO_SHA1 XMLSEC_NO_RIPEMD160_TRUE XMLSEC_NO_RIPEMD160_FALSE XMLSEC_NO_RIPEMD160 XMLSEC_NO_HMAC_TRUE XMLSEC_NO_HMAC_FALSE XMLSEC_NO_HMAC XMLSEC_NO_DSA_TRUE XMLSEC_NO_DSA_FALSE XMLSEC_NO_DSA XMLSEC_NO_RSA_TRUE XMLSEC_NO_RSA_FALSE XMLSEC_NO_RSA XMLSEC_NO_X509_TRUE XMLSEC_NO_X509_FALSE XMLSEC_NO_X509 XMLSEC_NO_DES_TRUE XMLSEC_NO_DES_FALSE XMLSEC_NO_DES XMLSEC_NO_AES_TRUE XMLSEC_NO_AES_FALSE XMLSEC_NO_AES XMLSEC_NO_XMLDSIG_TRUE XMLSEC_NO_XMLDSIG_FALSE XMLSEC_NO_XMLDSIG XMLSEC_NO_XMLENC_TRUE XMLSEC_NO_XMLENC_FALSE XMLSEC_NO_XMLENC XMLSEC_NO_XKMS_TRUE XMLSEC_NO_XKMS_FALSE XMLSEC_NO_XKMS XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_TRUE XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_FALSE XMLSEC_NO_CRYPTO_DYNAMIC_LOADING XMLSEC_DL_INCLUDES XMLSEC_DL_LIBS XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_TRUE XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_FALSE XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING XMLSEC_DOCDIR XMLSEC_STATIC_BINARIES XMLSEC_CORE_CFLAGS XMLSEC_CORE_LIBS XMLSEC_LIBDIR XMLSEC_OPENSSL_CFLAGS XMLSEC_OPENSSL_LIBS XMLSEC_GNUTLS_CFLAGS XMLSEC_GNUTLS_LIBS XMLSEC_NSS_CFLAGS XMLSEC_NSS_LIBS XMLSEC_CFLAGS XMLSEC_LIBS XMLSEC_DEFINES XMLSEC_APP_DEFINES XMLSEC_CRYPTO XMLSEC_CRYPTO_LIST XMLSEC_CRYPTO_DISABLED_LIST XMLSEC_CRYPTO_LIB XMLSEC_CRYPTO_CFLAGS XMLSEC_CRYPTO_LIBS XMLSEC_CRYPTO_PC_FILES_LIST LIBOBJS LTLIBOBJS'
22 # Initialize some variables set by options.
24 --with-nss=PFX nss location
25 --with-nspr=PFX nspr location (needed for NSS)
26 --with-mozilla-ver=VER mozilla version (alt to --with-nss, --with-nspr)
27 + --with-mscrypto try to use mscrypto
28 --with-html-dir=PATH path to installed docs
30 Some influential environment variables:
34 ac_cpp='$CPP $CPPFLAGS'
35 -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
36 -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
37 +ac_compile='$CC -c $ADDCFLAGS $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
38 +ac_link='$CC -o conftest$ac_exeext $ADDCFLAGS $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
39 ac_compiler_gnu=$ac_cv_c_compiler_gnu
40 if test -n "$ac_tool_prefix"; then
41 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
42 @@ -2698,15 +2699,15 @@
43 CFLAGS=$ac_save_CFLAGS
44 elif test $ac_cv_prog_cc_g = yes; then
45 if test "$GCC" = yes; then
47 + CFLAGS="$ADDCFLAGS -g -O2"
50 + CFLAGS="$ADDCFLAGS -g"
53 if test "$GCC" = yes; then
55 + CFLAGS="$ADDCFLAGS -O2"
61 echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
62 @@ -6350,11 +6351,11 @@
63 lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
66 - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
67 + beos* | cygwin* | mingw* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
68 # PIC is the default for these OSes.
71 - mingw* | pw32* | os2*)
73 # This hack is so that the source file can tell whether it is being
74 # built for inclusion in a dll (and should export symbols for example).
75 lt_prog_compiler_pic='-DDLL_EXPORT'
80 - mingw* | pw32* | os2*)
82 # This hack is so that the source file can tell whether it is being
83 # built for inclusion in a dll (and should export symbols for example).
84 lt_prog_compiler_pic='-DDLL_EXPORT'
86 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
88 if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
89 - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
90 + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--exclude-libs,ALL ${wl}--out-implib,$lib'
91 # If the export-symbols file already is a .def file (1st line
92 # is EXPORTS), use it as is; otherwise, prepend...
93 archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
98 - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
99 + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
100 version_type=freebsd-$objformat
101 case $version_type in
103 @@ -9046,7 +9047,7 @@
106 output_verbose_link_cmd='echo'
107 - archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring'
108 + archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name @executable_path/$soname $verstring'
109 module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
110 # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
111 archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
112 @@ -10088,7 +10089,7 @@
113 enable_shared_with_static_runtimes_CXX=yes
115 if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
116 - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
117 + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--exclude-libs,ALL ${wl}--out-implib,$lib'
118 # If the export-symbols file already is a .def file (1st line
119 # is EXPORTS), use it as is; otherwise, prepend...
120 archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
121 @@ -10816,10 +10817,10 @@
123 lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
125 - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
126 + beos* | cygwin* | mingw* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
127 # PIC is the default for these OSes.
129 - mingw* | os2* | pw32*)
131 # This hack is so that the source file can tell whether it is being
132 # built for inclusion in a dll (and should export symbols for example).
133 lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
134 @@ -11497,7 +11498,7 @@
138 - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
139 + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
140 version_type=freebsd-$objformat
141 case $version_type in
143 @@ -13259,11 +13260,11 @@
144 lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
147 - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
148 + beos* | cygwin* | mingw* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
149 # PIC is the default for these OSes.
152 - mingw* | pw32* | os2*)
154 # This hack is so that the source file can tell whether it is being
155 # built for inclusion in a dll (and should export symbols for example).
156 lt_prog_compiler_pic_F77='-DDLL_EXPORT'
157 @@ -13661,7 +13662,7 @@
158 export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
160 if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
161 - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
162 + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--exclude-libs,ALL ${wl}--out-implib,$lib'
163 # If the export-symbols file already is a .def file (1st line
164 # is EXPORTS), use it as is; otherwise, prepend...
165 archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
166 @@ -14667,7 +14668,7 @@
170 - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
171 + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
172 version_type=freebsd-$objformat
173 case $version_type in
175 @@ -15607,11 +15608,11 @@
176 lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
179 - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
180 + beos* | cygwin* | mingw* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
181 # PIC is the default for these OSes.
184 - mingw* | pw32* | os2*)
186 # This hack is so that the source file can tell whether it is being
187 # built for inclusion in a dll (and should export symbols for example).
188 lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
189 @@ -15666,7 +15667,7 @@
193 - mingw* | pw32* | os2*)
195 # This hack is so that the source file can tell whether it is being
196 # built for inclusion in a dll (and should export symbols for example).
197 lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
198 @@ -16009,7 +16010,7 @@
199 export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
201 if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
202 - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
203 + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--exclude-libs,ALL ${wl}--out-implib,$lib'
204 # If the export-symbols file already is a .def file (1st line
205 # is EXPORTS), use it as is; otherwise, prepend...
206 archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
207 @@ -17035,7 +17036,7 @@
211 - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
212 + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
213 version_type=freebsd-$objformat
214 case $version_type in
216 @@ -25678,12 +25679,26 @@
219 MOZILLA_MIN_VERSION="1.4"
220 +if test "z$MOZ_FLAVOUR" = "zfirefox" ; then
221 + MOZILLA_MIN_VERSION="1.0"
223 NSS_MIN_VERSION="3.2"
224 NSPR_MIN_VERSION="4.0"
227 -NSS_LIBS_LIST="-lnss3 -lsmime3"
228 -NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4"
231 +cygwin* | mingw* | pw32*)
232 + NSS_LIBS_LIST="-lnss3 -lsmime3"
233 + NSPR_LIBS_LIST="-lnspr4"
237 + NSS_LIBS_LIST="-lnss3 -lsoftokn3 -lsmime3"
238 + NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4"
242 NSS_CRYPTO_LIB="$PACKAGE-nss"
245 @@ -25766,23 +25781,122 @@
247 PKG_CONFIG_MIN_VERSION=0.9.0
248 if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
249 - echo "$as_me:$LINENO: checking for mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION" >&5
250 -echo $ECHO_N "checking for mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION... $ECHO_C" >&6
251 + echo "$as_me:$LINENO: checking for $MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION" >&5
252 +echo $ECHO_N "checking for $MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION... $ECHO_C" >&6
254 + if $PKG_CONFIG --exists "$MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION" ; then
255 + echo "$as_me:$LINENO: result: yes" >&5
256 +echo "${ECHO_T}yes" >&6
259 + echo "$as_me:$LINENO: checking NSS_CFLAGS" >&5
260 +echo $ECHO_N "checking NSS_CFLAGS... $ECHO_C" >&6
261 + NSS_CFLAGS=`$PKG_CONFIG --cflags "$MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION"`
262 + echo "$as_me:$LINENO: result: $NSS_CFLAGS" >&5
263 +echo "${ECHO_T}$NSS_CFLAGS" >&6
265 + echo "$as_me:$LINENO: checking NSS_LIBS" >&5
266 +echo $ECHO_N "checking NSS_LIBS... $ECHO_C" >&6
267 + NSS_LIBS=`$PKG_CONFIG --libs "$MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION"`
268 + echo "$as_me:$LINENO: result: $NSS_LIBS" >&5
269 +echo "${ECHO_T}$NSS_LIBS" >&6
273 + ## If we have a custom action on failure, don't print errors, but
274 + ## do set a variable so people can do so.
275 + NSS_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION"`
282 + echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
283 + echo "*** See http://www.freedesktop.org/software/pkgconfig"
287 + if test $succeeded = yes; then
293 + echo "$as_me:$LINENO: result: $NSS_FOUND" >&5
294 +echo "${ECHO_T}$NSS_FOUND" >&6
295 + if test "z$NSS_FOUND" = "zno" ; then
299 + if test -z "$PKG_CONFIG"; then
300 + # Extract the first word of "pkg-config", so it can be a program name with args.
301 +set dummy pkg-config; ac_word=$2
302 +echo "$as_me:$LINENO: checking for $ac_word" >&5
303 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
304 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
305 + echo $ECHO_N "(cached) $ECHO_C" >&6
307 + case $PKG_CONFIG in
309 + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
312 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
316 + test -z "$as_dir" && as_dir=.
317 + for ac_exec_ext in '' $ac_executable_extensions; do
318 + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
319 + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
320 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
326 + test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
330 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
332 +if test -n "$PKG_CONFIG"; then
333 + echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
334 +echo "${ECHO_T}$PKG_CONFIG" >&6
336 + echo "$as_me:$LINENO: result: no" >&5
337 +echo "${ECHO_T}no" >&6
342 + if test "$PKG_CONFIG" = "no" ; then
343 + echo "*** The pkg-config script could not be found. Make sure it is"
344 + echo "*** in your path, or set the PKG_CONFIG environment variable"
345 + echo "*** to the full path to pkg-config."
346 + echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
348 + PKG_CONFIG_MIN_VERSION=0.9.0
349 + if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
350 + echo "$as_me:$LINENO: checking for nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION" >&5
351 +echo $ECHO_N "checking for nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION... $ECHO_C" >&6
353 - if $PKG_CONFIG --exists "mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION" ; then
354 + if $PKG_CONFIG --exists "nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION" ; then
355 echo "$as_me:$LINENO: result: yes" >&5
356 echo "${ECHO_T}yes" >&6
359 echo "$as_me:$LINENO: checking NSS_CFLAGS" >&5
360 echo $ECHO_N "checking NSS_CFLAGS... $ECHO_C" >&6
361 - NSS_CFLAGS=`$PKG_CONFIG --cflags "mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION"`
362 + NSS_CFLAGS=`$PKG_CONFIG --cflags "nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION"`
363 echo "$as_me:$LINENO: result: $NSS_CFLAGS" >&5
364 echo "${ECHO_T}$NSS_CFLAGS" >&6
366 echo "$as_me:$LINENO: checking NSS_LIBS" >&5
367 echo $ECHO_N "checking NSS_LIBS... $ECHO_C" >&6
368 - NSS_LIBS=`$PKG_CONFIG --libs "mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION"`
369 + NSS_LIBS=`$PKG_CONFIG --libs "nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION"`
370 echo "$as_me:$LINENO: result: $NSS_LIBS" >&5
371 echo "${ECHO_T}$NSS_LIBS" >&6
373 @@ -25790,7 +25904,7 @@
375 ## If we have a custom action on failure, don't print errors, but
376 ## do set a variable so people can do so.
377 - NSS_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION"`
378 + NSS_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION"`
382 @@ -25808,6 +25922,9 @@
386 + echo "$as_me:$LINENO: result: $NSS_FOUND" >&5
387 +echo "${ECHO_T}$NSS_FOUND" >&6
391 if test "z$NSS_FOUND" = "zno" ; then
392 @@ -25817,8 +25934,8 @@
393 ac_mozilla_name=mozilla-$MOZILLA_MIN_VERSION
396 - ac_nss_lib_dir="/usr/lib /usr/lib64 /usr/local/lib /usr/lib/$ac_mozilla_name /usr/local/lib/$ac_mozilla_name"
397 - ac_nss_inc_dir="/usr/include /usr/include/mozilla /usr/local/include /usr/local/include/mozilla /usr/include/$ac_mozilla_name /usr/local/include/$ac_mozilla_name"
398 + ac_nss_lib_dir="${SOLARVERSION}/${INPATH}/lib${UPDMINOREXT}"
399 + ac_nss_inc_dir="${SOLARVERSION}/${INPATH}/inc${UPDMINOREXT}/mozilla"
401 echo "$as_me:$LINENO: checking for nspr libraries >= $NSPR_MIN_VERSION" >&5
402 echo $ECHO_N "checking for nspr libraries >= $NSPR_MIN_VERSION... $ECHO_C" >&6
403 @@ -25853,8 +25970,11 @@
406 for dir in $ac_nss_lib_dir ; do
407 - if test -f $dir/libnspr4.so ; then
408 - if test "z$dir" = "z/usr/lib" ; then
410 + cygwin* | mingw* | pw32*)
411 + if test -f $dir/libnspr4.so -o -f $dir/libnspr4.dylib -o -f $dir/libnspr4.a ; then
412 + # do not add -L/usr/lib because compiler does it anyway
413 + if test "z$dir" = "z/usr/lib" ; then
414 NSPR_LIBS="$NSPR_LIBS_LIST"
416 if test "z$with_gnu_ld" = "zyes" ; then
417 @@ -25865,7 +25985,26 @@
419 NSPR_LIBS_FOUND="yes"
426 + if test -f $dir/libnspr4.so -o -f $dir/libnspr4.dylib ; then
427 + # do not add -L/usr/lib because compiler does it anyway
428 + if test "z$dir" = "z/usr/lib" ; then
429 + NSPR_LIBS="$NSPR_LIBS_LIST"
431 + if test "z$with_gnu_ld" = "zyes" ; then
432 + NSPR_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $NSPR_LIBS_LIST"
434 + NSPR_LIBS="-L$dir $NSPR_LIBS_LIST"
437 + NSPR_LIBS_FOUND="yes"
445 @@ -25939,8 +26078,11 @@
448 for dir in $ac_nss_lib_dir ; do
449 - if test -f $dir/libnss3.so ; then
450 - if test "z$dir" = "z/usr/lib" ; then
452 + cygwin* | mingw* | pw32*)
453 + if test -f $dir/libnss3.so -o -f $dir/libnss3.dylib -o -f $dir/libnss3.a ; then
454 + # do not add -L/usr/lib because compiler does it anyway
455 + if test "z$dir" = "z/usr/lib" ; then
456 NSS_LIBS="$NSS_LIBS_LIST"
458 if test "z$with_gnu_ld" = "zyes" ; then
459 @@ -25951,7 +26093,26 @@
468 + if test -f $dir/libnss3.so -o -f $dir/libnss3.dylib ; then
469 + # do not add -L/usr/lib because compiler does it anyway
470 + if test "z$dir" = "z/usr/lib" ; then
471 + NSS_LIBS="$NSS_LIBS_LIST"
473 + if test "z$with_gnu_ld" = "zyes" ; then
474 + NSS_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $NSS_LIBS_LIST"
476 + NSS_LIBS="-L$dir $NSS_LIBS_LIST"
479 + NSS_LIBS_FOUND="yes"
487 @@ -26004,6 +26165,12 @@
493 + NSS_LIBS="$NSS_LIBS "`"$PERL" "$SOLARENV/bin/macosx-dylib-link-list.pl" $NSS_LIBS`
497 if test "z$NSS_FOUND" = "zyes" ; then
499 NSS_CFLAGS="$NSS_CFLAGS -DXMLSEC_CRYPTO_NSS=1"
500 @@ -26037,6 +26204,109 @@
509 +# Check whether --with-mscrypto or --without-mscrypto was given.
510 +if test "${with_mscrypto+set}" = set; then
511 + withval="$with_mscrypto"
514 +if test "z$with_mscrypto" = "zno" ; then
515 + echo "$as_me:$LINENO: checking for MSCRYPTO libraries" >&5
516 +echo $ECHO_N "checking for MSCRYPTO libraries... $ECHO_C" >&6
517 + echo "$as_me:$LINENO: result: no" >&5
518 +echo "${ECHO_T}no" >&6
519 + MSCRYPTO_FOUND="without"
521 + ac_mscrypto_lib_dir="${PSDK_HOME}/lib"
522 + ac_mscrypto_inc_dir="${SOLARVERSION}/${INPATH}/inc${UPDMINOREXT}/external/mingw/include ${COMPATH}/include ${COMPATH}/include/w32api"
523 + echo "$as_me:$LINENO: checking for mscrypto libraries" >&5
524 +echo $ECHO_N "checking for mscrypto libraries... $ECHO_C" >&6
525 + MSCRYPTO_INCLUDES_FOUND="no"
526 + MSCRYPTO_LIBS_FOUND="no"
529 + for dir in $ac_mscrypto_inc_dir ; do
530 + if test -f $dir/wincrypt.h ; then
531 + MSCRYPTO_CFLAGS="$MSCRYPTO_CFLAGS -I$dir"
532 + MSCRYPTO_INCLUDES_FOUND="yes"
533 + WINCRYPT_H="$dir/wincrypt.h"
538 + for dir in $ac_mscrypto_lib_dir ; do
539 + if test -f $dir/crypt32.lib ; then
540 + if test "z$with_gnu_ld" = "zyes" ; then
541 + MSCRYPTO_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $dir/crypt32.lib"
543 + MSCRYPTO_LIBS="-L$dir $dir/crypt32.lib"
545 + MSCRYPTO_LIBS_FOUND="yes"
550 + if test "z$MSCRYPTO_INCLUDES_FOUND" = "zyes" -a "z$MSCRYPTO_LIBS_FOUND" = "zyes" ; then
551 + OLD_CPPFLAGS=$CPPFLAGS
552 + CPPFLAGS="$MSCRYPTO_CFLAGS"
553 + cat >conftest.$ac_ext <<_ACEOF
556 +cat confdefs.h >>conftest.$ac_ext
557 +cat >>conftest.$ac_ext <<_ACEOF
558 +/* end confdefs.h. */
560 + #include <wincrypt.h>
561 + #if defined(_WINCRYPT_H) || defined(__WINCRYPT_H__)
566 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
567 + $EGREP "yes" >/dev/null 2>&1; then
578 + CPPFLAGS="$OLD_CPPFLAGS"
581 + if test "z$MSCRYPTO_FOUND" = "zyes" ; then
582 + echo "$as_me:$LINENO: result: yes" >&5
583 +echo "${ECHO_T}yes" >&6
585 + echo "$as_me:$LINENO: result: no" >&5
586 +echo "${ECHO_T}no" >&6
591 +if test "z$MSCRYPTO_FOUND" = "zyes" ; then
592 + MSCRYPTO_CFLAGS="$MSCRYPTO_CFLAGS -DXMLSEC_CRYPTO_MSCRYPTO=1"
594 + if test "z$XMLSEC_CRYPTO" = "z" ; then
595 + XMLSEC_CRYPTO="mscrypto"
596 + XMLSEC_CRYPTO_LIB="$PACKAGE-mscrypto"
597 + XMLSEC_CRYPTO_CFLAGS="$MSCRYPTO_CFLAGS"
598 + XMLSEC_CRYPTO_LIBS="$MSCRYPTO_LIBS"
600 + XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST mscrypto"
602 + XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST mscrypto"
607 echo "$as_me:$LINENO: checking for crypto library" >&5
608 echo $ECHO_N "checking for crypto library... $ECHO_C" >&6
609 if test "z$XMLSEC_CRYPTO" = "z" ; then
610 @@ -26604,7 +26874,7 @@
614 - ac_config_files="$ac_config_files include/xmlsec/version.h Makefile include/Makefile include/xmlsec/Makefile include/xmlsec/private/Makefile src/Makefile apps/Makefile docs/Makefile docs/api/Makefile man/Makefile xmlsec1Conf.sh:xmlsecConf.sh.in xmlsec1-config:xmlsec-config.in xmlsec1-openssl.pc:xmlsec-openssl.pc.in xmlsec1-gnutls.pc:xmlsec-gnutls.pc.in xmlsec1-nss.pc:xmlsec-nss.pc.in xmlsec1.spec:xmlsec.spec.in"
615 + ac_config_files="$ac_config_files include/xmlsec/version.h Makefile include/Makefile include/xmlsec/Makefile include/xmlsec/private/Makefile src/Makefile apps/Makefile docs/Makefile docs/api/Makefile man/Makefile xmlsec1Conf.sh:xmlsecConf.sh.in xmlsec1-config:xmlsec-config.in xmlsec1-openssl.pc:xmlsec-openssl.pc.in xmlsec1-gnutls.pc:xmlsec-gnutls.pc.in xmlsec1-nss.pc:xmlsec-nss.pc.in xmlsec1-mscrypto.pc:xmlsec-mscrypto.pc.in xmlsec1.spec:xmlsec.spec.in"
616 cat >confcache <<\_ACEOF
617 # This file is a shell script that caches the results of configure
618 # tests run on this system so they can be shared between configure
619 @@ -27521,6 +27791,8 @@
620 s,@NSS_MIN_VERSION@,$NSS_MIN_VERSION,;t t
621 s,@NSPR_MIN_VERSION@,$NSPR_MIN_VERSION,;t t
622 s,@MOZILLA_MIN_VERSION@,$MOZILLA_MIN_VERSION,;t t
623 +s,@MSCRYPTO_CFLAGS@,$MSCRYPTO_CFLAGS,;t t
624 +s,@MSCRYPTO_LIBS@,$MSCRYPTO_LIBS,;t t
625 s,@XMLSEC_NO_SHA1_TRUE@,$XMLSEC_NO_SHA1_TRUE,;t t
626 s,@XMLSEC_NO_SHA1_FALSE@,$XMLSEC_NO_SHA1_FALSE,;t t
627 s,@XMLSEC_NO_SHA1@,$XMLSEC_NO_SHA1,;t t
628 @@ -29231,6 +29503,8 @@
629 s,@NSS_MIN_VERSION@,$NSS_MIN_VERSION,;t t
630 s,@NSPR_MIN_VERSION@,$NSPR_MIN_VERSION,;t t
631 s,@MOZILLA_MIN_VERSION@,$MOZILLA_MIN_VERSION,;t t
632 +s,@MSCRYPTO_CFLAGS@,$MSCRYPTO_CFLAGS,;t t
633 +s,@MSCRYPTO_LIBS@,$MSCRYPTO_LIBS,;t t
634 s,@XMLSEC_NO_SHA1_TRUE@,$XMLSEC_NO_SHA1_TRUE,;t t
635 s,@XMLSEC_NO_SHA1_FALSE@,$XMLSEC_NO_SHA1_FALSE,;t t
636 s,@XMLSEC_NO_SHA1@,$XMLSEC_NO_SHA1,;t t
637 @@ -30941,6 +31215,8 @@
638 s,@NSS_MIN_VERSION@,$NSS_MIN_VERSION,;t t
639 s,@NSPR_MIN_VERSION@,$NSPR_MIN_VERSION,;t t
640 s,@MOZILLA_MIN_VERSION@,$MOZILLA_MIN_VERSION,;t t
641 +s,@MSCRYPTO_CFLAGS@,$MSCRYPTO_CFLAGS,;t t
642 +s,@MSCRYPTO_LIBS@,$MSCRYPTO_LIBS,;t t
643 s,@XMLSEC_NO_SHA1_TRUE@,$XMLSEC_NO_SHA1_TRUE,;t t
644 s,@XMLSEC_NO_SHA1_FALSE@,$XMLSEC_NO_SHA1_FALSE,;t t
645 s,@XMLSEC_NO_SHA1@,$XMLSEC_NO_SHA1,;t t
646 @@ -32653,6 +32929,1724 @@
647 s,@NSS_MIN_VERSION@,$NSS_MIN_VERSION,;t t
648 s,@NSPR_MIN_VERSION@,$NSPR_MIN_VERSION,;t t
649 s,@MOZILLA_MIN_VERSION@,$MOZILLA_MIN_VERSION,;t t
650 +s,@MSCRYPTO_CFLAGS@,$MSCRYPTO_CFLAGS,;t t
651 +s,@MSCRYPTO_LIBS@,$MSCRYPTO_LIBS,;t t
652 +s,@XMLSEC_NO_SHA1_TRUE@,$XMLSEC_NO_SHA1_TRUE,;t t
653 +s,@XMLSEC_NO_SHA1_FALSE@,$XMLSEC_NO_SHA1_FALSE,;t t
654 +s,@XMLSEC_NO_SHA1@,$XMLSEC_NO_SHA1,;t t
655 +s,@XMLSEC_NO_RIPEMD160_TRUE@,$XMLSEC_NO_RIPEMD160_TRUE,;t t
656 +s,@XMLSEC_NO_RIPEMD160_FALSE@,$XMLSEC_NO_RIPEMD160_FALSE,;t t
657 +s,@XMLSEC_NO_RIPEMD160@,$XMLSEC_NO_RIPEMD160,;t t
658 +s,@XMLSEC_NO_HMAC_TRUE@,$XMLSEC_NO_HMAC_TRUE,;t t
659 +s,@XMLSEC_NO_HMAC_FALSE@,$XMLSEC_NO_HMAC_FALSE,;t t
660 +s,@XMLSEC_NO_HMAC@,$XMLSEC_NO_HMAC,;t t
661 +s,@XMLSEC_NO_DSA_TRUE@,$XMLSEC_NO_DSA_TRUE,;t t
662 +s,@XMLSEC_NO_DSA_FALSE@,$XMLSEC_NO_DSA_FALSE,;t t
663 +s,@XMLSEC_NO_DSA@,$XMLSEC_NO_DSA,;t t
664 +s,@XMLSEC_NO_RSA_TRUE@,$XMLSEC_NO_RSA_TRUE,;t t
665 +s,@XMLSEC_NO_RSA_FALSE@,$XMLSEC_NO_RSA_FALSE,;t t
666 +s,@XMLSEC_NO_RSA@,$XMLSEC_NO_RSA,;t t
667 +s,@XMLSEC_NO_X509_TRUE@,$XMLSEC_NO_X509_TRUE,;t t
668 +s,@XMLSEC_NO_X509_FALSE@,$XMLSEC_NO_X509_FALSE,;t t
669 +s,@XMLSEC_NO_X509@,$XMLSEC_NO_X509,;t t
670 +s,@XMLSEC_NO_DES_TRUE@,$XMLSEC_NO_DES_TRUE,;t t
671 +s,@XMLSEC_NO_DES_FALSE@,$XMLSEC_NO_DES_FALSE,;t t
672 +s,@XMLSEC_NO_DES@,$XMLSEC_NO_DES,;t t
673 +s,@XMLSEC_NO_AES_TRUE@,$XMLSEC_NO_AES_TRUE,;t t
674 +s,@XMLSEC_NO_AES_FALSE@,$XMLSEC_NO_AES_FALSE,;t t
675 +s,@XMLSEC_NO_AES@,$XMLSEC_NO_AES,;t t
676 +s,@XMLSEC_NO_XMLDSIG_TRUE@,$XMLSEC_NO_XMLDSIG_TRUE,;t t
677 +s,@XMLSEC_NO_XMLDSIG_FALSE@,$XMLSEC_NO_XMLDSIG_FALSE,;t t
678 +s,@XMLSEC_NO_XMLDSIG@,$XMLSEC_NO_XMLDSIG,;t t
679 +s,@XMLSEC_NO_XMLENC_TRUE@,$XMLSEC_NO_XMLENC_TRUE,;t t
680 +s,@XMLSEC_NO_XMLENC_FALSE@,$XMLSEC_NO_XMLENC_FALSE,;t t
681 +s,@XMLSEC_NO_XMLENC@,$XMLSEC_NO_XMLENC,;t t
682 +s,@XMLSEC_NO_XKMS_TRUE@,$XMLSEC_NO_XKMS_TRUE,;t t
683 +s,@XMLSEC_NO_XKMS_FALSE@,$XMLSEC_NO_XKMS_FALSE,;t t
684 +s,@XMLSEC_NO_XKMS@,$XMLSEC_NO_XKMS,;t t
685 +s,@XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_TRUE@,$XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_TRUE,;t t
686 +s,@XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_FALSE@,$XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_FALSE,;t t
687 +s,@XMLSEC_NO_CRYPTO_DYNAMIC_LOADING@,$XMLSEC_NO_CRYPTO_DYNAMIC_LOADING,;t t
688 +s,@XMLSEC_DL_INCLUDES@,$XMLSEC_DL_INCLUDES,;t t
689 +s,@XMLSEC_DL_LIBS@,$XMLSEC_DL_LIBS,;t t
690 +s,@XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_TRUE@,$XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_TRUE,;t t
691 +s,@XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_FALSE@,$XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_FALSE,;t t
692 +s,@XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING@,$XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING,;t t
693 +s,@XMLSEC_DOCDIR@,$XMLSEC_DOCDIR,;t t
694 +s,@XMLSEC_STATIC_BINARIES@,$XMLSEC_STATIC_BINARIES,;t t
695 +s,@XMLSEC_CORE_CFLAGS@,$XMLSEC_CORE_CFLAGS,;t t
696 +s,@XMLSEC_CORE_LIBS@,$XMLSEC_CORE_LIBS,;t t
697 +s,@XMLSEC_LIBDIR@,$XMLSEC_LIBDIR,;t t
698 +s,@XMLSEC_OPENSSL_CFLAGS@,$XMLSEC_OPENSSL_CFLAGS,;t t
699 +s,@XMLSEC_OPENSSL_LIBS@,$XMLSEC_OPENSSL_LIBS,;t t
700 +s,@XMLSEC_GNUTLS_CFLAGS@,$XMLSEC_GNUTLS_CFLAGS,;t t
701 +s,@XMLSEC_GNUTLS_LIBS@,$XMLSEC_GNUTLS_LIBS,;t t
702 +s,@XMLSEC_NSS_CFLAGS@,$XMLSEC_NSS_CFLAGS,;t t
703 +s,@XMLSEC_NSS_LIBS@,$XMLSEC_NSS_LIBS,;t t
704 +s,@XMLSEC_CFLAGS@,$XMLSEC_CFLAGS,;t t
705 +s,@XMLSEC_LIBS@,$XMLSEC_LIBS,;t t
706 +s,@XMLSEC_DEFINES@,$XMLSEC_DEFINES,;t t
707 +s,@XMLSEC_APP_DEFINES@,$XMLSEC_APP_DEFINES,;t t
708 +s,@XMLSEC_CRYPTO@,$XMLSEC_CRYPTO,;t t
709 +s,@XMLSEC_CRYPTO_LIST@,$XMLSEC_CRYPTO_LIST,;t t
710 +s,@XMLSEC_CRYPTO_DISABLED_LIST@,$XMLSEC_CRYPTO_DISABLED_LIST,;t t
711 +s,@XMLSEC_CRYPTO_LIB@,$XMLSEC_CRYPTO_LIB,;t t
712 +s,@XMLSEC_CRYPTO_CFLAGS@,$XMLSEC_CRYPTO_CFLAGS,;t t
713 +s,@XMLSEC_CRYPTO_LIBS@,$XMLSEC_CRYPTO_LIBS,;t t
714 +s,@XMLSEC_CRYPTO_PC_FILES_LIST@,$XMLSEC_CRYPTO_PC_FILES_LIST,;t t
715 +s,@LIBOBJS@,$LIBOBJS,;t t
716 +s,@LTLIBOBJS@,$LTLIBOBJS,;t t
721 + cat >>$CONFIG_STATUS <<\_ACEOF
722 + # Split the substitutions into bite-sized pieces for seds with
723 + # small command number limits, like on Digital OSF/1 and HP-UX.
724 + ac_max_sed_lines=48
725 + ac_sed_frag=1 # Number of current file.
726 + ac_beg=1 # First line for current file.
727 + ac_end=$ac_max_sed_lines # Line after last line for current file.
730 + while $ac_more_lines; do
731 + if test $ac_beg -gt 1; then
732 + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
734 + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
736 + if test ! -s $tmp/subs.frag; then
737 + ac_more_lines=false
739 + # The purpose of the label and of the branching condition is to
740 + # speed up the sed processing (if there are no `@' at all, there
741 + # is no need to browse any of the substitutions).
742 + # These are the two extra sed commands mentioned above.
744 + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
745 + if test -z "$ac_sed_cmds"; then
746 + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
748 + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
750 + ac_sed_frag=`expr $ac_sed_frag + 1`
752 + ac_end=`expr $ac_end + $ac_max_sed_lines`
755 + if test -z "$ac_sed_cmds"; then
758 +fi # test -n "$CONFIG_FILES"
761 +cat >>$CONFIG_STATUS <<\_ACEOF
762 +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
763 + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
765 + - | *:- | *:-:* ) # input from stdin
767 + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
768 + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
769 + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
770 + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
771 + * ) ac_file_in=$ac_file.in ;;
774 + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
775 + ac_dir=`(dirname "$ac_file") 2>/dev/null ||
776 +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
777 + X"$ac_file" : 'X\(//\)[^/]' \| \
778 + X"$ac_file" : 'X\(//\)$' \| \
779 + X"$ac_file" : 'X\(/\)' \| \
780 + . : '\(.\)' 2>/dev/null ||
782 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
783 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
784 + /^X\(\/\/\)$/{ s//\1/; q; }
785 + /^X\(\/\).*/{ s//\1/; q; }
787 + { if $as_mkdir_p; then
792 + while test ! -d "$as_dir"; do
793 + as_dirs="$as_dir $as_dirs"
794 + as_dir=`(dirname "$as_dir") 2>/dev/null ||
795 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
796 + X"$as_dir" : 'X\(//\)[^/]' \| \
797 + X"$as_dir" : 'X\(//\)$' \| \
798 + X"$as_dir" : 'X\(/\)' \| \
799 + . : '\(.\)' 2>/dev/null ||
801 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
802 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
803 + /^X\(\/\/\)$/{ s//\1/; q; }
804 + /^X\(\/\).*/{ s//\1/; q; }
807 + test ! -n "$as_dirs" || mkdir $as_dirs
808 + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
809 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
810 + { (exit 1); exit 1; }; }; }
814 +if test "$ac_dir" != .; then
815 + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
816 + # A "../" for each directory in $ac_dir_suffix.
817 + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
819 + ac_dir_suffix= ac_top_builddir=
823 + .) # No --srcdir option. We are building in place.
825 + if test -z "$ac_top_builddir"; then
828 + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
830 + [\\/]* | ?:[\\/]* ) # Absolute path.
831 + ac_srcdir=$srcdir$ac_dir_suffix;
832 + ac_top_srcdir=$srcdir ;;
833 + *) # Relative path.
834 + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
835 + ac_top_srcdir=$ac_top_builddir$srcdir ;;
838 +# Do not use `cd foo && pwd` to compute absolute paths, because
839 +# the directories may not exist.
841 +.) ac_abs_builddir="$ac_dir";;
844 + .) ac_abs_builddir=`pwd`;;
845 + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
846 + *) ac_abs_builddir=`pwd`/"$ac_dir";;
849 +case $ac_abs_builddir in
850 +.) ac_abs_top_builddir=${ac_top_builddir}.;;
852 + case ${ac_top_builddir}. in
853 + .) ac_abs_top_builddir=$ac_abs_builddir;;
854 + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
855 + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
858 +case $ac_abs_builddir in
859 +.) ac_abs_srcdir=$ac_srcdir;;
862 + .) ac_abs_srcdir=$ac_abs_builddir;;
863 + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
864 + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
867 +case $ac_abs_builddir in
868 +.) ac_abs_top_srcdir=$ac_top_srcdir;;
870 + case $ac_top_srcdir in
871 + .) ac_abs_top_srcdir=$ac_abs_builddir;;
872 + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
873 + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
879 + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
880 + *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
883 + if test x"$ac_file" != x-; then
884 + { echo "$as_me:$LINENO: creating $ac_file" >&5
885 +echo "$as_me: creating $ac_file" >&6;}
888 + # Let's still pretend it is `configure' which instantiates (i.e., don't
889 + # use $as_me), people would be surprised to read:
890 + # /* config.h. Generated by config.status. */
891 + if test x"$ac_file" = x-; then
894 + configure_input="$ac_file. "
896 + configure_input=$configure_input"Generated from `echo $ac_file_in |
897 + sed 's,.*/,,'` by configure."
899 + # First look for the input files in the build tree, otherwise in the
901 + ac_file_inputs=`IFS=:
902 + for f in $ac_file_in; do
904 + -) echo $tmp/stdin ;;
906 + # Absolute (can't be DOS-style, as IFS=:)
907 + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
908 +echo "$as_me: error: cannot find input file: $f" >&2;}
909 + { (exit 1); exit 1; }; }
912 + if test -f "$f"; then
915 + elif test -f "$srcdir/$f"; then
920 + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
921 +echo "$as_me: error: cannot find input file: $f" >&2;}
922 + { (exit 1); exit 1; }; }
925 + done` || { (exit 1); exit 1; }
927 +cat >>$CONFIG_STATUS <<_ACEOF
931 +cat >>$CONFIG_STATUS <<\_ACEOF
933 +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
934 +s,@configure_input@,$configure_input,;t t
935 +s,@srcdir@,$ac_srcdir,;t t
936 +s,@abs_srcdir@,$ac_abs_srcdir,;t t
937 +s,@top_srcdir@,$ac_top_srcdir,;t t
938 +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
939 +s,@builddir@,$ac_builddir,;t t
940 +s,@abs_builddir@,$ac_abs_builddir,;t t
941 +s,@top_builddir@,$ac_top_builddir,;t t
942 +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
943 +s,@INSTALL@,$ac_INSTALL,;t t
944 +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
946 + if test x"$ac_file" != x-; then
947 + mv $tmp/out $ac_file
955 +cat >>$CONFIG_STATUS <<\_ACEOF
958 +# CONFIG_HEADER section.
961 +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
962 +# NAME is the cpp macro being defined and VALUE is the value it is being given.
964 +# ac_d sets the value in "#define NAME VALUE" lines.
965 +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
966 +ac_dB='[ ].*$,\1#\2'
969 +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
970 +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
971 +ac_uB='$,\1#\2define\3'
975 +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
976 + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
978 + - | *:- | *:-:* ) # input from stdin
980 + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
981 + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
982 + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
983 + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
984 + * ) ac_file_in=$ac_file.in ;;
987 + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
988 +echo "$as_me: creating $ac_file" >&6;}
990 + # First look for the input files in the build tree, otherwise in the
992 + ac_file_inputs=`IFS=:
993 + for f in $ac_file_in; do
995 + -) echo $tmp/stdin ;;
997 + # Absolute (can't be DOS-style, as IFS=:)
998 + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
999 +echo "$as_me: error: cannot find input file: $f" >&2;}
1000 + { (exit 1); exit 1; }; }
1001 + # Do quote $f, to prevent DOS paths from being IFS'd.
1004 + if test -f "$f"; then
1007 + elif test -f "$srcdir/$f"; then
1012 + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
1013 +echo "$as_me: error: cannot find input file: $f" >&2;}
1014 + { (exit 1); exit 1; }; }
1017 + done` || { (exit 1); exit 1; }
1018 + # Remove the trailing spaces.
1019 + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
1023 +# Transform confdefs.h into two sed scripts, `conftest.defines' and
1024 +# `conftest.undefs', that substitutes the proper values into
1025 +# config.h.in to produce config.h. The first handles `#define'
1026 +# templates, and the second `#undef' templates.
1027 +# And first: Protect against being on the right side of a sed subst in
1028 +# config.status. Protect against being in an unquoted here document
1029 +# in config.status.
1030 +rm -f conftest.defines conftest.undefs
1031 +# Using a here document instead of a string reduces the quoting nightmare.
1032 +# Putting comments in sed scripts is not portable.
1034 +# `end' is used to avoid that the second main sed command (meant for
1035 +# 0-ary CPP macros) applies to n-ary macro definitions.
1036 +# See the Autoconf documentation for `clear'.
1037 +cat >confdef2sed.sed <<\_ACEOF
1042 +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
1044 +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
1047 +# If some macros were called several times there might be several times
1048 +# the same #defines, which is useless. Nevertheless, we may not want to
1049 +# sort them, since we want the *last* AC-DEFINE to be honored.
1050 +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
1051 +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
1052 +rm -f confdef2sed.sed
1054 +# This sed command replaces #undef with comments. This is necessary, for
1055 +# example, in the case of _POSIX_SOURCE, which is predefined and required
1056 +# on some systems where configure will not decide to define it.
1057 +cat >>conftest.undefs <<\_ACEOF
1058 +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
1061 +# Break up conftest.defines because some shells have a limit on the size
1062 +# of here documents, and old seds have small limits too (100 cmds).
1063 +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
1064 +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
1065 +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
1066 +echo ' :' >>$CONFIG_STATUS
1067 +rm -f conftest.tail
1068 +while grep . conftest.defines >/dev/null
1070 + # Write a limited-size here document to $tmp/defines.sed.
1071 + echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
1072 + # Speed up: don't consider the non `#define' lines.
1073 + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
1074 + # Work around the forget-to-reset-the-flag bug.
1075 + echo 't clr' >>$CONFIG_STATUS
1076 + echo ': clr' >>$CONFIG_STATUS
1077 + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
1079 + sed -f $tmp/defines.sed $tmp/in >$tmp/out
1081 + mv $tmp/out $tmp/in
1083 + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
1084 + rm -f conftest.defines
1085 + mv conftest.tail conftest.defines
1087 +rm -f conftest.defines
1088 +echo ' fi # grep' >>$CONFIG_STATUS
1089 +echo >>$CONFIG_STATUS
1091 +# Break up conftest.undefs because some shells have a limit on the size
1092 +# of here documents, and old seds have small limits too (100 cmds).
1093 +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
1094 +rm -f conftest.tail
1095 +while grep . conftest.undefs >/dev/null
1097 + # Write a limited-size here document to $tmp/undefs.sed.
1098 + echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
1099 + # Speed up: don't consider the non `#undef'
1100 + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
1101 + # Work around the forget-to-reset-the-flag bug.
1102 + echo 't clr' >>$CONFIG_STATUS
1103 + echo ': clr' >>$CONFIG_STATUS
1104 + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
1106 + sed -f $tmp/undefs.sed $tmp/in >$tmp/out
1108 + mv $tmp/out $tmp/in
1110 + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
1111 + rm -f conftest.undefs
1112 + mv conftest.tail conftest.undefs
1114 +rm -f conftest.undefs
1116 +cat >>$CONFIG_STATUS <<\_ACEOF
1117 + # Let's still pretend it is `configure' which instantiates (i.e., don't
1118 + # use $as_me), people would be surprised to read:
1119 + # /* config.h. Generated by config.status. */
1120 + if test x"$ac_file" = x-; then
1121 + echo "/* Generated by configure. */" >$tmp/config.h
1123 + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
1125 + cat $tmp/in >>$tmp/config.h
1127 + if test x"$ac_file" != x-; then
1128 + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
1129 + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
1130 +echo "$as_me: $ac_file is unchanged" >&6;}
1132 + ac_dir=`(dirname "$ac_file") 2>/dev/null ||
1133 +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1134 + X"$ac_file" : 'X\(//\)[^/]' \| \
1135 + X"$ac_file" : 'X\(//\)$' \| \
1136 + X"$ac_file" : 'X\(/\)' \| \
1137 + . : '\(.\)' 2>/dev/null ||
1139 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1140 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1141 + /^X\(\/\/\)$/{ s//\1/; q; }
1142 + /^X\(\/\).*/{ s//\1/; q; }
1144 + { if $as_mkdir_p; then
1145 + mkdir -p "$ac_dir"
1149 + while test ! -d "$as_dir"; do
1150 + as_dirs="$as_dir $as_dirs"
1151 + as_dir=`(dirname "$as_dir") 2>/dev/null ||
1152 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1153 + X"$as_dir" : 'X\(//\)[^/]' \| \
1154 + X"$as_dir" : 'X\(//\)$' \| \
1155 + X"$as_dir" : 'X\(/\)' \| \
1156 + . : '\(.\)' 2>/dev/null ||
1158 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1159 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1160 + /^X\(\/\/\)$/{ s//\1/; q; }
1161 + /^X\(\/\).*/{ s//\1/; q; }
1164 + test ! -n "$as_dirs" || mkdir $as_dirs
1165 + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
1166 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
1167 + { (exit 1); exit 1; }; }; }
1170 + mv $tmp/config.h $ac_file
1174 + rm -f $tmp/config.h
1176 +# Compute $ac_file's index in $config_headers.
1178 +for _am_header in $config_headers :; do
1179 + case $_am_header in
1180 + $ac_file | $ac_file:* )
1183 + _am_stamp_count=`expr $_am_stamp_count + 1` ;;
1186 +echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
1187 +$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1188 + X$ac_file : 'X\(//\)[^/]' \| \
1189 + X$ac_file : 'X\(//\)$' \| \
1190 + X$ac_file : 'X\(/\)' \| \
1191 + . : '\(.\)' 2>/dev/null ||
1193 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1194 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1195 + /^X\(\/\/\)$/{ s//\1/; q; }
1196 + /^X\(\/\).*/{ s//\1/; q; }
1197 + s/.*/./; q'`/stamp-h$_am_stamp_count
1200 +cat >>$CONFIG_STATUS <<\_ACEOF
1203 +# CONFIG_COMMANDS section.
1205 +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
1206 + ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
1207 + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
1208 + ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
1209 +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1210 + X"$ac_dest" : 'X\(//\)[^/]' \| \
1211 + X"$ac_dest" : 'X\(//\)$' \| \
1212 + X"$ac_dest" : 'X\(/\)' \| \
1213 + . : '\(.\)' 2>/dev/null ||
1215 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1216 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1217 + /^X\(\/\/\)$/{ s//\1/; q; }
1218 + /^X\(\/\).*/{ s//\1/; q; }
1220 + { if $as_mkdir_p; then
1221 + mkdir -p "$ac_dir"
1225 + while test ! -d "$as_dir"; do
1226 + as_dirs="$as_dir $as_dirs"
1227 + as_dir=`(dirname "$as_dir") 2>/dev/null ||
1228 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1229 + X"$as_dir" : 'X\(//\)[^/]' \| \
1230 + X"$as_dir" : 'X\(//\)$' \| \
1231 + X"$as_dir" : 'X\(/\)' \| \
1232 + . : '\(.\)' 2>/dev/null ||
1234 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1235 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1236 + /^X\(\/\/\)$/{ s//\1/; q; }
1237 + /^X\(\/\).*/{ s//\1/; q; }
1240 + test ! -n "$as_dirs" || mkdir $as_dirs
1241 + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
1242 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
1243 + { (exit 1); exit 1; }; }; }
1247 +if test "$ac_dir" != .; then
1248 + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
1249 + # A "../" for each directory in $ac_dir_suffix.
1250 + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
1252 + ac_dir_suffix= ac_top_builddir=
1256 + .) # No --srcdir option. We are building in place.
1258 + if test -z "$ac_top_builddir"; then
1261 + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
1263 + [\\/]* | ?:[\\/]* ) # Absolute path.
1264 + ac_srcdir=$srcdir$ac_dir_suffix;
1265 + ac_top_srcdir=$srcdir ;;
1266 + *) # Relative path.
1267 + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
1268 + ac_top_srcdir=$ac_top_builddir$srcdir ;;
1271 +# Do not use `cd foo && pwd` to compute absolute paths, because
1272 +# the directories may not exist.
1274 +.) ac_abs_builddir="$ac_dir";;
1277 + .) ac_abs_builddir=`pwd`;;
1278 + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
1279 + *) ac_abs_builddir=`pwd`/"$ac_dir";;
1282 +case $ac_abs_builddir in
1283 +.) ac_abs_top_builddir=${ac_top_builddir}.;;
1285 + case ${ac_top_builddir}. in
1286 + .) ac_abs_top_builddir=$ac_abs_builddir;;
1287 + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
1288 + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
1291 +case $ac_abs_builddir in
1292 +.) ac_abs_srcdir=$ac_srcdir;;
1294 + case $ac_srcdir in
1295 + .) ac_abs_srcdir=$ac_abs_builddir;;
1296 + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
1297 + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
1300 +case $ac_abs_builddir in
1301 +.) ac_abs_top_srcdir=$ac_top_srcdir;;
1303 + case $ac_top_srcdir in
1304 + .) ac_abs_top_srcdir=$ac_abs_builddir;;
1305 + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
1306 + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
1311 + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
1312 +echo "$as_me: executing $ac_dest commands" >&6;}
1314 + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
1315 + # Strip MF so we end up with the name of the file.
1316 + mf=`echo "$mf" | sed -e 's/:.*$//'`
1317 + # Check whether this is an Automake generated Makefile or not.
1318 + # We used to match only the files named `Makefile.in', but
1319 + # some people rename them; so instead we look at the file content.
1320 + # Grep'ing the first line is not enough: some people post-process
1321 + # each Makefile.in and add a new line on top of each file to say so.
1322 + # So let's grep whole file.
1323 + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
1324 + dirpart=`(dirname "$mf") 2>/dev/null ||
1325 +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1326 + X"$mf" : 'X\(//\)[^/]' \| \
1327 + X"$mf" : 'X\(//\)$' \| \
1328 + X"$mf" : 'X\(/\)' \| \
1329 + . : '\(.\)' 2>/dev/null ||
1331 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1332 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1333 + /^X\(\/\/\)$/{ s//\1/; q; }
1334 + /^X\(\/\).*/{ s//\1/; q; }
1339 + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
1340 + # Extract the definition of DEP_FILES from the Makefile without
1342 + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
1343 + test -z "$DEPDIR" && continue
1344 + # When using ansi2knr, U may be empty or an underscore; expand it
1345 + U=`sed -n 's/^U = //p' < "$mf"`
1346 + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
1347 + # We invoke sed twice because it is the simplest approach to
1348 + # changing $(DEPDIR) to its actual value in the expansion.
1349 + for file in `sed -n '
1350 + /^DEP_FILES = .*\\\\$/ {
1359 + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
1360 + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
1361 + # Make sure the directory exists.
1362 + test -f "$dirpart/$file" && continue
1363 + fdir=`(dirname "$file") 2>/dev/null ||
1364 +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1365 + X"$file" : 'X\(//\)[^/]' \| \
1366 + X"$file" : 'X\(//\)$' \| \
1367 + X"$file" : 'X\(/\)' \| \
1368 + . : '\(.\)' 2>/dev/null ||
1370 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1371 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1372 + /^X\(\/\/\)$/{ s//\1/; q; }
1373 + /^X\(\/\).*/{ s//\1/; q; }
1375 + { if $as_mkdir_p; then
1376 + mkdir -p $dirpart/$fdir
1378 + as_dir=$dirpart/$fdir
1380 + while test ! -d "$as_dir"; do
1381 + as_dirs="$as_dir $as_dirs"
1382 + as_dir=`(dirname "$as_dir") 2>/dev/null ||
1383 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1384 + X"$as_dir" : 'X\(//\)[^/]' \| \
1385 + X"$as_dir" : 'X\(//\)$' \| \
1386 + X"$as_dir" : 'X\(/\)' \| \
1387 + . : '\(.\)' 2>/dev/null ||
1389 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
1390 + /^X\(\/\/\)[^/].*/{ s//\1/; q; }
1391 + /^X\(\/\/\)$/{ s//\1/; q; }
1392 + /^X\(\/\).*/{ s//\1/; q; }
1395 + test ! -n "$as_dirs" || mkdir $as_dirs
1396 + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
1397 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
1398 + { (exit 1); exit 1; }; }; }
1400 + # echo "creating $dirpart/$file"
1401 + echo '# dummy' > "$dirpart/$file"
1409 +cat >>$CONFIG_STATUS <<\_ACEOF
1411 +{ (exit 0); exit 0; }
1413 +chmod +x $CONFIG_STATUS
1414 +ac_clean_files=$ac_clean_files_save
1417 +# configure is writing to config.log, and then calls config.status.
1418 +# config.status does its own redirection, appending to config.log.
1419 +# Unfortunately, on DOS this fails, as config.log is still kept open
1420 +# by configure, so config.status won't be able to write to it; its
1421 +# output is simply discarded. So we exec the FD to /dev/null,
1422 +# effectively closing config.log, so it can be properly (re)opened and
1423 +# appended to by config.status. When coming back to configure, we
1424 +# need to make the FD available again.
1425 +if test "$no_create" != yes; then
1427 + ac_config_status_args=
1428 + test "$silent" = yes &&
1429 + ac_config_status_args="$ac_config_status_args --quiet"
1431 + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
1432 + exec 5>>config.log
1433 + # Use ||, not &&, to avoid exiting from the if with $? = 1, which
1434 + # would make configure fail if this is the last instruction.
1435 + $ac_cs_success || { (exit 1); exit 1; }
1440 +if test "z$MSCRYPTO_FOUND" = "zyes" ; then
1441 + ac_config_files="$ac_config_files include/xmlsec/mscrypto/Makefile src/mscrypto/Makefile"
1442 +cat >confcache <<\_ACEOF
1443 +# This file is a shell script that caches the results of configure
1444 +# tests run on this system so they can be shared between configure
1445 +# scripts and configure runs, see configure's option --config-cache.
1446 +# It is not useful on other systems. If it contains results you don't
1447 +# want to keep, you may remove or edit it.
1449 +# config.status only pays attention to the cache file if you give it
1450 +# the --recheck option to rerun configure.
1452 +# `ac_cv_env_foo' variables (set or unset) will be overridden when
1453 +# loading this file, other *unset* `ac_cv_foo' will be assigned the
1454 +# following values.
1458 +# The following way of writing the cache mishandles newlines in values,
1459 +# but we know of no workaround that is simple, portable, and efficient.
1460 +# So, don't put newlines in cache variables' values.
1461 +# Ultrix sh set writes to stderr and can't be redirected directly,
1462 +# and sets the high bit in the cache file unless we assign to the vars.
1465 + case `(ac_space=' '; set | grep ac_space) 2>&1` in
1467 + # `set' does not quote correctly, so add quotes (double-quote
1468 + # substitution turns \\\\ into \\, and sed turns \\ into \).
1471 + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
1474 + # `set' quotes correctly as required by POSIX, so do not add quotes.
1476 + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
1483 + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
1485 + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
1486 + : end' >>confcache
1487 +if diff $cache_file confcache >/dev/null 2>&1; then :; else
1488 + if test -w $cache_file; then
1489 + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
1490 + cat confcache >$cache_file
1492 + echo "not updating unwritable cache $cache_file"
1497 +test "x$prefix" = xNONE && prefix=$ac_default_prefix
1498 +# Let make expand exec_prefix.
1499 +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
1501 +# VPATH may cause trouble with some makes, so we remove $(srcdir),
1502 +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
1503 +# trailing colons and then remove the whole line if VPATH becomes empty
1504 +# (actually we leave an empty line to preserve line numbers).
1505 +if test "x$srcdir" = x.; then
1506 + ac_vpsub='/^[ ]*VPATH[ ]*=/{
1507 +s/:*\$(srcdir):*/:/;
1508 +s/:*\${srcdir}:*/:/;
1510 +s/^\([^=]*=[ ]*\):*/\1/;
1516 +DEFS=-DHAVE_CONFIG_H
1520 +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
1521 + # 1. Remove the extension, and $U if already installed.
1522 + ac_i=`echo "$ac_i" |
1523 + sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
1525 + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
1526 + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
1528 +LIBOBJS=$ac_libobjs
1530 +LTLIBOBJS=$ac_ltlibobjs
1533 +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
1534 + { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
1535 +Usually this means the macro was only invoked conditionally." >&5
1536 +echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
1537 +Usually this means the macro was only invoked conditionally." >&2;}
1538 + { (exit 1); exit 1; }; }
1540 +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
1541 + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
1542 +Usually this means the macro was only invoked conditionally." >&5
1543 +echo "$as_me: error: conditional \"AMDEP\" was never defined.
1544 +Usually this means the macro was only invoked conditionally." >&2;}
1545 + { (exit 1); exit 1; }; }
1547 +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
1548 + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
1549 +Usually this means the macro was only invoked conditionally." >&5
1550 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
1551 +Usually this means the macro was only invoked conditionally." >&2;}
1552 + { (exit 1); exit 1; }; }
1554 +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
1555 + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
1556 +Usually this means the macro was only invoked conditionally." >&5
1557 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
1558 +Usually this means the macro was only invoked conditionally." >&2;}
1559 + { (exit 1); exit 1; }; }
1561 +if test -z "${INSTALL_LTDL_TRUE}" && test -z "${INSTALL_LTDL_FALSE}"; then
1562 + { { echo "$as_me:$LINENO: error: conditional \"INSTALL_LTDL\" was never defined.
1563 +Usually this means the macro was only invoked conditionally." >&5
1564 +echo "$as_me: error: conditional \"INSTALL_LTDL\" was never defined.
1565 +Usually this means the macro was only invoked conditionally." >&2;}
1566 + { (exit 1); exit 1; }; }
1568 +if test -z "${CONVENIENCE_LTDL_TRUE}" && test -z "${CONVENIENCE_LTDL_FALSE}"; then
1569 + { { echo "$as_me:$LINENO: error: conditional \"CONVENIENCE_LTDL\" was never defined.
1570 +Usually this means the macro was only invoked conditionally." >&5
1571 +echo "$as_me: error: conditional \"CONVENIENCE_LTDL\" was never defined.
1572 +Usually this means the macro was only invoked conditionally." >&2;}
1573 + { (exit 1); exit 1; }; }
1575 +if test -z "${XMLSEC_NO_OPENSSL_TRUE}" && test -z "${XMLSEC_NO_OPENSSL_FALSE}"; then
1576 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_OPENSSL\" was never defined.
1577 +Usually this means the macro was only invoked conditionally." >&5
1578 +echo "$as_me: error: conditional \"XMLSEC_NO_OPENSSL\" was never defined.
1579 +Usually this means the macro was only invoked conditionally." >&2;}
1580 + { (exit 1); exit 1; }; }
1582 +if test -z "${XMLSEC_NO_GNUTLS_TRUE}" && test -z "${XMLSEC_NO_GNUTLS_FALSE}"; then
1583 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_GNUTLS\" was never defined.
1584 +Usually this means the macro was only invoked conditionally." >&5
1585 +echo "$as_me: error: conditional \"XMLSEC_NO_GNUTLS\" was never defined.
1586 +Usually this means the macro was only invoked conditionally." >&2;}
1587 + { (exit 1); exit 1; }; }
1589 +if test -z "${XMLSEC_NO_NSS_TRUE}" && test -z "${XMLSEC_NO_NSS_FALSE}"; then
1590 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_NSS\" was never defined.
1591 +Usually this means the macro was only invoked conditionally." >&5
1592 +echo "$as_me: error: conditional \"XMLSEC_NO_NSS\" was never defined.
1593 +Usually this means the macro was only invoked conditionally." >&2;}
1594 + { (exit 1); exit 1; }; }
1596 +if test -z "${XMLSEC_NO_SHA1_TRUE}" && test -z "${XMLSEC_NO_SHA1_FALSE}"; then
1597 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_SHA1\" was never defined.
1598 +Usually this means the macro was only invoked conditionally." >&5
1599 +echo "$as_me: error: conditional \"XMLSEC_NO_SHA1\" was never defined.
1600 +Usually this means the macro was only invoked conditionally." >&2;}
1601 + { (exit 1); exit 1; }; }
1603 +if test -z "${XMLSEC_NO_RIPEMD160_TRUE}" && test -z "${XMLSEC_NO_RIPEMD160_FALSE}"; then
1604 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_RIPEMD160\" was never defined.
1605 +Usually this means the macro was only invoked conditionally." >&5
1606 +echo "$as_me: error: conditional \"XMLSEC_NO_RIPEMD160\" was never defined.
1607 +Usually this means the macro was only invoked conditionally." >&2;}
1608 + { (exit 1); exit 1; }; }
1610 +if test -z "${XMLSEC_NO_HMAC_TRUE}" && test -z "${XMLSEC_NO_HMAC_FALSE}"; then
1611 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_HMAC\" was never defined.
1612 +Usually this means the macro was only invoked conditionally." >&5
1613 +echo "$as_me: error: conditional \"XMLSEC_NO_HMAC\" was never defined.
1614 +Usually this means the macro was only invoked conditionally." >&2;}
1615 + { (exit 1); exit 1; }; }
1617 +if test -z "${XMLSEC_NO_DSA_TRUE}" && test -z "${XMLSEC_NO_DSA_FALSE}"; then
1618 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_DSA\" was never defined.
1619 +Usually this means the macro was only invoked conditionally." >&5
1620 +echo "$as_me: error: conditional \"XMLSEC_NO_DSA\" was never defined.
1621 +Usually this means the macro was only invoked conditionally." >&2;}
1622 + { (exit 1); exit 1; }; }
1624 +if test -z "${XMLSEC_NO_RSA_TRUE}" && test -z "${XMLSEC_NO_RSA_FALSE}"; then
1625 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_RSA\" was never defined.
1626 +Usually this means the macro was only invoked conditionally." >&5
1627 +echo "$as_me: error: conditional \"XMLSEC_NO_RSA\" was never defined.
1628 +Usually this means the macro was only invoked conditionally." >&2;}
1629 + { (exit 1); exit 1; }; }
1631 +if test -z "${XMLSEC_NO_X509_TRUE}" && test -z "${XMLSEC_NO_X509_FALSE}"; then
1632 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_X509\" was never defined.
1633 +Usually this means the macro was only invoked conditionally." >&5
1634 +echo "$as_me: error: conditional \"XMLSEC_NO_X509\" was never defined.
1635 +Usually this means the macro was only invoked conditionally." >&2;}
1636 + { (exit 1); exit 1; }; }
1638 +if test -z "${XMLSEC_NO_DES_TRUE}" && test -z "${XMLSEC_NO_DES_FALSE}"; then
1639 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_DES\" was never defined.
1640 +Usually this means the macro was only invoked conditionally." >&5
1641 +echo "$as_me: error: conditional \"XMLSEC_NO_DES\" was never defined.
1642 +Usually this means the macro was only invoked conditionally." >&2;}
1643 + { (exit 1); exit 1; }; }
1645 +if test -z "${XMLSEC_NO_AES_TRUE}" && test -z "${XMLSEC_NO_AES_FALSE}"; then
1646 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_AES\" was never defined.
1647 +Usually this means the macro was only invoked conditionally." >&5
1648 +echo "$as_me: error: conditional \"XMLSEC_NO_AES\" was never defined.
1649 +Usually this means the macro was only invoked conditionally." >&2;}
1650 + { (exit 1); exit 1; }; }
1652 +if test -z "${XMLSEC_NO_XMLDSIG_TRUE}" && test -z "${XMLSEC_NO_XMLDSIG_FALSE}"; then
1653 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_XMLDSIG\" was never defined.
1654 +Usually this means the macro was only invoked conditionally." >&5
1655 +echo "$as_me: error: conditional \"XMLSEC_NO_XMLDSIG\" was never defined.
1656 +Usually this means the macro was only invoked conditionally." >&2;}
1657 + { (exit 1); exit 1; }; }
1659 +if test -z "${XMLSEC_NO_XMLENC_TRUE}" && test -z "${XMLSEC_NO_XMLENC_FALSE}"; then
1660 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_XMLENC\" was never defined.
1661 +Usually this means the macro was only invoked conditionally." >&5
1662 +echo "$as_me: error: conditional \"XMLSEC_NO_XMLENC\" was never defined.
1663 +Usually this means the macro was only invoked conditionally." >&2;}
1664 + { (exit 1); exit 1; }; }
1666 +if test -z "${XMLSEC_NO_XKMS_TRUE}" && test -z "${XMLSEC_NO_XKMS_FALSE}"; then
1667 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_XKMS\" was never defined.
1668 +Usually this means the macro was only invoked conditionally." >&5
1669 +echo "$as_me: error: conditional \"XMLSEC_NO_XKMS\" was never defined.
1670 +Usually this means the macro was only invoked conditionally." >&2;}
1671 + { (exit 1); exit 1; }; }
1673 +if test -z "${XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_TRUE}" && test -z "${XMLSEC_NO_CRYPTO_DYNAMIC_LOADING_FALSE}"; then
1674 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_CRYPTO_DYNAMIC_LOADING\" was never defined.
1675 +Usually this means the macro was only invoked conditionally." >&5
1676 +echo "$as_me: error: conditional \"XMLSEC_NO_CRYPTO_DYNAMIC_LOADING\" was never defined.
1677 +Usually this means the macro was only invoked conditionally." >&2;}
1678 + { (exit 1); exit 1; }; }
1680 +if test -z "${XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_TRUE}" && test -z "${XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING_FALSE}"; then
1681 + { { echo "$as_me:$LINENO: error: conditional \"XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING\" was never defined.
1682 +Usually this means the macro was only invoked conditionally." >&5
1683 +echo "$as_me: error: conditional \"XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING\" was never defined.
1684 +Usually this means the macro was only invoked conditionally." >&2;}
1685 + { (exit 1); exit 1; }; }
1688 +: ${CONFIG_STATUS=./config.status}
1689 +ac_clean_files_save=$ac_clean_files
1690 +ac_clean_files="$ac_clean_files $CONFIG_STATUS"
1691 +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
1692 +echo "$as_me: creating $CONFIG_STATUS" >&6;}
1693 +cat >$CONFIG_STATUS <<_ACEOF
1695 +# Generated by $as_me.
1696 +# Run this file to recreate the current configuration.
1697 +# Compiler output produced by configure, useful for debugging
1698 +# configure, is in config.log if it exists.
1701 +ac_cs_recheck=false
1703 +SHELL=\${CONFIG_SHELL-$SHELL}
1706 +cat >>$CONFIG_STATUS <<\_ACEOF
1707 +## --------------------- ##
1708 +## M4sh Initialization. ##
1709 +## --------------------- ##
1711 +# Be Bourne compatible
1712 +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
1715 + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
1716 + # is contrary to our usage. Disable this feature.
1717 + alias -g '${1+"$@"}'='"$@"'
1718 +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
1721 +DUALCASE=1; export DUALCASE # for MKS sh
1723 +# Support unset when possible.
1724 +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
1731 +# Work around bugs in pre-3.0 UWIN ksh.
1732 +$as_unset ENV MAIL MAILPATH
1739 + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
1740 + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
1741 + LC_TELEPHONE LC_TIME
1743 + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
1744 + eval $as_var=C; export $as_var
1750 +# Required to use basename.
1751 +if expr a : '\(a\)' >/dev/null 2>&1; then
1757 +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
1758 + as_basename=basename
1764 +# Name of the executable.
1765 +as_me=`$as_basename "$0" ||
1766 +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
1767 + X"$0" : 'X\(//\)$' \| \
1768 + X"$0" : 'X\(/\)$' \| \
1769 + . : '\(.\)' 2>/dev/null ||
1771 + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
1772 + /^X\/\(\/\/\)$/{ s//\1/; q; }
1773 + /^X\/\(\/\).*/{ s//\1/; q; }
1777 +# PATH needs CR, and LINENO needs CR and PATH.
1778 +# Avoid depending upon Character Ranges.
1779 +as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1780 +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1781 +as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1782 +as_cr_digits='0123456789'
1783 +as_cr_alnum=$as_cr_Letters$as_cr_digits
1785 +# The user is always right.
1786 +if test "${PATH_SEPARATOR+set}" != set; then
1787 + echo "#! /bin/sh" >conf$$.sh
1788 + echo "exit 0" >>conf$$.sh
1789 + chmod +x conf$$.sh
1790 + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
1791 + PATH_SEPARATOR=';'
1799 + as_lineno_1=$LINENO
1800 + as_lineno_2=$LINENO
1801 + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
1802 + test "x$as_lineno_1" != "x$as_lineno_2" &&
1803 + test "x$as_lineno_3" = "x$as_lineno_2" || {
1804 + # Find who we are. Look in the path if we contain no path at all
1805 + # relative or not.
1807 + *[\\/]* ) as_myself=$0 ;;
1808 + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1809 +for as_dir in $PATH
1812 + test -z "$as_dir" && as_dir=.
1813 + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
1818 + # We did not find ourselves, most probably we were run as `sh COMMAND'
1819 + # in which case we are not to be found in the path.
1820 + if test "x$as_myself" = x; then
1823 + if test ! -f "$as_myself"; then
1824 + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
1825 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
1826 + { (exit 1); exit 1; }; }
1828 + case $CONFIG_SHELL in
1830 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1831 +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
1834 + test -z "$as_dir" && as_dir=.
1835 + for as_base in sh bash ksh sh5; do
1838 + if ("$as_dir/$as_base" -c '
1839 + as_lineno_1=$LINENO
1840 + as_lineno_2=$LINENO
1841 + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
1842 + test "x$as_lineno_1" != "x$as_lineno_2" &&
1843 + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
1844 + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
1845 + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
1846 + CONFIG_SHELL=$as_dir/$as_base
1847 + export CONFIG_SHELL
1848 + exec "$CONFIG_SHELL" "$0" ${1+"$@"}
1856 + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
1857 + # uniformly replaced by the line number. The first 'sed' inserts a
1858 + # line-number line before each line; the second 'sed' does the real
1859 + # work. The second script uses 'N' to pair each line-number line
1860 + # with the numbered line, and appends trailing '-' during
1861 + # substitution so that $LINENO is not a special case at line end.
1862 + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
1863 + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
1864 + sed '=' <$as_myself |
1869 + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
1872 + s,^['$as_cr_digits']*\n,,
1873 + ' >$as_me.lineno &&
1874 + chmod +x $as_me.lineno ||
1875 + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
1876 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
1877 + { (exit 1); exit 1; }; }
1879 + # Don't try to exec as it changes $[0], causing all sort of problems
1880 + # (the dirname of $[0] is not the place where we might find the
1881 + # original and so on. Autoconf is especially sensible to this).
1883 + # Exit status is that of the last command.
1888 +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
1889 + *c*,-n*) ECHO_N= ECHO_C='
1891 + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
1892 + *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
1895 +if expr a : '\(a\)' >/dev/null 2>&1; then
1901 +rm -f conf$$ conf$$.exe conf$$.file
1903 +if ln -s conf$$.file conf$$ 2>/dev/null; then
1904 + # We could just check for DJGPP; but this test a) works b) is more generic
1905 + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
1906 + if test -f conf$$.exe; then
1907 + # Don't use ln at all; we don't have any links
1912 +elif ln conf$$.file conf$$ 2>/dev/null; then
1917 +rm -f conf$$ conf$$.exe conf$$.file
1919 +if mkdir -p . 2>/dev/null; then
1922 + test -d ./-p && rmdir ./-p
1926 +as_executable_p="test -f"
1928 +# Sed expression to map a string onto a valid CPP name.
1929 +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
1931 +# Sed expression to map a string onto a valid variable name.
1932 +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
1936 +# We need space, tab and new line, in precisely that order.
1946 +# Open the log real soon, to keep \$[0] and so on meaningful, and to
1947 +# report actual input values of CONFIG_FILES etc. instead of their
1948 +# values after options handling. Logging --version etc. is OK.
1952 + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
1953 +## Running $as_me. ##
1958 +This file was extended by $as_me, which was
1959 +generated by GNU Autoconf 2.59. Invocation command line was
1961 + CONFIG_FILES = $CONFIG_FILES
1962 + CONFIG_HEADERS = $CONFIG_HEADERS
1963 + CONFIG_LINKS = $CONFIG_LINKS
1964 + CONFIG_COMMANDS = $CONFIG_COMMANDS
1968 +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
1972 +# Files that config.status was made for.
1973 +if test -n "$ac_config_files"; then
1974 + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
1977 +if test -n "$ac_config_headers"; then
1978 + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
1981 +if test -n "$ac_config_links"; then
1982 + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
1985 +if test -n "$ac_config_commands"; then
1986 + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
1989 +cat >>$CONFIG_STATUS <<\_ACEOF
1992 +\`$as_me' instantiates files from templates according to the
1993 +current configuration.
1995 +Usage: $0 [OPTIONS] [FILE]...
1997 + -h, --help print this help, then exit
1998 + -V, --version print version number, then exit
1999 + -q, --quiet do not print progress messages
2000 + -d, --debug don't remove temporary files
2001 + --recheck update $as_me by reconfiguring in the same conditions
2002 + --file=FILE[:TEMPLATE]
2003 + instantiate the configuration file FILE
2004 + --header=FILE[:TEMPLATE]
2005 + instantiate the configuration header FILE
2007 +Configuration files:
2010 +Configuration headers:
2013 +Configuration commands:
2016 +Report bugs to <bug-autoconf@gnu.org>."
2019 +cat >>$CONFIG_STATUS <<_ACEOF
2022 +configured by $0, generated by GNU Autoconf 2.59,
2023 + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
2025 +Copyright (C) 2003 Free Software Foundation, Inc.
2026 +This config.status script is free software; the Free Software Foundation
2027 +gives unlimited permission to copy, distribute and modify it."
2032 +cat >>$CONFIG_STATUS <<\_ACEOF
2033 +# If no file are specified by the user, then we need to provide default
2034 +# value. By we need to know if files were specified by the user.
2040 + ac_option=`expr "x$1" : 'x\([^=]*\)='`
2041 + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
2049 + *) # This is not an option, so the user has probably given explicit
2052 + ac_need_defaults=false;;
2055 + case $ac_option in
2056 + # Handling of the options.
2058 +cat >>$CONFIG_STATUS <<\_ACEOF
2059 + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
2060 + ac_cs_recheck=: ;;
2061 + --version | --vers* | -V )
2062 + echo "$ac_cs_version"; exit 0 ;;
2064 + # Conflict between --help and --header
2065 + { { echo "$as_me:$LINENO: error: ambiguous option: $1
2066 +Try \`$0 --help' for more information." >&5
2067 +echo "$as_me: error: ambiguous option: $1
2068 +Try \`$0 --help' for more information." >&2;}
2069 + { (exit 1); exit 1; }; };;
2070 + --help | --hel | -h )
2071 + echo "$ac_cs_usage"; exit 0 ;;
2072 + --debug | --d* | -d )
2074 + --file | --fil | --fi | --f )
2076 + CONFIG_FILES="$CONFIG_FILES $ac_optarg"
2077 + ac_need_defaults=false;;
2078 + --header | --heade | --head | --hea )
2080 + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
2081 + ac_need_defaults=false;;
2082 + -q | -quiet | --quiet | --quie | --qui | --qu | --q \
2083 + | -silent | --silent | --silen | --sile | --sil | --si | --s)
2086 + # This is an error.
2087 + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
2088 +Try \`$0 --help' for more information." >&5
2089 +echo "$as_me: error: unrecognized option: $1
2090 +Try \`$0 --help' for more information." >&2;}
2091 + { (exit 1); exit 1; }; } ;;
2093 + *) ac_config_targets="$ac_config_targets $1" ;;
2099 +ac_configure_extra_args=
2101 +if $ac_cs_silent; then
2103 + ac_configure_extra_args="$ac_configure_extra_args --silent"
2107 +cat >>$CONFIG_STATUS <<_ACEOF
2108 +if \$ac_cs_recheck; then
2109 + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
2110 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
2115 +cat >>$CONFIG_STATUS <<_ACEOF
2117 +# INIT-COMMANDS section.
2120 +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
2126 +cat >>$CONFIG_STATUS <<\_ACEOF
2127 +for ac_config_target in $ac_config_targets
2129 + case "$ac_config_target" in
2130 + # Handling of arguments.
2131 + "include/xmlsec/version.h" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/version.h" ;;
2132 + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
2133 + "include/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
2134 + "include/xmlsec/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/Makefile" ;;
2135 + "include/xmlsec/private/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/private/Makefile" ;;
2136 + "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
2137 + "apps/Makefile" ) CONFIG_FILES="$CONFIG_FILES apps/Makefile" ;;
2138 + "docs/Makefile" ) CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;;
2139 + "docs/api/Makefile" ) CONFIG_FILES="$CONFIG_FILES docs/api/Makefile" ;;
2140 + "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
2141 + "xmlsec1Conf.sh" ) CONFIG_FILES="$CONFIG_FILES xmlsec1Conf.sh:xmlsecConf.sh.in" ;;
2142 + "xmlsec1-config" ) CONFIG_FILES="$CONFIG_FILES xmlsec1-config:xmlsec-config.in" ;;
2143 + "xmlsec1-openssl.pc" ) CONFIG_FILES="$CONFIG_FILES xmlsec1-openssl.pc:xmlsec-openssl.pc.in" ;;
2144 + "xmlsec1-gnutls.pc" ) CONFIG_FILES="$CONFIG_FILES xmlsec1-gnutls.pc:xmlsec-gnutls.pc.in" ;;
2145 + "xmlsec1-nss.pc" ) CONFIG_FILES="$CONFIG_FILES xmlsec1-nss.pc:xmlsec-nss.pc.in" ;;
2146 + "xmlsec1.spec" ) CONFIG_FILES="$CONFIG_FILES xmlsec1.spec:xmlsec.spec.in" ;;
2147 + "include/xmlsec/openssl/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/openssl/Makefile" ;;
2148 + "src/openssl/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/openssl/Makefile" ;;
2149 + "include/xmlsec/gnutls/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/gnutls/Makefile" ;;
2150 + "src/gnutls/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gnutls/Makefile" ;;
2151 + "include/xmlsec/nss/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/nss/Makefile" ;;
2152 + "src/nss/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/nss/Makefile" ;;
2153 + "include/xmlsec/mscrypto/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/xmlsec/mscrypto/Makefile" ;;
2154 + "src/mscrypto/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/mscrypto/Makefile" ;;
2155 + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
2156 + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
2157 + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
2158 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
2159 + { (exit 1); exit 1; }; };;
2163 +# If the user did not use the arguments to specify the items to instantiate,
2164 +# then the envvar interface is used. Set only those that are not.
2165 +# We use the long form for the default assignment because of an extremely
2166 +# bizarre bug on SunOS 4.1.3.
2167 +if $ac_need_defaults; then
2168 + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
2169 + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
2170 + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
2173 +# Have a temporary directory for convenience. Make it in the build tree
2174 +# simply because there is no reason to put it here, and in addition,
2175 +# creating and moving files from /tmp can sometimes cause problems.
2176 +# Create a temporary directory, and hook for its removal unless debugging.
2179 + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
2180 + trap '{ (exit 1); exit 1; }' 1 2 13 15
2183 +# Create a (secure) tmp directory for tmp files.
2186 + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
2187 + test -n "$tmp" && test -d "$tmp"
2190 + tmp=./confstat$$-$RANDOM
2191 + (umask 077 && mkdir $tmp)
2194 + echo "$me: cannot create a temporary directory in ." >&2
2195 + { (exit 1); exit 1; }
2200 +cat >>$CONFIG_STATUS <<_ACEOF
2203 +# CONFIG_FILES section.
2206 +# No need to generate the scripts if there are no CONFIG_FILES.
2207 +# This happens for instance when ./config.status config.h
2208 +if test -n "\$CONFIG_FILES"; then
2209 + # Protect against being on the right side of a sed subst in config.status.
2210 + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
2211 + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
2212 +s,@SHELL@,$SHELL,;t t
2213 +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
2214 +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
2215 +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
2216 +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
2217 +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
2218 +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
2219 +s,@exec_prefix@,$exec_prefix,;t t
2220 +s,@prefix@,$prefix,;t t
2221 +s,@program_transform_name@,$program_transform_name,;t t
2222 +s,@bindir@,$bindir,;t t
2223 +s,@sbindir@,$sbindir,;t t
2224 +s,@libexecdir@,$libexecdir,;t t
2225 +s,@datadir@,$datadir,;t t
2226 +s,@sysconfdir@,$sysconfdir,;t t
2227 +s,@sharedstatedir@,$sharedstatedir,;t t
2228 +s,@localstatedir@,$localstatedir,;t t
2229 +s,@libdir@,$libdir,;t t
2230 +s,@includedir@,$includedir,;t t
2231 +s,@oldincludedir@,$oldincludedir,;t t
2232 +s,@infodir@,$infodir,;t t
2233 +s,@mandir@,$mandir,;t t
2234 +s,@build_alias@,$build_alias,;t t
2235 +s,@host_alias@,$host_alias,;t t
2236 +s,@target_alias@,$target_alias,;t t
2237 +s,@DEFS@,$DEFS,;t t
2238 +s,@ECHO_C@,$ECHO_C,;t t
2239 +s,@ECHO_N@,$ECHO_N,;t t
2240 +s,@ECHO_T@,$ECHO_T,;t t
2241 +s,@LIBS@,$LIBS,;t t
2242 +s,@build@,$build,;t t
2243 +s,@build_cpu@,$build_cpu,;t t
2244 +s,@build_vendor@,$build_vendor,;t t
2245 +s,@build_os@,$build_os,;t t
2246 +s,@host@,$host,;t t
2247 +s,@host_cpu@,$host_cpu,;t t
2248 +s,@host_vendor@,$host_vendor,;t t
2249 +s,@host_os@,$host_os,;t t
2250 +s,@XMLSEC_VERSION@,$XMLSEC_VERSION,;t t
2251 +s,@XMLSEC_PACKAGE@,$XMLSEC_PACKAGE,;t t
2252 +s,@XMLSEC_VERSION_SAFE@,$XMLSEC_VERSION_SAFE,;t t
2253 +s,@XMLSEC_VERSION_MAJOR@,$XMLSEC_VERSION_MAJOR,;t t
2254 +s,@XMLSEC_VERSION_MINOR@,$XMLSEC_VERSION_MINOR,;t t
2255 +s,@XMLSEC_VERSION_SUBMINOR@,$XMLSEC_VERSION_SUBMINOR,;t t
2256 +s,@XMLSEC_VERSION_INFO@,$XMLSEC_VERSION_INFO,;t t
2257 +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
2258 +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
2259 +s,@INSTALL_DATA@,$INSTALL_DATA,;t t
2260 +s,@CYGPATH_W@,$CYGPATH_W,;t t
2261 +s,@PACKAGE@,$PACKAGE,;t t
2262 +s,@VERSION@,$VERSION,;t t
2263 +s,@ACLOCAL@,$ACLOCAL,;t t
2264 +s,@AUTOCONF@,$AUTOCONF,;t t
2265 +s,@AUTOMAKE@,$AUTOMAKE,;t t
2266 +s,@AUTOHEADER@,$AUTOHEADER,;t t
2267 +s,@MAKEINFO@,$MAKEINFO,;t t
2268 +s,@AMTAR@,$AMTAR,;t t
2269 +s,@install_sh@,$install_sh,;t t
2270 +s,@STRIP@,$STRIP,;t t
2271 +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
2272 +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
2273 +s,@mkdir_p@,$mkdir_p,;t t
2275 +s,@SET_MAKE@,$SET_MAKE,;t t
2276 +s,@am__leading_dot@,$am__leading_dot,;t t
2277 +s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
2278 +s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t
2279 +s,@MAINT@,$MAINT,;t t
2281 +s,@CFLAGS@,$CFLAGS,;t t
2282 +s,@LDFLAGS@,$LDFLAGS,;t t
2283 +s,@CPPFLAGS@,$CPPFLAGS,;t t
2284 +s,@ac_ct_CC@,$ac_ct_CC,;t t
2285 +s,@EXEEXT@,$EXEEXT,;t t
2286 +s,@OBJEXT@,$OBJEXT,;t t
2287 +s,@DEPDIR@,$DEPDIR,;t t
2288 +s,@am__include@,$am__include,;t t
2289 +s,@am__quote@,$am__quote,;t t
2290 +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t
2291 +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
2292 +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
2293 +s,@CCDEPMODE@,$CCDEPMODE,;t t
2294 +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
2295 +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
2296 +s,@EGREP@,$EGREP,;t t
2297 +s,@LN_S@,$LN_S,;t t
2298 +s,@ECHO@,$ECHO,;t t
2300 +s,@ac_ct_AR@,$ac_ct_AR,;t t
2301 +s,@RANLIB@,$RANLIB,;t t
2302 +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
2305 +s,@CXXFLAGS@,$CXXFLAGS,;t t
2306 +s,@ac_ct_CXX@,$ac_ct_CXX,;t t
2307 +s,@CXXDEPMODE@,$CXXDEPMODE,;t t
2308 +s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
2309 +s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
2310 +s,@CXXCPP@,$CXXCPP,;t t
2312 +s,@FFLAGS@,$FFLAGS,;t t
2313 +s,@ac_ct_F77@,$ac_ct_F77,;t t
2314 +s,@LIBTOOL@,$LIBTOOL,;t t
2319 +s,@HELP2MAN@,$HELP2MAN,;t t
2320 +s,@MAN2HTML@,$MAN2HTML,;t t
2322 +s,@ANSI2KNR@,$ANSI2KNR,;t t
2323 +s,@INSTALL_LTDL_TRUE@,$INSTALL_LTDL_TRUE,;t t
2324 +s,@INSTALL_LTDL_FALSE@,$INSTALL_LTDL_FALSE,;t t
2325 +s,@CONVENIENCE_LTDL_TRUE@,$CONVENIENCE_LTDL_TRUE,;t t
2326 +s,@CONVENIENCE_LTDL_FALSE@,$CONVENIENCE_LTDL_FALSE,;t t
2327 +s,@LIBADD_DL@,$LIBADD_DL,;t t
2328 +s,@PKG_CONFIG_ENABLED@,$PKG_CONFIG_ENABLED,;t t
2329 +s,@PKG_CONFIG@,$PKG_CONFIG,;t t
2330 +s,@LIBXML_CFLAGS@,$LIBXML_CFLAGS,;t t
2331 +s,@LIBXML_LIBS@,$LIBXML_LIBS,;t t
2332 +s,@LIBXML262_CFLAGS@,$LIBXML262_CFLAGS,;t t
2333 +s,@LIBXML262_LIBS@,$LIBXML262_LIBS,;t t
2334 +s,@LIBXML_CONFIG@,$LIBXML_CONFIG,;t t
2335 +s,@LIBXML_MIN_VERSION@,$LIBXML_MIN_VERSION,;t t
2336 +s,@LIBXSLT_CFLAGS@,$LIBXSLT_CFLAGS,;t t
2337 +s,@LIBXSLT_LIBS@,$LIBXSLT_LIBS,;t t
2338 +s,@XMLSEC_NO_LIBXSLT@,$XMLSEC_NO_LIBXSLT,;t t
2339 +s,@LIBXSLT_CONFIG@,$LIBXSLT_CONFIG,;t t
2340 +s,@LIBXSLT_MIN_VERSION@,$LIBXSLT_MIN_VERSION,;t t
2341 +s,@OPENSSL_CFLAGS@,$OPENSSL_CFLAGS,;t t
2342 +s,@OPENSSL_LIBS@,$OPENSSL_LIBS,;t t
2343 +s,@OPENSSL097_CFLAGS@,$OPENSSL097_CFLAGS,;t t
2344 +s,@OPENSSL097_LIBS@,$OPENSSL097_LIBS,;t t
2345 +s,@XMLSEC_NO_OPENSSL_TRUE@,$XMLSEC_NO_OPENSSL_TRUE,;t t
2346 +s,@XMLSEC_NO_OPENSSL_FALSE@,$XMLSEC_NO_OPENSSL_FALSE,;t t
2347 +s,@XMLSEC_NO_OPENSSL@,$XMLSEC_NO_OPENSSL,;t t
2348 +s,@OPENSSL_CRYPTO_LIB@,$OPENSSL_CRYPTO_LIB,;t t
2349 +s,@OPENSSL_MIN_VERSION@,$OPENSSL_MIN_VERSION,;t t
2350 +s,@GNUTLS_CFLAGS@,$GNUTLS_CFLAGS,;t t
2351 +s,@GNUTLS_LIBS@,$GNUTLS_LIBS,;t t
2352 +s,@XMLSEC_NO_GNUTLS_TRUE@,$XMLSEC_NO_GNUTLS_TRUE,;t t
2353 +s,@XMLSEC_NO_GNUTLS_FALSE@,$XMLSEC_NO_GNUTLS_FALSE,;t t
2354 +s,@XMLSEC_NO_GNUTLS@,$XMLSEC_NO_GNUTLS,;t t
2355 +s,@GNUTLS_CRYPTO_LIB@,$GNUTLS_CRYPTO_LIB,;t t
2356 +s,@GNUTLS_MIN_VERSION@,$GNUTLS_MIN_VERSION,;t t
2357 +s,@NSS_CFLAGS@,$NSS_CFLAGS,;t t
2358 +s,@NSS_LIBS@,$NSS_LIBS,;t t
2359 +s,@XMLSEC_NO_NSS_TRUE@,$XMLSEC_NO_NSS_TRUE,;t t
2360 +s,@XMLSEC_NO_NSS_FALSE@,$XMLSEC_NO_NSS_FALSE,;t t
2361 +s,@XMLSEC_NO_NSS@,$XMLSEC_NO_NSS,;t t
2362 +s,@NSS_CRYPTO_LIB@,$NSS_CRYPTO_LIB,;t t
2363 +s,@NSS_MIN_VERSION@,$NSS_MIN_VERSION,;t t
2364 +s,@NSPR_MIN_VERSION@,$NSPR_MIN_VERSION,;t t
2365 +s,@MOZILLA_MIN_VERSION@,$MOZILLA_MIN_VERSION,;t t
2366 +s,@MSCRYPTO_CFLAGS@,$MSCRYPTO_CFLAGS,;t t
2367 +s,@MSCRYPTO_LIBS@,$MSCRYPTO_LIBS,;t t
2368 s,@XMLSEC_NO_SHA1_TRUE@,$XMLSEC_NO_SHA1_TRUE,;t t
2369 s,@XMLSEC_NO_SHA1_FALSE@,$XMLSEC_NO_SHA1_FALSE,;t t
2370 s,@XMLSEC_NO_SHA1@,$XMLSEC_NO_SHA1,;t t
2371 @@ -34368,6 +36362,8 @@
2372 s,@NSS_MIN_VERSION@,$NSS_MIN_VERSION,;t t
2373 s,@NSPR_MIN_VERSION@,$NSPR_MIN_VERSION,;t t
2374 s,@MOZILLA_MIN_VERSION@,$MOZILLA_MIN_VERSION,;t t
2375 +s,@MSCRYPTO_CFLAGS@,$MSCRYPTO_CFLAGS,;t t
2376 +s,@MSCRYPTO_LIBS@,$MSCRYPTO_LIBS,;t t
2377 s,@XMLSEC_NO_SHA1_TRUE@,$XMLSEC_NO_SHA1_TRUE,;t t
2378 s,@XMLSEC_NO_SHA1_FALSE@,$XMLSEC_NO_SHA1_FALSE,;t t
2379 s,@XMLSEC_NO_SHA1@,$XMLSEC_NO_SHA1,;t t
2380 --- misc/xmlsec1-1.2.6/configure.in 2004-08-26 04:49:24.000000000 +0200
2381 +++ misc/build/xmlsec1-1.2.6/configure.in 2008-06-29 23:44:19.000000000 +0200
2382 @@ -503,12 +503,26 @@
2385 MOZILLA_MIN_VERSION="1.4"
2386 +if test "z$MOZ_FLAVOUR" = "zfirefox" ; then
2387 + MOZILLA_MIN_VERSION="1.0"
2389 NSS_MIN_VERSION="3.2"
2390 NSPR_MIN_VERSION="4.0"
2393 -NSS_LIBS_LIST="-lnss3 -lsmime3"
2394 -NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4"
2397 +cygwin* | mingw* | pw32*)
2398 + NSS_LIBS_LIST="-lnss3 -lsmime3"
2399 + NSPR_LIBS_LIST="-lnspr4"
2403 + NSS_LIBS_LIST="-lnss3 -lsoftokn3 -lsmime3"
2404 + NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4"
2408 NSS_CRYPTO_LIB="$PACKAGE-nss"
2411 @@ -521,9 +535,16 @@
2414 elif test "z$with_nss" = "z" -a "z$with_nspr" = "z" -a "z$with_mozilla_ver" = "z" -a "z$PKG_CONFIG_ENABLED" = "zyes" ; then
2415 - PKG_CHECK_MODULES(NSS, mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION,
2416 + PKG_CHECK_MODULES(NSS, $MOZ_FLAVOUR-nspr >= $MOZILLA_MIN_VERSION $MOZ_FLAVOUR-nss >= $MOZILLA_MIN_VERSION,
2419 + AC_MSG_RESULT($NSS_FOUND)
2420 + if test "z$NSS_FOUND" = "zno" ; then
2421 + PKG_CHECK_MODULES(NSS, nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION,
2424 + AC_MSG_RESULT($NSS_FOUND)
2428 if test "z$NSS_FOUND" = "zno" ; then
2430 ac_mozilla_name=mozilla-$MOZILLA_MIN_VERSION
2433 - ac_nss_lib_dir="/usr/lib /usr/lib64 /usr/local/lib /usr/lib/$ac_mozilla_name /usr/local/lib/$ac_mozilla_name"
2434 - ac_nss_inc_dir="/usr/include /usr/include/mozilla /usr/local/include /usr/local/include/mozilla /usr/include/$ac_mozilla_name /usr/local/include/$ac_mozilla_name"
2435 + ac_nss_lib_dir="${SOLARVERSION}/${INPATH}/lib${UPDMINOREXT}"
2436 + ac_nss_inc_dir="${SOLARVERSION}/${INPATH}/inc${UPDMINOREXT}/mozilla"
2438 AC_MSG_CHECKING(for nspr libraries >= $NSPR_MIN_VERSION)
2439 NSPR_INCLUDES_FOUND="no"
2443 for dir in $ac_nss_lib_dir ; do
2444 - if test -f $dir/libnspr4.so ; then
2446 + cygwin* | mingw* | pw32*)
2447 + if test -f $dir/libnspr4.so -o -f $dir/libnspr4.dylib -o -f $dir/libnspr4.a ; then
2448 dnl do not add -L/usr/lib because compiler does it anyway
2449 if test "z$dir" = "z/usr/lib" ; then
2450 NSPR_LIBS="$NSPR_LIBS_LIST"
2451 @@ -583,7 +606,26 @@
2453 NSPR_LIBS_FOUND="yes"
2460 + if test -f $dir/libnspr4.so -o -f $dir/libnspr4.dylib ; then
2461 + dnl do not add -L/usr/lib because compiler does it anyway
2462 + if test "z$dir" = "z/usr/lib" ; then
2463 + NSPR_LIBS="$NSPR_LIBS_LIST"
2465 + if test "z$with_gnu_ld" = "zyes" ; then
2466 + NSPR_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $NSPR_LIBS_LIST"
2468 + NSPR_LIBS="-L$dir $NSPR_LIBS_LIST"
2471 + NSPR_LIBS_FOUND="yes"
2482 for dir in $ac_nss_lib_dir ; do
2483 - if test -f $dir/libnss3.so ; then
2485 + cygwin* | mingw* | pw32*)
2486 + if test -f $dir/libnss3.so -o -f $dir/libnss3.dylib -o -f $dir/libnss3.a ; then
2487 dnl do not add -L/usr/lib because compiler does it anyway
2488 if test "z$dir" = "z/usr/lib" ; then
2489 NSS_LIBS="$NSS_LIBS_LIST"
2490 @@ -654,7 +698,26 @@
2492 NSS_LIBS_FOUND="yes"
2499 + if test -f $dir/libnss3.so -o -f $dir/libnss3.dylib ; then
2500 + dnl do not add -L/usr/lib because compiler does it anyway
2501 + if test "z$dir" = "z/usr/lib" ; then
2502 + NSS_LIBS="$NSS_LIBS_LIST"
2504 + if test "z$with_gnu_ld" = "zyes" ; then
2505 + NSS_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $NSS_LIBS_LIST"
2507 + NSS_LIBS="-L$dir $NSS_LIBS_LIST"
2510 + NSS_LIBS_FOUND="yes"
2518 --- misc/xmlsec1-1.2.6/include/xmlsec/mscrypto/Makefile.in 2008-06-29 23:44:40.000000000 +0200
2519 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/mscrypto/Makefile.in 2008-06-29 23:44:19.000000000 +0200
2522 +# Makefile.in generated by automake 1.8.3 from Makefile.am.
2523 +# @configure_input@
2525 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2526 +# 2003, 2004 Free Software Foundation, Inc.
2527 +# This Makefile.in is free software; the Free Software Foundation
2528 +# gives unlimited permission to copy and/or distribute it,
2529 +# with or without modifications, as long as this notice is preserved.
2531 +# This program is distributed in the hope that it will be useful,
2532 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
2533 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
2534 +# PARTICULAR PURPOSE.
2538 +HEADERS = $(xmlsecmscryptoinc_HEADERS)
2540 +xmlsecmscryptoinc_HEADERS = \
2552 +mostlyclean-libtool:
2556 + -rm -rf .libs _libs
2558 +all-am: Makefile $(HEADERS)
2560 +mostlyclean-generic:
2566 +clean-am: clean-generic clean-libtool mostlyclean-am
2568 +mostlyclean: mostlyclean-am
2570 +mostlyclean-am: mostlyclean-generic mostlyclean-libtool
2572 +.PHONY: all all-am clean clean-generic \
2574 + mostlyclean mostlyclean-generic mostlyclean-libtool
2577 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
2578 +# Otherwise a system limit (for SysV at least) may be exceeded.
2580 --- misc/xmlsec1-1.2.6/include/xmlsec/mscrypto/akmngr.h 2008-06-29 23:44:39.000000000 +0200
2581 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/mscrypto/akmngr.h 2008-06-29 23:44:19.000000000 +0200
2587 + * This is free software; see Copyright file in the source
2588 + * distribution for preciese wording.
2590 + * Copyright ..........................
2592 +#ifndef __XMLSEC_MSCRYPTO_AKMNGR_H__
2593 +#define __XMLSEC_MSCRYPTO_AKMNGR_H__
2595 +#include <windows.h>
2596 +#include <wincrypt.h>
2598 +#include <xmlsec/xmlsec.h>
2599 +#include <xmlsec/keys.h>
2600 +#include <xmlsec/transforms.h>
2604 +#endif /* __cplusplus */
2606 +XMLSEC_CRYPTO_EXPORT xmlSecKeysMngrPtr
2607 +xmlSecMSCryptoAppliedKeysMngrCreate(
2608 + HCERTSTORE keyStore ,
2609 + HCERTSTORE certStore
2612 +XMLSEC_CRYPTO_EXPORT int
2613 +xmlSecMSCryptoAppliedKeysMngrSymKeyLoad(
2614 + xmlSecKeysMngrPtr mngr ,
2618 +XMLSEC_CRYPTO_EXPORT int
2619 +xmlSecMSCryptoAppliedKeysMngrPubKeyLoad(
2620 + xmlSecKeysMngrPtr mngr ,
2624 +XMLSEC_CRYPTO_EXPORT int
2625 +xmlSecMSCryptoAppliedKeysMngrPriKeyLoad(
2626 + xmlSecKeysMngrPtr mngr ,
2630 +XMLSEC_CRYPTO_EXPORT int
2631 +xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore (
2632 + xmlSecKeysMngrPtr mngr ,
2633 + HCERTSTORE keyStore
2636 +XMLSEC_CRYPTO_EXPORT int
2637 +xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore (
2638 + xmlSecKeysMngrPtr mngr ,
2639 + HCERTSTORE trustedStore
2642 +XMLSEC_CRYPTO_EXPORT int
2643 +xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore (
2644 + xmlSecKeysMngrPtr mngr ,
2645 + HCERTSTORE untrustedStore
2650 +#endif /* __cplusplus */
2652 +#endif /* __XMLSEC_MSCRYPTO_AKMNGR_H__ */
2655 --- misc/xmlsec1-1.2.6/include/xmlsec/mscrypto/x509.h 2003-09-26 08:12:46.000000000 +0200
2656 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/mscrypto/x509.h 2008-06-29 23:44:19.000000000 +0200
2658 PCCERT_CONTEXT cert,
2659 xmlSecKeyDataType type);
2661 +XMLSEC_CRYPTO_EXPORT int xmlSecMSCryptoX509StoreAdoptKeyStore (
2662 + xmlSecKeyDataStorePtr store,
2663 + HCERTSTORE keyStore
2666 +XMLSEC_CRYPTO_EXPORT int xmlSecMSCryptoX509StoreAdoptTrustedStore (
2667 + xmlSecKeyDataStorePtr store,
2668 + HCERTSTORE trustedStore
2671 +XMLSEC_CRYPTO_EXPORT int xmlSecMSCryptoX509StoreAdoptUntrustedStore (
2672 + xmlSecKeyDataStorePtr store,
2673 + HCERTSTORE untrustedStore
2677 #endif /* XMLSEC_NO_X509 */
2679 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/Makefile.am 2003-07-30 04:46:35.000000000 +0200
2680 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/Makefile.am 2008-06-29 23:44:19.000000000 +0200
2682 xmlsecnssincdir = $(includedir)/xmlsec1/xmlsec/nss
2684 xmlsecnssinc_HEADERS = \
2698 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/Makefile.in 2004-08-26 08:00:31.000000000 +0200
2699 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/Makefile.in 2008-06-29 23:44:19.000000000 +0200
2702 xmlsecnssincdir = $(includedir)/xmlsec1/xmlsec/nss
2703 xmlsecnssinc_HEADERS = \
2717 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/akmngr.h 2008-06-29 23:44:39.000000000 +0200
2718 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/akmngr.h 2008-06-29 23:44:19.000000000 +0200
2724 + * This is free software; see Copyright file in the source
2725 + * distribution for preciese wording.
2727 + * Copyright ..........................
2729 +#ifndef __XMLSEC_NSS_AKMNGR_H__
2730 +#define __XMLSEC_NSS_AKMNGR_H__
2734 +#include <pk11func.h>
2737 +#include <xmlsec/xmlsec.h>
2738 +#include <xmlsec/keys.h>
2739 +#include <xmlsec/transforms.h>
2743 +#endif /* __cplusplus */
2745 +XMLSEC_CRYPTO_EXPORT xmlSecKeysMngrPtr
2746 +xmlSecNssAppliedKeysMngrCreate(
2747 + PK11SlotInfo** slots,
2749 + CERTCertDBHandle* handler
2752 +XMLSEC_CRYPTO_EXPORT int
2753 +xmlSecNssAppliedKeysMngrSymKeyLoad(
2754 + xmlSecKeysMngrPtr mngr ,
2755 + PK11SymKey* symKey
2758 +XMLSEC_CRYPTO_EXPORT int
2759 +xmlSecNssAppliedKeysMngrPubKeyLoad(
2760 + xmlSecKeysMngrPtr mngr ,
2761 + SECKEYPublicKey* pubKey
2764 +XMLSEC_CRYPTO_EXPORT int
2765 +xmlSecNssAppliedKeysMngrPriKeyLoad(
2766 + xmlSecKeysMngrPtr mngr ,
2767 + SECKEYPrivateKey* priKey
2772 +#endif /* __cplusplus */
2774 +#endif /* __XMLSEC_NSS_AKMNGR_H__ */
2777 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/app.h 2004-01-12 22:06:14.000000000 +0100
2778 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/app.h 2008-06-29 23:44:19.000000000 +0200
2780 #include <xmlsec/keysmngr.h>
2781 #include <xmlsec/transforms.h>
2783 +#include <xmlsec/nss/tokens.h>
2784 +#include <xmlsec/nss/akmngr.h>
2790 XMLSEC_CRYPTO_EXPORT int xmlSecNssAppDefaultKeysMngrInit (xmlSecKeysMngrPtr mngr);
2791 XMLSEC_CRYPTO_EXPORT int xmlSecNssAppDefaultKeysMngrAdoptKey(xmlSecKeysMngrPtr mngr,
2793 +XMLSEC_CRYPTO_EXPORT int xmlSecNssAppDefaultKeysMngrAdoptKeySlot(xmlSecKeysMngrPtr mngr,
2794 + xmlSecNssKeySlotPtr keySlot);
2795 XMLSEC_CRYPTO_EXPORT int xmlSecNssAppDefaultKeysMngrLoad (xmlSecKeysMngrPtr mngr,
2797 XMLSEC_CRYPTO_EXPORT int xmlSecNssAppDefaultKeysMngrSave (xmlSecKeysMngrPtr mngr,
2798 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/ciphers.h 2008-06-29 23:44:39.000000000 +0200
2799 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/ciphers.h 2008-06-29 23:44:19.000000000 +0200
2805 + * This is free software; see Copyright file in the source
2806 + * distribution for preciese wording.
2808 + * Copyright ..........................
2810 +#ifndef __XMLSEC_NSS_CIPHERS_H__
2811 +#define __XMLSEC_NSS_CIPHERS_H__
2815 +#endif /* __cplusplus */
2817 +#include <xmlsec/xmlsec.h>
2818 +#include <xmlsec/keys.h>
2819 +#include <xmlsec/transforms.h>
2822 +XMLSEC_CRYPTO_EXPORT int xmlSecNssSymKeyDataAdoptKey( xmlSecKeyDataPtr data,
2823 + PK11SymKey* symkey ) ;
2825 +XMLSEC_CRYPTO_EXPORT xmlSecKeyDataPtr xmlSecNssSymKeyDataKeyAdopt( PK11SymKey* symKey ) ;
2827 +XMLSEC_CRYPTO_EXPORT PK11SymKey* xmlSecNssSymKeyDataGetKey(xmlSecKeyDataPtr data);
2832 +#endif /* __cplusplus */
2834 +#endif /* __XMLSEC_NSS_CIPHERS_H__ */
2837 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/crypto.h 2004-01-12 22:06:14.000000000 +0100
2838 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/crypto.h 2008-06-29 23:44:19.000000000 +0200
2839 @@ -264,6 +264,15 @@
2840 xmlSecNssTransformRsaPkcs1GetKlass()
2841 XMLSEC_CRYPTO_EXPORT xmlSecTransformId xmlSecNssTransformRsaPkcs1GetKlass(void);
2844 + * xmlSecNssTransformRsaOaepId:
2846 + * The RSA OAEP key transport transform klass.
2848 +#define xmlSecNssTransformRsaOaepId \
2849 + xmlSecNssTransformRsaOaepGetKlass()
2850 +XMLSEC_CRYPTO_EXPORT xmlSecTransformId xmlSecNssTransformRsaOaepGetKlass(void);
2852 #endif /* XMLSEC_NO_RSA */
2855 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/keysstore.h 2003-07-30 04:46:35.000000000 +0200
2856 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/keysstore.h 2008-06-29 23:44:19.000000000 +0200
2858 #endif /* __cplusplus */
2860 #include <xmlsec/xmlsec.h>
2861 +#include <xmlsec/keysmngr.h>
2862 +#include <xmlsec/nss/tokens.h>
2864 /****************************************************************************
2867 XMLSEC_CRYPTO_EXPORT xmlSecKeyStoreId xmlSecNssKeysStoreGetKlass (void);
2868 XMLSEC_CRYPTO_EXPORT int xmlSecNssKeysStoreAdoptKey (xmlSecKeyStorePtr store,
2870 +XMLSEC_CRYPTO_EXPORT int xmlSecNssKeysStoreAdoptKeySlot(xmlSecKeyStorePtr store,
2871 + xmlSecNssKeySlotPtr keySlot);
2872 XMLSEC_CRYPTO_EXPORT int xmlSecNssKeysStoreLoad (xmlSecKeyStorePtr store,
2874 xmlSecKeysMngrPtr keysMngr);
2875 --- misc/xmlsec1-1.2.6/include/xmlsec/nss/tokens.h 2008-06-29 23:44:39.000000000 +0200
2876 +++ misc/build/xmlsec1-1.2.6/include/xmlsec/nss/tokens.h 2008-06-29 23:44:19.000000000 +0200
2882 + * This is free software; see Copyright file in the source
2883 + * distribution for preciese wording.
2885 + * Copyright (c) 2003 Sun Microsystems, Inc. All rights reserved.
2887 + * Contributor(s): _____________________________
2890 +#ifndef __XMLSEC_NSS_TOKENS_H__
2891 +#define __XMLSEC_NSS_TOKENS_H__
2893 +#include <string.h>
2896 +#include <pk11func.h>
2898 +#include <xmlsec/xmlsec.h>
2899 +#include <xmlsec/list.h>
2903 +#endif /* __cplusplus */
2906 + * xmlSecNssKeySlotListId
2908 + * The crypto mechanism list klass
2910 +#define xmlSecNssKeySlotListId xmlSecNssKeySlotListGetKlass()
2911 +XMLSEC_CRYPTO_EXPORT xmlSecPtrListId xmlSecNssKeySlotListGetKlass( void ) ;
2913 +/*******************************************
2914 + * KeySlot interfaces
2915 + *******************************************/
2917 + * Internal NSS key slot data
2918 + * @mechanismList: the mechanisms that the slot bound with.
2919 + * @slot: the pkcs slot
2921 + * This context is located after xmlSecPtrList
2923 +typedef struct _xmlSecNssKeySlot xmlSecNssKeySlot ;
2924 +typedef struct _xmlSecNssKeySlot* xmlSecNssKeySlotPtr ;
2926 +struct _xmlSecNssKeySlot {
2927 + CK_MECHANISM_TYPE_PTR mechanismList ; /* mech. array, NULL ternimated */
2928 + PK11SlotInfo* slot ;
2931 +XMLSEC_CRYPTO_EXPORT int
2932 +xmlSecNssKeySlotSetMechList(
2933 + xmlSecNssKeySlotPtr keySlot ,
2934 + CK_MECHANISM_TYPE_PTR mechanismList
2937 +XMLSEC_CRYPTO_EXPORT int
2938 +xmlSecNssKeySlotEnableMech(
2939 + xmlSecNssKeySlotPtr keySlot ,
2940 + CK_MECHANISM_TYPE mechanism
2943 +XMLSEC_CRYPTO_EXPORT int
2944 +xmlSecNssKeySlotDisableMech(
2945 + xmlSecNssKeySlotPtr keySlot ,
2946 + CK_MECHANISM_TYPE mechanism
2949 +XMLSEC_CRYPTO_EXPORT CK_MECHANISM_TYPE_PTR
2950 +xmlSecNssKeySlotGetMechList(
2951 + xmlSecNssKeySlotPtr keySlot
2954 +XMLSEC_CRYPTO_EXPORT int
2955 +xmlSecNssKeySlotSetSlot(
2956 + xmlSecNssKeySlotPtr keySlot ,
2957 + PK11SlotInfo* slot
2960 +XMLSEC_CRYPTO_EXPORT int
2961 +xmlSecNssKeySlotInitialize(
2962 + xmlSecNssKeySlotPtr keySlot ,
2963 + PK11SlotInfo* slot
2966 +XMLSEC_CRYPTO_EXPORT void
2967 +xmlSecNssKeySlotFinalize(
2968 + xmlSecNssKeySlotPtr keySlot
2971 +XMLSEC_CRYPTO_EXPORT PK11SlotInfo*
2972 +xmlSecNssKeySlotGetSlot(
2973 + xmlSecNssKeySlotPtr keySlot
2976 +XMLSEC_CRYPTO_EXPORT xmlSecNssKeySlotPtr
2977 +xmlSecNssKeySlotCreate() ;
2979 +XMLSEC_CRYPTO_EXPORT int
2980 +xmlSecNssKeySlotCopy(
2981 + xmlSecNssKeySlotPtr newKeySlot ,
2982 + xmlSecNssKeySlotPtr keySlot
2985 +XMLSEC_CRYPTO_EXPORT xmlSecNssKeySlotPtr
2986 +xmlSecNssKeySlotDuplicate(
2987 + xmlSecNssKeySlotPtr keySlot
2990 +XMLSEC_CRYPTO_EXPORT void
2991 +xmlSecNssKeySlotDestroy(
2992 + xmlSecNssKeySlotPtr keySlot
2995 +XMLSEC_CRYPTO_EXPORT int
2996 +xmlSecNssKeySlotBindMech(
2997 + xmlSecNssKeySlotPtr keySlot ,
2998 + CK_MECHANISM_TYPE type
3001 +XMLSEC_CRYPTO_EXPORT int
3002 +xmlSecNssKeySlotSupportMech(
3003 + xmlSecNssKeySlotPtr keySlot ,
3004 + CK_MECHANISM_TYPE type
3008 +/************************************************************************
3009 + * PKCS#11 crypto token interfaces
3011 + * A PKCS#11 slot repository will be defined internally. From the
3012 + * repository, a user can specify a particular slot for a certain crypto
3015 + * In some situation, some cryptographic operation should act in a user
3016 + * designated devices. The interfaces defined here provide the way. If
3017 + * the user do not initialize the repository distinctly, the interfaces
3018 + * use the default functions provided by NSS itself.
3020 + ************************************************************************/
3022 + * Initialize NSS pkcs#11 slot repository
3024 + * Returns 0 if success or -1 if an error occurs.
3026 +XMLSEC_CRYPTO_EXPORT int xmlSecNssSlotInitialize( void ) ;
3029 + * Shutdown and destroy NSS pkcs#11 slot repository
3031 +XMLSEC_CRYPTO_EXPORT void xmlSecNssSlotShutdown() ;
3034 + * Get PKCS#11 slot handler
3035 + * @type the mechanism that the slot must support.
3037 + * Returns a pointer to PKCS#11 slot or NULL if an error occurs.
3039 + * Notes: The returned handler must be destroied distinctly.
3041 +XMLSEC_CRYPTO_EXPORT PK11SlotInfo* xmlSecNssSlotGet( CK_MECHANISM_TYPE type ) ;
3044 + * Adopt a pkcs#11 slot with a mechanism into the repository
3045 + * @slot: the pkcs#11 slot.
3046 + * @mech: the mechanism.
3048 + * If @mech is available( @mech != CKM_INVALID_MECHANISM ), every operation with
3049 + * this mechanism only can perform on the @slot.
3051 + * Returns 0 if success or -1 if an error occurs.
3053 +XMLSEC_CRYPTO_EXPORT int xmlSecNssSlotAdopt( PK11SlotInfo* slot, CK_MECHANISM_TYPE mech ) ;
3057 +#endif /* __cplusplus */
3059 +#endif /* __XMLSEC_NSS_TOKENS_H__ */
3061 --- misc/xmlsec1-1.2.6/ltmain.sh 2004-08-26 08:00:15.000000000 +0200
3062 +++ misc/build/xmlsec1-1.2.6/ltmain.sh 2008-06-29 23:44:19.000000000 +0200
3063 @@ -1661,6 +1661,11 @@
3068 + deplibs="$deplibs $arg"
3074 deplibs="$deplibs $arg"
3075 @@ -1974,6 +1979,10 @@
3078 *.la) lib="$deplib" ;;
3080 + deplibs="$deplib $deplibs"
3084 if test "$pass" = conv; then
3085 deplibs="$deplib $deplibs"
3086 @@ -2994,13 +3003,13 @@
3091 - versuffix=".$current.$revision";
3092 + major=.`expr $current - $age`
3093 + versuffix="$major.$age.$revision"
3098 - versuffix=".$current";
3099 + major=.`expr $current - $age`
3100 + versuffix="$major.$age.$revision"
3104 @@ -3564,7 +3573,8 @@
3107 eval flag=\"$hardcode_libdir_flag_spec\"
3108 - dep_rpath="$dep_rpath $flag"
3110 +# dep_rpath="$dep_rpath $flag"
3112 elif test -n "$runpath_var"; then
3113 case "$perm_rpath " in
3114 --- misc/xmlsec1-1.2.6/src/bn.c 2004-06-21 20:33:27.000000000 +0200
3115 +++ misc/build/xmlsec1-1.2.6/src/bn.c 2008-06-29 23:44:19.000000000 +0200
3116 @@ -170,8 +170,10 @@
3119 xmlSecBnFromString(xmlSecBnPtr bn, const xmlChar* str, xmlSecSize base) {
3120 - xmlSecSize i, len;
3121 + xmlSecSize i, len, size;
3130 len = xmlStrlen(str);
3136 /* The result size could not exceed the input string length
3137 @@ -191,54 +193,131 @@
3138 * In truth, it would be likely less than 1/2 input string length
3139 * because each byte is represented by 2 chars. If needed,
3140 * buffer size would be increased by Mul/Add functions.
3141 + * Finally, we can add one byte for 00 or 10 prefix.
3143 - ret = xmlSecBufferSetMaxSize(bn, xmlSecBufferGetSize(bn) + len / 2 + 1);
3144 + ret = xmlSecBufferSetMaxSize(bn, xmlSecBufferGetSize(bn) + len / 2 + 1 + 1);
3146 - xmlSecError(XMLSEC_ERRORS_HERE,
3148 - "xmlSecBnRevLookupTable",
3149 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
3150 - "size=%d", len / 2 + 1);
3152 + xmlSecError(XMLSEC_ERRORS_HERE,
3154 + "xmlSecBnRevLookupTable",
3155 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3156 + "size=%d", len / 2 + 1);
3160 + /* figure out if it is positive or negative number */
3171 + /* check if it is + or - */
3175 + } else if(ch == '-') {
3180 + /* otherwise, it must be start of the number */
3181 + nn = xmlSecBnLookupTable[ch];
3182 + if((nn >= 0) && ((xmlSecSize)nn < base)) {
3183 + xmlSecAssert2(i > 0, -1);
3185 + /* no sign, positive by default */
3187 + --i; /* make sure that we will look at this character in next loop */
3190 + xmlSecError(XMLSEC_ERRORS_HERE,
3193 + XMLSEC_ERRORS_R_INVALID_DATA,
3194 + "char=%c;base=%d",
3200 + /* now parse the number itself */
3207 + xmlSecAssert2(ch <= sizeof(xmlSecBnLookupTable), -1);
3208 + nn = xmlSecBnLookupTable[ch];
3209 + if((nn < 0) || ((xmlSecSize)nn > base)) {
3210 + xmlSecError(XMLSEC_ERRORS_HERE,
3213 + XMLSEC_ERRORS_R_INVALID_DATA,
3214 + "char=%c;base=%d",
3219 + ret = xmlSecBnMul(bn, base);
3221 + xmlSecError(XMLSEC_ERRORS_HERE,
3224 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3229 + ret = xmlSecBnAdd(bn, nn);
3231 + xmlSecError(XMLSEC_ERRORS_HERE,
3234 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3240 - for(i = 0; i < len; i++) {
3246 - xmlSecAssert2(ch <= sizeof(xmlSecBnLookupTable), -1);
3247 - nn = xmlSecBnLookupTable[ch];
3248 - if((nn < 0) || ((xmlSecSize)nn > base)) {
3249 - xmlSecError(XMLSEC_ERRORS_HERE,
3252 - XMLSEC_ERRORS_R_INVALID_DATA,
3253 - "char=%c;base=%d",
3258 - ret = xmlSecBnMul(bn, base);
3260 - xmlSecError(XMLSEC_ERRORS_HERE,
3263 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
3268 - ret = xmlSecBnAdd(bn, nn);
3270 - xmlSecError(XMLSEC_ERRORS_HERE,
3273 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
3277 + /* check if we need to add 00 prefix */
3278 + data = xmlSecBufferGetData(bn);
3279 + size = xmlSecBufferGetSize(bn);
3280 + if((size > 0 && data[0] > 127)||(size==0)) {
3282 + ret = xmlSecBufferPrepend(bn, &ch, 1);
3284 + xmlSecError(XMLSEC_ERRORS_HERE,
3286 + "xmlSecBufferPrepend",
3287 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3293 + /* do 2's compliment and add 1 to represent negative value */
3294 + if(positive == 0) {
3295 + data = xmlSecBufferGetData(bn);
3296 + size = xmlSecBufferGetSize(bn);
3297 + for(i = 0; i < size; ++i) {
3301 + ret = xmlSecBnAdd(bn, 1);
3303 + xmlSecError(XMLSEC_ERRORS_HERE,
3306 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3313 @@ -256,8 +335,12 @@
3316 xmlSecBnToString(xmlSecBnPtr bn, xmlSecSize base) {
3320 - xmlSecSize i, len;
3321 + xmlSecSize i, len, size;
3327 @@ -265,35 +348,86 @@
3328 xmlSecAssert2(base > 1, NULL);
3329 xmlSecAssert2(base <= sizeof(xmlSecBnRevLookupTable), NULL);
3333 + data = xmlSecBufferGetData(bn);
3334 + size = xmlSecBufferGetSize(bn);
3335 + ret = xmlSecBnInitialize(&bn2, size);
3337 + xmlSecError(XMLSEC_ERRORS_HERE,
3340 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3345 + ret = xmlSecBnSetData(&bn2, data, size);
3347 + xmlSecError(XMLSEC_ERRORS_HERE,
3349 + "xmlSecBnSetData",
3350 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3352 + xmlSecBnFinalize(&bn2);
3356 + /* check if it is a negative number or not */
3357 + data = xmlSecBufferGetData(&bn2);
3358 + size = xmlSecBufferGetSize(&bn2);
3359 + if((size > 0) && (data[0] > 127)) {
3360 + /* subtract 1 and do 2's compliment */
3361 + ret = xmlSecBnAdd(&bn2, -1);
3363 + xmlSecError(XMLSEC_ERRORS_HERE,
3366 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3368 + xmlSecBnFinalize(&bn2);
3371 + for(i = 0; i < size; ++i) {
3380 /* Result string len is
3381 * len = log base (256) * <bn size>
3382 * Since the smallest base == 2 then we can get away with
3383 * len = 8 * <bn size>
3385 - len = 8 * xmlSecBufferGetSize(bn) + 1;
3386 + len = 8 * size + 1 + 1;
3387 res = (xmlChar*)xmlMalloc(len + 1);
3389 - xmlSecError(XMLSEC_ERRORS_HERE,
3392 - XMLSEC_ERRORS_R_MALLOC_FAILED,
3395 + xmlSecError(XMLSEC_ERRORS_HERE,
3398 + XMLSEC_ERRORS_R_MALLOC_FAILED,
3400 + xmlSecBnFinalize(&bn2);
3403 memset(res, 0, len + 1);
3405 - for(i = 0; (xmlSecBufferGetSize(bn) > 0) && (i < len); i++) {
3406 - if(xmlSecBnDiv(bn, base, &nn) < 0) {
3407 - xmlSecError(XMLSEC_ERRORS_HERE,
3410 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
3415 - xmlSecAssert2((size_t)nn < sizeof(xmlSecBnRevLookupTable), NULL);
3416 - res[i] = xmlSecBnRevLookupTable[nn];
3417 + for(i = 0; (xmlSecBufferGetSize(&bn2) > 0) && (i < len); i++) {
3418 + if(xmlSecBnDiv(&bn2, base, &nn) < 0) {
3419 + xmlSecError(XMLSEC_ERRORS_HERE,
3422 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3425 + xmlSecBnFinalize(&bn2);
3428 + xmlSecAssert2((size_t)nn < sizeof(xmlSecBnRevLookupTable), NULL);
3429 + res[i] = xmlSecBnRevLookupTable[nn];
3431 xmlSecAssert2(i < len, NULL);
3433 @@ -301,13 +435,20 @@
3434 for(len = i; (len > 1) && (res[len - 1] == '0'); len--);
3437 + /* add "-" for negative numbers */
3438 + if(positive == 0) {
3440 + res[++len] = '\0';
3443 /* swap the string because we wrote it in reverse order */
3444 for(i = 0; i < len / 2; i++) {
3446 - res[i] = res[len - i - 1];
3447 - res[len - i - 1] = ch;
3449 + res[i] = res[len - i - 1];
3450 + res[len - i - 1] = ch;
3453 + xmlSecBnFinalize(&bn2);
3460 data = xmlSecBufferGetData(bn);
3461 - for(over = 0, i = xmlSecBufferGetSize(bn); i > 0;) {
3462 + i = xmlSecBufferGetSize(bn);
3465 xmlSecAssert2(data != NULL, -1);
3467 over = over + multiplier * data[--i];
3468 @@ -487,43 +630,57 @@
3471 xmlSecBnAdd(xmlSecBnPtr bn, int delta) {
3479 xmlSecAssert2(bn != NULL, -1);
3480 - xmlSecAssert2(delta >= 0, -1);
3487 data = xmlSecBufferGetData(bn);
3488 - for(over = delta, i = xmlSecBufferGetSize(bn); i > 0;) {
3489 - xmlSecAssert2(data != NULL, -1);
3491 + for(over = delta, i = xmlSecBufferGetSize(bn); (i > 0) && (over > 0) ;) {
3492 + xmlSecAssert2(data != NULL, -1);
3494 - over += data[--i];
3495 - data[i] = over % 256;
3496 - over = over / 256;
3500 + data[i] = over % 256;
3501 + over = over / 256;
3506 - over = over / 256;
3509 + over = over / 256;
3511 - ret = xmlSecBufferPrepend(bn, &ch, 1);
3513 - xmlSecError(XMLSEC_ERRORS_HERE,
3515 - "xmlSecBufferPrepend",
3516 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
3520 + ret = xmlSecBufferPrepend(bn, &ch, 1);
3522 + xmlSecError(XMLSEC_ERRORS_HERE,
3524 + "xmlSecBufferPrepend",
3525 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
3531 + for(over = -delta, i = xmlSecBufferGetSize(bn); (i > 0) && (over > 0);) {
3532 + xmlSecAssert2(data != NULL, -1);
3537 + over = (over - tmp) / 256;
3539 + data[i] = tmp - over;
3552 - xmlNodeAddContent(cur, BAD_CAST "\n");
3553 + xmlNodeAddContent(cur, xmlSecStringCR);
3561 - xmlNodeAddContent(cur, BAD_CAST "\n");
3562 + xmlNodeAddContent(cur, xmlSecStringCR);
3566 --- misc/xmlsec1-1.2.6/src/dl.c 2003-10-29 16:57:20.000000000 +0100
3567 +++ misc/build/xmlsec1-1.2.6/src/dl.c 2008-06-29 23:44:19.000000000 +0200
3568 @@ -329,6 +329,10 @@
3569 xmlSecCryptoDLInit(void) {
3572 + /* use xmlMalloc/xmlFree */
3573 + xmlsec_lt_dlmalloc = xmlSecCryptoDLMalloc;
3574 + xmlsec_lt_dlfree = xmlSecCryptoDLFree;
3576 ret = xmlSecPtrListInitialize(&gXmlSecCryptoDLLibraries, xmlSecCryptoDLLibrariesListGetKlass());
3578 xmlSecError(XMLSEC_ERRORS_HERE,
3581 /* TODO: LTDL_SET_PRELOADED_SYMBOLS(); */
3583 - /* use xmlMalloc/xmlFree */
3584 - xmlsec_lt_dlmalloc = xmlSecCryptoDLMalloc;
3585 - xmlsec_lt_dlfree = xmlSecCryptoDLFree;
3589 --- misc/xmlsec1-1.2.6/src/mscrypto/Makefile.in 2008-06-29 23:44:40.000000000 +0200
3590 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/Makefile.in 2008-06-29 23:44:19.000000000 +0200
3593 +# Makefile.in generated by automake 1.8.3 from Makefile.am.
3594 +# @configure_input@
3596 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3597 +# 2003, 2004 Free Software Foundation, Inc.
3598 +# This Makefile.in is free software; the Free Software Foundation
3599 +# gives unlimited permission to copy and/or distribute it,
3600 +# with or without modifications, as long as this notice is preserved.
3602 +# This program is distributed in the hope that it will be useful,
3603 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
3604 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
3605 +# PARTICULAR PURPOSE.
3610 +top_srcdir = @top_srcdir@
3611 +top_builddir = ../..
3612 +LTLIBRARIES = $(lib_LTLIBRARIES)
3613 +am__DEPENDENCIES_1 =
3614 +libxmlsec1_mscrypto_la_DEPENDENCIES = ../libxmlsec1.la \
3615 + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
3616 + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
3618 +am_libxmlsec1_mscrypto_la_OBJECTS = akmngr.lo app.lo certkeys.lo ciphers.lo crypto.lo \
3619 + digests.lo keysstore.lo kt_rsa.lo signatures.lo symkeys.lo \
3620 + x509.lo x509vfy.lo $(am__objects_1)
3621 +libxmlsec1_mscrypto_la_OBJECTS = $(am_libxmlsec1_mscrypto_la_OBJECTS)
3622 +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
3623 +depcomp = $(SHELL) $(top_srcdir)/depcomp
3624 +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/app.Plo ./$(DEPDIR)/certkeys.Plo \
3625 +@AMDEP_TRUE@ ./$(DEPDIR)/ciphers.Plo ./$(DEPDIR)/crypto.Plo \
3626 +@AMDEP_TRUE@ ./$(DEPDIR)/digests.Plo ./$(DEPDIR)/keysstore.Plo \
3627 +@AMDEP_TRUE@ ./$(DEPDIR)/kt_rsa.Plo ./$(DEPDIR)/signatures.Plo \
3628 +@AMDEP_TRUE@ ./$(DEPDIR)/symkeys.Plo ./$(DEPDIR)/x509.Plo \
3629 +@AMDEP_TRUE@ ./$(DEPDIR)/x509vfy.Plo ./$(DEPDIR)/akmngr.Plo
3630 +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
3631 + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
3632 +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
3633 + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
3634 + $(AM_CFLAGS) $(CFLAGS)
3636 +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
3637 + $(AM_LDFLAGS) $(LDFLAGS) -o $@
3639 +CCDEPMODE = @CCDEPMODE@
3641 +CPPFLAGS = @CPPFLAGS@
3642 +CYGPATH_W = @CYGPATH_W@
3645 +LDFLAGS = @LDFLAGS@
3647 +LIBTOOL = @LIBTOOL@
3648 +LIBXML_CFLAGS = @LIBXML_CFLAGS@
3649 +LIBXML_LIBS = @LIBXML_LIBS@
3650 +MSCRYPTO_CFLAGS = @MSCRYPTO_CFLAGS@
3651 +MSCRYPTO_LIBS = @MSCRYPTO_LIBS@
3654 +XMLSEC_DEFINES = @XMLSEC_DEFINES@
3655 +exec_prefix = @exec_prefix@
3661 + -DPACKAGE=\"@PACKAGE@\" \
3663 + -I$(top_srcdir)/include \
3664 + $(XMLSEC_DEFINES) \
3665 + $(MSCRYPTO_CFLAGS) \
3666 + $(LIBXSLT_CFLAGS) \
3667 + $(LIBXML_CFLAGS) \
3670 +lib_LTLIBRARIES = \
3671 + libxmlsec1-mscrypto.la \
3674 +libxmlsec1_mscrypto_la_LIBADD = \
3675 + ../libxmlsec1.la \
3676 + $(MSCRYPTO_LIBS) \
3681 +libxmlsec1_mscrypto_la_LDFLAGS = \
3682 + -version-info @XMLSEC_VERSION_INFO@ \
3688 +.SUFFIXES: .c .lo .o .obj
3690 +clean-libLTLIBRARIES:
3691 + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
3692 + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
3693 + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
3694 + test "$$dir" = "$$p" && dir=.; \
3695 + echo "rm -f \"$${dir}/so_locations\""; \
3696 + rm -f "$${dir}/so_locations"; \
3698 +libxmlsec1-mscrypto.la: $(libxmlsec1_mscrypto_la_OBJECTS) $(libxmlsec1_mscrypto_la_DEPENDENCIES)
3699 + $(LINK) -rpath $(libdir) $(libxmlsec1_mscrypto_la_LDFLAGS) $(libxmlsec1_mscrypto_la_OBJECTS) $(libxmlsec1_mscrypto_la_LIBADD) $(LIBS)
3701 +mostlyclean-compile:
3702 + -rm -f *.$(OBJEXT)
3704 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/akmngr.Plo@am__quote@
3705 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/app.Plo@am__quote@
3706 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/certkeys.Plo@am__quote@
3707 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ciphers.Plo@am__quote@
3708 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypto.Plo@am__quote@
3709 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digests.Plo@am__quote@
3710 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keysstore.Plo@am__quote@
3711 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kt_rsa.Plo@am__quote@
3712 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signatures.Plo@am__quote@
3713 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symkeys.Plo@am__quote@
3714 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x509.Plo@am__quote@
3715 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x509vfy.Plo@am__quote@
3718 +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
3719 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
3720 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
3721 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
3722 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3723 +@am__fastdepCC_FALSE@ $(COMPILE) -c $<
3726 +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
3727 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
3728 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
3729 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
3730 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3731 +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
3734 +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
3735 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
3736 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
3737 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
3738 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
3739 +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
3741 +mostlyclean-libtool:
3745 + -rm -rf .libs _libs
3747 +all-am: Makefile $(LTLIBRARIES)
3749 +mostlyclean-generic:
3755 +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
3758 +mostlyclean: mostlyclean-am
3760 +mostlyclean-am: mostlyclean-compile mostlyclean-generic \
3761 + mostlyclean-libtool
3763 +.PHONY: all all-am clean clean-generic \
3764 + clean-libLTLIBRARIES clean-libtool \
3765 + maintainer-clean-generic mostlyclean mostlyclean-compile \
3766 + mostlyclean-generic mostlyclean-libtool
3768 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
3769 +# Otherwise a system limit (for SysV at least) may be exceeded.
3771 --- misc/xmlsec1-1.2.6/src/mscrypto/akmngr.c 2008-06-29 23:44:39.000000000 +0200
3772 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/akmngr.c 2008-06-29 23:44:19.000000000 +0200
3778 + * This is free software; see Copyright file in the source
3779 + * distribution for preciese wording.
3781 + * Copyright.........................
3783 +#include "globals.h"
3785 +#include <xmlsec/xmlsec.h>
3786 +#include <xmlsec/keys.h>
3787 +#include <xmlsec/transforms.h>
3788 +#include <xmlsec/errors.h>
3790 +#include <xmlsec/mscrypto/crypto.h>
3791 +#include <xmlsec/mscrypto/keysstore.h>
3792 +#include <xmlsec/mscrypto/akmngr.h>
3793 +#include <xmlsec/mscrypto/x509.h>
3796 + * xmlSecMSCryptoAppliedKeysMngrCreate:
3797 + * @hKeyStore: the pointer to key store.
3798 + * @hCertStore: the pointer to certificate database.
3800 + * Create and load key store and certificate database into keys manager
3802 + * Returns keys manager pointer on success or NULL otherwise.
3805 +xmlSecMSCryptoAppliedKeysMngrCreate(
3806 + HCERTSTORE hKeyStore ,
3807 + HCERTSTORE hCertStore
3809 + xmlSecKeyDataStorePtr certStore = NULL ;
3810 + xmlSecKeysMngrPtr keyMngr = NULL ;
3811 + xmlSecKeyStorePtr keyStore = NULL ;
3813 + keyStore = xmlSecKeyStoreCreate( xmlSecMSCryptoKeysStoreId ) ;
3814 + if( keyStore == NULL ) {
3815 + xmlSecError( XMLSEC_ERRORS_HERE ,
3817 + "xmlSecKeyStoreCreate" ,
3818 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3819 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3824 + * At present, MS Crypto engine do not provide a way to setup a key store.
3826 + if( keyStore != NULL ) {
3827 + /*TODO: binding key store.*/
3830 + keyMngr = xmlSecKeysMngrCreate() ;
3831 + if( keyMngr == NULL ) {
3832 + xmlSecError( XMLSEC_ERRORS_HERE ,
3834 + "xmlSecKeysMngrCreate" ,
3835 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3836 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3838 + xmlSecKeyStoreDestroy( keyStore ) ;
3843 + * Add key store to manager, from now on keys manager destroys the store if
3846 + if( xmlSecKeysMngrAdoptKeysStore( keyMngr, keyStore ) < 0 ) {
3847 + xmlSecError( XMLSEC_ERRORS_HERE ,
3848 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
3849 + "xmlSecKeysMngrAdoptKeyStore" ,
3850 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3851 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3853 + xmlSecKeyStoreDestroy( keyStore ) ;
3854 + xmlSecKeysMngrDestroy( keyMngr ) ;
3859 + * Initialize crypto library specific data in keys manager
3861 + if( xmlSecMSCryptoKeysMngrInit( keyMngr ) < 0 ) {
3862 + xmlSecError( XMLSEC_ERRORS_HERE ,
3864 + "xmlSecMSCryptoKeysMngrInit" ,
3865 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3866 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3868 + xmlSecKeysMngrDestroy( keyMngr ) ;
3873 + * Set certificate databse to X509 key data store
3876 + * At present, MS Crypto engine do not provide a way to setup a cert store.
3880 + * Set the getKey callback
3882 + keyMngr->getKey = xmlSecKeysMngrGetKey ;
3888 +xmlSecMSCryptoAppliedKeysMngrSymKeyLoad(
3889 + xmlSecKeysMngrPtr mngr ,
3892 + /*TODO: import the key into keys manager.*/
3897 +xmlSecMSCryptoAppliedKeysMngrPubKeyLoad(
3898 + xmlSecKeysMngrPtr mngr ,
3901 + /*TODO: import the key into keys manager.*/
3906 +xmlSecMSCryptoAppliedKeysMngrPriKeyLoad(
3907 + xmlSecKeysMngrPtr mngr ,
3910 + /*TODO: import the key into keys manager.*/
3915 +xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore (
3916 + xmlSecKeysMngrPtr mngr ,
3917 + HCERTSTORE keyStore
3919 + xmlSecKeyDataStorePtr x509Store ;
3921 + xmlSecAssert2( mngr != NULL, -1 ) ;
3922 + xmlSecAssert2( keyStore != NULL, -1 ) ;
3924 + x509Store = xmlSecKeysMngrGetDataStore( mngr, xmlSecMSCryptoX509StoreId ) ;
3925 + if( x509Store == NULL ) {
3926 + xmlSecError( XMLSEC_ERRORS_HERE ,
3928 + "xmlSecKeysMngrGetDataStore" ,
3929 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3930 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3934 + if( xmlSecMSCryptoX509StoreAdoptKeyStore( x509Store, keyStore ) < 0 ) {
3935 + xmlSecError( XMLSEC_ERRORS_HERE ,
3936 + xmlSecErrorsSafeString( xmlSecKeyDataStoreGetName( x509Store ) ) ,
3937 + "xmlSecMSCryptoX509StoreAdoptKeyStore" ,
3938 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3939 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3947 +xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore (
3948 + xmlSecKeysMngrPtr mngr ,
3949 + HCERTSTORE trustedStore
3951 + xmlSecKeyDataStorePtr x509Store ;
3953 + xmlSecAssert2( mngr != NULL, -1 ) ;
3954 + xmlSecAssert2( trustedStore != NULL, -1 ) ;
3956 + x509Store = xmlSecKeysMngrGetDataStore( mngr, xmlSecMSCryptoX509StoreId ) ;
3957 + if( x509Store == NULL ) {
3958 + xmlSecError( XMLSEC_ERRORS_HERE ,
3960 + "xmlSecKeysMngrGetDataStore" ,
3961 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3962 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3966 + if( xmlSecMSCryptoX509StoreAdoptTrustedStore( x509Store, trustedStore ) < 0 ) {
3967 + xmlSecError( XMLSEC_ERRORS_HERE ,
3968 + xmlSecErrorsSafeString( xmlSecKeyDataStoreGetName( x509Store ) ) ,
3969 + "xmlSecMSCryptoX509StoreAdoptKeyStore" ,
3970 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3971 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3979 +xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore (
3980 + xmlSecKeysMngrPtr mngr ,
3981 + HCERTSTORE untrustedStore
3983 + xmlSecKeyDataStorePtr x509Store ;
3985 + xmlSecAssert2( mngr != NULL, -1 ) ;
3986 + xmlSecAssert2( untrustedStore != NULL, -1 ) ;
3988 + x509Store = xmlSecKeysMngrGetDataStore( mngr, xmlSecMSCryptoX509StoreId ) ;
3989 + if( x509Store == NULL ) {
3990 + xmlSecError( XMLSEC_ERRORS_HERE ,
3992 + "xmlSecKeysMngrGetDataStore" ,
3993 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
3994 + XMLSEC_ERRORS_NO_MESSAGE ) ;
3998 + if( xmlSecMSCryptoX509StoreAdoptUntrustedStore( x509Store, untrustedStore ) < 0 ) {
3999 + xmlSecError( XMLSEC_ERRORS_HERE ,
4000 + xmlSecErrorsSafeString( xmlSecKeyDataStoreGetName( x509Store ) ) ,
4001 + "xmlSecMSCryptoX509StoreAdoptKeyStore" ,
4002 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
4003 + XMLSEC_ERRORS_NO_MESSAGE ) ;
4010 --- misc/xmlsec1-1.2.6/src/mscrypto/certkeys.c 2004-03-17 06:06:43.000000000 +0100
4011 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/certkeys.c 2008-06-29 23:44:19.000000000 +0200
4013 * a public key from xml document is provided, we need HCRYPTKEY.... The focus
4014 * now is however directed to certificates. Wouter
4016 +/** replaced by a wrapper style for WINNT 4.0
4017 struct _xmlSecMSCryptoKeyDataCtx {
4019 BOOL fCallerFreeProv;
4022 xmlSecKeyDataType type;
4026 + * A wrapper of HCRYPTKEY, a reference countor is introduced, the function is
4027 + * the same as CryptDuplicateKey. Because the CryptDuplicateKey is not support
4028 + * by WINNT 4.0, the wrapper will enable the library work on WINNT 4.0
4030 +struct _mscrypt_key {
4036 + * A wrapper of HCRYPTPROV, a reference countor is introduced, the function is
4037 + * the same as CryptContextAddRef. Because the CryptContextAddRef is not support
4038 + * by WINNT 4.0, the wrapper will enable the library work on WINNT 4.0
4040 +struct _mscrypt_prov {
4041 + HCRYPTPROV hProv ;
4046 +struct _xmlSecMSCryptoKeyDataCtx {
4047 + struct _mscrypt_prov* p_prov ;
4048 + LPCTSTR providerName;
4049 + DWORD providerType;
4050 + PCCERT_CONTEXT pCert;
4052 + struct _mscrypt_key* p_key ;
4053 + xmlSecKeyDataType type;
4056 +struct _mscrypt_key* mscrypt_create_key( HCRYPTKEY key ) {
4057 + struct _mscrypt_key* pkey ;
4059 + pkey = ( struct _mscrypt_key* )xmlMalloc( sizeof( struct _mscrypt_key ) ) ;
4060 + if( pkey == NULL ) {
4061 + xmlSecError( XMLSEC_ERRORS_HERE,
4062 + "mscrypt_create_key" ,
4064 + XMLSEC_ERRORS_R_MALLOC_FAILED ,
4065 + XMLSEC_ERRORS_NO_MESSAGE
4069 + pkey->hKey = key ;
4070 + pkey->refcnt = 1 ;
4075 +struct _mscrypt_key* mscrypt_acquire_key( struct _mscrypt_key* key ) {
4082 +int mscrypt_release_key( struct _mscrypt_key* key ) {
4085 + if( !key->refcnt ) {
4087 + CryptDestroyKey( key->hKey ) ;
4092 + return key->refcnt ;
4099 +struct _mscrypt_prov* mscrypt_create_prov( HCRYPTPROV prov, BOOL callerFree ) {
4100 + struct _mscrypt_prov* pprov ;
4102 + pprov = ( struct _mscrypt_prov* )xmlMalloc( sizeof( struct _mscrypt_prov ) ) ;
4103 + if( pprov == NULL ) {
4104 + xmlSecError( XMLSEC_ERRORS_HERE,
4105 + "mscrypt_create_prov" ,
4107 + XMLSEC_ERRORS_R_MALLOC_FAILED ,
4108 + XMLSEC_ERRORS_NO_MESSAGE
4112 + pprov->hProv = prov ;
4113 + pprov->freeprov = callerFree ;
4114 + pprov->refcnt = 1 ;
4119 +struct _mscrypt_prov* mscrypt_acquire_prov( struct _mscrypt_prov* prov ) {
4126 +int mscrypt_release_prov( struct _mscrypt_prov* prov ) {
4129 + if( !prov->refcnt ) {
4130 + if( prov->hProv && prov->freeprov ) {
4131 + CryptReleaseContext( prov->hProv, 0 ) ;
4136 + return prov->refcnt ;
4143 /******************************************************************************
4145 @@ -88,24 +207,20 @@
4146 ctx = xmlSecMSCryptoKeyDataGetCtx(data);
4147 xmlSecAssert2(ctx != NULL, -1);
4149 - if (ctx->hKey != 0) {
4150 - CryptDestroyKey(ctx->hKey);
4153 + if( ctx->p_key != 0 ) {
4154 + mscrypt_release_key( ctx->p_key ) ;
4156 + ctx->p_key = mscrypt_create_key( 0 ) ;
4158 if(ctx->pCert != NULL) {
4159 CertFreeCertificateContext(ctx->pCert);
4163 - if ((ctx->hProv != 0) && (ctx->fCallerFreeProv)) {
4164 - CryptReleaseContext(ctx->hProv, 0);
4166 - ctx->fCallerFreeProv = FALSE;
4169 - ctx->fCallerFreeProv = FALSE;
4171 + if( ( ctx->p_prov ) ) {
4172 + mscrypt_release_prov( ctx->p_prov ) ;
4174 + ctx->p_prov = mscrypt_create_prov( 0, FALSE ) ;
4179 if (!CryptAcquireCertificatePrivateKey(pCert,
4180 CRYPT_ACQUIRE_USE_PROV_INFO_FLAG,
4183 + &(ctx->p_prov->hProv),
4185 - &(ctx->fCallerFreeProv))) {
4186 + &(ctx->p_prov->freeprov))) {
4187 xmlSecError(XMLSEC_ERRORS_HERE,
4189 "CryptAcquireCertificatePrivateKey",
4190 @@ -127,46 +242,39 @@
4193 } else if((type & xmlSecKeyDataTypePublic) != 0){
4194 - if (!CryptAcquireContext(&(ctx->hProv),
4195 + if (!CryptAcquireContext(&(ctx->p_prov->hProv),
4197 - ctx->providerName,
4198 + NULL, /*AF: replaces "ctx->providerName" with "NULL" */
4200 CRYPT_VERIFYCONTEXT)) {
4201 - xmlSecError(XMLSEC_ERRORS_HERE,
4203 - "CryptAcquireContext",
4204 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
4205 - XMLSEC_ERRORS_NO_MESSAGE);
4208 - ctx->dwKeySpec = 0;
4209 - ctx->fCallerFreeProv = TRUE;
4210 + xmlSecError(XMLSEC_ERRORS_HERE,
4212 + "CryptAcquireContext",
4213 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4214 + XMLSEC_ERRORS_NO_MESSAGE);
4217 + ctx->dwKeySpec = 0;
4218 + ctx->p_prov->freeprov = TRUE;
4220 + if( !CryptImportPublicKeyInfo( ctx->p_prov->hProv,
4221 + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
4222 + &(pCert->pCertInfo->SubjectPublicKeyInfo),
4223 + &(ctx->p_key->hKey) ) ) {
4224 + xmlSecError(XMLSEC_ERRORS_HERE,
4226 + "CryptImportPublicKeyInfo",
4227 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4228 + XMLSEC_ERRORS_NO_MESSAGE);
4232 - xmlSecError(XMLSEC_ERRORS_HERE,
4233 + xmlSecError(XMLSEC_ERRORS_HERE,
4236 XMLSEC_ERRORS_R_XMLSEC_FAILED,
4237 "Unsupported keytype");
4241 - /* CryptImportPublicKeyInfo is only needed when a real key handle
4242 - * is needed. The key handle is needed for de/encrypting and for
4243 - * verifying of a signature, *not* for signing. We could call
4244 - * CryptImportPublicKeyInfo in xmlSecMSCryptoKeyDataGetKey instead
4245 - * so no unnessecary calls to CryptImportPublicKeyInfo are being
4248 - if(!CryptImportPublicKeyInfo(ctx->hProv,
4249 - X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
4250 - &(pCert->pCertInfo->SubjectPublicKeyInfo),
4252 - xmlSecError(XMLSEC_ERRORS_HERE,
4254 - "CryptImportPublicKeyInfo",
4255 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
4256 - XMLSEC_ERRORS_NO_MESSAGE);
4262 @@ -190,29 +298,26 @@
4263 ctx = xmlSecMSCryptoKeyDataGetCtx(data);
4264 xmlSecAssert2(ctx != NULL, -1);
4266 - if(ctx->hKey != 0) {
4267 - CryptDestroyKey(ctx->hKey);
4270 + if( ctx->p_key != 0 ) {
4271 + mscrypt_release_key( ctx->p_key ) ;
4272 + ctx->p_key = NULL ;
4275 if(ctx->pCert != NULL) {
4276 CertFreeCertificateContext(ctx->pCert);
4280 - if((ctx->hProv != 0) && ctx->fCallerFreeProv) {
4281 - CryptReleaseContext(ctx->hProv, 0);
4283 - ctx->fCallerFreeProv = FALSE;
4286 - ctx->fCallerFreeProv = FALSE;
4288 + if( ( ctx->p_prov ) ) {
4289 + mscrypt_release_prov( ctx->p_prov ) ;
4290 + ctx->p_prov = NULL ;
4292 + ctx->p_prov = NULL ;
4295 - ctx->hProv = hProv;
4296 - ctx->fCallerFreeProv = fCallerFreeProv;
4297 + ctx->p_prov = mscrypt_create_prov( hProv, FALSE ) ;
4298 ctx->dwKeySpec = dwKeySpec;
4300 + ctx->p_key = mscrypt_create_key( hKey ) ;
4305 ctx = xmlSecMSCryptoKeyDataGetCtx(data);
4306 xmlSecAssert2(ctx != NULL, 0);
4308 - return(ctx->hKey);
4309 + return( ctx->p_key ? ctx->p_key->hKey : 0 );
4314 ctx = xmlSecMSCryptoKeyDataGetCtx(data);
4315 xmlSecAssert2(ctx != NULL, 0);
4317 - return(ctx->hProv);
4318 + return( ctx->p_prov ? ctx->p_prov->hProv : 0 );
4322 @@ -316,25 +421,36 @@
4323 XMLSEC_ERRORS_NO_MESSAGE);
4328 - if (ctxSrc->hKey != 0) {
4329 - if (!CryptDuplicateKey(ctxSrc->hKey, NULL, 0, &(ctxDst->hKey))) {
4330 - xmlSecError(XMLSEC_ERRORS_HERE,
4331 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
4332 - "CryptDuplicateKey",
4333 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
4334 - XMLSEC_ERRORS_NO_MESSAGE);
4338 - if(ctxSrc->hProv != 0) {
4339 - CryptContextAddRef(ctxSrc->hProv, NULL, 0);
4340 - ctxDst->hProv = ctxSrc->hProv;
4341 - ctxDst->fCallerFreeProv = TRUE;
4343 - ctxDst->hProv = 0;
4344 - ctxDst->fCallerFreeProv = FALSE;
4346 + if( ctxSrc->p_key ) {
4347 + if( ctxDst->p_key )
4348 + mscrypt_release_key( ctxDst->p_key ) ;
4350 + ctxDst->p_key = mscrypt_acquire_key( ctxSrc->p_key ) ;
4351 + if( !ctxDst->p_key ) {
4352 + xmlSecError(XMLSEC_ERRORS_HERE,
4353 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
4354 + "mscrypt_acquire_key",
4355 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4356 + XMLSEC_ERRORS_NO_MESSAGE);
4361 + if( ctxSrc->p_prov ) {
4362 + if( ctxDst->p_prov )
4363 + mscrypt_release_prov( ctxDst->p_prov ) ;
4365 + ctxDst->p_prov = mscrypt_acquire_prov( ctxSrc->p_prov ) ;
4366 + if( !ctxDst->p_prov ) {
4367 + xmlSecError(XMLSEC_ERRORS_HERE,
4368 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
4369 + "mscrypt_acquire_prov",
4370 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4371 + XMLSEC_ERRORS_NO_MESSAGE);
4376 ctxDst->dwKeySpec = ctxSrc->dwKeySpec;
4377 @@ -355,16 +471,16 @@
4378 ctx = xmlSecMSCryptoKeyDataGetCtx(data);
4379 xmlSecAssert(ctx != NULL);
4381 - if (ctx->hKey != 0) {
4382 - CryptDestroyKey(ctx->hKey);
4383 + if( ctx->p_key ) {
4384 + mscrypt_release_key( ctx->p_key ) ;
4387 if(ctx->pCert != NULL) {
4388 CertFreeCertificateContext(ctx->pCert);
4391 - if ((ctx->hProv != 0) && ctx->fCallerFreeProv) {
4392 - CryptReleaseContext(ctx->hProv, 0);
4393 + if( ctx->p_prov ) {
4394 + mscrypt_release_prov( ctx->p_prov ) ;
4397 memset(ctx, 0, sizeof(xmlSecMSCryptoKeyDataCtx));
4398 @@ -384,14 +500,14 @@
4399 xmlSecAssert2(ctx->pCert->pCertInfo != NULL, 0);
4400 return (CertGetPublicKeyLength(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
4401 &(ctx->pCert->pCertInfo->SubjectPublicKeyInfo)));
4402 - } else if (ctx->hKey != 0) {
4403 + } else if (ctx->p_key != 0 && ctx->p_key->hKey != 0 ) {
4405 DWORD lenlen = sizeof(DWORD);
4407 - if (!CryptGetKeyParam(ctx->hKey, KP_KEYLEN, (BYTE *)&length, &lenlen, 0)) {
4409 + if (!CryptGetKeyParam(ctx->p_key->hKey, KP_KEYLEN, (BYTE *)&length, &lenlen, 0)) {
4410 xmlSecError(XMLSEC_ERRORS_HERE,
4412 - "CertDuplicateCertificateContext",
4413 + "CryptGetKeyParam",
4414 XMLSEC_ERRORS_R_CRYPTO_FAILED,
4415 XMLSEC_ERRORS_NO_MESSAGE);
4417 @@ -581,7 +697,11 @@
4418 static void xmlSecMSCryptoKeyDataRsaDebugDump(xmlSecKeyDataPtr data, FILE* output);
4419 static void xmlSecMSCryptoKeyDataRsaDebugXmlDump(xmlSecKeyDataPtr data, FILE* output);
4421 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4422 +static struct _xmlSecKeyDataKlass xmlSecMSCryptoKeyDataRsaKlass = {
4424 static xmlSecKeyDataKlass xmlSecMSCryptoKeyDataRsaKlass = {
4426 sizeof(xmlSecKeyDataKlass),
4427 xmlSecMSCryptoKeyDataSize,
4429 @@ -938,9 +1058,10 @@
4431 ctx = xmlSecMSCryptoKeyDataGetCtx(xmlSecKeyGetValue(key));
4432 xmlSecAssert2(ctx != NULL, -1);
4433 - xmlSecAssert2(ctx->hKey != 0, -1);
4434 + xmlSecAssert2(ctx->p_key != 0, -1);
4435 + xmlSecAssert2(ctx->p_key->hKey != 0, -1);
4437 - if (!CryptExportKey(ctx->hKey, 0, PUBLICKEYBLOB, 0, NULL, &dwBlobLen)) {
4438 + if (!CryptExportKey(ctx->p_key->hKey, 0, PUBLICKEYBLOB, 0, NULL, &dwBlobLen)) {
4439 xmlSecError(XMLSEC_ERRORS_HERE,
4440 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
4442 @@ -960,7 +1081,7 @@
4445 blob = xmlSecBufferGetData(&buf);
4446 - if (!CryptExportKey(ctx->hKey, 0, PUBLICKEYBLOB, 0, blob, &dwBlobLen)) {
4447 + if (!CryptExportKey(ctx->p_key->hKey, 0, PUBLICKEYBLOB, 0, blob, &dwBlobLen)) {
4448 xmlSecError(XMLSEC_ERRORS_HERE,
4449 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
4451 @@ -1295,7 +1416,11 @@
4452 static void xmlSecMSCryptoKeyDataDsaDebugXmlDump(xmlSecKeyDataPtr data,
4455 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4456 +static struct _xmlSecKeyDataKlass xmlSecMSCryptoKeyDataDsaKlass = {
4458 static xmlSecKeyDataKlass xmlSecMSCryptoKeyDataDsaKlass = {
4460 sizeof(xmlSecKeyDataKlass),
4461 xmlSecMSCryptoKeyDataSize,
4463 @@ -1797,9 +1922,10 @@
4465 ctx = xmlSecMSCryptoKeyDataGetCtx(xmlSecKeyGetValue(key));
4466 xmlSecAssert2(ctx != NULL, -1);
4467 - xmlSecAssert2(ctx->hKey != 0, -1);
4468 + xmlSecAssert2(ctx->p_key != 0, -1);
4469 + xmlSecAssert2(ctx->p_key->hKey != 0, -1);
4471 - if (!CryptExportKey(ctx->hKey, 0, PUBLICKEYBLOB, 0, NULL, &dwBlobLen)) {
4472 + if (!CryptExportKey(ctx->p_key->hKey, 0, PUBLICKEYBLOB, 0, NULL, &dwBlobLen)) {
4473 xmlSecError(XMLSEC_ERRORS_HERE,
4474 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
4476 @@ -1819,7 +1945,7 @@
4479 blob = xmlSecBufferGetData(&buf);
4480 - if (!CryptExportKey(ctx->hKey, 0, PUBLICKEYBLOB, 0, blob, &dwBlobLen)) {
4481 + if (!CryptExportKey(ctx->p_key->hKey, 0, PUBLICKEYBLOB, 0, blob, &dwBlobLen)) {
4482 xmlSecError(XMLSEC_ERRORS_HERE,
4483 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
4485 @@ -2010,7 +2136,6 @@
4492 xmlSecAssert2(xmlSecKeyDataIsValid(data), xmlSecKeyDataTypeUnknown);
4493 @@ -2043,12 +2168,14 @@
4494 dwKeySpec = AT_SIGNATURE;
4495 dwSize = ((sizeBits << 16) | CRYPT_EXPORTABLE);
4496 if (!CryptGenKey(hProv, CALG_DSS_SIGN, dwSize, &hKey)) {
4497 - xmlSecError(XMLSEC_ERRORS_HERE,
4498 + xmlSecError(XMLSEC_ERRORS_HERE,
4499 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4501 XMLSEC_ERRORS_R_CRYPTO_FAILED,
4502 XMLSEC_ERRORS_NO_MESSAGE);
4505 + CryptReleaseContext(hProv, 0);
4509 ret = xmlSecMSCryptoKeyDataAdoptKey(data, hProv, TRUE, hKey, dwKeySpec,
4510 @@ -2059,24 +2186,17 @@
4511 "xmlSecMSCryptoKeyDataAdoptKey",
4512 XMLSEC_ERRORS_R_XMLSEC_FAILED,
4513 XMLSEC_ERRORS_NO_MESSAGE);
4519 + CryptDestroyKey( hKey ) ;
4521 + CryptReleaseContext( hProv, 0 ) ;
4528 - CryptReleaseContext(ctx->hProv, 0);
4535 - CryptDestroyKey(hKey);
4542 static xmlSecKeyDataType
4543 --- misc/xmlsec1-1.2.6/src/mscrypto/ciphers.c 2003-09-26 08:12:51.000000000 +0200
4544 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/ciphers.c 2008-06-29 23:44:19.000000000 +0200
4545 @@ -785,7 +785,11 @@
4546 * AES CBC cipher transforms
4548 ********************************************************************/
4549 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4550 +static struct _xmlSecTransformKlass xmlSecMSCryptoAes128CbcKlass = {
4552 static xmlSecTransformKlass xmlSecMSCryptoAes128CbcKlass = {
4554 /* klass/object sizes */
4555 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
4556 xmlSecMSCryptoBlockCipherSize, /* xmlSecSize objSize */
4557 @@ -824,7 +828,11 @@
4558 return(&xmlSecMSCryptoAes128CbcKlass);
4561 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4562 +static struct _xmlSecTransformKlass xmlSecMSCryptoAes192CbcKlass = {
4564 static xmlSecTransformKlass xmlSecMSCryptoAes192CbcKlass = {
4566 /* klass/object sizes */
4567 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
4568 xmlSecMSCryptoBlockCipherSize, /* xmlSecSize objSize */
4569 @@ -863,7 +871,11 @@
4570 return(&xmlSecMSCryptoAes192CbcKlass);
4573 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4574 +static struct _xmlSecTransformKlass xmlSecMSCryptoAes256CbcKlass = {
4576 static xmlSecTransformKlass xmlSecMSCryptoAes256CbcKlass = {
4578 /* klass/object sizes */
4579 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
4580 xmlSecMSCryptoBlockCipherSize, /* xmlSecSize objSize */
4581 @@ -906,7 +918,11 @@
4584 #ifndef XMLSEC_NO_DES
4585 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4586 +static struct _xmlSecTransformKlass xmlSecMSCryptoDes3CbcKlass = {
4588 static xmlSecTransformKlass xmlSecMSCryptoDes3CbcKlass = {
4590 /* klass/object sizes */
4591 sizeof(xmlSecTransformKlass), /* size_t klassSize */
4592 xmlSecMSCryptoBlockCipherSize, /* size_t objSize */
4593 --- misc/xmlsec1-1.2.6/src/mscrypto/crypto.c 2003-11-12 03:38:51.000000000 +0100
4594 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/crypto.c 2008-06-29 23:44:19.000000000 +0200
4595 @@ -330,13 +330,15 @@
4597 xmlSecMSCryptoCertStrToName(DWORD dwCertEncodingType, LPCTSTR pszX500, DWORD dwStrType, DWORD* len) {
4600 + LPCTSTR ppszError = NULL;
4602 xmlSecAssert2(pszX500 != NULL, NULL);
4603 xmlSecAssert2(len != NULL, NULL);
4605 if (!CertStrToName(dwCertEncodingType, pszX500, dwStrType,
4606 - NULL, NULL, len, NULL)) {
4607 + NULL, NULL, len, &ppszError)) {
4608 /* this might not be an error, string might just not exist */
4609 + DWORD dw = GetLastError();
4613 --- misc/xmlsec1-1.2.6/src/mscrypto/digests.c 2003-09-30 04:09:51.000000000 +0200
4614 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/digests.c 2008-06-29 23:44:19.000000000 +0200
4617 /* TODO: Check what provider is best suited here.... */
4618 if (!CryptAcquireContext(&ctx->provider, NULL, MS_STRONG_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
4619 - xmlSecError(XMLSEC_ERRORS_HERE,
4620 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
4622 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
4623 - XMLSEC_ERRORS_NO_MESSAGE);
4625 + //#i57942# This is also committed in rev 1.4 of this file in the xmlsec project
4626 + if (!CryptAcquireContext(&ctx->provider, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
4627 + xmlSecError(XMLSEC_ERRORS_HERE,
4628 + xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
4630 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4631 + XMLSEC_ERRORS_NO_MESSAGE);
4637 @@ -298,7 +301,11 @@
4640 *****************************************************************************/
4641 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4642 +static struct _xmlSecTransformKlass xmlSecMSCryptoSha1Klass = {
4644 static xmlSecTransformKlass xmlSecMSCryptoSha1Klass = {
4646 /* klass/object sizes */
4647 sizeof(xmlSecTransformKlass), /* size_t klassSize */
4648 xmlSecMSCryptoDigestSize, /* size_t objSize */
4649 --- misc/xmlsec1-1.2.6/src/mscrypto/keysstore.c 2003-09-27 05:12:22.000000000 +0200
4650 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/keysstore.c 2008-06-29 23:44:19.000000000 +0200
4652 const xmlChar* name,
4653 xmlSecKeyInfoCtxPtr keyInfoCtx);
4655 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4656 +static struct _xmlSecKeyStoreKlass xmlSecMSCryptoKeysStoreKlass = {
4658 static xmlSecKeyStoreKlass xmlSecMSCryptoKeysStoreKlass = {
4660 sizeof(xmlSecKeyStoreKlass),
4661 xmlSecMSCryptoKeysStoreSize,
4663 --- misc/xmlsec1-1.2.6/src/mscrypto/kt_rsa.c 2003-09-26 22:29:25.000000000 +0200
4664 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/kt_rsa.c 2008-06-29 23:44:19.000000000 +0200
4666 static int xmlSecMSCryptoRsaPkcs1Process (xmlSecTransformPtr transform,
4667 xmlSecTransformCtxPtr transformCtx);
4669 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4670 +static struct _xmlSecTransformKlass xmlSecMSCryptoRsaPkcs1Klass = {
4672 static xmlSecTransformKlass xmlSecMSCryptoRsaPkcs1Klass = {
4674 /* klass/object sizes */
4675 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
4676 xmlSecMSCryptoRsaPkcs1Size, /* xmlSecSize objSize */
4677 --- misc/xmlsec1-1.2.6/src/mscrypto/signatures.c 2003-09-26 22:29:25.000000000 +0200
4678 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/signatures.c 2008-06-29 23:44:19.000000000 +0200
4679 @@ -483,7 +483,11 @@
4680 * RSA-SHA1 signature transform
4682 ***************************************************************************/
4683 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4684 +static struct _xmlSecTransformKlass xmlSecMSCryptoRsaSha1Klass = {
4686 static xmlSecTransformKlass xmlSecMSCryptoRsaSha1Klass = {
4688 /* klass/object sizes */
4689 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
4690 xmlSecMSCryptoSignatureSize, /* xmlSecSize objSize */
4691 @@ -531,7 +535,11 @@
4693 ***************************************************************************/
4695 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4696 +static struct _xmlSecTransformKlass xmlSecMSCryptoDsaSha1Klass = {
4698 static xmlSecTransformKlass xmlSecMSCryptoDsaSha1Klass = {
4700 /* klass/object sizes */
4701 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
4702 xmlSecMSCryptoSignatureSize, /* xmlSecSize objSize */
4703 --- misc/xmlsec1-1.2.6/src/mscrypto/symkeys.c 2003-09-26 02:58:13.000000000 +0200
4704 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/symkeys.c 2008-06-29 23:44:19.000000000 +0200
4706 * <xmlsec:AESKeyValue> processing
4708 *************************************************************************/
4709 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4710 +static struct _xmlSecKeyDataKlass xmlSecMSCryptoKeyDataAesKlass = {
4712 static xmlSecKeyDataKlass xmlSecMSCryptoKeyDataAesKlass = {
4714 sizeof(xmlSecKeyDataKlass),
4715 xmlSecKeyDataBinarySize,
4717 @@ -153,7 +157,11 @@
4718 * <xmlsec:DESKeyValue> processing
4720 *************************************************************************/
4721 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4722 +static struct _xmlSecKeyDataKlass xmlSecMSCryptoKeyDataDesKlass = {
4724 static xmlSecKeyDataKlass xmlSecMSCryptoKeyDataDesKlass = {
4726 sizeof(xmlSecKeyDataKlass),
4727 xmlSecKeyDataBinarySize,
4729 --- misc/xmlsec1-1.2.6/src/mscrypto/x509.c 2003-09-26 02:58:13.000000000 +0200
4730 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/x509.c 2008-06-29 23:44:19.000000000 +0200
4731 @@ -240,7 +240,11 @@
4735 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4736 +static struct _xmlSecKeyDataKlass xmlSecMSCryptoKeyDataX509Klass = {
4738 static xmlSecKeyDataKlass xmlSecMSCryptoKeyDataX509Klass = {
4740 sizeof(xmlSecKeyDataKlass),
4741 xmlSecMSCryptoX509DataSize,
4743 @@ -1572,6 +1576,7 @@
4744 xmlSecKeyInfoCtxPtr keyInfoCtx) {
4745 xmlSecMSCryptoX509DataCtxPtr ctx;
4746 xmlSecKeyDataStorePtr x509Store;
4747 + PCCERT_CONTEXT pCert ;
4750 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecMSCryptoKeyDataX509Id), -1);
4751 @@ -1610,6 +1615,53 @@
4756 + * I'll search key according to KeyReq.
4758 + pCert = CertDuplicateCertificateContext( ctx->keyCert ) ;
4759 + if( pCert == NULL ) {
4760 + xmlSecError( XMLSEC_ERRORS_HERE,
4761 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4762 + "CertDuplicateCertificateContext",
4763 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4764 + XMLSEC_ERRORS_NO_MESSAGE);
4769 + if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePrivate ) == xmlSecKeyDataTypePrivate ) {
4770 + keyValue = xmlSecMSCryptoCertAdopt( pCert, xmlSecKeyDataTypePrivate ) ;
4771 + if(keyValue == NULL) {
4772 + xmlSecError(XMLSEC_ERRORS_HERE,
4773 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4774 + "xmlSecMSCryptoCertAdopt",
4775 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
4776 + XMLSEC_ERRORS_NO_MESSAGE);
4778 + CertFreeCertificateContext( pCert ) ;
4782 + } else if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePublic ) == xmlSecKeyDataTypePublic ) {
4783 + keyValue = xmlSecMSCryptoCertAdopt( pCert, xmlSecKeyDataTypePublic ) ;
4784 + if(keyValue == NULL) {
4785 + xmlSecError(XMLSEC_ERRORS_HERE,
4786 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4787 + "xmlSecMSCryptoCertAdopt",
4788 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
4789 + XMLSEC_ERRORS_NO_MESSAGE);
4791 + CertFreeCertificateContext( pCert ) ;
4800 + * Get Public key from cert, which does not always work for sign action.
4802 keyValue = xmlSecMSCryptoX509CertGetKey(ctx->keyCert);
4803 if(keyValue == NULL) {
4804 xmlSecError(XMLSEC_ERRORS_HERE,
4805 @@ -1619,6 +1671,51 @@
4806 XMLSEC_ERRORS_NO_MESSAGE);
4812 + * I'll search key according to KeyReq.
4814 + pCert = CertDuplicateCertificateContext( ctx->keyCert ) ;
4815 + if( pCert == NULL ) {
4816 + xmlSecError( XMLSEC_ERRORS_HERE,
4817 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4818 + "CertDuplicateCertificateContext",
4819 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
4820 + XMLSEC_ERRORS_NO_MESSAGE);
4825 + if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePrivate ) == xmlSecKeyDataTypePrivate ) {
4826 + keyValue = xmlSecMSCryptoCertAdopt( pCert, xmlSecKeyDataTypePrivate ) ;
4827 + if(keyValue == NULL) {
4828 + xmlSecError(XMLSEC_ERRORS_HERE,
4829 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4830 + "xmlSecMSCryptoCertAdopt",
4831 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
4832 + XMLSEC_ERRORS_NO_MESSAGE);
4834 + CertFreeCertificateContext( pCert ) ;
4838 + } else if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePublic ) == xmlSecKeyDataTypePublic ) {
4839 + keyValue = xmlSecMSCryptoCertAdopt( pCert, xmlSecKeyDataTypePublic ) ;
4840 + if(keyValue == NULL) {
4841 + xmlSecError(XMLSEC_ERRORS_HERE,
4842 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
4843 + "xmlSecMSCryptoCertAdopt",
4844 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
4845 + XMLSEC_ERRORS_NO_MESSAGE);
4847 + CertFreeCertificateContext( pCert ) ;
4855 /* verify that the key matches our expectations */
4856 if(xmlSecKeyReqMatchKeyValue(&(keyInfoCtx->keyReq), keyValue) != 1) {
4857 @@ -1882,7 +1979,7 @@
4858 xmlSecAssert2(nm->pbData != NULL, NULL);
4859 xmlSecAssert2(nm->cbData > 0, NULL);
4861 - csz = CertNameToStr(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR, NULL, 0);
4862 + csz = CertNameToStr(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, NULL, 0);
4863 str = (char *)xmlMalloc(csz);
4865 xmlSecError(XMLSEC_ERRORS_HERE,
4866 @@ -1893,7 +1990,7 @@
4870 - csz = CertNameToStr(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR, str, csz);
4871 + csz = CertNameToStr(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, str, csz);
4873 xmlSecError(XMLSEC_ERRORS_HERE,
4875 @@ -1904,17 +2001,37 @@
4879 - res = xmlStrdup(BAD_CAST str);
4881 - xmlSecError(XMLSEC_ERRORS_HERE,
4884 - XMLSEC_ERRORS_R_MALLOC_FAILED,
4885 - XMLSEC_ERRORS_NO_MESSAGE);
4888 + /* aleksey: this is a hack, but mscrypto can not read E= flag and wants Email= instead.
4889 + * don't ask me how is it possible not to read something you wrote yourself but also
4890 + * see comment in the xmlSecMSCryptoX509FindCert function.
4892 + if(strncmp(str, "E=", 2) == 0) {
4893 + res = xmlMalloc(strlen(str) + 13 + 1);
4895 + xmlSecError(XMLSEC_ERRORS_HERE,
4898 + XMLSEC_ERRORS_R_MALLOC_FAILED,
4900 + strlen(str) + 13 + 1);
4905 + memcpy(res, "emailAddress=", 13);
4906 + strcpy(res + 13, BAD_CAST (str + 2));
4908 + res = xmlStrdup(BAD_CAST str);
4910 + xmlSecError(XMLSEC_ERRORS_HERE,
4913 + XMLSEC_ERRORS_R_MALLOC_FAILED,
4914 + XMLSEC_ERRORS_NO_MESSAGE);
4923 @@ -2153,7 +2270,11 @@
4925 xmlSecKeyInfoCtxPtr keyInfoCtx);
4927 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4928 +static struct _xmlSecKeyDataKlass xmlSecMSCryptoKeyDataRawX509CertKlass = {
4930 static xmlSecKeyDataKlass xmlSecMSCryptoKeyDataRawX509CertKlass = {
4932 sizeof(xmlSecKeyDataKlass),
4933 sizeof(xmlSecKeyData),
4935 --- misc/xmlsec1-1.2.6/src/mscrypto/x509vfy.c 2003-09-27 05:12:22.000000000 +0200
4936 +++ misc/build/xmlsec1-1.2.6/src/mscrypto/x509vfy.c 2008-06-29 23:44:19.000000000 +0200
4938 static xmlSecByte * xmlSecMSCryptoX509NameRead (xmlSecByte *str,
4941 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
4942 +static struct _xmlSecKeyDataStoreKlass xmlSecMSCryptoX509StoreKlass = {
4944 static xmlSecKeyDataStoreKlass xmlSecMSCryptoX509StoreKlass = {
4946 sizeof(xmlSecKeyDataStoreKlass),
4947 xmlSecMSCryptoX509StoreSize,
4950 xmlChar *issuerName, xmlChar *issuerSerial,
4951 xmlChar *ski, xmlSecKeyInfoCtx* keyInfoCtx) {
4952 xmlSecMSCryptoX509StoreCtxPtr ctx;
4953 + PCCERT_CONTEXT pCert ;
4955 xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId), NULL);
4956 xmlSecAssert2(keyInfoCtx != NULL, NULL);
4957 @@ -132,10 +137,17 @@
4958 ctx = xmlSecMSCryptoX509StoreGetCtx(store);
4959 xmlSecAssert2(ctx != NULL, NULL);
4960 xmlSecAssert2(ctx->untrusted != NULL, NULL);
4961 + xmlSecAssert2(ctx->trusted != NULL, NULL);
4963 - return(xmlSecMSCryptoX509FindCert(ctx->untrusted, subjectName, issuerName, issuerSerial, ski));
4966 + if( ctx->untrusted != NULL )
4967 + pCert = xmlSecMSCryptoX509FindCert( ctx->untrusted, subjectName, issuerName, issuerSerial, ski ) ;
4969 + if( ctx->trusted != NULL && pCert == NULL )
4970 + pCert = xmlSecMSCryptoX509FindCert( ctx->trusted, subjectName, issuerName, issuerSerial, ski ) ;
4976 xmlSecMSCryptoUnixTimeToFileTime(time_t t, LPFILETIME pft) {
4977 @@ -252,17 +264,22 @@
4981 -xmlSecMSCryptoX509StoreConstructCertsChain(xmlSecKeyDataStorePtr store, PCCERT_CONTEXT cert, HCERTSTORE certs,
4982 - xmlSecKeyInfoCtx* keyInfoCtx) {
4983 +xmlSecMSCryptoX509StoreConstructCertsChain(
4984 + xmlSecKeyDataStorePtr store ,
4985 + PCCERT_CONTEXT cert ,
4986 + HCERTSTORE certStore ,
4987 + xmlSecKeyInfoCtx* keyInfoCtx
4989 xmlSecMSCryptoX509StoreCtxPtr ctx;
4990 PCCERT_CONTEXT issuerCert = NULL;
4995 xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId), FALSE);
4996 xmlSecAssert2(cert != NULL, FALSE);
4997 xmlSecAssert2(cert->pCertInfo != NULL, FALSE);
4998 - xmlSecAssert2(certs != NULL, FALSE);
4999 + xmlSecAssert2(certStore != NULL, FALSE);
5000 xmlSecAssert2(keyInfoCtx != NULL, FALSE);
5002 ctx = xmlSecMSCryptoX509StoreGetCtx(store);
5003 @@ -283,60 +300,85 @@
5007 - if (!xmlSecMSCryptoCheckRevocation(certs, cert)) {
5008 + if (!xmlSecMSCryptoCheckRevocation(certStore, cert)) {
5012 - /* try the untrusted certs in the chain */
5013 - issuerCert = CertFindCertificateInStore(certs,
5015 + * Firstly try to find the cert in the trusted cert store. We will trust
5016 + * the certificate in the trusted store.
5018 + issuerCert = CertFindCertificateInStore(ctx->trusted,
5019 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5021 CERT_FIND_SUBJECT_NAME,
5022 - &(cert->pCertInfo->Issuer),
5023 + &(cert->pCertInfo->Subject),
5025 - if(issuerCert == cert) {
5026 - /* self signed cert, forget it */
5027 - CertFreeCertificateContext(issuerCert);
5028 - } else if(issuerCert != NULL) {
5029 - flags = CERT_STORE_REVOCATION_FLAG | CERT_STORE_SIGNATURE_FLAG;
5030 - if(!CertVerifySubjectCertificateContext(cert, issuerCert, &flags)) {
5031 - xmlSecMSCryptoX509StoreCertError(store, issuerCert, flags);
5032 - CertFreeCertificateContext(issuerCert);
5035 - if(!xmlSecMSCryptoX509StoreConstructCertsChain(store, issuerCert, certs, keyInfoCtx)) {
5036 - xmlSecMSCryptoX509StoreCertError(store, issuerCert, flags);
5037 - CertFreeCertificateContext(issuerCert);
5040 - CertFreeCertificateContext(issuerCert);
5042 + if( issuerCert != NULL ) {
5043 + /* We have found the trusted cert, so return true */
5044 + CertFreeCertificateContext( issuerCert ) ;
5048 - /* try the untrusted certs in the store */
5049 - issuerCert = CertFindCertificateInStore(ctx->untrusted,
5050 + /* Check whether the certificate is self signed certificate */
5051 + selfSigned = CertCompareCertificateName( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, &(cert->pCertInfo->Subject), &(cert->pCertInfo->Issuer) ) ;
5053 + /* try the untrusted certs in the chain */
5054 + if( !selfSigned ) {
5055 + issuerCert = CertFindCertificateInStore(certStore,
5056 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5058 CERT_FIND_SUBJECT_NAME,
5059 &(cert->pCertInfo->Issuer),
5061 - if(issuerCert == cert) {
5062 - /* self signed cert, forget it */
5063 - CertFreeCertificateContext(issuerCert);
5064 - } else if(issuerCert != NULL) {
5065 - flags = CERT_STORE_REVOCATION_FLAG | CERT_STORE_SIGNATURE_FLAG;
5066 - if(!CertVerifySubjectCertificateContext(cert, issuerCert, &flags)) {
5067 - xmlSecMSCryptoX509StoreCertError(store, issuerCert, flags);
5068 - CertFreeCertificateContext(issuerCert);
5071 - if(!xmlSecMSCryptoX509StoreConstructCertsChain(store, issuerCert, certs, keyInfoCtx)) {
5072 - CertFreeCertificateContext(issuerCert);
5074 + if( issuerCert != NULL && CertCompareCertificate( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert->pCertInfo, issuerCert->pCertInfo ) ) {
5075 + /* self signed cert, forget it */
5076 + CertFreeCertificateContext(issuerCert);
5077 + } else if(issuerCert != NULL) {
5078 + flags = CERT_STORE_REVOCATION_FLAG | CERT_STORE_SIGNATURE_FLAG;
5079 + if(!CertVerifySubjectCertificateContext(cert, issuerCert, &flags)) {
5080 + xmlSecMSCryptoX509StoreCertError(store, issuerCert, flags);
5081 + CertFreeCertificateContext(issuerCert);
5084 + if(!xmlSecMSCryptoX509StoreConstructCertsChain(store, issuerCert, certStore, keyInfoCtx)) {
5085 + xmlSecMSCryptoX509StoreCertError(store, issuerCert, flags);
5086 + CertFreeCertificateContext(issuerCert);
5090 + CertFreeCertificateContext(issuerCert);
5095 + /* try the untrusted certs in the store */
5096 + if( !selfSigned ) {
5097 + issuerCert = CertFindCertificateInStore(ctx->untrusted,
5098 + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5100 + CERT_FIND_SUBJECT_NAME,
5101 + &(cert->pCertInfo->Issuer),
5103 + if( issuerCert != NULL && CertCompareCertificate( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert->pCertInfo, issuerCert->pCertInfo ) ) {
5104 + /* self signed cert, forget it */
5105 + CertFreeCertificateContext(issuerCert);
5106 + } else if(issuerCert != NULL) {
5107 + flags = CERT_STORE_REVOCATION_FLAG | CERT_STORE_SIGNATURE_FLAG;
5108 + if(!CertVerifySubjectCertificateContext(cert, issuerCert, &flags)) {
5109 + xmlSecMSCryptoX509StoreCertError(store, issuerCert, flags);
5110 + CertFreeCertificateContext(issuerCert);
5113 + if(!xmlSecMSCryptoX509StoreConstructCertsChain(store, issuerCert, certStore, keyInfoCtx)) {
5114 + CertFreeCertificateContext(issuerCert);
5118 + CertFreeCertificateContext(issuerCert);
5122 - CertFreeCertificateContext(issuerCert);
5126 /* try to find issuer cert in the trusted cert in the store */
5127 issuerCert = CertFindCertificateInStore(ctx->trusted,
5128 @@ -379,26 +421,61 @@
5129 xmlSecAssert2(certs != NULL, NULL);
5130 xmlSecAssert2(keyInfoCtx != NULL, NULL);
5132 - while((cert = CertEnumCertificatesInStore(certs, cert)) != NULL){
5133 - PCCERT_CONTEXT nextCert = NULL;
5134 + while( ( cert = CertEnumCertificatesInStore( certs, cert ) ) != NULL ) {
5135 + PCCERT_CONTEXT nextCert ;
5136 + unsigned char selected ;
5138 - xmlSecAssert2(cert->pCertInfo != NULL, NULL);
5139 + xmlSecAssert2( cert->pCertInfo != NULL, NULL ) ;
5141 - /* if cert is the issuer of any other cert in the list, then it is
5142 - * to be skipped */
5143 - nextCert = CertFindCertificateInStore(certs,
5144 + /* if cert is the issuer of any other cert in the list, then it is
5145 + * to be skipped except that the cert list only have one self-signed
5148 + for( selected = 0, nextCert = NULL ; ; ) {
5149 + nextCert = CertFindCertificateInStore( certs,
5150 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5152 CERT_FIND_ISSUER_NAME,
5153 &(cert->pCertInfo->Subject),
5155 - if(nextCert != NULL) {
5156 - CertFreeCertificateContext(nextCert);
5159 - if(xmlSecMSCryptoX509StoreConstructCertsChain(store, cert, certs, keyInfoCtx)) {
5163 + if( nextCert != NULL ) {
5164 + if( CertCompareCertificate( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert->pCertInfo, nextCert->pCertInfo ) ) {
5177 + if( nextCert != NULL )
5178 + CertFreeCertificateContext( nextCert ) ;
5184 + /* JL: OpenOffice.org implements its own certificate verification routine.
5185 + The goal is to seperate validation of the signature
5186 + and the certificate. For example, OOo could show that the document signature is valid,
5187 + but the certificate could not be verified. If we do not prevent the verification of
5188 + the certificate by libxmlsec and the verification fails, then the XML signature will not be
5189 + verified. This would happen, for example, if the root certificate is not installed.
5191 + In the store schould only be the certificate from the X509Certificate element
5192 + and the X509IssuerSerial element. The latter is only there
5193 + if the certificate is installed. Both certificates must be the same!
5194 + In case of writing the signature, the store contains only the certificate that
5195 + was created based on the information from the X509IssuerSerial element. */
5198 +/* if( xmlSecMSCryptoX509StoreConstructCertsChain( store, cert, certs, keyInfoCtx ) ) {
5204 @@ -458,9 +535,126 @@
5209 +xmlSecMSCryptoX509StoreAdoptKeyStore (
5210 + xmlSecKeyDataStorePtr store,
5211 + HCERTSTORE keyStore
5213 + xmlSecMSCryptoX509StoreCtxPtr ctx;
5216 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId), -1);
5217 + xmlSecAssert2( keyStore != NULL, -1);
5219 + ctx = xmlSecMSCryptoX509StoreGetCtx(store);
5220 + xmlSecAssert2(ctx != NULL, -1);
5221 + xmlSecAssert2(ctx->trusted != NULL, -1);
5223 + if( !CertAddStoreToCollection ( ctx->trusted , keyStore , CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , 2 ) ) {
5224 + xmlSecError(XMLSEC_ERRORS_HERE,
5225 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5226 + "CertAddStoreToCollection",
5227 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5228 + XMLSEC_ERRORS_NO_MESSAGE);
5233 + PCCERT_CONTEXT ptCert ;
5237 + ptCert = CertEnumCertificatesInStore( ctx->trusted, ptCert ) ;
5238 + if( ptCert == NULL )
5247 +xmlSecMSCryptoX509StoreAdoptTrustedStore (
5248 + xmlSecKeyDataStorePtr store,
5249 + HCERTSTORE trustedStore
5251 + xmlSecMSCryptoX509StoreCtxPtr ctx;
5254 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId), -1);
5255 + xmlSecAssert2( trustedStore != NULL, -1);
5257 + ctx = xmlSecMSCryptoX509StoreGetCtx(store);
5258 + xmlSecAssert2(ctx != NULL, -1);
5259 + xmlSecAssert2(ctx->trusted != NULL, -1);
5261 + if( !CertAddStoreToCollection ( ctx->trusted , trustedStore , CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , 3 ) ) {
5262 + xmlSecError(XMLSEC_ERRORS_HERE,
5263 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5264 + "CertAddStoreToCollection",
5265 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5266 + XMLSEC_ERRORS_NO_MESSAGE);
5271 + PCCERT_CONTEXT ptCert ;
5275 + ptCert = CertEnumCertificatesInStore( ctx->trusted, ptCert ) ;
5276 + if( ptCert == NULL )
5285 +xmlSecMSCryptoX509StoreAdoptUntrustedStore (
5286 + xmlSecKeyDataStorePtr store,
5287 + HCERTSTORE untrustedStore
5289 + xmlSecMSCryptoX509StoreCtxPtr ctx;
5292 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId), -1);
5293 + xmlSecAssert2( untrustedStore != NULL, -1);
5295 + ctx = xmlSecMSCryptoX509StoreGetCtx(store);
5296 + xmlSecAssert2(ctx != NULL, -1);
5297 + xmlSecAssert2(ctx->untrusted != NULL, -1);
5299 + if( !CertAddStoreToCollection ( ctx->untrusted , untrustedStore , CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG , 2 ) ) {
5300 + xmlSecError(XMLSEC_ERRORS_HERE,
5301 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5302 + "CertAddStoreToCollection",
5303 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5304 + XMLSEC_ERRORS_NO_MESSAGE);
5309 + PCCERT_CONTEXT ptCert ;
5313 + ptCert = CertEnumCertificatesInStore( ctx->untrusted, ptCert ) ;
5314 + if( ptCert == NULL )
5323 xmlSecMSCryptoX509StoreInitialize(xmlSecKeyDataStorePtr store) {
5324 xmlSecMSCryptoX509StoreCtxPtr ctx;
5325 + HCERTSTORE hTrustedMemStore ;
5326 + HCERTSTORE hUntrustedMemStore ;
5328 xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId), -1);
5330 ctx = xmlSecMSCryptoX509StoreGetCtx(store);
5331 @@ -468,36 +662,104 @@
5333 memset(ctx, 0, sizeof(xmlSecMSCryptoX509StoreCtx));
5335 + /* create trusted certs store collection */
5336 + ctx->trusted = CertOpenStore(CERT_STORE_PROV_COLLECTION,
5341 + if(ctx->trusted == NULL) {
5342 + xmlSecError(XMLSEC_ERRORS_HERE,
5343 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5345 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5346 + XMLSEC_ERRORS_NO_MESSAGE);
5350 /* create trusted certs store */
5351 - ctx->trusted = CertOpenStore(CERT_STORE_PROV_MEMORY,
5352 + hTrustedMemStore = CertOpenStore(CERT_STORE_PROV_MEMORY,
5353 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5355 CERT_STORE_CREATE_NEW_FLAG,
5357 - if(ctx->trusted == NULL) {
5358 + if(hTrustedMemStore == NULL) {
5359 xmlSecError(XMLSEC_ERRORS_HERE,
5360 xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5362 XMLSEC_ERRORS_R_CRYPTO_FAILED,
5363 XMLSEC_ERRORS_NO_MESSAGE);
5364 + CertCloseStore(ctx->trusted, CERT_CLOSE_STORE_FORCE_FLAG);
5365 + ctx->trusted = NULL ;
5369 - /* create trusted certs store */
5370 - ctx->untrusted = CertOpenStore(CERT_STORE_PROV_MEMORY,
5371 + /* add the memory trusted certs store to trusted certs store collection */
5372 + if( !CertAddStoreToCollection( ctx->trusted, hTrustedMemStore, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 1 ) ) {
5373 + xmlSecError(XMLSEC_ERRORS_HERE,
5374 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5375 + "CertAddStoreToCollection",
5376 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5377 + XMLSEC_ERRORS_NO_MESSAGE);
5378 + CertCloseStore(ctx->trusted, CERT_CLOSE_STORE_FORCE_FLAG);
5379 + CertCloseStore(hTrustedMemStore, CERT_CLOSE_STORE_CHECK_FLAG);
5380 + ctx->trusted = NULL ;
5383 + CertCloseStore(hTrustedMemStore, CERT_CLOSE_STORE_CHECK_FLAG);
5385 + /* create untrusted certs store collection */
5386 + ctx->untrusted = CertOpenStore(CERT_STORE_PROV_COLLECTION,
5391 + if(ctx->untrusted == NULL) {
5392 + xmlSecError(XMLSEC_ERRORS_HERE,
5393 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5395 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5396 + XMLSEC_ERRORS_NO_MESSAGE);
5397 + CertCloseStore(ctx->trusted, CERT_CLOSE_STORE_FORCE_FLAG);
5398 + ctx->trusted = NULL ;
5402 + /* create untrusted certs store */
5403 + hUntrustedMemStore = CertOpenStore(CERT_STORE_PROV_MEMORY,
5404 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5406 CERT_STORE_CREATE_NEW_FLAG,
5408 - if(ctx->untrusted == NULL) {
5409 + if(hUntrustedMemStore == NULL) {
5410 xmlSecError(XMLSEC_ERRORS_HERE,
5411 xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5413 XMLSEC_ERRORS_R_CRYPTO_FAILED,
5414 XMLSEC_ERRORS_NO_MESSAGE);
5415 + CertCloseStore(ctx->trusted, CERT_CLOSE_STORE_FORCE_FLAG);
5416 + CertCloseStore(ctx->untrusted, CERT_CLOSE_STORE_FORCE_FLAG);
5417 + ctx->trusted = NULL ;
5418 + ctx->untrusted = NULL ;
5422 + /* add the memory trusted certs store to untrusted certs store collection */
5423 + if( !CertAddStoreToCollection( ctx->untrusted, hUntrustedMemStore, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 1 ) ) {
5424 + xmlSecError(XMLSEC_ERRORS_HERE,
5425 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
5426 + "CertAddStoreToCollection",
5427 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
5428 + XMLSEC_ERRORS_NO_MESSAGE);
5429 + CertCloseStore(ctx->untrusted, CERT_CLOSE_STORE_FORCE_FLAG);
5430 + CertCloseStore(ctx->trusted, CERT_CLOSE_STORE_FORCE_FLAG);
5431 + CertCloseStore(hUntrustedMemStore, CERT_CLOSE_STORE_CHECK_FLAG);
5432 + ctx->trusted = NULL ;
5433 + ctx->untrusted = NULL ;
5436 + CertCloseStore(hUntrustedMemStore, CERT_CLOSE_STORE_CHECK_FLAG);
5441 @@ -567,10 +829,41 @@
5443 if((pCert == NULL) && (NULL != issuerName) && (NULL != issuerSerial)) {
5444 xmlSecBn issuerSerialBn;
5447 + CRYPT_INTEGER_BLOB cib;
5451 + /* aleksey: for some unknown to me reasons, mscrypto wants Email
5452 + * instead of emailAddress. This code is not bullet proof and may
5453 + * produce incorrect results if someone has "emailAddress=" string
5454 + * in one of the fields, but it is best I can suggest to fix this problem.
5455 + * Also see xmlSecMSCryptoX509NameWrite function.
5457 + while( (p = (xmlChar*)xmlStrstr(issuerName, BAD_CAST "emailAddress=")) != NULL) {
5458 + memcpy(p, " Email=", 13);
5463 + /* get issuer name */
5464 + cName = xmlSecMSCryptoCertStrToName(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5466 + CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG | CERT_OID_NAME_STR | CERT_NAME_STR_REVERSE_FLAG,
5468 + if(cName == NULL) {
5469 + xmlSecError(XMLSEC_ERRORS_HERE,
5471 + "xmlSecMSCryptoCertStrToName",
5472 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
5473 + XMLSEC_ERRORS_NO_MESSAGE);
5476 + cnb.pbData = cName;
5477 + cnb.cbData = cNameLen;
5479 + /* get serial number */
5480 ret = xmlSecBnInitialize(&issuerSerialBn, 0);
5482 xmlSecError(XMLSEC_ERRORS_HERE,
5484 "xmlSecBnInitialize",
5485 XMLSEC_ERRORS_R_XMLSEC_FAILED,
5486 XMLSEC_ERRORS_NO_MESSAGE);
5491 @@ -589,26 +883,30 @@
5492 XMLSEC_ERRORS_R_XMLSEC_FAILED,
5493 XMLSEC_ERRORS_NO_MESSAGE);
5494 xmlSecBnFinalize(&issuerSerialBn);
5500 - cName = xmlSecMSCryptoCertStrToName(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
5502 - CERT_OID_NAME_STR | CERT_NAME_STR_REVERSE_FLAG,
5504 - if(cName == NULL) {
5505 + /* I have no clue why at a sudden a swap is needed to
5506 + * convert from lsb... This code is purely based upon
5507 + * trial and error :( WK
5509 + ret = xmlSecBnReverse(&issuerSerialBn);
5511 xmlSecError(XMLSEC_ERRORS_HERE,
5513 - "xmlSecMSCryptoCertStrToName",
5514 + "xmlSecBnReverse",
5515 XMLSEC_ERRORS_R_XMLSEC_FAILED,
5516 XMLSEC_ERRORS_NO_MESSAGE);
5517 xmlSecBnFinalize(&issuerSerialBn);
5523 - cnb.pbData = cName;
5524 - cnb.cbData = cNameLen;
5525 - while((pCert = CertFindCertificateInStore(store,
5526 + cib.pbData = xmlSecBufferGetData(&issuerSerialBn);
5527 + cib.cbData = xmlSecBufferGetSize(&issuerSerialBn);
5529 + while((pCert = CertFindCertificateInStore(store,
5530 PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
5532 CERT_FIND_ISSUER_NAME,
5533 @@ -622,10 +920,9 @@
5534 if((pCert->pCertInfo != NULL) &&
5535 (pCert->pCertInfo->SerialNumber.pbData != NULL) &&
5536 (pCert->pCertInfo->SerialNumber.cbData > 0) &&
5537 - (0 == xmlSecBnCompareReverse(&issuerSerialBn, pCert->pCertInfo->SerialNumber.pbData,
5538 - pCert->pCertInfo->SerialNumber.cbData))) {
5541 + (CertCompareIntegerBlob(&(pCert->pCertInfo->SerialNumber), &cib) == TRUE)
5547 --- misc/xmlsec1-1.2.6/src/nss/Makefile.am 2003-09-16 11:43:03.000000000 +0200
5548 +++ misc/build/xmlsec1-1.2.6/src/nss/Makefile.am 2008-06-29 23:44:19.000000000 +0200
5552 libxmlsec1_nss_la_SOURCES =\
5575 libxmlsec1_nss_la_LIBADD = \
5576 --- misc/xmlsec1-1.2.6/src/nss/Makefile.in 2004-08-26 08:00:32.000000000 +0200
5577 +++ misc/build/xmlsec1-1.2.6/src/nss/Makefile.in 2008-06-29 23:44:19.000000000 +0200
5579 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
5580 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
5582 -am_libxmlsec1_nss_la_OBJECTS = app.lo bignum.lo ciphers.lo crypto.lo \
5583 +am_libxmlsec1_nss_la_OBJECTS = akmngr.lo app.lo bignum.lo ciphers.lo crypto.lo \
5584 digests.lo hmac.lo pkikeys.lo signatures.lo symkeys.lo x509.lo \
5585 - x509vfy.lo keysstore.lo kt_rsa.lo kw_des.lo kw_aes.lo \
5586 + x509vfy.lo keysstore.lo tokens.lo keytrans.lo keywrapers.lo \
5588 libxmlsec1_nss_la_OBJECTS = $(am_libxmlsec1_nss_la_OBJECTS)
5589 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
5591 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/app.Plo ./$(DEPDIR)/bignum.Plo \
5592 @AMDEP_TRUE@ ./$(DEPDIR)/ciphers.Plo ./$(DEPDIR)/crypto.Plo \
5593 @AMDEP_TRUE@ ./$(DEPDIR)/digests.Plo ./$(DEPDIR)/hmac.Plo \
5594 -@AMDEP_TRUE@ ./$(DEPDIR)/keysstore.Plo ./$(DEPDIR)/kt_rsa.Plo \
5595 -@AMDEP_TRUE@ ./$(DEPDIR)/kw_aes.Plo ./$(DEPDIR)/kw_des.Plo \
5596 +@AMDEP_TRUE@ ./$(DEPDIR)/keysstore.Plo ./$(DEPDIR)/tokens.Plo \
5597 +@AMDEP_TRUE@ ./$(DEPDIR)/keywrapers.Plo ./$(DEPDIR)/keytrans.Plo \
5598 @AMDEP_TRUE@ ./$(DEPDIR)/pkikeys.Plo ./$(DEPDIR)/signatures.Plo \
5599 @AMDEP_TRUE@ ./$(DEPDIR)/symkeys.Plo ./$(DEPDIR)/x509.Plo \
5600 -@AMDEP_TRUE@ ./$(DEPDIR)/x509vfy.Plo
5601 +@AMDEP_TRUE@ ./$(DEPDIR)/x509vfy.Plo ./$(DEPDIR)/akmngr.Plo
5602 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
5603 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
5604 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
5605 @@ -321,21 +321,22 @@
5608 libxmlsec1_nss_la_SOURCES = \
5631 libxmlsec1_nss_la_LIBADD = \
5636 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/akmngr.Plo@am__quote@
5637 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/app.Plo@am__quote@
5638 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bignum.Plo@am__quote@
5639 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ciphers.Plo@am__quote@
5641 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digests.Plo@am__quote@
5642 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hmac.Plo@am__quote@
5643 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keysstore.Plo@am__quote@
5644 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kt_rsa.Plo@am__quote@
5645 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kw_aes.Plo@am__quote@
5646 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kw_des.Plo@am__quote@
5647 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tokens.Plo@am__quote@
5648 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keywrapers.Plo@am__quote@
5649 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keytrans.Plo@am__quote@
5650 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pkikeys.Plo@am__quote@
5651 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signatures.Plo@am__quote@
5652 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symkeys.Plo@am__quote@
5653 --- misc/xmlsec1-1.2.6/src/nss/akmngr.c 2008-06-29 23:44:39.000000000 +0200
5654 +++ misc/build/xmlsec1-1.2.6/src/nss/akmngr.c 2008-06-29 23:44:19.000000000 +0200
5660 + * This is free software; see Copyright file in the source
5661 + * distribution for preciese wording.
5663 + * Copyright.........................
5665 +#include "globals.h"
5669 +#include <pk11func.h>
5673 +#include <xmlsec/xmlsec.h>
5674 +#include <xmlsec/keys.h>
5675 +#include <xmlsec/transforms.h>
5676 +#include <xmlsec/errors.h>
5678 +#include <xmlsec/nss/crypto.h>
5679 +#include <xmlsec/nss/tokens.h>
5680 +#include <xmlsec/nss/akmngr.h>
5681 +#include <xmlsec/nss/pkikeys.h>
5682 +#include <xmlsec/nss/ciphers.h>
5683 +#include <xmlsec/nss/keysstore.h>
5686 + * xmlSecNssAppliedKeysMngrCreate:
5687 + * @slot: array of pointers to NSS PKCS#11 slot infomation.
5688 + * @cSlots: number of slots in the array
5689 + * @handler: the pointer to NSS certificate database.
5691 + * Create and load NSS crypto slot and certificate database into keys manager
5693 + * Returns keys manager pointer on success or NULL otherwise.
5696 +xmlSecNssAppliedKeysMngrCreate(
5697 + PK11SlotInfo** slots,
5699 + CERTCertDBHandle* handler
5701 + xmlSecKeyDataStorePtr certStore = NULL ;
5702 + xmlSecKeysMngrPtr keyMngr = NULL ;
5703 + xmlSecKeyStorePtr keyStore = NULL ;
5705 + keyStore = xmlSecKeyStoreCreate( xmlSecNssKeysStoreId ) ;
5706 + if( keyStore == NULL ) {
5707 + xmlSecError( XMLSEC_ERRORS_HERE ,
5709 + "xmlSecKeyStoreCreate" ,
5710 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5711 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5715 + for (islot = 0; islot < cSlots; islot++)
5717 + xmlSecNssKeySlotPtr keySlot ;
5719 + /* Create a key slot */
5720 + keySlot = xmlSecNssKeySlotCreate() ;
5721 + if( keySlot == NULL ) {
5722 + xmlSecError( XMLSEC_ERRORS_HERE ,
5723 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
5724 + "xmlSecNssKeySlotCreate" ,
5725 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5726 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5728 + xmlSecKeyStoreDestroy( keyStore ) ;
5733 + if( xmlSecNssKeySlotSetSlot( keySlot , slots[islot] ) < 0 ) {
5734 + xmlSecError( XMLSEC_ERRORS_HERE ,
5735 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
5736 + "xmlSecNssKeySlotSetSlot" ,
5737 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5738 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5740 + xmlSecKeyStoreDestroy( keyStore ) ;
5741 + xmlSecNssKeySlotDestroy( keySlot ) ;
5745 + /* Adopt keySlot */
5746 + if( xmlSecNssKeysStoreAdoptKeySlot( keyStore , keySlot ) < 0 ) {
5747 + xmlSecError( XMLSEC_ERRORS_HERE ,
5748 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
5749 + "xmlSecNssKeysStoreAdoptKeySlot" ,
5750 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5751 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5753 + xmlSecKeyStoreDestroy( keyStore ) ;
5754 + xmlSecNssKeySlotDestroy( keySlot ) ;
5759 + keyMngr = xmlSecKeysMngrCreate() ;
5760 + if( keyMngr == NULL ) {
5761 + xmlSecError( XMLSEC_ERRORS_HERE ,
5763 + "xmlSecKeysMngrCreate" ,
5764 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5765 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5767 + xmlSecKeyStoreDestroy( keyStore ) ;
5772 + * Add key store to manager, from now on keys manager destroys the store if
5775 + if( xmlSecKeysMngrAdoptKeysStore( keyMngr, keyStore ) < 0 ) {
5776 + xmlSecError( XMLSEC_ERRORS_HERE ,
5777 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
5778 + "xmlSecKeysMngrAdoptKeyStore" ,
5779 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5780 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5782 + xmlSecKeyStoreDestroy( keyStore ) ;
5783 + xmlSecKeysMngrDestroy( keyMngr ) ;
5788 + * Initialize crypto library specific data in keys manager
5790 + if( xmlSecNssKeysMngrInit( keyMngr ) < 0 ) {
5791 + xmlSecError( XMLSEC_ERRORS_HERE ,
5793 + "xmlSecKeysMngrCreate" ,
5794 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5795 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5797 + xmlSecKeysMngrDestroy( keyMngr ) ;
5802 + * Set certificate databse to X509 key data store
5805 + * Because Tej's implementation of certDB use the default DB, so I ignore
5806 + * the certDB handler at present. I'll modify the cert store sources to
5807 + * accept particular certDB instead of default ones.
5808 + certStore = xmlSecKeysMngrGetDataStore( keyMngr , xmlSecNssKeyDataStoreX509Id ) ;
5809 + if( certStore == NULL ) {
5810 + xmlSecError( XMLSEC_ERRORS_HERE ,
5811 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
5812 + "xmlSecKeysMngrGetDataStore" ,
5813 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5814 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5816 + xmlSecKeysMngrDestroy( keyMngr ) ;
5820 + if( xmlSecNssKeyDataStoreX509SetCertDb( certStore , handler ) < 0 ) {
5821 + xmlSecError( XMLSEC_ERRORS_HERE ,
5822 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
5823 + "xmlSecNssKeyDataStoreX509SetCertDb" ,
5824 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5825 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5827 + xmlSecKeysMngrDestroy( keyMngr ) ;
5833 + * Set the getKey callback
5835 + keyMngr->getKey = xmlSecKeysMngrGetKey ;
5841 +xmlSecNssAppliedKeysMngrSymKeyLoad(
5842 + xmlSecKeysMngrPtr mngr ,
5843 + PK11SymKey* symKey
5845 + xmlSecKeyPtr key ;
5846 + xmlSecKeyDataPtr data ;
5847 + xmlSecKeyStorePtr keyStore ;
5849 + xmlSecAssert2( mngr != NULL , -1 ) ;
5850 + xmlSecAssert2( symKey != NULL , -1 ) ;
5852 + keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ;
5853 + if( keyStore == NULL ) {
5854 + xmlSecError( XMLSEC_ERRORS_HERE ,
5856 + "xmlSecKeysMngrGetKeysStore" ,
5857 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5858 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5861 + xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ;
5863 + data = xmlSecNssSymKeyDataKeyAdopt( symKey ) ;
5864 + if( data == NULL ) {
5865 + xmlSecError( XMLSEC_ERRORS_HERE ,
5867 + "xmlSecNssSymKeyDataKeyAdopt" ,
5868 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5869 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5873 + key = xmlSecKeyCreate() ;
5874 + if( key == NULL ) {
5875 + xmlSecError( XMLSEC_ERRORS_HERE ,
5877 + "xmlSecNssSymKeyDataKeyAdopt" ,
5878 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5879 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5880 + xmlSecKeyDataDestroy( data ) ;
5884 + if( xmlSecKeySetValue( key , data ) < 0 ) {
5885 + xmlSecError( XMLSEC_ERRORS_HERE ,
5887 + "xmlSecNssSymKeyDataKeyAdopt" ,
5888 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5889 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5890 + xmlSecKeyDataDestroy( data ) ;
5894 + if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) {
5895 + xmlSecError( XMLSEC_ERRORS_HERE ,
5897 + "xmlSecNssSymKeyDataKeyAdopt" ,
5898 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5899 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5900 + xmlSecKeyDestroy( key ) ;
5908 +xmlSecNssAppliedKeysMngrPubKeyLoad(
5909 + xmlSecKeysMngrPtr mngr ,
5910 + SECKEYPublicKey* pubKey
5912 + xmlSecKeyPtr key ;
5913 + xmlSecKeyDataPtr data ;
5914 + xmlSecKeyStorePtr keyStore ;
5916 + xmlSecAssert2( mngr != NULL , -1 ) ;
5917 + xmlSecAssert2( pubKey != NULL , -1 ) ;
5919 + keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ;
5920 + if( keyStore == NULL ) {
5921 + xmlSecError( XMLSEC_ERRORS_HERE ,
5923 + "xmlSecKeysMngrGetKeysStore" ,
5924 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5925 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5928 + xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ;
5930 + data = xmlSecNssPKIAdoptKey( NULL, pubKey ) ;
5931 + if( data == NULL ) {
5932 + xmlSecError( XMLSEC_ERRORS_HERE ,
5934 + "xmlSecNssPKIAdoptKey" ,
5935 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5936 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5940 + key = xmlSecKeyCreate() ;
5941 + if( key == NULL ) {
5942 + xmlSecError( XMLSEC_ERRORS_HERE ,
5944 + "xmlSecNssSymKeyDataKeyAdopt" ,
5945 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5946 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5947 + xmlSecKeyDataDestroy( data ) ;
5951 + if( xmlSecKeySetValue( key , data ) < 0 ) {
5952 + xmlSecError( XMLSEC_ERRORS_HERE ,
5954 + "xmlSecNssSymKeyDataKeyAdopt" ,
5955 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5956 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5957 + xmlSecKeyDataDestroy( data ) ;
5961 + if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) {
5962 + xmlSecError( XMLSEC_ERRORS_HERE ,
5964 + "xmlSecNssSymKeyDataKeyAdopt" ,
5965 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5966 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5967 + xmlSecKeyDestroy( key ) ;
5975 +xmlSecNssAppliedKeysMngrPriKeyLoad(
5976 + xmlSecKeysMngrPtr mngr ,
5977 + SECKEYPrivateKey* priKey
5979 + xmlSecKeyPtr key ;
5980 + xmlSecKeyDataPtr data ;
5981 + xmlSecKeyStorePtr keyStore ;
5983 + xmlSecAssert2( mngr != NULL , -1 ) ;
5984 + xmlSecAssert2( priKey != NULL , -1 ) ;
5986 + keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ;
5987 + if( keyStore == NULL ) {
5988 + xmlSecError( XMLSEC_ERRORS_HERE ,
5990 + "xmlSecKeysMngrGetKeysStore" ,
5991 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
5992 + XMLSEC_ERRORS_NO_MESSAGE ) ;
5995 + xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ;
5997 + data = xmlSecNssPKIAdoptKey( priKey, NULL ) ;
5998 + if( data == NULL ) {
5999 + xmlSecError( XMLSEC_ERRORS_HERE ,
6001 + "xmlSecNssPKIAdoptKey" ,
6002 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
6003 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6007 + key = xmlSecKeyCreate() ;
6008 + if( key == NULL ) {
6009 + xmlSecError( XMLSEC_ERRORS_HERE ,
6011 + "xmlSecNssSymKeyDataKeyAdopt" ,
6012 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
6013 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6014 + xmlSecKeyDataDestroy( data ) ;
6018 + if( xmlSecKeySetValue( key , data ) < 0 ) {
6019 + xmlSecError( XMLSEC_ERRORS_HERE ,
6021 + "xmlSecNssSymKeyDataKeyAdopt" ,
6022 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
6023 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6024 + xmlSecKeyDataDestroy( data ) ;
6028 + if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) {
6029 + xmlSecError( XMLSEC_ERRORS_HERE ,
6031 + "xmlSecNssSymKeyDataKeyAdopt" ,
6032 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
6033 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6034 + xmlSecKeyDestroy( key ) ;
6041 --- misc/xmlsec1-1.2.6/src/nss/ciphers.c 2003-09-26 02:58:15.000000000 +0200
6042 +++ misc/build/xmlsec1-1.2.6/src/nss/ciphers.c 2008-06-29 23:44:19.000000000 +0200
6047 - * This is free software; see Copyright file in the source
6048 - * distribution for preciese wording.
6050 - * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com>
6051 - * Copyright (c) 2003 America Online, Inc. All rights reserved.
6053 +/* -- C Source File -- **/
6054 #include "globals.h"
6056 +#include <stdlib.h>
6061 -#include <secoid.h>
6062 #include <pk11func.h>
6064 #include <xmlsec/xmlsec.h>
6065 +#include <xmlsec/xmltree.h>
6066 +#include <xmlsec/base64.h>
6067 #include <xmlsec/keys.h>
6068 +#include <xmlsec/keyinfo.h>
6069 #include <xmlsec/transforms.h>
6070 #include <xmlsec/errors.h>
6072 #include <xmlsec/nss/crypto.h>
6073 +#include <xmlsec/nss/ciphers.h>
6075 -#define XMLSEC_NSS_MAX_KEY_SIZE 32
6076 -#define XMLSEC_NSS_MAX_IV_SIZE 32
6077 -#define XMLSEC_NSS_MAX_BLOCK_SIZE 32
6079 -/**************************************************************************
6081 - * Internal Nss Block cipher CTX
6083 + * Internal Nss Block Cipher Context
6085 - *****************************************************************************/
6086 -typedef struct _xmlSecNssBlockCipherCtx xmlSecNssBlockCipherCtx,
6087 - *xmlSecNssBlockCipherCtxPtr;
6088 + * This context is designed for repositing a block cipher for transform
6090 +typedef struct _xmlSecNssBlockCipherCtx xmlSecNssBlockCipherCtx ;
6091 +typedef struct _xmlSecNssBlockCipherCtx* xmlSecNssBlockCipherCtxPtr ;
6093 struct _xmlSecNssBlockCipherCtx {
6094 - CK_MECHANISM_TYPE cipher;
6095 - PK11Context* cipherCtx;
6096 - xmlSecKeyDataId keyId;
6097 - int keyInitialized;
6098 - int ctxInitialized;
6099 - xmlSecByte key[XMLSEC_NSS_MAX_KEY_SIZE];
6100 - xmlSecSize keySize;
6101 - xmlSecByte iv[XMLSEC_NSS_MAX_IV_SIZE];
6102 - xmlSecSize ivSize;
6104 -static int xmlSecNssBlockCipherCtxInit (xmlSecNssBlockCipherCtxPtr ctx,
6105 - xmlSecBufferPtr in,
6106 - xmlSecBufferPtr out,
6108 - const xmlChar* cipherName,
6109 - xmlSecTransformCtxPtr transformCtx);
6110 -static int xmlSecNssBlockCipherCtxUpdate (xmlSecNssBlockCipherCtxPtr ctx,
6111 - xmlSecBufferPtr in,
6112 - xmlSecBufferPtr out,
6114 - const xmlChar* cipherName,
6115 - xmlSecTransformCtxPtr transformCtx);
6116 -static int xmlSecNssBlockCipherCtxFinal (xmlSecNssBlockCipherCtxPtr ctx,
6117 - xmlSecBufferPtr in,
6118 - xmlSecBufferPtr out,
6120 - const xmlChar* cipherName,
6121 - xmlSecTransformCtxPtr transformCtx);
6123 -xmlSecNssBlockCipherCtxInit(xmlSecNssBlockCipherCtxPtr ctx,
6124 - xmlSecBufferPtr in, xmlSecBufferPtr out,
6126 - const xmlChar* cipherName,
6127 - xmlSecTransformCtxPtr transformCtx) {
6130 - PK11SlotInfo* slot;
6131 - PK11SymKey* symKey;
6136 - xmlSecAssert2(ctx != NULL, -1);
6137 - xmlSecAssert2(ctx->cipher != 0, -1);
6138 - xmlSecAssert2(ctx->cipherCtx == NULL, -1);
6139 - xmlSecAssert2(ctx->keyInitialized != 0, -1);
6140 - xmlSecAssert2(ctx->ctxInitialized == 0, -1);
6141 - xmlSecAssert2(in != NULL, -1);
6142 - xmlSecAssert2(out != NULL, -1);
6143 - xmlSecAssert2(transformCtx != NULL, -1);
6145 - ivLen = PK11_GetIVLength(ctx->cipher);
6146 - xmlSecAssert2(ivLen > 0, -1);
6147 - xmlSecAssert2((xmlSecSize)ivLen <= sizeof(ctx->iv), -1);
6150 - /* generate random iv */
6151 - rv = PK11_GenerateRandom(ctx->iv, ivLen);
6152 - if(rv != SECSuccess) {
6153 - xmlSecError(XMLSEC_ERRORS_HERE,
6154 - xmlSecErrorsSafeString(cipherName),
6155 - "PK11_GenerateRandom",
6156 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6157 - "size=%d", ivLen);
6161 - /* write iv to the output */
6162 - ret = xmlSecBufferAppend(out, ctx->iv, ivLen);
6164 - xmlSecError(XMLSEC_ERRORS_HERE,
6165 - xmlSecErrorsSafeString(cipherName),
6166 - "xmlSecBufferAppend",
6167 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6168 - "size=%d", ivLen);
6173 - /* if we don't have enough data, exit and hope that
6174 - * we'll have iv next time */
6175 - if(xmlSecBufferGetSize(in) < (xmlSecSize)ivLen) {
6179 - /* copy iv to our buffer*/
6180 - xmlSecAssert2(xmlSecBufferGetData(in) != NULL, -1);
6181 - memcpy(ctx->iv, xmlSecBufferGetData(in), ivLen);
6183 - /* and remove from input */
6184 - ret = xmlSecBufferRemoveHead(in, ivLen);
6186 - xmlSecError(XMLSEC_ERRORS_HERE,
6187 - xmlSecErrorsSafeString(cipherName),
6188 - "xmlSecBufferRemoveHead",
6189 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6190 - "size=%d", ivLen);
6192 + CK_MECHANISM_TYPE cipher ;
6193 + PK11SymKey* symkey ;
6194 + PK11Context* cipherCtx ;
6195 + xmlSecKeyDataId keyId ;
6198 +#define xmlSecNssBlockCipherSize \
6199 + ( sizeof( xmlSecTransform ) + sizeof( xmlSecNssBlockCipherCtx ) )
6201 +#define xmlSecNssBlockCipherGetCtx( transform ) \
6202 + ( ( xmlSecNssBlockCipherCtxPtr )( ( ( xmlSecByte* )( transform ) ) + sizeof( xmlSecTransform ) ) )
6205 +xmlSecNssBlockCipherCheckId(
6206 + xmlSecTransformPtr transform
6208 + #ifndef XMLSEC_NO_DES
6209 + if( xmlSecTransformCheckId( transform, xmlSecNssTransformDes3CbcId ) ) {
6213 + #endif /* XMLSEC_NO_DES */
6215 - memset(&keyItem, 0, sizeof(keyItem));
6216 - keyItem.data = ctx->key;
6217 - keyItem.len = ctx->keySize;
6218 - memset(&ivItem, 0, sizeof(ivItem));
6219 - ivItem.data = ctx->iv;
6220 - ivItem.len = ctx->ivSize;
6222 - slot = PK11_GetBestSlot(ctx->cipher, NULL);
6223 - if(slot == NULL) {
6224 - xmlSecError(XMLSEC_ERRORS_HERE,
6225 - xmlSecErrorsSafeString(cipherName),
6226 - "PK11_GetBestSlot",
6227 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6228 - XMLSEC_ERRORS_NO_MESSAGE);
6232 - symKey = PK11_ImportSymKey(slot, ctx->cipher, PK11_OriginDerive,
6233 - CKA_SIGN, &keyItem, NULL);
6234 - if(symKey == NULL) {
6235 - xmlSecError(XMLSEC_ERRORS_HERE,
6236 - xmlSecErrorsSafeString(cipherName),
6237 - "PK11_ImportSymKey",
6238 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6239 - XMLSEC_ERRORS_NO_MESSAGE);
6240 - PK11_FreeSlot(slot);
6243 + #ifndef XMLSEC_NO_AES
6244 + if( xmlSecTransformCheckId( transform, xmlSecNssTransformAes128CbcId ) ||
6245 + xmlSecTransformCheckId( transform, xmlSecNssTransformAes192CbcId ) ||
6246 + xmlSecTransformCheckId( transform, xmlSecNssTransformAes256CbcId ) ) {
6248 - ctx->cipherCtx = PK11_CreateContextBySymKey(ctx->cipher,
6249 - (encrypt) ? CKA_ENCRYPT : CKA_DECRYPT,
6251 - if(ctx->cipherCtx == NULL) {
6252 - xmlSecError(XMLSEC_ERRORS_HERE,
6253 - xmlSecErrorsSafeString(cipherName),
6254 - "PK11_CreateContextBySymKey",
6255 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6256 - XMLSEC_ERRORS_NO_MESSAGE);
6257 - PK11_FreeSymKey(symKey);
6258 - PK11_FreeSlot(slot);
6263 - ctx->ctxInitialized = 1;
6264 - PK11_FreeSymKey(symKey);
6265 - PK11_FreeSlot(slot);
6267 + #endif /* XMLSEC_NO_AES */
6273 -xmlSecNssBlockCipherCtxUpdate(xmlSecNssBlockCipherCtxPtr ctx,
6274 - xmlSecBufferPtr in, xmlSecBufferPtr out,
6276 - const xmlChar* cipherName,
6277 - xmlSecTransformCtxPtr transformCtx) {
6278 - xmlSecSize inSize, inBlocks, outSize;
6281 - xmlSecByte* outBuf;
6285 - xmlSecAssert2(ctx != NULL, -1);
6286 - xmlSecAssert2(ctx->cipher != 0, -1);
6287 - xmlSecAssert2(ctx->cipherCtx != NULL, -1);
6288 - xmlSecAssert2(ctx->ctxInitialized != 0, -1);
6289 - xmlSecAssert2(in != NULL, -1);
6290 - xmlSecAssert2(out != NULL, -1);
6291 - xmlSecAssert2(transformCtx != NULL, -1);
6293 +xmlSecNssBlockCipherFetchCtx(
6294 + xmlSecNssBlockCipherCtxPtr context ,
6295 + xmlSecTransformId id
6297 + xmlSecAssert2( context != NULL, -1 ) ;
6299 + #ifndef XMLSEC_NO_DES
6300 + if( id == xmlSecNssTransformDes3CbcId ) {
6301 + context->cipher = CKM_DES3_CBC ;
6302 + context->keyId = xmlSecNssKeyDataDesId ;
6304 + #endif /* XMLSEC_NO_DES */
6306 + #ifndef XMLSEC_NO_AES
6307 + if( id == xmlSecNssTransformAes128CbcId ) {
6308 + context->cipher = CKM_AES_CBC ;
6309 + context->keyId = xmlSecNssKeyDataAesId ;
6311 + if( id == xmlSecNssTransformAes192CbcId ) {
6312 + context->cipher = CKM_AES_CBC ;
6313 + context->keyId = xmlSecNssKeyDataAesId ;
6315 + if( id == xmlSecNssTransformAes256CbcId ) {
6316 + context->cipher = CKM_AES_CBC ;
6317 + context->keyId = xmlSecNssKeyDataAesId ;
6319 + #endif /* XMLSEC_NO_AES */
6322 + xmlSecError( XMLSEC_ERRORS_HERE ,
6325 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6326 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6330 - blockLen = PK11_GetBlockSize(ctx->cipher, NULL);
6331 - xmlSecAssert2(blockLen > 0, -1);
6335 - inSize = xmlSecBufferGetSize(in);
6336 - outSize = xmlSecBufferGetSize(out);
6338 - if(inSize < (xmlSecSize)blockLen) {
6342 + * xmlSecTransformInitializeMethod:
6343 + * @transform: the pointer to transform object.
6345 + * The transform specific initialization method.
6347 + * Returns 0 on success or a negative value otherwise.
6350 +xmlSecNssBlockCipherInitialize(
6351 + xmlSecTransformPtr transform
6353 + xmlSecNssBlockCipherCtxPtr context = NULL ;
6355 + xmlSecAssert2( xmlSecNssBlockCipherCheckId( transform ), -1 ) ;
6356 + xmlSecAssert2( xmlSecTransformCheckSize( transform, xmlSecNssBlockCipherSize ), -1 ) ;
6358 + context = xmlSecNssBlockCipherGetCtx( transform ) ;
6359 + if( context == NULL ) {
6360 + xmlSecError( XMLSEC_ERRORS_HERE ,
6361 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
6362 + "xmlSecNssBlockCipherGetCtx" ,
6363 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6364 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6368 + if( xmlSecNssBlockCipherFetchCtx( context , transform->id ) < 0 ) {
6369 + xmlSecError( XMLSEC_ERRORS_HERE ,
6370 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
6371 + "xmlSecNssBlockCipherFetchCtx" ,
6372 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6373 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6378 - inBlocks = inSize / ((xmlSecSize)blockLen);
6380 - /* we want to have the last block in the input buffer
6381 - * for padding check */
6382 - inBlocks = (inSize - 1) / ((xmlSecSize)blockLen);
6384 - inSize = inBlocks * ((xmlSecSize)blockLen);
6385 + context->symkey = NULL ;
6386 + context->cipherCtx = NULL ;
6388 - /* we write out the input size plus may be one block */
6389 - ret = xmlSecBufferSetMaxSize(out, outSize + inSize + blockLen);
6391 - xmlSecError(XMLSEC_ERRORS_HERE,
6392 - xmlSecErrorsSafeString(cipherName),
6393 - "xmlSecBufferSetMaxSize",
6394 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6395 - "size=%d", outSize + inSize + blockLen);
6398 - outBuf = xmlSecBufferGetData(out) + outSize;
6400 - rv = PK11_CipherOp(ctx->cipherCtx, outBuf, &outLen, inSize + blockLen,
6401 - xmlSecBufferGetData(in), inSize);
6402 - if(rv != SECSuccess) {
6403 - xmlSecError(XMLSEC_ERRORS_HERE,
6404 - xmlSecErrorsSafeString(cipherName),
6406 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6407 - XMLSEC_ERRORS_NO_MESSAGE);
6410 - xmlSecAssert2((xmlSecSize)outLen == inSize, -1);
6412 - /* set correct output buffer size */
6413 - ret = xmlSecBufferSetSize(out, outSize + outLen);
6415 - xmlSecError(XMLSEC_ERRORS_HERE,
6416 - xmlSecErrorsSafeString(cipherName),
6417 - "xmlSecBufferSetSize",
6418 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6419 - "size=%d", outSize + outLen);
6423 - /* remove the processed block from input */
6424 - ret = xmlSecBufferRemoveHead(in, inSize);
6426 - xmlSecError(XMLSEC_ERRORS_HERE,
6427 - xmlSecErrorsSafeString(cipherName),
6428 - "xmlSecBufferRemoveHead",
6429 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6430 - "size=%d", inSize);
6438 -xmlSecNssBlockCipherCtxFinal(xmlSecNssBlockCipherCtxPtr ctx,
6439 - xmlSecBufferPtr in,
6440 - xmlSecBufferPtr out,
6442 - const xmlChar* cipherName,
6443 - xmlSecTransformCtxPtr transformCtx) {
6444 - xmlSecSize inSize, outSize;
6445 - int blockLen, outLen = 0;
6446 - xmlSecByte* inBuf;
6447 - xmlSecByte* outBuf;
6451 - xmlSecAssert2(ctx != NULL, -1);
6452 - xmlSecAssert2(ctx->cipher != 0, -1);
6453 - xmlSecAssert2(ctx->cipherCtx != NULL, -1);
6454 - xmlSecAssert2(ctx->ctxInitialized != 0, -1);
6455 - xmlSecAssert2(in != NULL, -1);
6456 - xmlSecAssert2(out != NULL, -1);
6457 - xmlSecAssert2(transformCtx != NULL, -1);
6459 - blockLen = PK11_GetBlockSize(ctx->cipher, NULL);
6460 - xmlSecAssert2(blockLen > 0, -1);
6462 + * xmlSecTransformFinalizeMethod:
6463 + * @transform: the pointer to transform object.
6465 + * The transform specific destroy method.
6468 +xmlSecNssBlockCipherFinalize(
6469 + xmlSecTransformPtr transform
6471 + xmlSecNssBlockCipherCtxPtr context = NULL ;
6473 - inSize = xmlSecBufferGetSize(in);
6474 - outSize = xmlSecBufferGetSize(out);
6475 + xmlSecAssert( xmlSecNssBlockCipherCheckId( transform ) ) ;
6476 + xmlSecAssert( xmlSecTransformCheckSize( transform, xmlSecNssBlockCipherSize ) ) ;
6478 - if(encrypt != 0) {
6479 - xmlSecAssert2(inSize < (xmlSecSize)blockLen, -1);
6481 - /* create padding */
6482 - ret = xmlSecBufferSetMaxSize(in, blockLen);
6484 - xmlSecError(XMLSEC_ERRORS_HERE,
6485 - xmlSecErrorsSafeString(cipherName),
6486 - "xmlSecBufferSetMaxSize",
6487 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6488 - "size=%d", blockLen);
6491 - inBuf = xmlSecBufferGetData(in);
6493 - /* generate random padding */
6494 - if((xmlSecSize)blockLen > (inSize + 1)) {
6495 - rv = PK11_GenerateRandom(inBuf + inSize, blockLen - inSize - 1);
6496 - if(rv != SECSuccess) {
6497 - xmlSecError(XMLSEC_ERRORS_HERE,
6498 - xmlSecErrorsSafeString(cipherName),
6499 - "PK11_GenerateRandom",
6500 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6501 - "size=%d", blockLen - inSize - 1);
6505 - inBuf[blockLen - 1] = blockLen - inSize;
6506 - inSize = blockLen;
6508 - if(inSize != (xmlSecSize)blockLen) {
6509 - xmlSecError(XMLSEC_ERRORS_HERE,
6510 - xmlSecErrorsSafeString(cipherName),
6512 - XMLSEC_ERRORS_R_INVALID_DATA,
6513 - "data=%d;block=%d", inSize, blockLen);
6515 + context = xmlSecNssBlockCipherGetCtx( transform ) ;
6516 + if( context == NULL ) {
6517 + xmlSecError( XMLSEC_ERRORS_HERE ,
6518 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
6519 + "xmlSecNssBlockCipherGetCtx" ,
6520 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6521 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6526 - /* process last block */
6527 - ret = xmlSecBufferSetMaxSize(out, outSize + 2 * blockLen);
6529 - xmlSecError(XMLSEC_ERRORS_HERE,
6530 - xmlSecErrorsSafeString(cipherName),
6531 - "xmlSecBufferSetMaxSize",
6532 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6533 - "size=%d", outSize + 2 * blockLen);
6536 - outBuf = xmlSecBufferGetData(out) + outSize;
6538 - rv = PK11_CipherOp(ctx->cipherCtx, outBuf, &outLen, 2 * blockLen,
6539 - xmlSecBufferGetData(in), inSize);
6540 - if(rv != SECSuccess) {
6541 - xmlSecError(XMLSEC_ERRORS_HERE,
6542 - xmlSecErrorsSafeString(cipherName),
6544 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
6545 - XMLSEC_ERRORS_NO_MESSAGE);
6548 - xmlSecAssert2((xmlSecSize)outLen == inSize, -1);
6550 - if(encrypt == 0) {
6551 - /* check padding */
6552 - if(outLen < outBuf[blockLen - 1]) {
6553 - xmlSecError(XMLSEC_ERRORS_HERE,
6554 - xmlSecErrorsSafeString(cipherName),
6556 - XMLSEC_ERRORS_R_INVALID_DATA,
6557 - "padding=%d;buffer=%d",
6558 - outBuf[blockLen - 1], outLen);
6561 - outLen -= outBuf[blockLen - 1];
6564 - /* set correct output buffer size */
6565 - ret = xmlSecBufferSetSize(out, outSize + outLen);
6567 - xmlSecError(XMLSEC_ERRORS_HERE,
6568 - xmlSecErrorsSafeString(cipherName),
6569 - "xmlSecBufferSetSize",
6570 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6571 - "size=%d", outSize + outLen);
6574 + if( context->cipherCtx != NULL ) {
6575 + PK11_DestroyContext( context->cipherCtx, PR_TRUE ) ;
6576 + context->cipherCtx = NULL ;
6579 - /* remove the processed block from input */
6580 - ret = xmlSecBufferRemoveHead(in, inSize);
6582 - xmlSecError(XMLSEC_ERRORS_HERE,
6583 - xmlSecErrorsSafeString(cipherName),
6584 - "xmlSecBufferRemoveHead",
6585 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
6586 - "size=%d", inSize);
6589 + if( context->symkey != NULL ) {
6590 + PK11_FreeSymKey( context->symkey ) ;
6591 + context->symkey = NULL ;
6595 + context->cipher = CKM_INVALID_MECHANISM ;
6596 + context->keyId = NULL ;
6600 -/******************************************************************************
6602 - * EVP Block Cipher transforms
6604 + * xmlSecTransformSetKeyRequirementsMethod:
6605 + * @transform: the pointer to transform object.
6606 + * @keyReq: the pointer to key requirements structure.
6608 - * xmlSecNssBlockCipherCtx block is located after xmlSecTransform structure
6609 + * Transform specific method to set transform's key requirements.
6611 - *****************************************************************************/
6612 -#define xmlSecNssBlockCipherSize \
6613 - (sizeof(xmlSecTransform) + sizeof(xmlSecNssBlockCipherCtx))
6614 -#define xmlSecNssBlockCipherGetCtx(transform) \
6615 - ((xmlSecNssBlockCipherCtxPtr)(((xmlSecByte*)(transform)) + sizeof(xmlSecTransform)))
6617 -static int xmlSecNssBlockCipherInitialize (xmlSecTransformPtr transform);
6618 -static void xmlSecNssBlockCipherFinalize (xmlSecTransformPtr transform);
6619 -static int xmlSecNssBlockCipherSetKeyReq (xmlSecTransformPtr transform,
6620 - xmlSecKeyReqPtr keyReq);
6621 -static int xmlSecNssBlockCipherSetKey (xmlSecTransformPtr transform,
6622 - xmlSecKeyPtr key);
6623 -static int xmlSecNssBlockCipherExecute (xmlSecTransformPtr transform,
6625 - xmlSecTransformCtxPtr transformCtx);
6626 -static int xmlSecNssBlockCipherCheckId (xmlSecTransformPtr transform);
6629 + * Returns 0 on success or a negative value otherwise.
6632 +xmlSecNssBlockCipherSetKeyReq(
6633 + xmlSecTransformPtr transform ,
6634 + xmlSecKeyReqPtr keyReq
6636 + xmlSecNssBlockCipherCtxPtr context = NULL ;
6637 + xmlSecSize cipherSize = 0 ;
6639 + xmlSecAssert2( xmlSecNssBlockCipherCheckId( transform ), -1 ) ;
6640 + xmlSecAssert2( xmlSecTransformCheckSize( transform, xmlSecNssBlockCipherSize ), -1 ) ;
6641 + xmlSecAssert2( keyReq != NULL , -1 ) ;
6642 + xmlSecAssert2( ( transform->operation == xmlSecTransformOperationEncrypt ) || ( transform->operation == xmlSecTransformOperationDecrypt ), -1 ) ;
6644 + context = xmlSecNssBlockCipherGetCtx( transform ) ;
6645 + if( context == NULL ) {
6646 + xmlSecError( XMLSEC_ERRORS_HERE ,
6647 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
6648 + "xmlSecNssBlockCipherGetCtx" ,
6649 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6650 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6654 + keyReq->keyId = context->keyId ;
6655 + keyReq->keyType = xmlSecKeyDataTypeSymmetric ;
6657 + if( transform->operation == xmlSecTransformOperationEncrypt ) {
6658 + keyReq->keyUsage = xmlSecKeyUsageEncrypt ;
6660 + keyReq->keyUsage = xmlSecKeyUsageDecrypt ;
6664 + if( context->symkey != NULL )
6665 + cipherSize = PK11_GetKeyLength( context->symkey ) ;
6668 -xmlSecNssBlockCipherCheckId(xmlSecTransformPtr transform) {
6669 -#ifndef XMLSEC_NO_DES
6670 - if(xmlSecTransformCheckId(transform, xmlSecNssTransformDes3CbcId)) {
6673 -#endif /* XMLSEC_NO_DES */
6674 + keyReq->keyBitsSize = cipherSize * 8 ;
6677 -#ifndef XMLSEC_NO_AES
6678 - if(xmlSecTransformCheckId(transform, xmlSecNssTransformAes128CbcId) ||
6679 - xmlSecTransformCheckId(transform, xmlSecNssTransformAes192CbcId) ||
6680 - xmlSecTransformCheckId(transform, xmlSecNssTransformAes256CbcId)) {
6684 -#endif /* XMLSEC_NO_AES */
6691 -xmlSecNssBlockCipherInitialize(xmlSecTransformPtr transform) {
6692 - xmlSecNssBlockCipherCtxPtr ctx;
6694 - xmlSecAssert2(xmlSecNssBlockCipherCheckId(transform), -1);
6695 - xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssBlockCipherSize), -1);
6697 + * xmlSecTransformSetKeyMethod:
6698 + * @transform: the pointer to transform object.
6699 + * @key: the pointer to key.
6701 + * The transform specific method to set the key for use.
6703 + * Returns 0 on success or a negative value otherwise.
6706 +xmlSecNssBlockCipherSetKey(
6707 + xmlSecTransformPtr transform ,
6710 + xmlSecNssBlockCipherCtxPtr context = NULL ;
6711 + xmlSecKeyDataPtr keyData = NULL ;
6712 + PK11SymKey* symkey = NULL ;
6713 + CK_ATTRIBUTE_TYPE operation ;
6716 + xmlSecAssert2( xmlSecNssBlockCipherCheckId( transform ), -1 ) ;
6717 + xmlSecAssert2( xmlSecTransformCheckSize( transform, xmlSecNssBlockCipherSize ), -1 ) ;
6718 + xmlSecAssert2( key != NULL , -1 ) ;
6719 + xmlSecAssert2( ( transform->operation == xmlSecTransformOperationEncrypt ) || ( transform->operation == xmlSecTransformOperationDecrypt ), -1 ) ;
6721 + context = xmlSecNssBlockCipherGetCtx( transform ) ;
6722 + if( context == NULL || context->keyId == NULL || context->symkey != NULL ) {
6723 + xmlSecError( XMLSEC_ERRORS_HERE ,
6724 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
6725 + "xmlSecNssBlockCipherGetCtx" ,
6726 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6727 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6730 + xmlSecAssert2( xmlSecKeyCheckId( key, context->keyId ), -1 ) ;
6732 + keyData = xmlSecKeyGetValue( key ) ;
6733 + if( keyData == NULL ) {
6734 + xmlSecError( XMLSEC_ERRORS_HERE ,
6735 + xmlSecErrorsSafeString( xmlSecKeyGetName( key ) ) ,
6736 + "xmlSecKeyGetValue" ,
6737 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6738 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6742 + if( ( symkey = xmlSecNssSymKeyDataGetKey( keyData ) ) == NULL ) {
6743 + xmlSecError( XMLSEC_ERRORS_HERE ,
6744 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( keyData ) ) ,
6745 + "xmlSecNssSymKeyDataGetKey" ,
6746 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6747 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6751 - ctx = xmlSecNssBlockCipherGetCtx(transform);
6752 - xmlSecAssert2(ctx != NULL, -1);
6754 - memset(ctx, 0, sizeof(xmlSecNssBlockCipherCtx));
6755 + context->symkey = symkey ;
6757 -#ifndef XMLSEC_NO_DES
6758 - if(transform->id == xmlSecNssTransformDes3CbcId) {
6759 - ctx->cipher = CKM_DES3_CBC;
6760 - ctx->keyId = xmlSecNssKeyDataDesId;
6761 - ctx->keySize = 24;
6763 -#endif /* XMLSEC_NO_DES */
6765 -#ifndef XMLSEC_NO_AES
6766 - if(transform->id == xmlSecNssTransformAes128CbcId) {
6767 - ctx->cipher = CKM_AES_CBC;
6768 - ctx->keyId = xmlSecNssKeyDataAesId;
6769 - ctx->keySize = 16;
6770 - } else if(transform->id == xmlSecNssTransformAes192CbcId) {
6771 - ctx->cipher = CKM_AES_CBC;
6772 - ctx->keyId = xmlSecNssKeyDataAesId;
6773 - ctx->keySize = 24;
6774 - } else if(transform->id == xmlSecNssTransformAes256CbcId) {
6775 - ctx->cipher = CKM_AES_CBC;
6776 - ctx->keyId = xmlSecNssKeyDataAesId;
6777 - ctx->keySize = 32;
6779 -#endif /* XMLSEC_NO_AES */
6782 - xmlSecError(XMLSEC_ERRORS_HERE,
6783 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
6785 - XMLSEC_ERRORS_R_INVALID_TRANSFORM,
6786 - XMLSEC_ERRORS_NO_MESSAGE);
6795 -xmlSecNssBlockCipherFinalize(xmlSecTransformPtr transform) {
6796 - xmlSecNssBlockCipherCtxPtr ctx;
6798 - xmlSecAssert(xmlSecNssBlockCipherCheckId(transform));
6799 - xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecNssBlockCipherSize));
6801 + * Block cipher transform init
6804 +xmlSecNssBlockCipherCtxInit(
6805 + xmlSecNssBlockCipherCtxPtr ctx ,
6806 + xmlSecBufferPtr in ,
6807 + xmlSecBufferPtr out ,
6809 + const xmlChar* cipherName ,
6810 + xmlSecTransformCtxPtr transformCtx
6813 + SECItem* secParam = NULL ;
6814 + xmlSecBufferPtr ivBuf = NULL ;
6817 + xmlSecAssert2( ctx != NULL , -1 ) ;
6818 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
6819 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
6820 + xmlSecAssert2( ctx->cipherCtx == NULL , -1 ) ;
6821 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
6822 + xmlSecAssert2( in != NULL , -1 ) ;
6823 + xmlSecAssert2( out != NULL , -1 ) ;
6824 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
6826 + ivLen = PK11_GetIVLength( ctx->cipher ) ;
6828 + xmlSecError( XMLSEC_ERRORS_HERE ,
6830 + "PK11_GetIVLength" ,
6831 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6832 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6836 + if( ( ivBuf = xmlSecBufferCreate( ivLen ) ) == NULL ) {
6837 + xmlSecError( XMLSEC_ERRORS_HERE ,
6839 + "xmlSecBufferCreate" ,
6840 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6841 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6846 + if( PK11_GenerateRandom( ivBuf->data , ivLen ) != SECSuccess ) {
6847 + xmlSecError( XMLSEC_ERRORS_HERE ,
6848 + xmlSecErrorsSafeString( cipherName ) ,
6849 + "PK11_GenerateRandom" ,
6850 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6851 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6852 + xmlSecBufferDestroy( ivBuf ) ;
6855 + if( xmlSecBufferSetSize( ivBuf , ivLen ) < 0 ) {
6856 + xmlSecError( XMLSEC_ERRORS_HERE ,
6858 + "xmlSecBufferSetSize" ,
6859 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6860 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6861 + xmlSecBufferDestroy( ivBuf ) ;
6865 + if( xmlSecBufferAppend( out , ivBuf->data , ivLen ) < 0 ) {
6866 + xmlSecError( XMLSEC_ERRORS_HERE ,
6867 + xmlSecErrorsSafeString( cipherName ) ,
6868 + "xmlSecBufferAppend" ,
6869 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6870 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6871 + xmlSecBufferDestroy( ivBuf ) ;
6875 + if( xmlSecBufferSetData( ivBuf , in->data , ivLen ) < 0 ) {
6876 + xmlSecError( XMLSEC_ERRORS_HERE ,
6877 + xmlSecErrorsSafeString( cipherName ) ,
6878 + "xmlSecBufferSetData" ,
6879 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6880 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6881 + xmlSecBufferDestroy( ivBuf ) ;
6885 + if( xmlSecBufferRemoveHead( in , ivLen ) < 0 ) {
6886 + xmlSecError( XMLSEC_ERRORS_HERE ,
6887 + xmlSecErrorsSafeString( cipherName ) ,
6888 + "xmlSecBufferRemoveHead" ,
6889 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6890 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6891 + xmlSecBufferDestroy( ivBuf ) ;
6896 + ivItem.data = xmlSecBufferGetData( ivBuf ) ;
6897 + ivItem.len = xmlSecBufferGetSize( ivBuf ) ;
6898 + if( ( secParam = PK11_ParamFromIV( ctx->cipher , &ivItem ) ) == NULL ) {
6899 + xmlSecError( XMLSEC_ERRORS_HERE ,
6900 + xmlSecErrorsSafeString( cipherName ) ,
6901 + "PK11_ParamFromIV" ,
6902 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6903 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6904 + xmlSecBufferDestroy( ivBuf ) ;
6908 + ctx->cipherCtx = PK11_CreateContextBySymKey( ctx->cipher , encrypt ? CKA_ENCRYPT : CKA_DECRYPT , ctx->symkey , secParam ) ;
6909 + if( ctx->cipherCtx == NULL ) {
6910 + xmlSecError( XMLSEC_ERRORS_HERE ,
6911 + xmlSecErrorsSafeString( cipherName ) ,
6912 + "xmlSecBufferRemoveHead" ,
6913 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6914 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6915 + SECITEM_FreeItem( secParam , PR_TRUE ) ;
6916 + xmlSecBufferDestroy( ivBuf ) ;
6920 - ctx = xmlSecNssBlockCipherGetCtx(transform);
6921 - xmlSecAssert(ctx != NULL);
6922 + SECITEM_FreeItem( secParam , PR_TRUE ) ;
6923 + xmlSecBufferDestroy( ivBuf ) ;
6925 - if(ctx->cipherCtx != NULL) {
6926 - PK11_DestroyContext(ctx->cipherCtx, PR_TRUE);
6929 - memset(ctx, 0, sizeof(xmlSecNssBlockCipherCtx));
6934 -xmlSecNssBlockCipherSetKeyReq(xmlSecTransformPtr transform, xmlSecKeyReqPtr keyReq) {
6935 - xmlSecNssBlockCipherCtxPtr ctx;
6937 - xmlSecAssert2(xmlSecNssBlockCipherCheckId(transform), -1);
6938 - xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
6939 - xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssBlockCipherSize), -1);
6940 - xmlSecAssert2(keyReq != NULL, -1);
6942 - ctx = xmlSecNssBlockCipherGetCtx(transform);
6943 - xmlSecAssert2(ctx != NULL, -1);
6944 - xmlSecAssert2(ctx->keyId != NULL, -1);
6946 - keyReq->keyId = ctx->keyId;
6947 - keyReq->keyType = xmlSecKeyDataTypeSymmetric;
6948 - if(transform->operation == xmlSecTransformOperationEncrypt) {
6949 - keyReq->keyUsage = xmlSecKeyUsageEncrypt;
6951 - keyReq->keyUsage = xmlSecKeyUsageDecrypt;
6953 - keyReq->keyBitsSize = 8 * ctx->keySize;
6957 + * Block cipher transform update
6960 +xmlSecNssBlockCipherCtxUpdate(
6961 + xmlSecNssBlockCipherCtxPtr ctx ,
6962 + xmlSecBufferPtr in ,
6963 + xmlSecBufferPtr out ,
6965 + const xmlChar* cipherName ,
6966 + xmlSecTransformCtxPtr transformCtx
6968 + xmlSecSize inSize ;
6969 + xmlSecSize outSize ;
6970 + xmlSecSize inBlocks ;
6973 + xmlSecByte* outBuf ;
6975 + xmlSecAssert2( ctx != NULL , -1 ) ;
6976 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
6977 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
6978 + xmlSecAssert2( ctx->cipherCtx != NULL , -1 ) ;
6979 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
6980 + xmlSecAssert2( in != NULL , -1 ) ;
6981 + xmlSecAssert2( out != NULL , -1 ) ;
6982 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
6984 + if( ( blockSize = PK11_GetBlockSize( ctx->cipher , NULL ) ) < 0 ) {
6985 + xmlSecError( XMLSEC_ERRORS_HERE ,
6986 + xmlSecErrorsSafeString( cipherName ) ,
6987 + "PK11_GetBlockSize" ,
6988 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
6989 + XMLSEC_ERRORS_NO_MESSAGE ) ;
6993 + inSize = xmlSecBufferGetSize( in ) ;
6994 + outSize = xmlSecBufferGetSize( out ) ;
6996 + inBlocks = ( encrypt != 0 ? inSize : ( inSize - 1 ) ) / blockSize ;
6997 + inSize = inBlocks * blockSize ;
6999 + if( inSize < blockSize ) {
7003 + if( xmlSecBufferSetMaxSize( out , outSize + inSize + blockSize ) < 0 ) {
7004 + xmlSecError( XMLSEC_ERRORS_HERE ,
7005 + xmlSecErrorsSafeString( cipherName ) ,
7006 + "xmlSecBufferSetMaxSize" ,
7007 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7008 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7011 + outBuf = xmlSecBufferGetData( out ) + outSize ;
7013 + if( PK11_CipherOp( ctx->cipherCtx , outBuf , &outLen , inSize + blockSize , xmlSecBufferGetData( in ) , inSize ) != SECSuccess ) {
7014 + xmlSecError( XMLSEC_ERRORS_HERE ,
7015 + xmlSecErrorsSafeString( cipherName ) ,
7017 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7018 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7022 + if( xmlSecBufferSetSize( out , outSize + outLen ) < 0 ) {
7023 + xmlSecError( XMLSEC_ERRORS_HERE ,
7024 + xmlSecErrorsSafeString( cipherName ) ,
7025 + "xmlSecBufferSetSize" ,
7026 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7027 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7031 + if( xmlSecBufferRemoveHead( in , inSize ) < 0 ) {
7032 + xmlSecError( XMLSEC_ERRORS_HERE ,
7033 + xmlSecErrorsSafeString( cipherName ) ,
7034 + "xmlSecBufferRemoveHead" ,
7035 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7036 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7041 -xmlSecNssBlockCipherSetKey(xmlSecTransformPtr transform, xmlSecKeyPtr key) {
7042 - xmlSecNssBlockCipherCtxPtr ctx;
7043 - xmlSecBufferPtr buffer;
7045 - xmlSecAssert2(xmlSecNssBlockCipherCheckId(transform), -1);
7046 - xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
7047 - xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssBlockCipherSize), -1);
7048 - xmlSecAssert2(key != NULL, -1);
7050 - ctx = xmlSecNssBlockCipherGetCtx(transform);
7051 - xmlSecAssert2(ctx != NULL, -1);
7052 - xmlSecAssert2(ctx->cipher != 0, -1);
7053 - xmlSecAssert2(ctx->keyInitialized == 0, -1);
7054 - xmlSecAssert2(ctx->keyId != NULL, -1);
7055 - xmlSecAssert2(xmlSecKeyCheckId(key, ctx->keyId), -1);
7057 - xmlSecAssert2(ctx->keySize > 0, -1);
7058 - xmlSecAssert2(ctx->keySize <= sizeof(ctx->key), -1);
7060 - buffer = xmlSecKeyDataBinaryValueGetBuffer(xmlSecKeyGetValue(key));
7061 - xmlSecAssert2(buffer != NULL, -1);
7063 - if(xmlSecBufferGetSize(buffer) < ctx->keySize) {
7064 - xmlSecError(XMLSEC_ERRORS_HERE,
7065 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7067 - XMLSEC_ERRORS_R_INVALID_KEY_DATA_SIZE,
7068 - "keySize=%d;expected=%d",
7069 - xmlSecBufferGetSize(buffer), ctx->keySize);
7073 - xmlSecAssert2(xmlSecBufferGetData(buffer) != NULL, -1);
7074 - memcpy(ctx->key, xmlSecBufferGetData(buffer), ctx->keySize);
7076 - ctx->keyInitialized = 1;
7082 + * Block cipher transform final
7085 -xmlSecNssBlockCipherExecute(xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx) {
7086 - xmlSecNssBlockCipherCtxPtr ctx;
7087 - xmlSecBufferPtr in, out;
7090 - xmlSecAssert2(xmlSecNssBlockCipherCheckId(transform), -1);
7091 - xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
7092 - xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssBlockCipherSize), -1);
7093 - xmlSecAssert2(transformCtx != NULL, -1);
7095 - in = &(transform->inBuf);
7096 - out = &(transform->outBuf);
7098 - ctx = xmlSecNssBlockCipherGetCtx(transform);
7099 - xmlSecAssert2(ctx != NULL, -1);
7100 +xmlSecNssBlockCipherCtxFinal(
7101 + xmlSecNssBlockCipherCtxPtr ctx ,
7102 + xmlSecBufferPtr in ,
7103 + xmlSecBufferPtr out ,
7105 + const xmlChar* cipherName ,
7106 + xmlSecTransformCtxPtr transformCtx
7108 + xmlSecSize inSize ;
7109 + xmlSecSize outSize ;
7112 + xmlSecByte* inBuf ;
7113 + xmlSecByte* outBuf ;
7115 + xmlSecAssert2( ctx != NULL , -1 ) ;
7116 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
7117 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
7118 + xmlSecAssert2( ctx->cipherCtx != NULL , -1 ) ;
7119 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
7120 + xmlSecAssert2( in != NULL , -1 ) ;
7121 + xmlSecAssert2( out != NULL , -1 ) ;
7122 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
7124 + if( ( blockSize = PK11_GetBlockSize( ctx->cipher , NULL ) ) < 0 ) {
7125 + xmlSecError( XMLSEC_ERRORS_HERE ,
7126 + xmlSecErrorsSafeString( cipherName ) ,
7127 + "PK11_GetBlockSize" ,
7128 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7129 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7133 + inSize = xmlSecBufferGetSize( in ) ;
7134 + outSize = xmlSecBufferGetSize( out ) ;
7136 + /******************************************************************/
7137 + if( encrypt != 0 ) {
7138 + xmlSecAssert2( inSize < blockSize, -1 ) ;
7140 + /* create padding */
7141 + if( xmlSecBufferSetMaxSize( in , blockSize ) < 0 ) {
7142 + xmlSecError( XMLSEC_ERRORS_HERE ,
7143 + xmlSecErrorsSafeString( cipherName ) ,
7144 + "xmlSecBufferSetMaxSize" ,
7145 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7146 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7149 + inBuf = xmlSecBufferGetData( in ) ;
7151 + /* generate random */
7152 + if( blockSize > ( inSize + 1 ) ) {
7153 + if( PK11_GenerateRandom( inBuf + inSize, blockSize - inSize - 1 ) != SECSuccess ) {
7154 + xmlSecError( XMLSEC_ERRORS_HERE ,
7155 + xmlSecErrorsSafeString( cipherName ) ,
7156 + "PK11_GenerateRandom" ,
7157 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7158 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7163 + inBuf[blockSize-1] = blockSize - inSize ;
7164 + inSize = blockSize ;
7166 + if( inSize != blockSize ) {
7167 + xmlSecError( XMLSEC_ERRORS_HERE ,
7168 + xmlSecErrorsSafeString( cipherName ) ,
7170 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7171 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7176 + /* process the last block */
7177 + if( xmlSecBufferSetMaxSize( out , outSize + inSize + blockSize ) < 0 ) {
7178 + xmlSecError( XMLSEC_ERRORS_HERE ,
7179 + xmlSecErrorsSafeString( cipherName ) ,
7180 + "xmlSecBufferSetMaxSize" ,
7181 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7182 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7185 + outBuf = xmlSecBufferGetData( out ) + outSize ;
7187 + if( PK11_CipherOp( ctx->cipherCtx , outBuf , &outLen , inSize + blockSize , xmlSecBufferGetData( in ) , inSize ) != SECSuccess ) {
7188 + xmlSecError( XMLSEC_ERRORS_HERE ,
7189 + xmlSecErrorsSafeString( cipherName ) ,
7191 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7192 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7196 + if( encrypt == 0 ) {
7197 + /* check padding */
7198 + if( outLen < outBuf[blockSize-1] ) {
7199 + xmlSecError( XMLSEC_ERRORS_HERE ,
7200 + xmlSecErrorsSafeString( cipherName ) ,
7202 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7203 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7207 + outLen -= outBuf[blockSize-1] ;
7209 + /******************************************************************/
7211 + /******************************************************************
7212 + if( xmlSecBufferSetMaxSize( out , outSize + blockSize ) < 0 ) {
7213 + xmlSecError( XMLSEC_ERRORS_HERE ,
7214 + xmlSecErrorsSafeString( cipherName ) ,
7215 + "xmlSecBufferSetMaxSize" ,
7216 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7217 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7221 + outBuf = xmlSecBufferGetData( out ) + outSize ;
7223 + if( PK11_DigestFinal( ctx->cipherCtx , outBuf , &outLen , blockSize ) != SECSuccess ) {
7224 + xmlSecError( XMLSEC_ERRORS_HERE ,
7225 + xmlSecErrorsSafeString( cipherName ) ,
7226 + "PK11_DigestFinal" ,
7227 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7228 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7231 + ******************************************************************/
7233 + if( xmlSecBufferSetSize( out , outSize + outLen ) < 0 ) {
7234 + xmlSecError( XMLSEC_ERRORS_HERE ,
7235 + xmlSecErrorsSafeString( cipherName ) ,
7236 + "xmlSecBufferSetSize" ,
7237 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7238 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7242 + if( xmlSecBufferRemoveHead( in , inSize ) < 0 ) {
7243 + xmlSecError( XMLSEC_ERRORS_HERE ,
7244 + xmlSecErrorsSafeString( cipherName ) ,
7245 + "xmlSecBufferRemoveHead" ,
7246 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7247 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7251 +/* PK11_Finalize( ctx->cipherCtx ) ;*/
7252 + PK11_DestroyContext( ctx->cipherCtx , PR_TRUE ) ;
7253 + ctx->cipherCtx = NULL ;
7255 - if(transform->status == xmlSecTransformStatusNone) {
7256 - transform->status = xmlSecTransformStatusWorking;
7259 - if(transform->status == xmlSecTransformStatusWorking) {
7260 - if(ctx->ctxInitialized == 0) {
7261 - ret = xmlSecNssBlockCipherCtxInit(ctx, in, out,
7262 - (transform->operation == xmlSecTransformOperationEncrypt) ? 1 : 0,
7263 - xmlSecTransformGetName(transform), transformCtx);
7265 - xmlSecError(XMLSEC_ERRORS_HERE,
7266 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7267 - "xmlSecNssBlockCipherCtxInit",
7268 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
7269 - XMLSEC_ERRORS_NO_MESSAGE);
7273 - if((ctx->ctxInitialized == 0) && (last != 0)) {
7274 - xmlSecError(XMLSEC_ERRORS_HERE,
7275 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7277 - XMLSEC_ERRORS_R_INVALID_DATA,
7278 - "not enough data to initialize transform");
7282 - if(ctx->ctxInitialized != 0) {
7283 - ret = xmlSecNssBlockCipherCtxUpdate(ctx, in, out,
7284 - (transform->operation == xmlSecTransformOperationEncrypt) ? 1 : 0,
7285 - xmlSecTransformGetName(transform), transformCtx);
7287 - xmlSecError(XMLSEC_ERRORS_HERE,
7288 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7289 - "xmlSecNssBlockCipherCtxUpdate",
7290 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
7291 - XMLSEC_ERRORS_NO_MESSAGE);
7297 - ret = xmlSecNssBlockCipherCtxFinal(ctx, in, out,
7298 - (transform->operation == xmlSecTransformOperationEncrypt) ? 1 : 0,
7299 - xmlSecTransformGetName(transform), transformCtx);
7301 - xmlSecError(XMLSEC_ERRORS_HERE,
7302 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7303 - "xmlSecNssBlockCipherCtxFinal",
7304 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
7305 - XMLSEC_ERRORS_NO_MESSAGE);
7308 - transform->status = xmlSecTransformStatusFinished;
7310 - } else if(transform->status == xmlSecTransformStatusFinished) {
7311 - /* the only way we can get here is if there is no input */
7312 - xmlSecAssert2(xmlSecBufferGetSize(in) == 0, -1);
7313 - } else if(transform->status == xmlSecTransformStatusNone) {
7314 - /* the only way we can get here is if there is no enough data in the input */
7315 - xmlSecAssert2(last == 0, -1);
7317 - xmlSecError(XMLSEC_ERRORS_HERE,
7318 - xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7320 - XMLSEC_ERRORS_R_INVALID_STATUS,
7321 - "status=%d", transform->status);
7330 -#ifndef XMLSEC_NO_AES
7331 -/*********************************************************************
7334 + * xmlSecTransformExecuteMethod:
7335 + * @transform: the pointer to transform object.
7336 + * @last: the flag: if set to 1 then it's the last data chunk.
7337 + * @transformCtx: the pointer to transform context object.
7339 - * AES CBC cipher transforms
7340 + * Transform specific method to process a chunk of data.
7342 - ********************************************************************/
7343 + * Returns 0 on success or a negative value otherwise.
7346 +xmlSecNssBlockCipherExecute(
7347 + xmlSecTransformPtr transform ,
7349 + xmlSecTransformCtxPtr transformCtx
7351 + xmlSecNssBlockCipherCtxPtr context = NULL ;
7352 + xmlSecBufferPtr inBuf = NULL ;
7353 + xmlSecBufferPtr outBuf = NULL ;
7354 + const xmlChar* cipherName ;
7358 + xmlSecAssert2( xmlSecNssBlockCipherCheckId( transform ), -1 ) ;
7359 + xmlSecAssert2( xmlSecTransformCheckSize( transform, xmlSecNssBlockCipherSize ), -1 ) ;
7360 + xmlSecAssert2( ( transform->operation == xmlSecTransformOperationEncrypt ) || ( transform->operation == xmlSecTransformOperationDecrypt ), -1 ) ;
7361 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
7363 + context = xmlSecNssBlockCipherGetCtx( transform ) ;
7364 + if( context == NULL ) {
7365 + xmlSecError( XMLSEC_ERRORS_HERE ,
7366 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7367 + "xmlSecNssBlockCipherGetCtx" ,
7368 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
7369 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7373 + inBuf = &( transform->inBuf ) ;
7374 + outBuf = &( transform->outBuf ) ;
7376 + if( transform->status == xmlSecTransformStatusNone ) {
7377 + transform->status = xmlSecTransformStatusWorking ;
7380 + operation = ( transform->operation == xmlSecTransformOperationEncrypt ) ? 1 : 0 ;
7381 + cipherName = xmlSecTransformGetName( transform ) ;
7383 + if( transform->status == xmlSecTransformStatusWorking ) {
7384 + if( context->cipherCtx == NULL ) {
7385 + rtv = xmlSecNssBlockCipherCtxInit( context, inBuf , outBuf , operation , cipherName , transformCtx ) ;
7387 + xmlSecError( XMLSEC_ERRORS_HERE ,
7388 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7389 + "xmlSecNssBlockCipherCtxInit" ,
7390 + XMLSEC_ERRORS_R_INVALID_STATUS ,
7391 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7396 + if( context->cipherCtx == NULL && last != 0 ) {
7397 + xmlSecError( XMLSEC_ERRORS_HERE ,
7398 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7400 + XMLSEC_ERRORS_R_INVALID_STATUS ,
7401 + "No enough data to intialize transform" ) ;
7405 + if( context->cipherCtx != NULL ) {
7406 + rtv = xmlSecNssBlockCipherCtxUpdate( context, inBuf , outBuf , operation , cipherName , transformCtx ) ;
7408 + xmlSecError( XMLSEC_ERRORS_HERE ,
7409 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7410 + "xmlSecNssBlockCipherCtxUpdate" ,
7411 + XMLSEC_ERRORS_R_INVALID_STATUS ,
7412 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7418 + rtv = xmlSecNssBlockCipherCtxFinal( context, inBuf , outBuf , operation , cipherName , transformCtx ) ;
7420 + xmlSecError( XMLSEC_ERRORS_HERE ,
7421 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7422 + "xmlSecNssBlockCipherCtxFinal" ,
7423 + XMLSEC_ERRORS_R_INVALID_STATUS ,
7424 + XMLSEC_ERRORS_NO_MESSAGE ) ;
7427 + transform->status = xmlSecTransformStatusFinished ;
7429 + } else if( transform->status == xmlSecTransformStatusFinished ) {
7430 + if( xmlSecBufferGetSize( inBuf ) != 0 ) {
7431 + xmlSecError( XMLSEC_ERRORS_HERE ,
7432 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7434 + XMLSEC_ERRORS_R_INVALID_STATUS ,
7435 + "status=%d", transform->status ) ;
7439 + xmlSecError( XMLSEC_ERRORS_HERE ,
7440 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
7442 + XMLSEC_ERRORS_R_INVALID_STATUS ,
7443 + "status=%d", transform->status ) ;
7450 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7451 +static struct _xmlSecTransformKlass xmlSecNssAes128CbcKlass = {
7453 static xmlSecTransformKlass xmlSecNssAes128CbcKlass = {
7454 - /* klass/object sizes */
7455 - sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7456 - xmlSecNssBlockCipherSize, /* xmlSecSize objSize */
7458 - xmlSecNameAes128Cbc, /* const xmlChar* name; */
7459 - xmlSecHrefAes128Cbc, /* const xmlChar* href; */
7460 - xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
7462 - xmlSecNssBlockCipherInitialize, /* xmlSecTransformInitializeMethod initialize; */
7463 - xmlSecNssBlockCipherFinalize, /* xmlSecTransformFinalizeMethod finalize; */
7464 - NULL, /* xmlSecTransformNodeReadMethod readNode; */
7465 - NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
7466 - xmlSecNssBlockCipherSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
7467 - xmlSecNssBlockCipherSetKey, /* xmlSecTransformSetKeyMethod setKey; */
7468 - NULL, /* xmlSecTransformValidateMethod validate; */
7469 - xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
7470 - xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
7471 - xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
7472 - NULL, /* xmlSecTransformPushXmlMethod pushXml; */
7473 - NULL, /* xmlSecTransformPopXmlMethod popXml; */
7474 - xmlSecNssBlockCipherExecute, /* xmlSecTransformExecuteMethod execute; */
7476 - NULL, /* void* reserved0; */
7477 - NULL, /* void* reserved1; */
7480 + sizeof( xmlSecTransformKlass ) ,
7481 + xmlSecNssBlockCipherSize ,
7483 + xmlSecNameAes128Cbc ,
7484 + xmlSecHrefAes128Cbc ,
7485 + xmlSecTransformUsageEncryptionMethod ,
7487 + xmlSecNssBlockCipherInitialize ,
7488 + xmlSecNssBlockCipherFinalize ,
7492 + xmlSecNssBlockCipherSetKeyReq ,
7493 + xmlSecNssBlockCipherSetKey ,
7495 + xmlSecTransformDefaultGetDataType ,
7497 + xmlSecTransformDefaultPushBin ,
7498 + xmlSecTransformDefaultPopBin ,
7501 + xmlSecNssBlockCipherExecute ,
7508 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7509 +static struct _xmlSecTransformKlass xmlSecNssAes192CbcKlass = {
7511 +static xmlSecTransformKlass xmlSecNssAes192CbcKlass = {
7513 + sizeof( xmlSecTransformKlass ) ,
7514 + xmlSecNssBlockCipherSize ,
7516 + xmlSecNameAes192Cbc ,
7517 + xmlSecHrefAes192Cbc ,
7518 + xmlSecTransformUsageEncryptionMethod ,
7520 + xmlSecNssBlockCipherInitialize ,
7521 + xmlSecNssBlockCipherFinalize ,
7525 + xmlSecNssBlockCipherSetKeyReq ,
7526 + xmlSecNssBlockCipherSetKey ,
7528 + xmlSecTransformDefaultGetDataType ,
7530 + xmlSecTransformDefaultPushBin ,
7531 + xmlSecTransformDefaultPopBin ,
7534 + xmlSecNssBlockCipherExecute ,
7541 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7542 +static struct _xmlSecTransformKlass xmlSecNssAes256CbcKlass = {
7544 +static xmlSecTransformKlass xmlSecNssAes256CbcKlass = {
7546 + sizeof( xmlSecTransformKlass ) ,
7547 + xmlSecNssBlockCipherSize ,
7549 + xmlSecNameAes256Cbc ,
7550 + xmlSecHrefAes256Cbc ,
7551 + xmlSecTransformUsageEncryptionMethod ,
7553 + xmlSecNssBlockCipherInitialize ,
7554 + xmlSecNssBlockCipherFinalize ,
7558 + xmlSecNssBlockCipherSetKeyReq ,
7559 + xmlSecNssBlockCipherSetKey ,
7561 + xmlSecTransformDefaultGetDataType ,
7563 + xmlSecTransformDefaultPushBin ,
7564 + xmlSecTransformDefaultPopBin ,
7567 + xmlSecNssBlockCipherExecute ,
7573 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7574 +static struct _xmlSecTransformKlass xmlSecNssDes3CbcKlass = {
7576 +static xmlSecTransformKlass xmlSecNssDes3CbcKlass = {
7578 + sizeof( xmlSecTransformKlass ) ,
7579 + xmlSecNssBlockCipherSize ,
7581 + xmlSecNameDes3Cbc ,
7582 + xmlSecHrefDes3Cbc ,
7583 + xmlSecTransformUsageEncryptionMethod ,
7585 + xmlSecNssBlockCipherInitialize ,
7586 + xmlSecNssBlockCipherFinalize ,
7590 + xmlSecNssBlockCipherSetKeyReq ,
7591 + xmlSecNssBlockCipherSetKey ,
7593 + xmlSecTransformDefaultGetDataType ,
7595 + xmlSecTransformDefaultPushBin ,
7596 + xmlSecTransformDefaultPopBin ,
7599 + xmlSecNssBlockCipherExecute ,
7606 - * xmlSecNssTransformAes128CbcGetKlass:
7608 - * AES 128 CBC encryption transform klass.
7610 - * Returns pointer to AES 128 CBC encryption transform.
7613 -xmlSecNssTransformAes128CbcGetKlass(void) {
7614 - return(&xmlSecNssAes128CbcKlass);
7615 + * xmlSecNssTransformAes128CbcGetKlass
7617 + * Get the AES128_CBC transform klass
7619 + * Return AES128_CBC transform klass
7622 +xmlSecNssTransformAes128CbcGetKlass( void ) {
7623 + return ( &xmlSecNssAes128CbcKlass ) ;
7626 -static xmlSecTransformKlass xmlSecNssAes192CbcKlass = {
7627 - /* klass/object sizes */
7628 - sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7629 - xmlSecNssBlockCipherSize, /* xmlSecSize objSize */
7631 - xmlSecNameAes192Cbc, /* const xmlChar* name; */
7632 - xmlSecHrefAes192Cbc, /* const xmlChar* href; */
7633 - xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
7635 - xmlSecNssBlockCipherInitialize, /* xmlSecTransformInitializeMethod initialize; */
7636 - xmlSecNssBlockCipherFinalize, /* xmlSecTransformFinalizeMethod finalize; */
7637 - NULL, /* xmlSecTransformNodeReadMethod readNode; */
7638 - NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
7639 - xmlSecNssBlockCipherSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
7640 - xmlSecNssBlockCipherSetKey, /* xmlSecTransformSetKeyMethod setKey; */
7641 - NULL, /* xmlSecTransformValidateMethod validate; */
7642 - xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
7643 - xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
7644 - xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
7645 - NULL, /* xmlSecTransformPushXmlMethod pushXml; */
7646 - NULL, /* xmlSecTransformPopXmlMethod popXml; */
7647 - xmlSecNssBlockCipherExecute, /* xmlSecTransformExecuteMethod execute; */
7649 - NULL, /* void* reserved0; */
7650 - NULL, /* void* reserved1; */
7654 - * xmlSecNssTransformAes192CbcGetKlass:
7656 - * AES 192 CBC encryption transform klass.
7658 - * Returns pointer to AES 192 CBC encryption transform.
7661 -xmlSecNssTransformAes192CbcGetKlass(void) {
7662 - return(&xmlSecNssAes192CbcKlass);
7663 + * xmlSecNssTransformAes192CbcGetKlass
7665 + * Get the AES192_CBC transform klass
7667 + * Return AES192_CBC transform klass
7670 +xmlSecNssTransformAes192CbcGetKlass( void ) {
7671 + return ( &xmlSecNssAes192CbcKlass ) ;
7674 -static xmlSecTransformKlass xmlSecNssAes256CbcKlass = {
7675 - /* klass/object sizes */
7676 - sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7677 - xmlSecNssBlockCipherSize, /* xmlSecSize objSize */
7679 - xmlSecNameAes256Cbc, /* const xmlChar* name; */
7680 - xmlSecHrefAes256Cbc, /* const xmlChar* href; */
7681 - xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
7683 - xmlSecNssBlockCipherInitialize, /* xmlSecTransformInitializeMethod initialize; */
7684 - xmlSecNssBlockCipherFinalize, /* xmlSecTransformFinalizeMethod finalize; */
7685 - NULL, /* xmlSecTransformNodeReadMethod readNode; */
7686 - NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
7687 - xmlSecNssBlockCipherSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
7688 - xmlSecNssBlockCipherSetKey, /* xmlSecTransformSetKeyMethod setKey; */
7689 - NULL, /* xmlSecTransformValidateMethod validate; */
7690 - xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
7691 - xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
7692 - xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
7693 - NULL, /* xmlSecTransformPushXmlMethod pushXml; */
7694 - NULL, /* xmlSecTransformPopXmlMethod popXml; */
7695 - xmlSecNssBlockCipherExecute, /* xmlSecTransformExecuteMethod execute; */
7697 - NULL, /* void* reserved0; */
7698 - NULL, /* void* reserved1; */
7702 - * xmlSecNssTransformAes256CbcGetKlass:
7704 - * AES 256 CBC encryption transform klass.
7706 - * Returns pointer to AES 256 CBC encryption transform.
7709 -xmlSecNssTransformAes256CbcGetKlass(void) {
7710 - return(&xmlSecNssAes256CbcKlass);
7711 + * xmlSecNssTransformAes256CbcGetKlass
7713 + * Get the AES256_CBC transform klass
7715 + * Return AES256_CBC transform klass
7718 +xmlSecNssTransformAes256CbcGetKlass( void ) {
7719 + return ( &xmlSecNssAes256CbcKlass ) ;
7722 -#endif /* XMLSEC_NO_AES */
7724 -#ifndef XMLSEC_NO_DES
7725 -static xmlSecTransformKlass xmlSecNssDes3CbcKlass = {
7726 - /* klass/object sizes */
7727 - sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7728 - xmlSecNssBlockCipherSize, /* xmlSecSize objSize */
7730 - xmlSecNameDes3Cbc, /* const xmlChar* name; */
7731 - xmlSecHrefDes3Cbc, /* const xmlChar* href; */
7732 - xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
7734 - xmlSecNssBlockCipherInitialize, /* xmlSecTransformInitializeMethod initialize; */
7735 - xmlSecNssBlockCipherFinalize, /* xmlSecTransformFinalizeMethod finalize; */
7736 - NULL, /* xmlSecTransformNodeReadMethod readNode; */
7737 - NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
7738 - xmlSecNssBlockCipherSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
7739 - xmlSecNssBlockCipherSetKey, /* xmlSecTransformSetKeyMethod setKey; */
7740 - NULL, /* xmlSecTransformValidateMethod validate; */
7741 - xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
7742 - xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
7743 - xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
7744 - NULL, /* xmlSecTransformPushXmlMethod pushXml; */
7745 - NULL, /* xmlSecTransformPopXmlMethod popXml; */
7746 - xmlSecNssBlockCipherExecute, /* xmlSecTransformExecuteMethod execute; */
7748 - NULL, /* void* reserved0; */
7749 - NULL, /* void* reserved1; */
7753 - * xmlSecNssTransformDes3CbcGetKlass:
7755 + * xmlSecNssTransformDes3CbcGetKlass
7757 - * Triple DES CBC encryption transform klass.
7759 - * Returns pointer to Triple DES encryption transform.
7760 + * Get the DES3_CBC transform klass
7762 + * Return DES3_CBC transform klass
7765 -xmlSecNssTransformDes3CbcGetKlass(void) {
7766 - return(&xmlSecNssDes3CbcKlass);
7768 +xmlSecNssTransformDes3CbcGetKlass( void ) {
7769 + return ( &xmlSecNssDes3CbcKlass ) ;
7771 -#endif /* XMLSEC_NO_DES */
7774 --- misc/xmlsec1-1.2.6/src/nss/crypto.c 2003-10-29 16:57:25.000000000 +0100
7775 +++ misc/build/xmlsec1-1.2.6/src/nss/crypto.c 2008-06-29 23:44:19.000000000 +0200
7778 * High level routines form xmlsec command line utility
7781 gXmlSecNssFunctions->cryptoAppInit = xmlSecNssAppInit;
7782 gXmlSecNssFunctions->cryptoAppShutdown = xmlSecNssAppShutdown;
7783 gXmlSecNssFunctions->cryptoAppDefaultKeysMngrInit = xmlSecNssAppDefaultKeysMngrInit;
7784 @@ -143,10 +144,29 @@
7785 gXmlSecNssFunctions->cryptoAppPkcs12LoadMemory = xmlSecNssAppPkcs12LoadMemory;
7786 gXmlSecNssFunctions->cryptoAppKeyCertLoad = xmlSecNssAppKeyCertLoad;
7787 gXmlSecNssFunctions->cryptoAppKeyCertLoadMemory = xmlSecNssAppKeyCertLoadMemory;
7788 -#endif /* XMLSEC_NO_X509 */
7790 gXmlSecNssFunctions->cryptoAppKeyLoad = xmlSecNssAppKeyLoad;
7791 gXmlSecNssFunctions->cryptoAppKeyLoadMemory = xmlSecNssAppKeyLoadMemory;
7792 gXmlSecNssFunctions->cryptoAppDefaultPwdCallback = (void*)xmlSecNssAppGetDefaultPwdCallback;
7795 + gXmlSecNssFunctions->cryptoAppInit = NULL ;
7796 + gXmlSecNssFunctions->cryptoAppShutdown = NULL ;
7797 + gXmlSecNssFunctions->cryptoAppDefaultKeysMngrInit = NULL ;
7798 + gXmlSecNssFunctions->cryptoAppDefaultKeysMngrAdoptKey = NULL ;
7799 + gXmlSecNssFunctions->cryptoAppDefaultKeysMngrLoad = NULL ;
7800 + gXmlSecNssFunctions->cryptoAppDefaultKeysMngrSave = NULL ;
7801 +#ifndef XMLSEC_NO_X509
7802 + gXmlSecNssFunctions->cryptoAppKeysMngrCertLoad = NULL ;
7803 + gXmlSecNssFunctions->cryptoAppKeysMngrCertLoadMemory= NULL ;
7804 + gXmlSecNssFunctions->cryptoAppPkcs12Load = NULL ;
7805 + gXmlSecNssFunctions->cryptoAppPkcs12LoadMemory = NULL ;
7806 + gXmlSecNssFunctions->cryptoAppKeyCertLoad = NULL ;
7807 + gXmlSecNssFunctions->cryptoAppKeyCertLoadMemory = NULL ;
7808 +#endif /* XMLSEC_NO_X509 */
7809 + gXmlSecNssFunctions->cryptoAppKeyLoad = NULL ;
7810 + gXmlSecNssFunctions->cryptoAppKeyLoadMemory = NULL ;
7811 + gXmlSecNssFunctions->cryptoAppDefaultPwdCallback = (void*)NULL ;
7813 return(gXmlSecNssFunctions);
7815 --- misc/xmlsec1-1.2.6/src/nss/digests.c 2003-09-26 02:58:15.000000000 +0200
7816 +++ misc/build/xmlsec1-1.2.6/src/nss/digests.c 2008-06-29 23:44:19.000000000 +0200
7818 #include <xmlsec/transforms.h>
7819 #include <xmlsec/errors.h>
7821 -#include <xmlsec/nss/app.h>
7822 #include <xmlsec/nss/crypto.h>
7824 #define XMLSEC_NSS_MAX_DIGEST_SIZE 32
7826 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7827 "SECOID_FindOIDByTag",
7828 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7829 - XMLSEC_ERRORS_NO_MESSAGE);
7830 + "error code=%d", PORT_GetError());
7835 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7836 "PK11_CreateDigestContext",
7837 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7838 - XMLSEC_ERRORS_NO_MESSAGE);
7839 + "error code=%d", PORT_GetError());
7844 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7846 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7847 - XMLSEC_ERRORS_NO_MESSAGE);
7848 + "error code=%d", PORT_GetError());
7851 transform->status = xmlSecTransformStatusWorking;
7853 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7855 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7856 - XMLSEC_ERRORS_NO_MESSAGE);
7857 + "error code=%d", PORT_GetError());
7862 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7864 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7865 - XMLSEC_ERRORS_NO_MESSAGE);
7866 + "error code=%d", PORT_GetError());
7869 xmlSecAssert2(ctx->dgstSize > 0, -1);
7870 @@ -285,7 +284,11 @@
7871 * SHA1 Digest transforms
7873 *****************************************************************************/
7874 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7875 +static struct _xmlSecTransformKlass xmlSecNssSha1Klass = {
7877 static xmlSecTransformKlass xmlSecNssSha1Klass = {
7879 /* klass/object sizes */
7880 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7881 xmlSecNssDigestSize, /* xmlSecSize objSize */
7882 --- misc/xmlsec1-1.2.6/src/nss/hmac.c 2003-09-26 02:58:15.000000000 +0200
7883 +++ misc/build/xmlsec1-1.2.6/src/nss/hmac.c 2008-06-29 23:44:19.000000000 +0200
7885 #include <xmlsec/transforms.h>
7886 #include <xmlsec/errors.h>
7888 -#include <xmlsec/nss/app.h>
7889 #include <xmlsec/nss/crypto.h>
7890 +#include <xmlsec/nss/tokens.h>
7892 #define XMLSEC_NSS_MAX_HMAC_SIZE 128
7894 @@ -241,13 +241,13 @@
7895 keyItem.data = xmlSecBufferGetData(buffer);
7896 keyItem.len = xmlSecBufferGetSize(buffer);
7898 - slot = PK11_GetBestSlot(ctx->digestType, NULL);
7899 + slot = xmlSecNssSlotGet(ctx->digestType);
7901 xmlSecError(XMLSEC_ERRORS_HERE,
7902 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7903 - "PK11_GetBestSlot",
7904 + "xmlSecNssSlotGet",
7905 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7906 - XMLSEC_ERRORS_NO_MESSAGE);
7907 + "error code=%d", PORT_GetError());
7912 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7913 "PK11_ImportSymKey",
7914 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7915 - XMLSEC_ERRORS_NO_MESSAGE);
7916 + "error code=%d", PORT_GetError());
7917 PK11_FreeSlot(slot);
7921 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7922 "PK11_CreateContextBySymKey",
7923 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7924 - XMLSEC_ERRORS_NO_MESSAGE);
7925 + "error code=%d", PORT_GetError());
7926 PK11_FreeSymKey(symKey);
7927 PK11_FreeSlot(slot);
7930 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7932 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7933 - XMLSEC_ERRORS_NO_MESSAGE);
7934 + "error code=%d", PORT_GetError());
7937 transform->status = xmlSecTransformStatusWorking;
7939 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7941 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7942 - XMLSEC_ERRORS_NO_MESSAGE);
7943 + "error code=%d", PORT_GetError());
7948 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
7950 XMLSEC_ERRORS_R_CRYPTO_FAILED,
7951 - XMLSEC_ERRORS_NO_MESSAGE);
7952 + "error code=%d", PORT_GetError());
7955 xmlSecAssert2(dgstSize > 0, -1);
7956 @@ -459,7 +459,11 @@
7960 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7961 +static struct _xmlSecTransformKlass xmlSecNssHmacSha1Klass = {
7963 static xmlSecTransformKlass xmlSecNssHmacSha1Klass = {
7965 /* klass/object sizes */
7966 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7967 xmlSecNssHmacSize, /* xmlSecSize objSize */
7968 @@ -501,7 +505,11 @@
7972 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7973 +static struct _xmlSecTransformKlass xmlSecNssHmacRipemd160Klass = {
7975 static xmlSecTransformKlass xmlSecNssHmacRipemd160Klass = {
7977 /* klass/object sizes */
7978 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7979 xmlSecNssHmacSize, /* xmlSecSize objSize */
7980 @@ -543,7 +551,11 @@
7984 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
7985 +static struct _xmlSecTransformKlass xmlSecNssHmacMd5Klass = {
7987 static xmlSecTransformKlass xmlSecNssHmacMd5Klass = {
7989 /* klass/object sizes */
7990 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
7991 xmlSecNssHmacSize, /* xmlSecSize objSize */
7992 --- misc/xmlsec1-1.2.6/src/nss/keysstore.c 2003-09-26 02:58:15.000000000 +0200
7993 +++ misc/build/xmlsec1-1.2.6/src/nss/keysstore.c 2008-06-29 23:44:19.000000000 +0200
7998 - * Nss keys store that uses Simple Keys Store under the hood. Uses the
7999 - * Nss DB as a backing store for the finding keys, but the NSS DB is
8000 - * not written to by the keys store.
8001 - * So, if store->findkey is done and the key is not found in the simple
8002 - * keys store, the NSS DB is looked up.
8003 - * If store is called to adopt a key, that key is not written to the NSS
8005 - * Thus, the NSS DB can be used to pre-load keys and becomes an alternate
8006 - * source of keys for xmlsec
8008 * This is free software; see Copyright file in the source
8009 * distribution for precise wording.
8011 - * Copyright (c) 2003 America Online, Inc. All rights reserved.
8012 + * Copyright................................
8014 -#include "globals.h"
8016 -#include <stdlib.h>
8018 + * NSS key store uses a key list and a slot list as the key repository. NSS slot
8019 + * list is a backup repository for the finding keys. If a key is not found from
8020 + * the key list, the NSS slot list is looked up.
8022 + * Any key in the key list will not save to pkcs11 slot. When a store to called
8023 + * to adopt a key, the key is resident in the key list; While a store to called
8024 + * to set a is resident in the key list; While a store to called to set a slot
8025 + * list, which means that the keys in the listed slot can be used for xml sign-
8026 + * nature or encryption.
8028 + * Then, a user can adjust slot list to effect the crypto behaviors of xmlSec.
8030 + * The framework will decrease the user interfaces to administrate xmlSec crypto
8031 + * engine. He can only focus on NSS layer functions. For examples, after the
8032 + * user set up a slot list handler to the keys store, he do not need to do any
8033 + * other work atop xmlSec interfaces, his action on the slot list handler, such
8034 + * as add a token to, delete a token from the list, will directly effect the key
8035 + * store behaviors.
8037 + * For example, a scenariio:
8038 + * 0. Create a slot list;( NSS interfaces )
8039 + * 1. Create a keys store;( xmlSec interfaces )
8040 + * 2. Set slot list with the keys store;( xmlSec Interfaces )
8041 + * 3. Add a slot to the slot list;( NSS interfaces )
8042 + * 4. Perform xml signature; ( xmlSec Interfaces )
8043 + * 5. Deleter a slot from the slot list;( NSS interfaces )
8044 + * 6. Perform xml encryption; ( xmlSec Interfaces )
8045 + * 7. Perform xml signature;( xmlSec Interfaces )
8046 + * 8. Destroy the keys store;( xmlSec Interfaces )
8047 + * 8. Destroy the slot list.( NSS Interfaces )
8050 +#include "globals.h"
8055 -#include <pk11func.h>
8058 +#include <pk11func.h>
8059 +#include <prinit.h>
8062 -#include <libxml/tree.h>
8064 #include <xmlsec/xmlsec.h>
8065 -#include <xmlsec/buffer.h>
8066 -#include <xmlsec/base64.h>
8067 -#include <xmlsec/errors.h>
8068 -#include <xmlsec/xmltree.h>
8070 +#include <xmlsec/keys.h>
8071 #include <xmlsec/keysmngr.h>
8072 +#include <xmlsec/transforms.h>
8073 +#include <xmlsec/xmltree.h>
8074 +#include <xmlsec/errors.h>
8076 #include <xmlsec/nss/crypto.h>
8077 #include <xmlsec/nss/keysstore.h>
8078 -#include <xmlsec/nss/x509.h>
8079 +#include <xmlsec/nss/tokens.h>
8080 +#include <xmlsec/nss/ciphers.h>
8081 #include <xmlsec/nss/pkikeys.h>
8083 -/****************************************************************************
8085 + * Internal NSS key store context
8087 - * Nss Keys Store. Uses Simple Keys Store under the hood
8089 - * Simple Keys Store ptr is located after xmlSecKeyStore
8090 + * This context is located after xmlSecKeyStore
8092 +typedef struct _xmlSecNssKeysStoreCtx xmlSecNssKeysStoreCtx ;
8093 +typedef struct _xmlSecNssKeysStoreCtx* xmlSecNssKeysStoreCtxPtr ;
8095 +struct _xmlSecNssKeysStoreCtx {
8096 + xmlSecPtrListPtr keyList ;
8097 + xmlSecPtrListPtr slotList ;
8100 +#define xmlSecNssKeysStoreSize \
8101 + ( sizeof( xmlSecKeyStore ) + sizeof( xmlSecNssKeysStoreCtx ) )
8103 +#define xmlSecNssKeysStoreGetCtx( data ) \
8104 + ( ( xmlSecNssKeysStoreCtxPtr )( ( ( xmlSecByte* )( data ) ) + sizeof( xmlSecKeyStore ) ) )
8106 +int xmlSecNssKeysStoreAdoptKeySlot(
8107 + xmlSecKeyStorePtr store ,
8108 + xmlSecNssKeySlotPtr keySlot
8110 + xmlSecNssKeysStoreCtxPtr context = NULL ;
8112 + xmlSecAssert2( xmlSecKeyStoreCheckId( store , xmlSecNssKeysStoreId ) , -1 ) ;
8113 + xmlSecAssert2( xmlSecKeyStoreCheckSize( store , xmlSecNssKeysStoreSize ) , -1 ) ;
8115 + context = xmlSecNssKeysStoreGetCtx( store ) ;
8116 + if( context == NULL ) {
8117 + xmlSecError( XMLSEC_ERRORS_HERE ,
8118 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8119 + "xmlSecNssKeysStoreGetCtx" ,
8120 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8121 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8125 + if( context->slotList == NULL ) {
8126 + if( ( context->slotList = xmlSecPtrListCreate( xmlSecNssKeySlotListId ) ) == NULL ) {
8127 + xmlSecError( XMLSEC_ERRORS_HERE ,
8128 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8129 + "xmlSecPtrListCreate" ,
8130 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8131 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8136 + if( !xmlSecPtrListCheckId( context->slotList , xmlSecNssKeySlotListId ) ) {
8137 + xmlSecError( XMLSEC_ERRORS_HERE ,
8138 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8139 + "xmlSecPtrListCheckId" ,
8140 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8141 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8145 + if( xmlSecPtrListAdd( context->slotList , keySlot ) < 0 ) {
8146 + xmlSecError( XMLSEC_ERRORS_HERE ,
8147 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8148 + "xmlSecPtrListAdd" ,
8149 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8150 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8157 +int xmlSecNssKeysStoreAdoptKey(
8158 + xmlSecKeyStorePtr store ,
8161 + xmlSecNssKeysStoreCtxPtr context = NULL ;
8163 + xmlSecAssert2( xmlSecKeyStoreCheckId( store , xmlSecNssKeysStoreId ) , -1 ) ;
8164 + xmlSecAssert2( xmlSecKeyStoreCheckSize( store , xmlSecNssKeysStoreSize ) , -1 ) ;
8166 + context = xmlSecNssKeysStoreGetCtx( store ) ;
8167 + if( context == NULL ) {
8168 + xmlSecError( XMLSEC_ERRORS_HERE ,
8169 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8170 + "xmlSecNssKeysStoreGetCtx" ,
8171 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8172 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8176 + if( context->keyList == NULL ) {
8177 + if( ( context->keyList = xmlSecPtrListCreate( xmlSecKeyPtrListId ) ) == NULL ) {
8178 + xmlSecError( XMLSEC_ERRORS_HERE ,
8179 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8180 + "xmlSecPtrListCreate" ,
8181 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8182 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8187 + if( !xmlSecPtrListCheckId( context->keyList , xmlSecKeyPtrListId ) ) {
8188 + xmlSecError( XMLSEC_ERRORS_HERE ,
8189 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8190 + "xmlSecPtrListCheckId" ,
8191 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8192 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8196 + if( xmlSecPtrListAdd( context->keyList , key ) < 0 ) {
8197 + xmlSecError( XMLSEC_ERRORS_HERE ,
8198 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8199 + "xmlSecPtrListAdd" ,
8200 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8201 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8209 + * xmlSecKeyStoreInitializeMethod:
8210 + * @store: the store.
8212 - ***************************************************************************/
8213 -#define xmlSecNssKeysStoreSize \
8214 - (sizeof(xmlSecKeyStore) + sizeof(xmlSecKeyStorePtr))
8216 -#define xmlSecNssKeysStoreGetSS(store) \
8217 - ((xmlSecKeyStoreCheckSize((store), xmlSecNssKeysStoreSize)) ? \
8218 - (xmlSecKeyStorePtr*)(((xmlSecByte*)(store)) + sizeof(xmlSecKeyStore)) : \
8219 - (xmlSecKeyStorePtr*)NULL)
8221 -static int xmlSecNssKeysStoreInitialize (xmlSecKeyStorePtr store);
8222 -static void xmlSecNssKeysStoreFinalize (xmlSecKeyStorePtr store);
8223 -static xmlSecKeyPtr xmlSecNssKeysStoreFindKey (xmlSecKeyStorePtr store,
8224 - const xmlChar* name,
8225 - xmlSecKeyInfoCtxPtr keyInfoCtx);
8226 + * Keys store specific initialization method.
8228 + * Returns 0 on success or a negative value if an error occurs.
8231 +xmlSecNssKeysStoreInitialize(
8232 + xmlSecKeyStorePtr store
8234 + xmlSecNssKeysStoreCtxPtr context = NULL ;
8236 + xmlSecAssert2( xmlSecKeyStoreCheckId( store , xmlSecNssKeysStoreId ) , -1 ) ;
8237 + xmlSecAssert2( xmlSecKeyStoreCheckSize( store , xmlSecNssKeysStoreSize ) , -1 ) ;
8239 + context = xmlSecNssKeysStoreGetCtx( store ) ;
8240 + if( context == NULL ) {
8241 + xmlSecError( XMLSEC_ERRORS_HERE ,
8242 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8243 + "xmlSecNssKeysStoreGetCtx" ,
8244 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8245 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8249 -static xmlSecKeyStoreKlass xmlSecNssKeysStoreKlass = {
8250 - sizeof(xmlSecKeyStoreKlass),
8251 - xmlSecNssKeysStoreSize,
8252 + context->keyList = NULL ;
8253 + context->slotList = NULL ;
8256 - BAD_CAST "NSS-keys-store", /* const xmlChar* name; */
8258 - /* constructors/destructor */
8259 - xmlSecNssKeysStoreInitialize, /* xmlSecKeyStoreInitializeMethod initialize; */
8260 - xmlSecNssKeysStoreFinalize, /* xmlSecKeyStoreFinalizeMethod finalize; */
8261 - xmlSecNssKeysStoreFindKey, /* xmlSecKeyStoreFindKeyMethod findKey; */
8263 - /* reserved for the future */
8264 - NULL, /* void* reserved0; */
8265 - NULL, /* void* reserved1; */
8271 - * xmlSecNssKeysStoreGetKlass:
8273 - * The Nss list based keys store klass.
8275 + * xmlSecKeyStoreFinalizeMethod:
8276 + * @store: the store.
8278 - * Returns Nss list based keys store klass.
8279 + * Keys store specific finalization (destroy) method.
8282 -xmlSecNssKeysStoreGetKlass(void) {
8283 - return(&xmlSecNssKeysStoreKlass);
8285 +xmlSecNssKeysStoreFinalize(
8286 + xmlSecKeyStorePtr store
8288 + xmlSecNssKeysStoreCtxPtr context = NULL ;
8290 + xmlSecAssert( xmlSecKeyStoreCheckId( store , xmlSecNssKeysStoreId ) ) ;
8291 + xmlSecAssert( xmlSecKeyStoreCheckSize( store , xmlSecNssKeysStoreSize ) ) ;
8293 + context = xmlSecNssKeysStoreGetCtx( store ) ;
8294 + if( context == NULL ) {
8295 + xmlSecError( XMLSEC_ERRORS_HERE ,
8296 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8297 + "xmlSecNssKeysStoreGetCtx" ,
8298 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8299 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8303 + if( context->keyList != NULL ) {
8304 + xmlSecPtrListDestroy( context->keyList ) ;
8305 + context->keyList = NULL ;
8308 + if( context->slotList != NULL ) {
8309 + xmlSecPtrListDestroy( context->slotList ) ;
8310 + context->slotList = NULL ;
8315 - * xmlSecNssKeysStoreAdoptKey:
8316 - * @store: the pointer to Nss keys store.
8317 - * @key: the pointer to key.
8319 - * Adds @key to the @store.
8321 +xmlSecNssKeysStoreFindKeyFromSlot(
8322 + PK11SlotInfo* slot,
8323 + const xmlChar* name,
8324 + xmlSecKeyInfoCtxPtr keyInfoCtx
8326 + xmlSecKeyPtr key = NULL ;
8327 + xmlSecKeyDataPtr data = NULL ;
8330 + xmlSecAssert2( slot != NULL , NULL ) ;
8331 + xmlSecAssert2( name != NULL , NULL ) ;
8332 + xmlSecAssert2( keyInfoCtx != NULL , NULL ) ;
8334 + if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypeSymmetric ) == xmlSecKeyDataTypeSymmetric ) {
8335 + PK11SymKey* symKey ;
8336 + PK11SymKey* curKey ;
8338 + /* Find symmetric key from the slot by name */
8339 + symKey = PK11_ListFixedKeysInSlot( slot , ( char* )name , NULL ) ;
8340 + for( curKey = symKey ; curKey != NULL ; curKey = PK11_GetNextSymKey( curKey ) ) {
8341 + /* Check the key request */
8342 + length = PK11_GetKeyLength( curKey ) ;
8344 + if( ( keyInfoCtx->keyReq.keyBitsSize > 0 ) &&
8346 + ( length < keyInfoCtx->keyReq.keyBitsSize ) )
8349 + /* We find a eligible key */
8350 + data = xmlSecNssSymKeyDataKeyAdopt( curKey ) ;
8351 + if( data == NULL ) {
8357 + /* Destroy the sym key list */
8358 + for( curKey = symKey ; curKey != NULL ; ) {
8360 + curKey = PK11_GetNextSymKey( symKey ) ;
8361 + PK11_FreeSymKey( symKey ) ;
8363 + } else if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePublic ) == xmlSecKeyDataTypePublic ) {
8364 + SECKEYPublicKeyList* pubKeyList ;
8365 + SECKEYPublicKey* pubKey ;
8366 + SECKEYPublicKeyListNode* curPub ;
8368 + /* Find asymmetric key from the slot by name */
8369 + pubKeyList = PK11_ListPublicKeysInSlot( slot , ( char* )name ) ;
8371 + curPub = PUBKEY_LIST_HEAD(pubKeyList);
8372 + for( ; !PUBKEY_LIST_END(curPub, pubKeyList) ; curPub = PUBKEY_LIST_NEXT( curPub ) ) {
8373 + /* Check the key request */
8374 + length = SECKEY_PublicKeyStrength( curPub->key ) ;
8376 + if( ( keyInfoCtx->keyReq.keyBitsSize > 0 ) &&
8378 + ( length < keyInfoCtx->keyReq.keyBitsSize ) )
8381 + /* We find a eligible key */
8382 + pubKey = curPub->key ;
8386 + if( pubKey != NULL ) {
8387 + data = xmlSecNssPKIAdoptKey( NULL, pubKey ) ;
8388 + if( data == NULL ) {
8393 + /* Destroy the public key list */
8394 + SECKEY_DestroyPublicKeyList( pubKeyList ) ;
8395 + } else if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePrivate ) == xmlSecKeyDataTypePrivate ) {
8396 + SECKEYPrivateKeyList* priKeyList = NULL ;
8397 + SECKEYPrivateKey* priKey = NULL ;
8398 + SECKEYPrivateKeyListNode* curPri ;
8400 + /* Find asymmetric key from the slot by name */
8401 + priKeyList = PK11_ListPrivKeysInSlot( slot , ( char* )name , NULL ) ;
8403 + curPri = PRIVKEY_LIST_HEAD(priKeyList);
8404 + for( ; !PRIVKEY_LIST_END(curPri, priKeyList) ; curPri = PRIVKEY_LIST_NEXT( curPri ) ) {
8405 + /* Check the key request */
8406 + length = PK11_SignatureLen( curPri->key ) ;
8408 + if( ( keyInfoCtx->keyReq.keyBitsSize > 0 ) &&
8410 + ( length < keyInfoCtx->keyReq.keyBitsSize ) )
8413 + /* We find a eligible key */
8414 + priKey = curPri->key ;
8418 + if( priKey != NULL ) {
8419 + data = xmlSecNssPKIAdoptKey( priKey, NULL ) ;
8420 + if( data == NULL ) {
8425 + /* Destroy the private key list */
8426 + SECKEY_DestroyPrivateKeyList( priKeyList ) ;
8429 + /* If we have gotten the key value */
8430 + if( data != NULL ) {
8431 + if( ( key = xmlSecKeyCreate() ) == NULL ) {
8432 + xmlSecError( XMLSEC_ERRORS_HERE ,
8434 + "xmlSecKeyCreate" ,
8435 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8436 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8438 + xmlSecKeyDataDestroy( data ) ;
8442 + if( xmlSecKeySetValue( key , data ) < 0 ) {
8443 + xmlSecError( XMLSEC_ERRORS_HERE ,
8445 + "xmlSecKeySetValue" ,
8446 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8447 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8449 + xmlSecKeyDestroy( key ) ;
8450 + xmlSecKeyDataDestroy( data ) ;
8459 + * xmlSecKeyStoreFindKeyMethod:
8460 + * @store: the store.
8461 + * @name: the desired key name.
8462 + * @keyInfoCtx: the pointer to key info context.
8464 - * Returns 0 on success or a negative value if an error occurs.
8465 + * Keys store specific find method. The caller is responsible for destroying
8466 + * the returned key using #xmlSecKeyDestroy method.
8468 + * Returns the pointer to a key or NULL if key is not found or an error occurs.
8471 -xmlSecNssKeysStoreAdoptKey(xmlSecKeyStorePtr store, xmlSecKeyPtr key) {
8472 - xmlSecKeyStorePtr *ss;
8474 - xmlSecAssert2(xmlSecKeyStoreCheckId(store, xmlSecNssKeysStoreId), -1);
8475 - xmlSecAssert2((key != NULL), -1);
8476 +static xmlSecKeyPtr
8477 +xmlSecNssKeysStoreFindKey(
8478 + xmlSecKeyStorePtr store ,
8479 + const xmlChar* name ,
8480 + xmlSecKeyInfoCtxPtr keyInfoCtx
8482 + xmlSecNssKeysStoreCtxPtr context = NULL ;
8483 + xmlSecKeyPtr key = NULL ;
8484 + xmlSecNssKeySlotPtr keySlot = NULL ;
8488 + xmlSecAssert2( xmlSecKeyStoreCheckId( store , xmlSecNssKeysStoreId ) , NULL ) ;
8489 + xmlSecAssert2( xmlSecKeyStoreCheckSize( store , xmlSecNssKeysStoreSize ) , NULL ) ;
8490 + xmlSecAssert2( keyInfoCtx != NULL , NULL ) ;
8492 + context = xmlSecNssKeysStoreGetCtx( store ) ;
8493 + if( context == NULL ) {
8494 + xmlSecError( XMLSEC_ERRORS_HERE ,
8495 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8496 + "xmlSecNssKeysStoreGetCtx" ,
8497 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8498 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8503 + * Look for key at keyList at first.
8505 + if( context->keyList != NULL ) {
8506 + size = xmlSecPtrListGetSize( context->keyList ) ;
8507 + for( pos = 0 ; pos < size ; pos ++ ) {
8508 + key = ( xmlSecKeyPtr )xmlSecPtrListGetItem( context->keyList , pos ) ;
8509 + if( key != NULL && xmlSecKeyMatch( key , name , &( keyInfoCtx->keyReq ) ) ) {
8510 + return xmlSecKeyDuplicate( key ) ;
8516 + * Find the key from slotList
8518 + if( context->slotList != NULL ) {
8519 + PK11SlotInfo* slot = NULL ;
8521 + size = xmlSecPtrListGetSize( context->slotList ) ;
8522 + for( pos = 0 ; pos < size ; pos ++ ) {
8523 + keySlot = ( xmlSecNssKeySlotPtr )xmlSecPtrListGetItem( context->slotList , pos ) ;
8524 + slot = xmlSecNssKeySlotGetSlot( keySlot ) ;
8525 + if( slot == NULL ) {
8528 + key = xmlSecNssKeysStoreFindKeyFromSlot( slot, name, keyInfoCtx ) ;
8529 + if( key == NULL ) {
8539 + * Create a session key if we can not find the key from keyList and slotList
8541 + if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypeSession ) == xmlSecKeyDataTypeSession ) {
8542 + key = xmlSecKeyGenerate( keyInfoCtx->keyReq.keyId , keyInfoCtx->keyReq.keyBitsSize , xmlSecKeyDataTypeSession ) ;
8543 + if( key == NULL ) {
8544 + xmlSecError( XMLSEC_ERRORS_HERE ,
8545 + xmlSecErrorsSafeString( xmlSecKeyStoreGetName( store ) ) ,
8546 + "xmlSecKeySetValue" ,
8547 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
8548 + XMLSEC_ERRORS_NO_MESSAGE ) ;
8556 + * We have no way to find the key any more.
8561 - ss = xmlSecNssKeysStoreGetSS(store);
8562 - xmlSecAssert2(((ss != NULL) && (*ss != NULL) &&
8563 - (xmlSecKeyStoreCheckId(*ss, xmlSecSimpleKeysStoreId))), -1);
8564 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
8565 +static struct _xmlSecKeyStoreKlass xmlSecNssKeysStoreKlass = {
8567 +static xmlSecKeyStoreKlass xmlSecNssKeysStoreKlass = {
8569 + sizeof( xmlSecKeyStoreKlass ) ,
8570 + xmlSecNssKeysStoreSize ,
8571 + BAD_CAST "implicit_nss_keys_store" ,
8572 + xmlSecNssKeysStoreInitialize ,
8573 + xmlSecNssKeysStoreFinalize ,
8574 + xmlSecNssKeysStoreFindKey ,
8579 - return (xmlSecSimpleKeysStoreAdoptKey(*ss, key));
8581 + * xmlSecNssKeysStoreGetKlass:
8583 + * The simple list based keys store klass.
8585 + * Returns simple list based keys store klass.
8588 +xmlSecNssKeysStoreGetKlass( void ) {
8589 + return &xmlSecNssKeysStoreKlass ;
8593 +/**************************
8594 + * Application routines
8597 * xmlSecNssKeysStoreLoad:
8598 * @store: the pointer to Nss keys store.
8599 @@ -125,8 +528,11 @@
8600 * Returns 0 on success or a negative value if an error occurs.
8603 -xmlSecNssKeysStoreLoad(xmlSecKeyStorePtr store, const char *uri,
8604 - xmlSecKeysMngrPtr keysMngr) {
8605 +xmlSecNssKeysStoreLoad(
8606 + xmlSecKeyStorePtr store,
8608 + xmlSecKeysMngrPtr keysMngr
8613 @@ -252,254 +658,147 @@
8616 xmlSecNssKeysStoreSave(xmlSecKeyStorePtr store, const char *filename, xmlSecKeyDataType type) {
8617 - xmlSecKeyStorePtr *ss;
8619 - xmlSecAssert2(xmlSecKeyStoreCheckId(store, xmlSecNssKeysStoreId), -1);
8620 - xmlSecAssert2((filename != NULL), -1);
8622 - ss = xmlSecNssKeysStoreGetSS(store);
8623 - xmlSecAssert2(((ss != NULL) && (*ss != NULL) &&
8624 - (xmlSecKeyStoreCheckId(*ss, xmlSecSimpleKeysStoreId))), -1);
8626 - return (xmlSecSimpleKeysStoreSave(*ss, filename, type));
8630 -xmlSecNssKeysStoreInitialize(xmlSecKeyStorePtr store) {
8631 - xmlSecKeyStorePtr *ss;
8633 - xmlSecAssert2(xmlSecKeyStoreCheckId(store, xmlSecNssKeysStoreId), -1);
8634 + xmlSecKeyInfoCtx keyInfoCtx;
8635 + xmlSecNssKeysStoreCtxPtr context ;
8636 + xmlSecPtrListPtr list;
8638 + xmlSecSize i, keysSize;
8641 + xmlSecKeyDataPtr data;
8642 + xmlSecPtrListPtr idsList;
8643 + xmlSecKeyDataId dataId;
8644 + xmlSecSize idsSize, j;
8647 - ss = xmlSecNssKeysStoreGetSS(store);
8648 - xmlSecAssert2((*ss == NULL), -1);
8649 + xmlSecAssert2( xmlSecKeyStoreCheckId( store , xmlSecNssKeysStoreId ), -1 ) ;
8650 + xmlSecAssert2( xmlSecKeyStoreCheckSize( store , xmlSecNssKeysStoreSize ), -1 ) ;
8651 + xmlSecAssert2(filename != NULL, -1);
8653 + context = xmlSecNssKeysStoreGetCtx( store ) ;
8654 + xmlSecAssert2( context != NULL, -1 );
8656 + list = context->keyList ;
8657 + xmlSecAssert2( list != NULL, -1 );
8658 + xmlSecAssert2(xmlSecPtrListCheckId(list, xmlSecKeyPtrListId), -1);
8660 - *ss = xmlSecKeyStoreCreate(xmlSecSimpleKeysStoreId);
8662 - xmlSecError(XMLSEC_ERRORS_HERE,
8664 + doc = xmlSecCreateTree(BAD_CAST "Keys", xmlSecNs);
8666 + xmlSecError(XMLSEC_ERRORS_HERE,
8667 xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8668 - "xmlSecKeyStoreCreate",
8669 + "xmlSecCreateTree",
8670 XMLSEC_ERRORS_R_XMLSEC_FAILED,
8671 - "xmlSecSimpleKeysStoreId");
8673 + XMLSEC_ERRORS_NO_MESSAGE);
8681 -xmlSecNssKeysStoreFinalize(xmlSecKeyStorePtr store) {
8682 - xmlSecKeyStorePtr *ss;
8684 - xmlSecAssert(xmlSecKeyStoreCheckId(store, xmlSecNssKeysStoreId));
8686 - ss = xmlSecNssKeysStoreGetSS(store);
8687 - xmlSecAssert((ss != NULL) && (*ss != NULL));
8689 - xmlSecKeyStoreDestroy(*ss);
8692 -static xmlSecKeyPtr
8693 -xmlSecNssKeysStoreFindKey(xmlSecKeyStorePtr store, const xmlChar* name,
8694 - xmlSecKeyInfoCtxPtr keyInfoCtx) {
8695 - xmlSecKeyStorePtr* ss;
8696 - xmlSecKeyPtr key = NULL;
8697 - xmlSecKeyPtr retval = NULL;
8698 - xmlSecKeyReqPtr keyReq = NULL;
8699 - CERTCertificate *cert = NULL;
8700 - SECKEYPublicKey *pubkey = NULL;
8701 - SECKEYPrivateKey *privkey = NULL;
8702 - xmlSecKeyDataPtr data = NULL;
8703 - xmlSecKeyDataPtr x509Data = NULL;
8706 - xmlSecAssert2(xmlSecKeyStoreCheckId(store, xmlSecNssKeysStoreId), NULL);
8707 - xmlSecAssert2(keyInfoCtx != NULL, NULL);
8709 - ss = xmlSecNssKeysStoreGetSS(store);
8710 - xmlSecAssert2(((ss != NULL) && (*ss != NULL)), NULL);
8712 - key = xmlSecKeyStoreFindKey(*ss, name, keyInfoCtx);
8713 - if (key != NULL) {
8716 + idsList = xmlSecKeyDataIdsGet();
8717 + xmlSecAssert2(idsList != NULL, -1);
8719 + keysSize = xmlSecPtrListGetSize(list);
8720 + idsSize = xmlSecPtrListGetSize(idsList);
8721 + for(i = 0; i < keysSize; ++i) {
8722 + key = (xmlSecKeyPtr)xmlSecPtrListGetItem(list, i);
8723 + xmlSecAssert2(key != NULL, -1);
8725 + cur = xmlSecAddChild(xmlDocGetRootElement(doc), xmlSecNodeKeyInfo, xmlSecDSigNs);
8727 + xmlSecError(XMLSEC_ERRORS_HERE,
8728 + xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8730 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
8732 + xmlSecErrorsSafeString(xmlSecNodeKeyInfo));
8737 - /* Try to find the key in the NSS DB, and construct an xmlSecKey.
8738 - * we must have a name to lookup keys in NSS DB.
8740 - if (name == NULL) {
8743 + /* special data key name */
8744 + if(xmlSecKeyGetName(key) != NULL) {
8745 + if(xmlSecAddChild(cur, xmlSecNodeKeyName, xmlSecDSigNs) == NULL) {
8746 + xmlSecError(XMLSEC_ERRORS_HERE,
8747 + xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8749 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
8751 + xmlSecErrorsSafeString(xmlSecNodeKeyName));
8757 + /* create nodes for other keys data */
8758 + for(j = 0; j < idsSize; ++j) {
8759 + dataId = (xmlSecKeyDataId)xmlSecPtrListGetItem(idsList, j);
8760 + xmlSecAssert2(dataId != xmlSecKeyDataIdUnknown, -1);
8762 - /* what type of key are we looking for?
8763 - * TBD: For now, we'll look only for public/private keys using the
8764 - * name as a cert nickname. Later on, we can attempt to find
8765 - * symmetric keys using PK11_FindFixedKey
8767 - keyReq = &(keyInfoCtx->keyReq);
8768 - if (keyReq->keyType &
8769 - (xmlSecKeyDataTypePublic | xmlSecKeyDataTypePrivate)) {
8770 - cert = CERT_FindCertByNickname (CERT_GetDefaultCertDB(), (char *)name);
8771 - if (cert == NULL) {
8775 - if (keyReq->keyType & xmlSecKeyDataTypePublic) {
8776 - pubkey = CERT_ExtractPublicKey(cert);
8777 - if (pubkey == NULL) {
8778 - xmlSecError(XMLSEC_ERRORS_HERE,
8780 - "CERT_ExtractPublicKey",
8781 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
8782 - XMLSEC_ERRORS_NO_MESSAGE);
8784 + if(dataId->dataNodeName == NULL) {
8788 + data = xmlSecKeyGetData(key, dataId);
8789 + if(data == NULL) {
8794 - if (keyReq->keyType & xmlSecKeyDataTypePrivate) {
8795 - privkey = PK11_FindKeyByAnyCert(cert, NULL);
8796 - if (privkey == NULL) {
8797 - xmlSecError(XMLSEC_ERRORS_HERE,
8799 - "PK11_FindKeyByAnyCert",
8800 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
8801 - XMLSEC_ERRORS_NO_MESSAGE);
8803 + if(xmlSecAddChild(cur, dataId->dataNodeName, dataId->dataNodeNs) == NULL) {
8804 + xmlSecError(XMLSEC_ERRORS_HERE,
8805 + xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8807 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
8809 + xmlSecErrorsSafeString(dataId->dataNodeName));
8815 - data = xmlSecNssPKIAdoptKey(privkey, pubkey);
8816 - if(data == NULL) {
8817 - xmlSecError(XMLSEC_ERRORS_HERE,
8819 - "xmlSecNssPKIAdoptKey",
8820 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
8821 - XMLSEC_ERRORS_NO_MESSAGE);
8827 - key = xmlSecKeyCreate();
8828 - if (key == NULL) {
8829 + ret = xmlSecKeyInfoCtxInitialize(&keyInfoCtx, NULL);
8831 xmlSecError(XMLSEC_ERRORS_HERE,
8833 - "xmlSecKeyCreate",
8834 + xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8835 + "xmlSecKeyInfoCtxInitialize",
8836 XMLSEC_ERRORS_R_XMLSEC_FAILED,
8837 XMLSEC_ERRORS_NO_MESSAGE);
8841 - x509Data = xmlSecKeyDataCreate(xmlSecNssKeyDataX509Id);
8842 - if(x509Data == NULL) {
8843 - xmlSecError(XMLSEC_ERRORS_HERE,
8845 - "xmlSecKeyDataCreate",
8846 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
8848 - xmlSecErrorsSafeString(xmlSecTransformKlassGetName(xmlSecNssKeyDataX509Id)));
8852 - ret = xmlSecNssKeyDataX509AdoptKeyCert(x509Data, cert);
8854 - xmlSecError(XMLSEC_ERRORS_HERE,
8856 - "xmlSecNssKeyDataX509AdoptKeyCert",
8857 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
8859 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(x509Data)));
8862 - cert = CERT_DupCertificate(cert);
8863 - if (cert == NULL) {
8864 - xmlSecError(XMLSEC_ERRORS_HERE,
8866 - "CERT_DupCertificate",
8867 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
8869 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(x509Data)));
8873 - ret = xmlSecNssKeyDataX509AdoptCert(x509Data, cert);
8875 - xmlSecError(XMLSEC_ERRORS_HERE,
8877 - "xmlSecNssKeyDataX509AdoptCert",
8878 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
8880 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(x509Data)));
8887 - ret = xmlSecKeySetValue(key, data);
8889 - xmlSecError(XMLSEC_ERRORS_HERE,
8891 - "xmlSecKeySetValue",
8892 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
8894 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)));
8898 + keyInfoCtx.mode = xmlSecKeyInfoModeWrite;
8899 + keyInfoCtx.keyReq.keyId = xmlSecKeyDataIdUnknown;
8900 + keyInfoCtx.keyReq.keyType = type;
8901 + keyInfoCtx.keyReq.keyUsage = xmlSecKeyDataUsageAny;
8903 - ret = xmlSecKeyAdoptData(key, x509Data);
8905 + /* finally write key in the node */
8906 + ret = xmlSecKeyInfoNodeWrite(cur, key, &keyInfoCtx);
8908 xmlSecError(XMLSEC_ERRORS_HERE,
8910 - "xmlSecKeyAdoptData",
8911 + xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8912 + "xmlSecKeyInfoNodeWrite",
8913 XMLSEC_ERRORS_R_XMLSEC_FAILED,
8915 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(x509Data)));
8925 - if (cert != NULL) {
8926 - CERT_DestroyCertificate(cert);
8928 - if (pubkey != NULL) {
8929 - SECKEY_DestroyPublicKey(pubkey);
8931 - if (privkey != NULL) {
8932 - SECKEY_DestroyPrivateKey(privkey);
8934 - if (data != NULL) {
8935 - xmlSecKeyDataDestroy(data);
8937 - if (x509Data != NULL) {
8938 - xmlSecKeyDataDestroy(x509Data);
8940 - if (key != NULL) {
8941 - xmlSecKeyDestroy(key);
8942 + XMLSEC_ERRORS_NO_MESSAGE);
8943 + xmlSecKeyInfoCtxFinalize(&keyInfoCtx);
8947 + xmlSecKeyInfoCtxFinalize(&keyInfoCtx);
8950 - /* now that we have a key, make sure it is valid and let the simple
8951 - * store adopt it */
8953 - if (xmlSecKeyIsValid(retval)) {
8954 - ret = xmlSecSimpleKeysStoreAdoptKey(*ss, retval);
8957 + /* now write result */
8958 + ret = xmlSaveFormatFile(filename, doc, 1);
8960 xmlSecError(XMLSEC_ERRORS_HERE,
8961 - xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8962 - "xmlSecSimpleKeysStoreAdoptKey",
8963 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
8964 - XMLSEC_ERRORS_NO_MESSAGE);
8965 - xmlSecKeyDestroy(retval);
8969 - xmlSecKeyDestroy(retval);
8975 + xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
8976 + "xmlSaveFormatFile",
8977 + XMLSEC_ERRORS_R_XML_FAILED,
8979 + xmlSecErrorsSafeString(filename));
8988 --- misc/xmlsec1-1.2.6/src/nss/keytrans.c 2008-06-29 23:44:39.000000000 +0200
8989 +++ misc/build/xmlsec1-1.2.6/src/nss/keytrans.c 2008-06-29 23:44:19.000000000 +0200
8996 + * AES Algorithm support
8998 + * This is free software; see Copyright file in the source
8999 + * distribution for preciese wording.
9001 + * Copyright .................................
9003 +#include "globals.h"
9005 +#include <stdlib.h>
9007 +#include <string.h>
9010 +#include <pk11func.h>
9015 +#include <xmlsec/xmlsec.h>
9016 +#include <xmlsec/xmltree.h>
9017 +#include <xmlsec/keys.h>
9018 +#include <xmlsec/transforms.h>
9019 +#include <xmlsec/errors.h>
9021 +#include <xmlsec/nss/crypto.h>
9022 +#include <xmlsec/nss/pkikeys.h>
9023 +#include <xmlsec/nss/tokens.h>
9025 +/*********************************************************************
9027 + * key transform transforms
9029 + ********************************************************************/
9030 +typedef struct _xmlSecNssKeyTransportCtx xmlSecNssKeyTransportCtx ;
9031 +typedef struct _xmlSecNssKeyTransportCtx* xmlSecNssKeyTransportCtxPtr ;
9033 +#define xmlSecNssKeyTransportSize \
9034 + ( sizeof( xmlSecTransform ) + sizeof( xmlSecNssKeyTransportCtx ) )
9036 +#define xmlSecNssKeyTransportGetCtx( transform ) \
9037 + ( ( xmlSecNssKeyTransportCtxPtr )( ( ( xmlSecByte* )( transform ) ) + sizeof( xmlSecTransform ) ) )
9039 +struct _xmlSecNssKeyTransportCtx {
9040 + CK_MECHANISM_TYPE cipher ;
9041 + SECKEYPublicKey* pubkey ;
9042 + SECKEYPrivateKey* prikey ;
9043 + xmlSecKeyDataId keyId ;
9044 + xmlSecBufferPtr material ; /* to be encrypted/decrypted material */
9047 +static int xmlSecNssKeyTransportInitialize(xmlSecTransformPtr transform);
9048 +static void xmlSecNssKeyTransportFinalize(xmlSecTransformPtr transform);
9049 +static int xmlSecNssKeyTransportSetKeyReq(xmlSecTransformPtr transform,
9050 + xmlSecKeyReqPtr keyReq);
9051 +static int xmlSecNssKeyTransportSetKey(xmlSecTransformPtr transform,
9052 + xmlSecKeyPtr key);
9053 +static int xmlSecNssKeyTransportExecute(xmlSecTransformPtr transform,
9055 + xmlSecTransformCtxPtr transformCtx);
9056 +static xmlSecSize xmlSecNssKeyTransportGetKeySize(xmlSecTransformPtr transform);
9059 +xmlSecNssKeyTransportCheckId(
9060 + xmlSecTransformPtr transform
9062 + #ifndef XMLSEC_NO_RSA
9063 + if( xmlSecTransformCheckId( transform, xmlSecNssTransformRsaPkcs1Id ) ||
9064 + xmlSecTransformCheckId( transform, xmlSecNssTransformRsaOaepId ) ) {
9068 + #endif /* XMLSEC_NO_RSA */
9074 +xmlSecNssKeyTransportInitialize(xmlSecTransformPtr transform) {
9075 + xmlSecNssKeyTransportCtxPtr context ;
9078 + xmlSecAssert2(xmlSecNssKeyTransportCheckId(transform), -1);
9079 + xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssKeyTransportSize), -1);
9081 + context = xmlSecNssKeyTransportGetCtx( transform ) ;
9082 + xmlSecAssert2( context != NULL , -1 ) ;
9084 + #ifndef XMLSEC_NO_RSA
9085 + if( transform->id == xmlSecNssTransformRsaPkcs1Id ) {
9086 + context->cipher = CKM_RSA_PKCS ;
9087 + context->keyId = xmlSecNssKeyDataRsaId ;
9088 + } else if( transform->id == xmlSecNssTransformRsaOaepId ) {
9089 + context->cipher = CKM_RSA_PKCS_OAEP ;
9090 + context->keyId = xmlSecNssKeyDataRsaId ;
9092 + #endif /* XMLSEC_NO_RSA */
9095 + xmlSecError( XMLSEC_ERRORS_HERE ,
9096 + xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
9098 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9099 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9103 + context->pubkey = NULL ;
9104 + context->prikey = NULL ;
9105 + context->material = NULL ;
9111 +xmlSecNssKeyTransportFinalize(xmlSecTransformPtr transform) {
9112 + xmlSecNssKeyTransportCtxPtr context ;
9114 + xmlSecAssert(xmlSecNssKeyTransportCheckId(transform));
9115 + xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecNssKeyTransportSize));
9117 + context = xmlSecNssKeyTransportGetCtx( transform ) ;
9118 + xmlSecAssert( context != NULL ) ;
9120 + if( context->pubkey != NULL ) {
9121 + SECKEY_DestroyPublicKey( context->pubkey ) ;
9122 + context->pubkey = NULL ;
9125 + if( context->prikey != NULL ) {
9126 + SECKEY_DestroyPrivateKey( context->prikey ) ;
9127 + context->prikey = NULL ;
9130 + if( context->material != NULL ) {
9131 + xmlSecBufferDestroy(context->material);
9132 + context->material = NULL ;
9137 +xmlSecNssKeyTransportSetKeyReq(xmlSecTransformPtr transform, xmlSecKeyReqPtr keyReq) {
9138 + xmlSecNssKeyTransportCtxPtr context ;
9139 + xmlSecSize cipherSize = 0 ;
9142 + xmlSecAssert2(xmlSecNssKeyTransportCheckId(transform), -1);
9143 + xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssKeyTransportSize), -1);
9144 + xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
9145 + xmlSecAssert2(keyReq != NULL, -1);
9147 + context = xmlSecNssKeyTransportGetCtx( transform ) ;
9148 + xmlSecAssert2( context != NULL , -1 ) ;
9150 + keyReq->keyId = context->keyId;
9151 + if(transform->operation == xmlSecTransformOperationEncrypt) {
9152 + keyReq->keyUsage = xmlSecKeyUsageEncrypt;
9153 + keyReq->keyType = xmlSecKeyDataTypePublic;
9155 + keyReq->keyUsage = xmlSecKeyUsageDecrypt;
9156 + keyReq->keyType = xmlSecKeyDataTypePrivate;
9163 +xmlSecNssKeyTransportSetKey(xmlSecTransformPtr transform, xmlSecKeyPtr key) {
9164 + xmlSecNssKeyTransportCtxPtr context = NULL ;
9165 + xmlSecKeyDataPtr keyData = NULL ;
9166 + SECKEYPublicKey* pubkey = NULL ;
9167 + SECKEYPrivateKey* prikey = NULL ;
9169 + xmlSecAssert2(xmlSecNssKeyTransportCheckId(transform), -1);
9170 + xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssKeyTransportSize), -1);
9171 + xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
9172 + xmlSecAssert2(key != NULL, -1);
9174 + context = xmlSecNssKeyTransportGetCtx( transform ) ;
9175 + if( context == NULL || context->keyId == NULL || context->pubkey != NULL ) {
9176 + xmlSecError( XMLSEC_ERRORS_HERE ,
9177 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9178 + "xmlSecNssKeyTransportGetCtx" ,
9179 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9180 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9183 + xmlSecAssert2( xmlSecKeyCheckId( key, context->keyId ), -1 ) ;
9185 + keyData = xmlSecKeyGetValue( key ) ;
9186 + if( keyData == NULL ) {
9187 + xmlSecError( XMLSEC_ERRORS_HERE ,
9188 + xmlSecErrorsSafeString( xmlSecKeyGetName( key ) ) ,
9189 + "xmlSecKeyGetValue" ,
9190 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9191 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9195 + if(transform->operation == xmlSecTransformOperationEncrypt) {
9196 + if( ( pubkey = xmlSecNssPKIKeyDataGetPubKey( keyData ) ) == NULL ) {
9197 + xmlSecError( XMLSEC_ERRORS_HERE ,
9198 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( keyData ) ) ,
9199 + "xmlSecNssPKIKeyDataGetPubKey" ,
9200 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9201 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9205 + context->pubkey = pubkey ;
9207 + if( ( prikey = xmlSecNssPKIKeyDataGetPrivKey( keyData ) ) == NULL ) {
9208 + xmlSecError( XMLSEC_ERRORS_HERE ,
9209 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( keyData ) ) ,
9210 + "xmlSecNssPKIKeyDataGetPrivKey" ,
9211 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9212 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9216 + context->prikey = prikey ;
9223 + * key wrap transform
9226 +xmlSecNssKeyTransportCtxInit(
9227 + xmlSecNssKeyTransportCtxPtr ctx ,
9228 + xmlSecBufferPtr in ,
9229 + xmlSecBufferPtr out ,
9231 + xmlSecTransformCtxPtr transformCtx
9233 + xmlSecSize blockSize ;
9235 + xmlSecAssert2( ctx != NULL , -1 ) ;
9236 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
9237 + xmlSecAssert2( ( ctx->pubkey != NULL && encrypt ) || ( ctx->prikey != NULL && !encrypt ), -1 ) ;
9238 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
9239 + xmlSecAssert2( in != NULL , -1 ) ;
9240 + xmlSecAssert2( out != NULL , -1 ) ;
9241 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
9243 + if( ctx->material != NULL ) {
9244 + xmlSecBufferDestroy( ctx->material ) ;
9245 + ctx->material = NULL ;
9248 + if( ctx->pubkey != NULL ) {
9249 + blockSize = SECKEY_PublicKeyStrength( ctx->pubkey ) ;
9250 + } else if( ctx->prikey != NULL ) {
9251 + blockSize = PK11_SignatureLen( ctx->prikey ) ;
9256 + if( blockSize < 0 ) {
9257 + xmlSecError( XMLSEC_ERRORS_HERE ,
9260 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9261 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9265 + ctx->material = xmlSecBufferCreate( blockSize ) ;
9266 + if( ctx->material == NULL ) {
9267 + xmlSecError( XMLSEC_ERRORS_HERE ,
9269 + "xmlSecBufferCreate" ,
9270 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9271 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9275 + /* read raw key material into context */
9276 + if( xmlSecBufferSetData( ctx->material, xmlSecBufferGetData(in), xmlSecBufferGetSize(in) ) < 0 ) {
9277 + xmlSecError( XMLSEC_ERRORS_HERE ,
9279 + "xmlSecBufferSetData" ,
9280 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9281 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9285 + if( xmlSecBufferRemoveHead( in , xmlSecBufferGetSize(in) ) < 0 ) {
9286 + xmlSecError( XMLSEC_ERRORS_HERE ,
9288 + "xmlSecBufferRemoveHead" ,
9289 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9290 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9298 + * key wrap transform update
9301 +xmlSecNssKeyTransportCtxUpdate(
9302 + xmlSecNssKeyTransportCtxPtr ctx ,
9303 + xmlSecBufferPtr in ,
9304 + xmlSecBufferPtr out ,
9306 + xmlSecTransformCtxPtr transformCtx
9308 + xmlSecAssert2( ctx != NULL , -1 ) ;
9309 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
9310 + xmlSecAssert2( ( ctx->pubkey != NULL && encrypt ) || ( ctx->prikey != NULL && !encrypt ), -1 ) ;
9311 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
9312 + xmlSecAssert2( ctx->material != NULL , -1 ) ;
9313 + xmlSecAssert2( in != NULL , -1 ) ;
9314 + xmlSecAssert2( out != NULL , -1 ) ;
9315 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
9317 + /* read raw key material and append into context */
9318 + if( xmlSecBufferAppend( ctx->material, xmlSecBufferGetData(in), xmlSecBufferGetSize(in) ) < 0 ) {
9319 + xmlSecError( XMLSEC_ERRORS_HERE ,
9321 + "xmlSecBufferAppend" ,
9322 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9323 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9327 + if( xmlSecBufferRemoveHead( in , xmlSecBufferGetSize(in) ) < 0 ) {
9328 + xmlSecError( XMLSEC_ERRORS_HERE ,
9330 + "xmlSecBufferRemoveHead" ,
9331 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9332 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9340 + * Block cipher transform final
9343 +xmlSecNssKeyTransportCtxFinal(
9344 + xmlSecNssKeyTransportCtxPtr ctx ,
9345 + xmlSecBufferPtr in ,
9346 + xmlSecBufferPtr out ,
9348 + xmlSecTransformCtxPtr transformCtx
9350 + SECKEYPublicKey* targetKey ;
9351 + PK11SymKey* symKey ;
9352 + PK11SlotInfo* slot ;
9354 + xmlSecSize blockSize ;
9355 + xmlSecBufferPtr result ;
9357 + xmlSecAssert2( ctx != NULL , -1 ) ;
9358 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
9359 + xmlSecAssert2( ( ctx->pubkey != NULL && encrypt ) || ( ctx->prikey != NULL && !encrypt ), -1 ) ;
9360 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
9361 + xmlSecAssert2( ctx->material != NULL , -1 ) ;
9362 + xmlSecAssert2( in != NULL , -1 ) ;
9363 + xmlSecAssert2( out != NULL , -1 ) ;
9364 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
9366 + /* read raw key material and append into context */
9367 + if( xmlSecBufferAppend( ctx->material, xmlSecBufferGetData(in), xmlSecBufferGetSize(in) ) < 0 ) {
9368 + xmlSecError( XMLSEC_ERRORS_HERE ,
9370 + "xmlSecBufferAppend" ,
9371 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9372 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9376 + if( xmlSecBufferRemoveHead( in , xmlSecBufferGetSize(in) ) < 0 ) {
9377 + xmlSecError( XMLSEC_ERRORS_HERE ,
9379 + "xmlSecBufferRemoveHead" ,
9380 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9381 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9385 + /* Now we get all of the key materail */
9386 + /* from now on we will wrap or unwrap the key */
9387 + if( ctx->pubkey != NULL ) {
9388 + blockSize = SECKEY_PublicKeyStrength( ctx->pubkey ) ;
9389 + } else if( ctx->prikey != NULL ) {
9390 + blockSize = PK11_SignatureLen( ctx->prikey ) ;
9395 + if( blockSize < 0 ) {
9396 + xmlSecError( XMLSEC_ERRORS_HERE ,
9398 + "PK11_GetBlockSize" ,
9399 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9400 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9404 + result = xmlSecBufferCreate( blockSize * 2 ) ;
9405 + if( result == NULL ) {
9406 + xmlSecError( XMLSEC_ERRORS_HERE ,
9408 + "xmlSecBufferCreate" ,
9409 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9410 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9414 + oriskv.type = siBuffer ;
9415 + oriskv.data = xmlSecBufferGetData( ctx->material ) ;
9416 + oriskv.len = xmlSecBufferGetSize( ctx->material ) ;
9418 + if( encrypt != 0 ) {
9419 + CK_OBJECT_HANDLE id ;
9422 + /* Create template symmetric key from material */
9423 + if( ( slot = ctx->pubkey->pkcs11Slot ) == NULL ) {
9424 + slot = xmlSecNssSlotGet( ctx->cipher ) ;
9425 + if( slot == NULL ) {
9426 + xmlSecError( XMLSEC_ERRORS_HERE ,
9428 + "xmlSecNssSlotGet" ,
9429 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9430 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9431 + xmlSecBufferDestroy(result);
9435 + id = PK11_ImportPublicKey( slot, ctx->pubkey, PR_FALSE ) ;
9436 + if( id == CK_INVALID_HANDLE ) {
9437 + xmlSecError( XMLSEC_ERRORS_HERE ,
9439 + "PK11_ImportPublicKey" ,
9440 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9441 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9442 + xmlSecBufferDestroy(result);
9443 + PK11_FreeSlot( slot ) ;
9448 + /* pay attention to mechanism */
9449 + symKey = PK11_ImportSymKey( slot, ctx->cipher, PK11_OriginUnwrap, CKA_WRAP, &oriskv, NULL ) ;
9450 + if( symKey == NULL ) {
9451 + xmlSecError( XMLSEC_ERRORS_HERE ,
9453 + "PK11_ImportSymKey" ,
9454 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9455 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9456 + xmlSecBufferDestroy(result);
9457 + PK11_FreeSlot( slot ) ;
9461 + wrpskv.type = siBuffer ;
9462 + wrpskv.data = xmlSecBufferGetData( result ) ;
9463 + wrpskv.len = xmlSecBufferGetMaxSize( result ) ;
9465 + if( PK11_PubWrapSymKey( ctx->cipher, ctx->pubkey, symKey, &wrpskv ) != SECSuccess ) {
9466 + xmlSecError( XMLSEC_ERRORS_HERE ,
9468 + "PK11_PubWrapSymKey" ,
9469 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9470 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9471 + PK11_FreeSymKey( symKey ) ;
9472 + xmlSecBufferDestroy(result);
9473 + PK11_FreeSlot( slot ) ;
9477 + if( xmlSecBufferSetSize( result , wrpskv.len ) < 0 ) {
9478 + xmlSecError( XMLSEC_ERRORS_HERE ,
9480 + "xmlSecBufferSetSize" ,
9481 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9482 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9483 + PK11_FreeSymKey( symKey ) ;
9484 + xmlSecBufferDestroy(result);
9485 + PK11_FreeSlot( slot ) ;
9488 + PK11_FreeSymKey( symKey ) ;
9489 + PK11_FreeSlot( slot ) ;
9491 + SECItem* keyItem ;
9492 + CK_OBJECT_HANDLE id1 ;
9494 + /* pay attention to mechanism */
9495 + if( ( symKey = PK11_PubUnwrapSymKey( ctx->prikey, &oriskv, ctx->cipher, CKA_UNWRAP, 0 ) ) == NULL ) {
9496 + xmlSecError( XMLSEC_ERRORS_HERE ,
9498 + "PK11_PubUnwrapSymKey" ,
9499 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9500 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9501 + xmlSecBufferDestroy(result);
9505 + /* Extract raw data from symmetric key */
9506 + if( PK11_ExtractKeyValue( symKey ) != SECSuccess ) {
9507 + xmlSecError( XMLSEC_ERRORS_HERE ,
9509 + "PK11_ExtractKeyValue" ,
9510 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9511 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9512 + PK11_FreeSymKey( symKey ) ;
9513 + xmlSecBufferDestroy(result);
9517 + if( ( keyItem = PK11_GetKeyData( symKey ) ) == NULL ) {
9518 + xmlSecError( XMLSEC_ERRORS_HERE ,
9520 + "PK11_GetKeyData" ,
9521 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9522 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9523 + PK11_FreeSymKey( symKey ) ;
9524 + xmlSecBufferDestroy(result);
9528 + if( xmlSecBufferSetData( result, keyItem->data, keyItem->len ) < 0 ) {
9529 + xmlSecError( XMLSEC_ERRORS_HERE ,
9531 + "PK11_PubUnwrapSymKey" ,
9532 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9533 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9534 + PK11_FreeSymKey( symKey ) ;
9535 + xmlSecBufferDestroy(result);
9538 + PK11_FreeSymKey( symKey ) ;
9541 + /* Write output */
9542 + if( xmlSecBufferAppend( out, xmlSecBufferGetData(result), xmlSecBufferGetSize(result) ) < 0 ) {
9543 + xmlSecError( XMLSEC_ERRORS_HERE ,
9545 + "xmlSecBufferAppend" ,
9546 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9547 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9548 + xmlSecBufferDestroy(result);
9551 + xmlSecBufferDestroy(result);
9557 +xmlSecNssKeyTransportExecute(xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx) {
9558 + xmlSecNssKeyTransportCtxPtr context = NULL ;
9559 + xmlSecBufferPtr inBuf, outBuf ;
9563 + xmlSecAssert2( xmlSecNssKeyTransportCheckId( transform ), -1 ) ;
9564 + xmlSecAssert2( xmlSecTransformCheckSize( transform, xmlSecNssKeyTransportSize ), -1 ) ;
9565 + xmlSecAssert2( ( transform->operation == xmlSecTransformOperationEncrypt ) || ( transform->operation == xmlSecTransformOperationDecrypt ), -1 ) ;
9566 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
9568 + context = xmlSecNssKeyTransportGetCtx( transform ) ;
9569 + if( context == NULL ) {
9570 + xmlSecError( XMLSEC_ERRORS_HERE ,
9571 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9572 + "xmlSecNssKeyTransportGetCtx" ,
9573 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9574 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9578 + inBuf = &( transform->inBuf ) ;
9579 + outBuf = &( transform->outBuf ) ;
9581 + if( transform->status == xmlSecTransformStatusNone ) {
9582 + transform->status = xmlSecTransformStatusWorking ;
9585 + operation = ( transform->operation == xmlSecTransformOperationEncrypt ) ? 1 : 0 ;
9586 + if( transform->status == xmlSecTransformStatusWorking ) {
9587 + if( context->material == NULL ) {
9588 + rtv = xmlSecNssKeyTransportCtxInit( context, inBuf , outBuf , operation , transformCtx ) ;
9590 + xmlSecError( XMLSEC_ERRORS_HERE ,
9591 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9592 + "xmlSecNssKeyTransportCtxInit" ,
9593 + XMLSEC_ERRORS_R_INVALID_STATUS ,
9594 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9599 + if( context->material == NULL && last != 0 ) {
9600 + xmlSecError( XMLSEC_ERRORS_HERE ,
9601 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9603 + XMLSEC_ERRORS_R_INVALID_STATUS ,
9604 + "No enough data to intialize transform" ) ;
9608 + if( context->material != NULL ) {
9609 + rtv = xmlSecNssKeyTransportCtxUpdate( context, inBuf , outBuf , operation , transformCtx ) ;
9611 + xmlSecError( XMLSEC_ERRORS_HERE ,
9612 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9613 + "xmlSecNssKeyTransportCtxUpdate" ,
9614 + XMLSEC_ERRORS_R_INVALID_STATUS ,
9615 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9621 + rtv = xmlSecNssKeyTransportCtxFinal( context, inBuf , outBuf , operation , transformCtx ) ;
9623 + xmlSecError( XMLSEC_ERRORS_HERE ,
9624 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9625 + "xmlSecNssKeyTransportCtxFinal" ,
9626 + XMLSEC_ERRORS_R_INVALID_STATUS ,
9627 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9630 + transform->status = xmlSecTransformStatusFinished ;
9632 + } else if( transform->status == xmlSecTransformStatusFinished ) {
9633 + if( xmlSecBufferGetSize( inBuf ) != 0 ) {
9634 + xmlSecError( XMLSEC_ERRORS_HERE ,
9635 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9637 + XMLSEC_ERRORS_R_INVALID_STATUS ,
9638 + "status=%d", transform->status ) ;
9642 + xmlSecError( XMLSEC_ERRORS_HERE ,
9643 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9645 + XMLSEC_ERRORS_R_INVALID_STATUS ,
9646 + "status=%d", transform->status ) ;
9654 +#ifndef XMLSEC_NO_RSA
9656 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
9657 +static struct _xmlSecTransformKlass xmlSecNssRsaPkcs1Klass = {
9659 +static xmlSecTransformKlass xmlSecNssRsaPkcs1Klass = {
9661 + /* klass/object sizes */
9662 + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
9663 + xmlSecNssKeyTransportSize, /* xmlSecSize objSize */
9665 + xmlSecNameRsaPkcs1, /* const xmlChar* name; */
9666 + xmlSecHrefRsaPkcs1, /* const xmlChar* href; */
9667 + xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
9669 + xmlSecNssKeyTransportInitialize, /* xmlSecTransformInitializeMethod initialize; */
9670 + xmlSecNssKeyTransportFinalize, /* xmlSecTransformFinalizeMethod finalize; */
9671 + NULL, /* xmlSecTransformNodeReadMethod readNode; */
9672 + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
9673 + xmlSecNssKeyTransportSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
9674 + xmlSecNssKeyTransportSetKey, /* xmlSecTransformSetKeyMethod setKey; */
9675 + NULL, /* xmlSecTransformValidateMethod validate; */
9676 + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
9677 + xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
9678 + xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
9679 + NULL, /* xmlSecTransformPushXmlMethod pushXml; */
9680 + NULL, /* xmlSecTransformPopXmlMethod popXml; */
9681 + xmlSecNssKeyTransportExecute, /* xmlSecTransformExecuteMethod execute; */
9683 + NULL, /* void* reserved0; */
9684 + NULL, /* void* reserved1; */
9687 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
9688 +static struct _xmlSecTransformKlass xmlSecNssRsaOaepKlass = {
9690 +static xmlSecTransformKlass xmlSecNssRsaOaepKlass = {
9692 + /* klass/object sizes */
9693 + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
9694 + xmlSecNssKeyTransportSize, /* xmlSecSize objSize */
9696 + xmlSecNameRsaOaep, /* const xmlChar* name; */
9697 + xmlSecHrefRsaOaep, /* const xmlChar* href; */
9698 + xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
9700 + xmlSecNssKeyTransportInitialize, /* xmlSecTransformInitializeMethod initialize; */
9701 + xmlSecNssKeyTransportFinalize, /* xmlSecTransformFinalizeMethod finalize; */
9702 + NULL, /* xmlSecTransformNodeReadMethod readNode; */
9703 + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
9704 + xmlSecNssKeyTransportSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
9705 + xmlSecNssKeyTransportSetKey, /* xmlSecTransformSetKeyMethod setKey; */
9706 + NULL, /* xmlSecTransformValidateMethod validate; */
9707 + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
9708 + xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
9709 + xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
9710 + NULL, /* xmlSecTransformPushXmlMethod pushXml; */
9711 + NULL, /* xmlSecTransformPopXmlMethod popXml; */
9712 + xmlSecNssKeyTransportExecute, /* xmlSecTransformExecuteMethod execute; */
9714 + NULL, /* void* reserved0; */
9715 + NULL, /* void* reserved1; */
9719 + * xmlSecNssTransformRsaPkcs1GetKlass:
9721 + * The RSA-PKCS1 key transport transform klass.
9723 + * Returns RSA-PKCS1 key transport transform klass.
9726 +xmlSecNssTransformRsaPkcs1GetKlass(void) {
9727 + return(&xmlSecNssRsaPkcs1Klass);
9731 + * xmlSecNssTransformRsaOaepGetKlass:
9733 + * The RSA-PKCS1 key transport transform klass.
9735 + * Returns RSA-PKCS1 key transport transform klass.
9738 +xmlSecNssTransformRsaOaepGetKlass(void) {
9739 + return(&xmlSecNssRsaOaepKlass);
9742 +#endif /* XMLSEC_NO_RSA */
9744 --- misc/xmlsec1-1.2.6/src/nss/keywrapers.c 2008-06-29 23:44:40.000000000 +0200
9745 +++ misc/build/xmlsec1-1.2.6/src/nss/keywrapers.c 2008-06-29 23:44:19.000000000 +0200
9752 + * AES Algorithm support
9754 + * This is free software; see Copyright file in the source
9755 + * distribution for preciese wording.
9757 + * Copyright .................................
9759 +#include "globals.h"
9761 +#include <stdlib.h>
9763 +#include <string.h>
9766 +#include <pk11func.h>
9769 +#include <xmlsec/xmlsec.h>
9770 +#include <xmlsec/xmltree.h>
9771 +#include <xmlsec/keys.h>
9772 +#include <xmlsec/transforms.h>
9773 +#include <xmlsec/errors.h>
9775 +#include <xmlsec/nss/crypto.h>
9776 +#include <xmlsec/nss/ciphers.h>
9778 +#define XMLSEC_NSS_AES128_KEY_SIZE 16
9779 +#define XMLSEC_NSS_AES192_KEY_SIZE 24
9780 +#define XMLSEC_NSS_AES256_KEY_SIZE 32
9781 +#define XMLSEC_NSS_DES3_KEY_SIZE 24
9782 +#define XMLSEC_NSS_DES3_KEY_LENGTH 24
9783 +#define XMLSEC_NSS_DES3_IV_LENGTH 8
9784 +#define XMLSEC_NSS_DES3_BLOCK_LENGTH 8
9786 +static xmlSecByte xmlSecNssKWDes3Iv[XMLSEC_NSS_DES3_IV_LENGTH] = {
9787 + 0x4a, 0xdd, 0xa2, 0x2c, 0x79, 0xe8, 0x21, 0x05
9790 +/*********************************************************************
9792 + * key wrap transforms
9794 + ********************************************************************/
9795 +typedef struct _xmlSecNssKeyWrapCtx xmlSecNssKeyWrapCtx ;
9796 +typedef struct _xmlSecNssKeyWrapCtx* xmlSecNssKeyWrapCtxPtr ;
9798 +#define xmlSecNssKeyWrapSize \
9799 + ( sizeof( xmlSecTransform ) + sizeof( xmlSecNssKeyWrapCtx ) )
9801 +#define xmlSecNssKeyWrapGetCtx( transform ) \
9802 + ( ( xmlSecNssKeyWrapCtxPtr )( ( ( xmlSecByte* )( transform ) ) + sizeof( xmlSecTransform ) ) )
9804 +struct _xmlSecNssKeyWrapCtx {
9805 + CK_MECHANISM_TYPE cipher ;
9806 + PK11SymKey* symkey ;
9807 + xmlSecKeyDataId keyId ;
9808 + xmlSecBufferPtr material ; /* to be encrypted/decrypted key material */
9811 +static int xmlSecNssKeyWrapInitialize(xmlSecTransformPtr transform);
9812 +static void xmlSecNssKeyWrapFinalize(xmlSecTransformPtr transform);
9813 +static int xmlSecNssKeyWrapSetKeyReq(xmlSecTransformPtr transform,
9814 + xmlSecKeyReqPtr keyReq);
9815 +static int xmlSecNssKeyWrapSetKey(xmlSecTransformPtr transform,
9816 + xmlSecKeyPtr key);
9817 +static int xmlSecNssKeyWrapExecute(xmlSecTransformPtr transform,
9819 + xmlSecTransformCtxPtr transformCtx);
9820 +static xmlSecSize xmlSecNssKeyWrapGetKeySize(xmlSecTransformPtr transform);
9823 +xmlSecNssKeyWrapCheckId(
9824 + xmlSecTransformPtr transform
9826 + #ifndef XMLSEC_NO_DES
9827 + if( xmlSecTransformCheckId( transform, xmlSecNssTransformKWDes3Id ) ) {
9830 + #endif /* XMLSEC_NO_DES */
9832 + #ifndef XMLSEC_NO_AES
9833 + if( xmlSecTransformCheckId( transform, xmlSecNssTransformKWAes128Id ) ||
9834 + xmlSecTransformCheckId( transform, xmlSecNssTransformKWAes192Id ) ||
9835 + xmlSecTransformCheckId( transform, xmlSecNssTransformKWAes256Id ) ) {
9839 + #endif /* XMLSEC_NO_AES */
9845 +xmlSecNssKeyWrapGetKeySize(xmlSecTransformPtr transform) {
9846 +#ifndef XMLSEC_NO_DES
9847 + if( xmlSecTransformCheckId( transform, xmlSecNssTransformKWDes3Id ) ) {
9848 + return(XMLSEC_NSS_DES3_KEY_SIZE);
9850 +#endif /* XMLSEC_NO_DES */
9852 +#ifndef XMLSEC_NO_AES
9853 + if(xmlSecTransformCheckId(transform, xmlSecNssTransformKWAes128Id)) {
9854 + return(XMLSEC_NSS_AES128_KEY_SIZE);
9855 + } else if(xmlSecTransformCheckId(transform, xmlSecNssTransformKWAes192Id)) {
9856 + return(XMLSEC_NSS_AES192_KEY_SIZE);
9857 + } else if(xmlSecTransformCheckId(transform, xmlSecNssTransformKWAes256Id)) {
9858 + return(XMLSEC_NSS_AES256_KEY_SIZE);
9859 + } else if(xmlSecTransformCheckId(transform, xmlSecNssTransformKWAes256Id)) {
9860 + return(XMLSEC_NSS_AES256_KEY_SIZE);
9862 +#endif /* XMLSEC_NO_AES */
9870 +xmlSecNssKeyWrapInitialize(xmlSecTransformPtr transform) {
9871 + xmlSecNssKeyWrapCtxPtr context ;
9874 + xmlSecAssert2(xmlSecNssKeyWrapCheckId(transform), -1);
9875 + xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssKeyWrapSize), -1);
9877 + context = xmlSecNssKeyWrapGetCtx( transform ) ;
9878 + xmlSecAssert2( context != NULL , -1 ) ;
9880 + #ifndef XMLSEC_NO_DES
9881 + if( transform->id == xmlSecNssTransformKWDes3Id ) {
9882 + context->cipher = CKM_DES3_CBC ;
9883 + context->keyId = xmlSecNssKeyDataDesId ;
9885 + #endif /* XMLSEC_NO_DES */
9887 + #ifndef XMLSEC_NO_AES
9888 + if( transform->id == xmlSecNssTransformKWAes128Id ) {
9889 + /* context->cipher = CKM_NETSCAPE_AES_KEY_WRAP ;*/
9890 + context->cipher = CKM_AES_CBC ;
9891 + context->keyId = xmlSecNssKeyDataAesId ;
9893 + if( transform->id == xmlSecNssTransformKWAes192Id ) {
9894 + /* context->cipher = CKM_NETSCAPE_AES_KEY_WRAP ;*/
9895 + context->cipher = CKM_AES_CBC ;
9896 + context->keyId = xmlSecNssKeyDataAesId ;
9898 + if( transform->id == xmlSecNssTransformKWAes256Id ) {
9899 + /* context->cipher = CKM_NETSCAPE_AES_KEY_WRAP ;*/
9900 + context->cipher = CKM_AES_CBC ;
9901 + context->keyId = xmlSecNssKeyDataAesId ;
9903 + #endif /* XMLSEC_NO_AES */
9907 + xmlSecError( XMLSEC_ERRORS_HERE ,
9908 + xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
9910 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9911 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9915 + context->symkey = NULL ;
9916 + context->material = NULL ;
9922 +xmlSecNssKeyWrapFinalize(xmlSecTransformPtr transform) {
9923 + xmlSecNssKeyWrapCtxPtr context ;
9925 + xmlSecAssert(xmlSecNssKeyWrapCheckId(transform));
9926 + xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecNssKeyWrapSize));
9928 + context = xmlSecNssKeyWrapGetCtx( transform ) ;
9929 + xmlSecAssert( context != NULL ) ;
9931 + if( context->symkey != NULL ) {
9932 + PK11_FreeSymKey( context->symkey ) ;
9933 + context->symkey = NULL ;
9936 + if( context->material != NULL ) {
9937 + xmlSecBufferDestroy(context->material);
9938 + context->material = NULL ;
9943 +xmlSecNssKeyWrapSetKeyReq(xmlSecTransformPtr transform, xmlSecKeyReqPtr keyReq) {
9944 + xmlSecNssKeyWrapCtxPtr context ;
9945 + xmlSecSize cipherSize = 0 ;
9948 + xmlSecAssert2(xmlSecNssKeyWrapCheckId(transform), -1);
9949 + xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssKeyWrapSize), -1);
9950 + xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
9951 + xmlSecAssert2(keyReq != NULL, -1);
9953 + context = xmlSecNssKeyWrapGetCtx( transform ) ;
9954 + xmlSecAssert2( context != NULL , -1 ) ;
9956 + keyReq->keyId = context->keyId;
9957 + keyReq->keyType = xmlSecKeyDataTypeSymmetric;
9958 + if(transform->operation == xmlSecTransformOperationEncrypt) {
9959 + keyReq->keyUsage = xmlSecKeyUsageEncrypt;
9961 + keyReq->keyUsage = xmlSecKeyUsageDecrypt;
9964 + keyReq->keyBitsSize = xmlSecNssKeyWrapGetKeySize( transform ) ;
9970 +xmlSecNssKeyWrapSetKey(xmlSecTransformPtr transform, xmlSecKeyPtr key) {
9971 + xmlSecNssKeyWrapCtxPtr context = NULL ;
9972 + xmlSecKeyDataPtr keyData = NULL ;
9973 + PK11SymKey* symkey = NULL ;
9975 + xmlSecAssert2(xmlSecNssKeyWrapCheckId(transform), -1);
9976 + xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecNssKeyWrapSize), -1);
9977 + xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
9978 + xmlSecAssert2(key != NULL, -1);
9980 + context = xmlSecNssKeyWrapGetCtx( transform ) ;
9981 + if( context == NULL || context->keyId == NULL || context->symkey != NULL ) {
9982 + xmlSecError( XMLSEC_ERRORS_HERE ,
9983 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
9984 + "xmlSecNssKeyWrapGetCtx" ,
9985 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9986 + XMLSEC_ERRORS_NO_MESSAGE ) ;
9989 + xmlSecAssert2( xmlSecKeyCheckId( key, context->keyId ), -1 ) ;
9991 + keyData = xmlSecKeyGetValue( key ) ;
9992 + if( keyData == NULL ) {
9993 + xmlSecError( XMLSEC_ERRORS_HERE ,
9994 + xmlSecErrorsSafeString( xmlSecKeyGetName( key ) ) ,
9995 + "xmlSecKeyGetValue" ,
9996 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
9997 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10001 + if( ( symkey = xmlSecNssSymKeyDataGetKey( keyData ) ) == NULL ) {
10002 + xmlSecError( XMLSEC_ERRORS_HERE ,
10003 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( keyData ) ) ,
10004 + "xmlSecNssSymKeyDataGetKey" ,
10005 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10006 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10010 + context->symkey = symkey ;
10016 + * key wrap transform
10019 +xmlSecNssKeyWrapCtxInit(
10020 + xmlSecNssKeyWrapCtxPtr ctx ,
10021 + xmlSecBufferPtr in ,
10022 + xmlSecBufferPtr out ,
10024 + xmlSecTransformCtxPtr transformCtx
10026 + xmlSecSize blockSize ;
10028 + xmlSecAssert2( ctx != NULL , -1 ) ;
10029 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
10030 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
10031 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
10032 + xmlSecAssert2( in != NULL , -1 ) ;
10033 + xmlSecAssert2( out != NULL , -1 ) ;
10034 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
10036 + if( ctx->material != NULL ) {
10037 + xmlSecBufferDestroy( ctx->material ) ;
10038 + ctx->material = NULL ;
10041 + if( ( blockSize = PK11_GetBlockSize( ctx->cipher , NULL ) ) < 0 ) {
10042 + xmlSecError( XMLSEC_ERRORS_HERE ,
10044 + "PK11_GetBlockSize" ,
10045 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10046 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10050 + ctx->material = xmlSecBufferCreate( blockSize ) ;
10051 + if( ctx->material == NULL ) {
10052 + xmlSecError( XMLSEC_ERRORS_HERE ,
10054 + "xmlSecBufferCreate" ,
10055 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10056 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10060 + /* read raw key material into context */
10061 + if( xmlSecBufferSetData( ctx->material, xmlSecBufferGetData(in), xmlSecBufferGetSize(in) ) < 0 ) {
10062 + xmlSecError( XMLSEC_ERRORS_HERE ,
10064 + "xmlSecBufferSetData" ,
10065 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10066 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10070 + if( xmlSecBufferRemoveHead( in , xmlSecBufferGetSize(in) ) < 0 ) {
10071 + xmlSecError( XMLSEC_ERRORS_HERE ,
10073 + "xmlSecBufferRemoveHead" ,
10074 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10075 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10083 + * key wrap transform update
10086 +xmlSecNssKeyWrapCtxUpdate(
10087 + xmlSecNssKeyWrapCtxPtr ctx ,
10088 + xmlSecBufferPtr in ,
10089 + xmlSecBufferPtr out ,
10091 + xmlSecTransformCtxPtr transformCtx
10093 + xmlSecAssert2( ctx != NULL , -1 ) ;
10094 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
10095 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
10096 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
10097 + xmlSecAssert2( ctx->material != NULL , -1 ) ;
10098 + xmlSecAssert2( in != NULL , -1 ) ;
10099 + xmlSecAssert2( out != NULL , -1 ) ;
10100 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
10102 + /* read raw key material and append into context */
10103 + if( xmlSecBufferAppend( ctx->material, xmlSecBufferGetData(in), xmlSecBufferGetSize(in) ) < 0 ) {
10104 + xmlSecError( XMLSEC_ERRORS_HERE ,
10106 + "xmlSecBufferAppend" ,
10107 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10108 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10112 + if( xmlSecBufferRemoveHead( in , xmlSecBufferGetSize(in) ) < 0 ) {
10113 + xmlSecError( XMLSEC_ERRORS_HERE ,
10115 + "xmlSecBufferRemoveHead" ,
10116 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10117 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10125 +xmlSecNssKWDes3BufferReverse(xmlSecByte *buf, xmlSecSize size) {
10130 + xmlSecAssert2(buf != NULL, -1);
10134 + for(i = 0; i < s; ++i) {
10136 + buf[i] = buf[size - i];
10137 + buf[size - i] = c;
10142 +static xmlSecByte *
10143 +xmlSecNssComputeSHA1(const xmlSecByte *in, xmlSecSize inSize,
10144 + xmlSecByte *out, xmlSecSize outSize)
10146 + PK11Context *context = NULL;
10148 + xmlSecByte *digest = NULL;
10149 + unsigned int len;
10151 + xmlSecAssert2(in != NULL, NULL);
10152 + xmlSecAssert2(out != NULL, NULL);
10153 + xmlSecAssert2(outSize >= SHA1_LENGTH, NULL);
10155 + /* Create a context for hashing (digesting) */
10156 + context = PK11_CreateDigestContext(SEC_OID_SHA1);
10157 + if (context == NULL) {
10158 + xmlSecError(XMLSEC_ERRORS_HERE,
10160 + "PK11_CreateDigestContext",
10161 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10162 + "error code = %d", PORT_GetError());
10166 + s = PK11_DigestBegin(context);
10167 + if (s != SECSuccess) {
10168 + xmlSecError(XMLSEC_ERRORS_HERE,
10170 + "PK11_DigestBegin",
10171 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10172 + "error code = %d", PORT_GetError());
10176 + s = PK11_DigestOp(context, in, inSize);
10177 + if (s != SECSuccess) {
10178 + xmlSecError(XMLSEC_ERRORS_HERE,
10181 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10182 + "error code = %d", PORT_GetError());
10186 + s = PK11_DigestFinal(context, out, &len, outSize);
10187 + if (s != SECSuccess) {
10188 + xmlSecError(XMLSEC_ERRORS_HERE,
10190 + "PK11_DigestFinal",
10191 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10192 + "error code = %d", PORT_GetError());
10195 + xmlSecAssert2(len == SHA1_LENGTH, NULL);
10200 + if (context != NULL) {
10201 + PK11_DestroyContext(context, PR_TRUE);
10207 +xmlSecNssKWDes3Encrypt(
10208 + PK11SymKey* symKey ,
10209 + CK_MECHANISM_TYPE cipherMech ,
10210 + const xmlSecByte* iv ,
10211 + xmlSecSize ivSize ,
10212 + const xmlSecByte* in ,
10213 + xmlSecSize inSize ,
10214 + xmlSecByte* out ,
10215 + xmlSecSize outSize ,
10218 + PK11Context* EncContext = NULL;
10220 + SECItem* secParam = NULL ;
10222 + unsigned int tmp2_outlen;
10223 + int result_len = -1;
10226 + xmlSecAssert2( cipherMech != CKM_INVALID_MECHANISM , -1 ) ;
10227 + xmlSecAssert2( symKey != NULL , -1 ) ;
10228 + xmlSecAssert2(iv != NULL, -1);
10229 + xmlSecAssert2(ivSize == XMLSEC_NSS_DES3_IV_LENGTH, -1);
10230 + xmlSecAssert2(in != NULL, -1);
10231 + xmlSecAssert2(inSize > 0, -1);
10232 + xmlSecAssert2(out != NULL, -1);
10233 + xmlSecAssert2(outSize >= inSize, -1);
10236 + ivItem.data = ( unsigned char* )iv ;
10237 + ivItem.len = ivSize ;
10239 + secParam = PK11_ParamFromIV(cipherMech, &ivItem);
10240 + if (secParam == NULL) {
10241 + xmlSecError(XMLSEC_ERRORS_HERE,
10243 + "PK11_ParamFromIV",
10244 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10245 + "Error code = %d", PORT_GetError());
10249 + EncContext = PK11_CreateContextBySymKey(cipherMech,
10250 + enc ? CKA_ENCRYPT : CKA_DECRYPT,
10251 + symKey, secParam);
10252 + if (EncContext == NULL) {
10253 + xmlSecError(XMLSEC_ERRORS_HERE,
10255 + "PK11_CreateContextBySymKey",
10256 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10257 + "Error code = %d", PORT_GetError());
10261 + tmp1_outlen = tmp2_outlen = 0;
10262 + rv = PK11_CipherOp(EncContext, out, &tmp1_outlen, outSize,
10263 + (unsigned char *)in, inSize);
10264 + if (rv != SECSuccess) {
10265 + xmlSecError(XMLSEC_ERRORS_HERE,
10268 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10269 + "Error code = %d", PORT_GetError());
10273 + rv = PK11_DigestFinal(EncContext, out+tmp1_outlen,
10274 + &tmp2_outlen, outSize-tmp1_outlen);
10275 + if (rv != SECSuccess) {
10276 + xmlSecError(XMLSEC_ERRORS_HERE,
10278 + "PK11_DigestFinal",
10279 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10280 + "Error code = %d", PORT_GetError());
10284 + result_len = tmp1_outlen + tmp2_outlen;
10288 + SECITEM_FreeItem(secParam, PR_TRUE);
10290 + if (EncContext) {
10291 + PK11_DestroyContext(EncContext, PR_TRUE);
10294 + return(result_len);
10298 +xmlSecNssKeyWrapDesOp(
10299 + xmlSecNssKeyWrapCtxPtr ctx ,
10301 + xmlSecBufferPtr result
10303 + xmlSecByte sha1[SHA1_LENGTH];
10304 + xmlSecByte iv[XMLSEC_NSS_DES3_IV_LENGTH];
10306 + xmlSecSize inSize;
10308 + xmlSecSize outSize;
10311 + SECStatus status;
10313 + xmlSecAssert2( ctx != NULL , -1 ) ;
10314 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
10315 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
10316 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
10317 + xmlSecAssert2( ctx->material != NULL , -1 ) ;
10318 + xmlSecAssert2( result != NULL , -1 ) ;
10320 + in = xmlSecBufferGetData(ctx->material);
10321 + inSize = xmlSecBufferGetSize(ctx->material) ;
10322 + out = xmlSecBufferGetData(result);
10323 + outSize = xmlSecBufferGetMaxSize(result) ;
10325 + /* step 2: calculate sha1 and CMS */
10326 + if(xmlSecNssComputeSHA1(in, inSize, sha1, SHA1_LENGTH) == NULL) {
10327 + xmlSecError(XMLSEC_ERRORS_HERE,
10329 + "xmlSecNssComputeSHA1",
10330 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10331 + XMLSEC_ERRORS_NO_MESSAGE);
10335 + /* step 3: construct WKCKS */
10336 + memcpy(out, in, inSize);
10337 + memcpy(out + inSize, sha1, XMLSEC_NSS_DES3_BLOCK_LENGTH);
10339 + /* step 4: generate random iv */
10340 + status = PK11_GenerateRandom(iv, XMLSEC_NSS_DES3_IV_LENGTH);
10341 + if(status != SECSuccess) {
10342 + xmlSecError(XMLSEC_ERRORS_HERE,
10344 + "PK11_GenerateRandom",
10345 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10346 + "error code = %d", PORT_GetError());
10350 + /* step 5: first encryption, result is TEMP1 */
10351 + ret = xmlSecNssKWDes3Encrypt( ctx->symkey, ctx->cipher,
10352 + iv, XMLSEC_NSS_DES3_IV_LENGTH,
10353 + out, inSize + XMLSEC_NSS_DES3_IV_LENGTH,
10354 + out, outSize, 1);
10356 + xmlSecError(XMLSEC_ERRORS_HERE,
10358 + "xmlSecNssKWDes3Encrypt",
10359 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10360 + XMLSEC_ERRORS_NO_MESSAGE);
10364 + /* step 6: construct TEMP2=IV || TEMP1 */
10365 + memmove(out + XMLSEC_NSS_DES3_IV_LENGTH, out,
10366 + inSize + XMLSEC_NSS_DES3_IV_LENGTH);
10367 + memcpy(out, iv, XMLSEC_NSS_DES3_IV_LENGTH);
10368 + s = ret + XMLSEC_NSS_DES3_IV_LENGTH;
10370 + /* step 7: reverse octets order, result is TEMP3 */
10371 + ret = xmlSecNssKWDes3BufferReverse(out, s);
10373 + xmlSecError(XMLSEC_ERRORS_HERE,
10375 + "xmlSecNssKWDes3BufferReverse",
10376 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10377 + XMLSEC_ERRORS_NO_MESSAGE);
10381 + /* step 8: second encryption with static IV */
10382 + ret = xmlSecNssKWDes3Encrypt( ctx->symkey, ctx->cipher,
10383 + xmlSecNssKWDes3Iv, XMLSEC_NSS_DES3_IV_LENGTH,
10385 + out, outSize, 1);
10387 + xmlSecError(XMLSEC_ERRORS_HERE,
10389 + "xmlSecNssKWDes3Encrypt",
10390 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10391 + XMLSEC_ERRORS_NO_MESSAGE);
10396 + if( xmlSecBufferSetSize( result , s ) < 0 ) {
10397 + xmlSecError(XMLSEC_ERRORS_HERE,
10399 + "xmlSecBufferSetSize",
10400 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10401 + XMLSEC_ERRORS_NO_MESSAGE);
10405 + /* step 2: first decryption with static IV, result is TEMP3 */
10406 + ret = xmlSecNssKWDes3Encrypt( ctx->symkey, ctx->cipher,
10407 + xmlSecNssKWDes3Iv, XMLSEC_NSS_DES3_IV_LENGTH,
10409 + out, outSize, 0);
10410 + if((ret < 0) || (ret < XMLSEC_NSS_DES3_IV_LENGTH)) {
10411 + xmlSecError(XMLSEC_ERRORS_HERE,
10413 + "xmlSecNssKWDes3Encrypt",
10414 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10415 + XMLSEC_ERRORS_NO_MESSAGE);
10420 + /* step 3: reverse octets order in TEMP3, result is TEMP2 */
10421 + ret = xmlSecNssKWDes3BufferReverse(out, s);
10423 + xmlSecError(XMLSEC_ERRORS_HERE,
10425 + "xmlSecNssKWDes3BufferReverse",
10426 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10427 + XMLSEC_ERRORS_NO_MESSAGE);
10431 + /* steps 4 and 5: get IV and decrypt second time, result is WKCKS */
10432 + ret = xmlSecNssKWDes3Encrypt( ctx->symkey, ctx->cipher,
10433 + out, XMLSEC_NSS_DES3_IV_LENGTH,
10434 + out+XMLSEC_NSS_DES3_IV_LENGTH, s-XMLSEC_NSS_DES3_IV_LENGTH,
10435 + out, outSize, 0);
10436 + if((ret < 0) || (ret < XMLSEC_NSS_DES3_BLOCK_LENGTH)) {
10437 + xmlSecError(XMLSEC_ERRORS_HERE,
10439 + "xmlSecNssKWDes3Encrypt",
10440 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10441 + XMLSEC_ERRORS_NO_MESSAGE);
10444 + s = ret - XMLSEC_NSS_DES3_IV_LENGTH;
10446 + /* steps 6 and 7: calculate SHA1 and validate it */
10447 + if(xmlSecNssComputeSHA1(out, s, sha1, SHA1_LENGTH) == NULL) {
10448 + xmlSecError(XMLSEC_ERRORS_HERE,
10450 + "xmlSecNssComputeSHA1",
10451 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
10452 + XMLSEC_ERRORS_NO_MESSAGE);
10456 + if(memcmp(sha1, out + s, XMLSEC_NSS_DES3_BLOCK_LENGTH) != 0) {
10457 + xmlSecError(XMLSEC_ERRORS_HERE,
10460 + XMLSEC_ERRORS_R_INVALID_DATA,
10461 + "SHA1 does not match");
10465 + if( xmlSecBufferSetSize( result , s ) < 0 ) {
10466 + xmlSecError(XMLSEC_ERRORS_HERE,
10468 + "xmlSecBufferSetSize",
10469 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
10470 + XMLSEC_ERRORS_NO_MESSAGE);
10479 +xmlSecNssKeyWrapAesOp(
10480 + xmlSecNssKeyWrapCtxPtr ctx ,
10482 + xmlSecBufferPtr result
10484 + PK11Context* cipherCtx = NULL;
10486 + SECItem* secParam = NULL ;
10487 + xmlSecSize inSize ;
10488 + xmlSecSize inBlocks ;
10492 + xmlSecByte* out ;
10493 + xmlSecSize outSize;
10495 + xmlSecAssert2( ctx != NULL , -1 ) ;
10496 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
10497 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
10498 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
10499 + xmlSecAssert2( ctx->material != NULL , -1 ) ;
10500 + xmlSecAssert2( result != NULL , -1 ) ;
10502 + /* Do not set any IV */
10503 + memset(&ivItem, 0, sizeof(ivItem));
10505 + /* Get block size */
10506 + if( ( blockSize = PK11_GetBlockSize( ctx->cipher , NULL ) ) < 0 ) {
10507 + xmlSecError( XMLSEC_ERRORS_HERE ,
10509 + "PK11_GetBlockSize" ,
10510 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10511 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10515 + inSize = xmlSecBufferGetSize( ctx->material ) ;
10516 + if( xmlSecBufferSetMaxSize( result , inSize + blockSize ) < 0 ) {
10517 + xmlSecError( XMLSEC_ERRORS_HERE ,
10519 + "xmlSecBufferSetMaxSize" ,
10520 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10521 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10525 + /* Get Param for context initialization */
10526 + if( ( secParam = PK11_ParamFromIV( ctx->cipher , &ivItem ) ) == NULL ) {
10527 + xmlSecError( XMLSEC_ERRORS_HERE ,
10529 + "PK11_ParamFromIV" ,
10530 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10531 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10535 + cipherCtx = PK11_CreateContextBySymKey( ctx->cipher , encrypt ? CKA_ENCRYPT : CKA_DECRYPT , ctx->symkey , secParam ) ;
10536 + if( cipherCtx == NULL ) {
10537 + xmlSecError( XMLSEC_ERRORS_HERE ,
10539 + "PK11_CreateContextBySymKey" ,
10540 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10541 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10542 + SECITEM_FreeItem( secParam , PR_TRUE ) ;
10546 + out = xmlSecBufferGetData(result) ;
10547 + outSize = xmlSecBufferGetMaxSize(result) ;
10548 + if( PK11_CipherOp( cipherCtx , out, &midSize , outSize , xmlSecBufferGetData( ctx->material ) , inSize ) != SECSuccess ) {
10549 + xmlSecError( XMLSEC_ERRORS_HERE ,
10551 + "PK11_CipherOp" ,
10552 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10553 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10557 + if( PK11_DigestFinal( cipherCtx , out + midSize , &finSize , outSize - midSize ) != SECSuccess ) {
10558 + xmlSecError( XMLSEC_ERRORS_HERE ,
10560 + "PK11_DigestFinal" ,
10561 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10562 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10566 + if( xmlSecBufferSetSize( result , midSize + finSize ) < 0 ) {
10567 + xmlSecError( XMLSEC_ERRORS_HERE ,
10569 + "xmlSecBufferSetSize" ,
10570 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10571 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10579 + * Block cipher transform final
10582 +xmlSecNssKeyWrapCtxFinal(
10583 + xmlSecNssKeyWrapCtxPtr ctx ,
10584 + xmlSecBufferPtr in ,
10585 + xmlSecBufferPtr out ,
10587 + xmlSecTransformCtxPtr transformCtx
10589 + PK11SymKey* targetKey ;
10590 + xmlSecSize blockSize ;
10591 + xmlSecBufferPtr result ;
10593 + xmlSecAssert2( ctx != NULL , -1 ) ;
10594 + xmlSecAssert2( ctx->cipher != CKM_INVALID_MECHANISM , -1 ) ;
10595 + xmlSecAssert2( ctx->symkey != NULL , -1 ) ;
10596 + xmlSecAssert2( ctx->keyId != NULL , -1 ) ;
10597 + xmlSecAssert2( ctx->material != NULL , -1 ) ;
10598 + xmlSecAssert2( in != NULL , -1 ) ;
10599 + xmlSecAssert2( out != NULL , -1 ) ;
10600 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
10602 + /* read raw key material and append into context */
10603 + if( xmlSecBufferAppend( ctx->material, xmlSecBufferGetData(in), xmlSecBufferGetSize(in) ) < 0 ) {
10604 + xmlSecError( XMLSEC_ERRORS_HERE ,
10606 + "xmlSecBufferAppend" ,
10607 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10608 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10612 + if( xmlSecBufferRemoveHead( in , xmlSecBufferGetSize(in) ) < 0 ) {
10613 + xmlSecError( XMLSEC_ERRORS_HERE ,
10615 + "xmlSecBufferRemoveHead" ,
10616 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10617 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10621 + /* Now we get all of the key materail */
10622 + /* from now on we will wrap or unwrap the key */
10623 + if( ( blockSize = PK11_GetBlockSize( ctx->cipher , NULL ) ) < 0 ) {
10624 + xmlSecError( XMLSEC_ERRORS_HERE ,
10626 + "PK11_GetBlockSize" ,
10627 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10628 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10632 + result = xmlSecBufferCreate( blockSize ) ;
10633 + if( result == NULL ) {
10634 + xmlSecError( XMLSEC_ERRORS_HERE ,
10636 + "xmlSecBufferCreate" ,
10637 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10638 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10642 + switch( ctx->cipher ) {
10643 + case CKM_DES3_CBC :
10644 + if( xmlSecNssKeyWrapDesOp(ctx, encrypt, result) < 0 ) {
10645 + xmlSecError( XMLSEC_ERRORS_HERE ,
10647 + "xmlSecNssKeyWrapDesOp" ,
10648 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10649 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10650 + xmlSecBufferDestroy(result);
10654 + /* case CKM_NETSCAPE_AES_KEY_WRAP :*/
10655 + case CKM_AES_CBC :
10656 + if( xmlSecNssKeyWrapAesOp(ctx, encrypt, result) < 0 ) {
10657 + xmlSecError( XMLSEC_ERRORS_HERE ,
10659 + "xmlSecNssKeyWrapAesOp" ,
10660 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10661 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10662 + xmlSecBufferDestroy(result);
10668 + /* Write output */
10669 + if( xmlSecBufferAppend( out, xmlSecBufferGetData(result), xmlSecBufferGetSize(result) ) < 0 ) {
10670 + xmlSecError( XMLSEC_ERRORS_HERE ,
10672 + "xmlSecBufferAppend" ,
10673 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10674 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10675 + xmlSecBufferDestroy(result);
10678 + xmlSecBufferDestroy(result);
10684 +xmlSecNssKeyWrapExecute(xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx) {
10685 + xmlSecNssKeyWrapCtxPtr context = NULL ;
10686 + xmlSecBufferPtr inBuf, outBuf ;
10690 + xmlSecAssert2( xmlSecNssKeyWrapCheckId( transform ), -1 ) ;
10691 + xmlSecAssert2( xmlSecTransformCheckSize( transform, xmlSecNssKeyWrapSize ), -1 ) ;
10692 + xmlSecAssert2( ( transform->operation == xmlSecTransformOperationEncrypt ) || ( transform->operation == xmlSecTransformOperationDecrypt ), -1 ) ;
10693 + xmlSecAssert2( transformCtx != NULL , -1 ) ;
10695 + context = xmlSecNssKeyWrapGetCtx( transform ) ;
10696 + if( context == NULL ) {
10697 + xmlSecError( XMLSEC_ERRORS_HERE ,
10698 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10699 + "xmlSecNssKeyWrapGetCtx" ,
10700 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
10701 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10705 + inBuf = &( transform->inBuf ) ;
10706 + outBuf = &( transform->outBuf ) ;
10708 + if( transform->status == xmlSecTransformStatusNone ) {
10709 + transform->status = xmlSecTransformStatusWorking ;
10712 + operation = ( transform->operation == xmlSecTransformOperationEncrypt ) ? 1 : 0 ;
10713 + if( transform->status == xmlSecTransformStatusWorking ) {
10714 + if( context->material == NULL ) {
10715 + rtv = xmlSecNssKeyWrapCtxInit( context, inBuf , outBuf , operation , transformCtx ) ;
10717 + xmlSecError( XMLSEC_ERRORS_HERE ,
10718 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10719 + "xmlSecNssKeyWrapCtxInit" ,
10720 + XMLSEC_ERRORS_R_INVALID_STATUS ,
10721 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10726 + if( context->material == NULL && last != 0 ) {
10727 + xmlSecError( XMLSEC_ERRORS_HERE ,
10728 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10730 + XMLSEC_ERRORS_R_INVALID_STATUS ,
10731 + "No enough data to intialize transform" ) ;
10735 + if( context->material != NULL ) {
10736 + rtv = xmlSecNssKeyWrapCtxUpdate( context, inBuf , outBuf , operation , transformCtx ) ;
10738 + xmlSecError( XMLSEC_ERRORS_HERE ,
10739 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10740 + "xmlSecNssKeyWrapCtxUpdate" ,
10741 + XMLSEC_ERRORS_R_INVALID_STATUS ,
10742 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10748 + rtv = xmlSecNssKeyWrapCtxFinal( context, inBuf , outBuf , operation , transformCtx ) ;
10750 + xmlSecError( XMLSEC_ERRORS_HERE ,
10751 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10752 + "xmlSecNssKeyWrapCtxFinal" ,
10753 + XMLSEC_ERRORS_R_INVALID_STATUS ,
10754 + XMLSEC_ERRORS_NO_MESSAGE ) ;
10757 + transform->status = xmlSecTransformStatusFinished ;
10759 + } else if( transform->status == xmlSecTransformStatusFinished ) {
10760 + if( xmlSecBufferGetSize( inBuf ) != 0 ) {
10761 + xmlSecError( XMLSEC_ERRORS_HERE ,
10762 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10764 + XMLSEC_ERRORS_R_INVALID_STATUS ,
10765 + "status=%d", transform->status ) ;
10769 + xmlSecError( XMLSEC_ERRORS_HERE ,
10770 + xmlSecErrorsSafeString( xmlSecTransformGetName( transform ) ) ,
10772 + XMLSEC_ERRORS_R_INVALID_STATUS ,
10773 + "status=%d", transform->status ) ;
10780 +#ifndef XMLSEC_NO_AES
10783 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
10784 +static struct _xmlSecTransformKlass xmlSecNssKWAes128Klass = {
10786 +static xmlSecTransformKlass xmlSecNssKWAes128Klass = {
10788 + /* klass/object sizes */
10789 + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
10790 + xmlSecNssKeyWrapSize, /* xmlSecSize objSize */
10792 + xmlSecNameKWAes128, /* const xmlChar* name; */
10793 + xmlSecHrefKWAes128, /* const xmlChar* href; */
10794 + xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
10796 + xmlSecNssKeyWrapInitialize, /* xmlSecTransformInitializeMethod initialize; */
10797 + xmlSecNssKeyWrapFinalize, /* xmlSecTransformFinalizeMethod finalize; */
10798 + NULL, /* xmlSecTransformNodeReadMethod readNode; */
10799 + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
10800 + xmlSecNssKeyWrapSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
10801 + xmlSecNssKeyWrapSetKey, /* xmlSecTransformSetKeyMethod setKey; */
10802 + NULL, /* xmlSecTransformValidateMethod validate; */
10803 + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
10804 + xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
10805 + xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
10806 + NULL, /* xmlSecTransformPushXmlMethod pushXml; */
10807 + NULL, /* xmlSecTransformPopXmlMethod popXml; */
10808 + xmlSecNssKeyWrapExecute, /* xmlSecTransformExecuteMethod execute; */
10810 + NULL, /* void* reserved0; */
10811 + NULL, /* void* reserved1; */
10814 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
10815 +static struct _xmlSecTransformKlass xmlSecNssKWAes192Klass = {
10817 +static xmlSecTransformKlass xmlSecNssKWAes192Klass = {
10819 + /* klass/object sizes */
10820 + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
10821 + xmlSecNssKeyWrapSize, /* xmlSecSize objSize */
10823 + xmlSecNameKWAes192, /* const xmlChar* name; */
10824 + xmlSecHrefKWAes192, /* const xmlChar* href; */
10825 + xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
10827 + xmlSecNssKeyWrapInitialize, /* xmlSecTransformInitializeMethod initialize; */
10828 + xmlSecNssKeyWrapFinalize, /* xmlSecTransformFinalizeMethod finalize; */
10829 + NULL, /* xmlSecTransformNodeReadMethod readNode; */
10830 + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
10831 + xmlSecNssKeyWrapSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
10832 + xmlSecNssKeyWrapSetKey, /* xmlSecTransformSetKeyMethod setKey; */
10833 + NULL, /* xmlSecTransformValidateMethod validate; */
10834 + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
10835 + xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
10836 + xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
10837 + NULL, /* xmlSecTransformPushXmlMethod pushXml; */
10838 + NULL, /* xmlSecTransformPopXmlMethod popXml; */
10839 + xmlSecNssKeyWrapExecute, /* xmlSecTransformExecuteMethod execute; */
10841 + NULL, /* void* reserved0; */
10842 + NULL, /* void* reserved1; */
10845 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
10846 +static struct _xmlSecTransformKlass xmlSecNssKWAes256Klass = {
10848 +static xmlSecTransformKlass xmlSecNssKWAes256Klass = {
10850 + /* klass/object sizes */
10851 + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
10852 + xmlSecNssKeyWrapSize, /* xmlSecSize objSize */
10854 + xmlSecNameKWAes256, /* const xmlChar* name; */
10855 + xmlSecHrefKWAes256, /* const xmlChar* href; */
10856 + xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
10858 + xmlSecNssKeyWrapInitialize, /* xmlSecTransformInitializeMethod initialize; */
10859 + xmlSecNssKeyWrapFinalize, /* xmlSecTransformFinalizeMethod finalize; */
10860 + NULL, /* xmlSecTransformNodeReadMethod readNode; */
10861 + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
10862 + xmlSecNssKeyWrapSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
10863 + xmlSecNssKeyWrapSetKey, /* xmlSecTransformSetKeyMethod setKey; */
10864 + NULL, /* xmlSecTransformValidateMethod validate; */
10865 + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
10866 + xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
10867 + xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
10868 + NULL, /* xmlSecTransformPushXmlMethod pushXml; */
10869 + NULL, /* xmlSecTransformPopXmlMethod popXml; */
10870 + xmlSecNssKeyWrapExecute, /* xmlSecTransformExecuteMethod execute; */
10872 + NULL, /* void* reserved0; */
10873 + NULL, /* void* reserved1; */
10877 + * xmlSecNssTransformKWAes128GetKlass:
10879 + * The AES-128 key wrapper transform klass.
10881 + * Returns AES-128 key wrapper transform klass.
10884 +xmlSecNssTransformKWAes128GetKlass(void) {
10885 + return(&xmlSecNssKWAes128Klass);
10889 + * xmlSecNssTransformKWAes192GetKlass:
10891 + * The AES-192 key wrapper transform klass.
10893 + * Returns AES-192 key wrapper transform klass.
10896 +xmlSecNssTransformKWAes192GetKlass(void) {
10897 + return(&xmlSecNssKWAes192Klass);
10902 + * The AES-256 key wrapper transform klass.
10904 + * Returns AES-256 key wrapper transform klass.
10907 +xmlSecNssTransformKWAes256GetKlass(void) {
10908 + return(&xmlSecNssKWAes256Klass);
10911 +#endif /* XMLSEC_NO_AES */
10914 +#ifndef XMLSEC_NO_DES
10916 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
10917 +static struct _xmlSecTransformKlass xmlSecNssKWDes3Klass = {
10919 +static xmlSecTransformKlass xmlSecNssKWDes3Klass = {
10921 + /* klass/object sizes */
10922 + sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
10923 + xmlSecNssKeyWrapSize, /* xmlSecSize objSize */
10925 + xmlSecNameKWDes3, /* const xmlChar* name; */
10926 + xmlSecHrefKWDes3, /* const xmlChar* href; */
10927 + xmlSecTransformUsageEncryptionMethod, /* xmlSecAlgorithmUsage usage; */
10929 + xmlSecNssKeyWrapInitialize, /* xmlSecTransformInitializeMethod initialize; */
10930 + xmlSecNssKeyWrapFinalize, /* xmlSecTransformFinalizeMethod finalize; */
10931 + NULL, /* xmlSecTransformNodeReadMethod readNode; */
10932 + NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
10933 + xmlSecNssKeyWrapSetKeyReq, /* xmlSecTransformSetKeyMethod setKeyReq; */
10934 + xmlSecNssKeyWrapSetKey, /* xmlSecTransformSetKeyMethod setKey; */
10935 + NULL, /* xmlSecTransformValidateMethod validate; */
10936 + xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
10937 + xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
10938 + xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
10939 + NULL, /* xmlSecTransformPushXmlMethod pushXml; */
10940 + NULL, /* xmlSecTransformPopXmlMethod popXml; */
10941 + xmlSecNssKeyWrapExecute, /* xmlSecTransformExecuteMethod execute; */
10943 + NULL, /* void* reserved0; */
10944 + NULL, /* void* reserved1; */
10948 + * xmlSecNssTransformKWDes3GetKlass:
10950 + * The Triple DES key wrapper transform klass.
10952 + * Returns Triple DES key wrapper transform klass.
10955 +xmlSecNssTransformKWDes3GetKlass(void) {
10956 + return(&xmlSecNssKWDes3Klass);
10959 +#endif /* XMLSEC_NO_DES */
10961 --- misc/xmlsec1-1.2.6/src/nss/pkikeys.c 2004-03-17 06:06:45.000000000 +0100
10962 +++ misc/build/xmlsec1-1.2.6/src/nss/pkikeys.c 2008-06-29 23:44:19.000000000 +0200
10964 * distribution for preciese wording.
10966 * Copyright (c) 2003 America Online, Inc. All rights reserved.
10967 + * Copyright ...........................
10969 #include "globals.h"
10972 #include <xmlsec/nss/crypto.h>
10973 #include <xmlsec/nss/bignum.h>
10974 #include <xmlsec/nss/pkikeys.h>
10975 +#include <xmlsec/nss/tokens.h>
10977 /**************************************************************************
10979 @@ -98,14 +100,13 @@
10981 xmlSecAssert(ctx != NULL);
10982 if (ctx->privkey != NULL) {
10983 - SECKEY_DestroyPrivateKey(ctx->privkey);
10984 - ctx->privkey = NULL;
10985 + SECKEY_DestroyPrivateKey(ctx->privkey);
10986 + ctx->privkey = NULL;
10991 - SECKEY_DestroyPublicKey(ctx->pubkey);
10992 - ctx->pubkey = NULL;
10993 + if (ctx->pubkey) {
10994 + SECKEY_DestroyPublicKey(ctx->pubkey);
10995 + ctx->pubkey = NULL;
10999 @@ -115,29 +116,32 @@
11000 xmlSecNssPKIKeyDataCtxPtr ctxSrc)
11002 xmlSecNSSPKIKeyDataCtxFree(ctxDst);
11003 + ctxDst->privkey = NULL ;
11004 + ctxDst->pubkey = NULL ;
11005 if (ctxSrc->privkey != NULL) {
11006 - ctxDst->privkey = SECKEY_CopyPrivateKey(ctxSrc->privkey);
11007 - if(ctxDst->privkey == NULL) {
11008 - xmlSecError(XMLSEC_ERRORS_HERE,
11010 - "SECKEY_CopyPrivateKey",
11011 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
11012 - XMLSEC_ERRORS_NO_MESSAGE);
11015 + ctxDst->privkey = SECKEY_CopyPrivateKey(ctxSrc->privkey);
11016 + if(ctxDst->privkey == NULL) {
11017 + xmlSecError(XMLSEC_ERRORS_HERE,
11019 + "SECKEY_CopyPrivateKey",
11020 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
11021 + "error code=%d", PORT_GetError());
11026 if (ctxSrc->pubkey != NULL) {
11027 - ctxDst->pubkey = SECKEY_CopyPublicKey(ctxSrc->pubkey);
11028 - if(ctxDst->pubkey == NULL) {
11029 - xmlSecError(XMLSEC_ERRORS_HERE,
11031 - "SECKEY_CopyPublicKey",
11032 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
11033 - XMLSEC_ERRORS_NO_MESSAGE);
11036 + ctxDst->pubkey = SECKEY_CopyPublicKey(ctxSrc->pubkey);
11037 + if(ctxDst->pubkey == NULL) {
11038 + xmlSecError(XMLSEC_ERRORS_HERE,
11040 + "SECKEY_CopyPublicKey",
11041 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
11042 + "error code=%d", PORT_GetError());
11050 @@ -147,20 +151,41 @@
11051 SECKEYPublicKey *pubkey)
11053 xmlSecNssPKIKeyDataCtxPtr ctx;
11054 + KeyType pubType = nullKey ;
11055 + KeyType priType = nullKey ;
11057 xmlSecAssert2(xmlSecKeyDataIsValid(data), -1);
11058 xmlSecAssert2(xmlSecKeyDataCheckSize(data, xmlSecNssPKIKeyDataSize), -1);
11060 + if( privkey != NULL ) {
11061 + priType = SECKEY_GetPrivateKeyType( privkey ) ;
11064 + if( pubkey != NULL ) {
11065 + pubType = SECKEY_GetPublicKeyType( pubkey ) ;
11068 + if( priType != nullKey && pubType != nullKey ) {
11069 + if( pubType != priType ) {
11070 + xmlSecError( XMLSEC_ERRORS_HERE ,
11073 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
11074 + "different type of private and public key" ) ;
11079 ctx = xmlSecNssPKIKeyDataGetCtx(data);
11080 xmlSecAssert2(ctx != NULL, -1);
11082 if (ctx->privkey) {
11083 - SECKEY_DestroyPrivateKey(ctx->privkey);
11084 + SECKEY_DestroyPrivateKey(ctx->privkey);
11086 ctx->privkey = privkey;
11089 - SECKEY_DestroyPublicKey(ctx->pubkey);
11090 + SECKEY_DestroyPublicKey(ctx->pubkey);
11092 ctx->pubkey = pubkey;
11094 @@ -183,61 +208,75 @@
11096 xmlSecKeyDataPtr data = NULL;
11100 - if (pubkey != NULL) {
11101 - kt = SECKEY_GetPublicKeyType(pubkey);
11103 - kt = SECKEY_GetPrivateKeyType(privkey);
11104 - pubkey = SECKEY_ConvertToPublicKey(privkey);
11106 + KeyType pubType = nullKey ;
11107 + KeyType priType = nullKey ;
11110 + if( privkey != NULL ) {
11111 + priType = SECKEY_GetPrivateKeyType( privkey ) ;
11114 + if( pubkey != NULL ) {
11115 + pubType = SECKEY_GetPublicKeyType( pubkey ) ;
11118 + if( priType != nullKey && pubType != nullKey ) {
11119 + if( pubType != priType ) {
11120 + xmlSecError( XMLSEC_ERRORS_HERE ,
11123 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
11124 + "different type of private and public key" ) ;
11129 + pubType = priType != nullKey ? priType : pubType ;
11130 + switch(pubType) {
11131 #ifndef XMLSEC_NO_RSA
11133 - data = xmlSecKeyDataCreate(xmlSecNssKeyDataRsaId);
11134 - if(data == NULL) {
11135 - xmlSecError(XMLSEC_ERRORS_HERE,
11137 - "xmlSecKeyDataCreate",
11138 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
11139 - "xmlSecNssKeyDataRsaId");
11143 + data = xmlSecKeyDataCreate(xmlSecNssKeyDataRsaId);
11144 + if(data == NULL) {
11145 + xmlSecError(XMLSEC_ERRORS_HERE,
11147 + "xmlSecKeyDataCreate",
11148 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
11149 + "xmlSecNssKeyDataRsaId");
11153 #endif /* XMLSEC_NO_RSA */
11154 #ifndef XMLSEC_NO_DSA
11156 - data = xmlSecKeyDataCreate(xmlSecNssKeyDataDsaId);
11157 - if(data == NULL) {
11158 - xmlSecError(XMLSEC_ERRORS_HERE,
11160 - "xmlSecKeyDataCreate",
11161 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
11162 - "xmlSecNssKeyDataDsaId");
11166 + data = xmlSecKeyDataCreate(xmlSecNssKeyDataDsaId);
11167 + if(data == NULL) {
11168 + xmlSecError(XMLSEC_ERRORS_HERE,
11170 + "xmlSecKeyDataCreate",
11171 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
11172 + "xmlSecNssKeyDataDsaId");
11176 #endif /* XMLSEC_NO_DSA */
11178 - xmlSecError(XMLSEC_ERRORS_HERE,
11179 + xmlSecError(XMLSEC_ERRORS_HERE,
11182 XMLSEC_ERRORS_R_INVALID_TYPE,
11183 - "PKI key type %d not supported", kt);
11185 + "PKI key type %d not supported", pubType);
11189 xmlSecAssert2(data != NULL, NULL);
11190 ret = xmlSecNssPKIKeyDataAdoptKey(data, privkey, pubkey);
11192 - xmlSecError(XMLSEC_ERRORS_HERE,
11193 + xmlSecError(XMLSEC_ERRORS_HERE,
11195 "xmlSecNssPKIKeyDataAdoptKey",
11196 XMLSEC_ERRORS_R_XMLSEC_FAILED,
11197 XMLSEC_ERRORS_NO_MESSAGE);
11198 - xmlSecKeyDataDestroy(data);
11200 + xmlSecKeyDataDestroy(data);
11205 @@ -263,7 +302,7 @@
11206 xmlSecAssert2(ctx != NULL, NULL);
11207 xmlSecAssert2(ctx->pubkey != NULL, NULL);
11209 - ret = SECKEY_CopyPublicKey(ctx->pubkey);
11210 + ret = SECKEY_CopyPublicKey(ctx->pubkey);
11214 @@ -312,9 +351,9 @@
11215 xmlSecAssert2(ctx != NULL, nullKey);
11217 if (ctx->pubkey != NULL) {
11218 - kt = SECKEY_GetPublicKeyType(ctx->pubkey);
11219 + kt = SECKEY_GetPublicKeyType(ctx->pubkey);
11221 - kt = SECKEY_GetPrivateKeyType(ctx->privkey);
11222 + kt = SECKEY_GetPrivateKeyType(ctx->privkey);
11226 @@ -453,7 +492,11 @@
11227 static void xmlSecNssKeyDataDsaDebugXmlDump (xmlSecKeyDataPtr data,
11230 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
11231 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataDsaKlass = {
11233 static xmlSecKeyDataKlass xmlSecNssKeyDataDsaKlass = {
11235 sizeof(xmlSecKeyDataKlass),
11236 xmlSecNssPKIKeyDataSize,
11238 @@ -553,13 +596,13 @@
11242 - slot = PK11_GetBestSlot(CKM_DSA, NULL);
11243 + slot = xmlSecNssSlotGet(CKM_DSA);
11245 xmlSecError(XMLSEC_ERRORS_HERE,
11246 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11247 - "PK11_GetBestSlot",
11248 + "xmlSecNssSlotGet",
11249 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11250 - XMLSEC_ERRORS_NO_MESSAGE);
11251 + "error code=%d", PORT_GetError());
11255 @@ -570,7 +613,7 @@
11256 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11258 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11259 - XMLSEC_ERRORS_NO_MESSAGE);
11260 + "error code=%d", PORT_GetError());
11264 @@ -582,7 +625,7 @@
11265 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11266 "PORT_ArenaZAlloc",
11267 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11268 - XMLSEC_ERRORS_NO_MESSAGE);
11269 + "error code=%d", PORT_GetError());
11270 PORT_FreeArena(arena, PR_FALSE);
11273 @@ -750,21 +793,21 @@
11281 if (slot != NULL) {
11282 - PK11_FreeSlot(slot);
11283 + PK11_FreeSlot(slot);
11286 - if (pubkey != NULL) {
11287 - SECKEY_DestroyPublicKey(pubkey);
11289 - if (data != NULL) {
11290 - xmlSecKeyDataDestroy(data);
11293 + if (pubkey != NULL) {
11294 + SECKEY_DestroyPublicKey(pubkey);
11297 + if (data != NULL) {
11298 + xmlSecKeyDataDestroy(data);
11304 @@ -783,7 +826,7 @@
11306 ctx = xmlSecNssPKIKeyDataGetCtx(xmlSecKeyGetValue(key));
11307 xmlSecAssert2(ctx != NULL, -1);
11308 - xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == dsaKey, -1);
11309 +/* xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == dsaKey, -1);*/
11311 if(((xmlSecKeyDataTypePublic | xmlSecKeyDataTypePrivate) & keyInfoCtx->keyReq.keyType) == 0) {
11312 /* we can have only private key or public key */
11313 @@ -905,7 +948,8 @@
11314 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
11315 "PK11_PQG_ParamGen",
11316 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11317 - "size=%d", sizeBits);
11318 + "size=%d, error code=%d", sizeBits, PORT_GetError());
11323 @@ -915,11 +959,12 @@
11324 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
11325 "PK11_PQG_VerifyParams",
11326 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11327 - "size=%d", sizeBits);
11328 + "size=%d, error code=%d", sizeBits, PORT_GetError());
11333 - slot = PK11_GetBestSlot(CKM_DSA_KEY_PAIR_GEN, NULL);
11334 + slot = xmlSecNssSlotGet(CKM_DSA_KEY_PAIR_GEN);
11335 PK11_Authenticate(slot, PR_TRUE, NULL /* default pwd callback */);
11336 privkey = PK11_GenerateKeyPair(slot, CKM_DSA_KEY_PAIR_GEN, pqgParams,
11337 &pubkey, PR_FALSE, PR_TRUE, NULL);
11338 @@ -929,8 +974,9 @@
11339 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
11340 "PK11_GenerateKeyPair",
11341 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11342 - XMLSEC_ERRORS_NO_MESSAGE);
11343 + "error code=%d", PORT_GetError());
11349 @@ -943,29 +989,32 @@
11350 XMLSEC_ERRORS_NO_MESSAGE);
11359 if (slot != NULL) {
11360 - PK11_FreeSlot(slot);
11361 + PK11_FreeSlot(slot);
11364 if (pqgParams != NULL) {
11365 - PK11_PQG_DestroyParams(pqgParams);
11366 + PK11_PQG_DestroyParams(pqgParams);
11369 if (pqgVerify != NULL) {
11370 - PK11_PQG_DestroyVerify(pqgVerify);
11374 + PK11_PQG_DestroyVerify(pqgVerify);
11377 if (pubkey != NULL) {
11378 - SECKEY_DestroyPublicKey(pubkey);
11379 + SECKEY_DestroyPublicKey(pubkey);
11382 if (privkey != NULL) {
11383 - SECKEY_DestroyPrivateKey(privkey);
11384 + SECKEY_DestroyPrivateKey(privkey);
11391 static xmlSecKeyDataType
11392 @@ -975,11 +1024,11 @@
11393 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecNssKeyDataDsaId), xmlSecKeyDataTypeUnknown);
11394 ctx = xmlSecNssPKIKeyDataGetCtx(data);
11395 xmlSecAssert2(ctx != NULL, -1);
11396 - xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == dsaKey, -1);
11397 +/* xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == dsaKey, -1);*/
11398 if (ctx->privkey != NULL) {
11399 - return(xmlSecKeyDataTypePrivate | xmlSecKeyDataTypePublic);
11401 - return(xmlSecKeyDataTypePublic);
11402 + return(xmlSecKeyDataTypePrivate | xmlSecKeyDataTypePublic);
11403 + } else if( ctx->pubkey != NULL ) {
11404 + return(xmlSecKeyDataTypePublic);
11407 return(xmlSecKeyDataTypeUnknown);
11408 @@ -992,7 +1041,7 @@
11409 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecNssKeyDataDsaId), 0);
11410 ctx = xmlSecNssPKIKeyDataGetCtx(data);
11411 xmlSecAssert2(ctx != NULL, -1);
11412 - xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == dsaKey, -1);
11413 +/* xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == dsaKey, -1);*/
11415 return(8 * SECKEY_PublicKeyStrength(ctx->pubkey));
11417 @@ -1084,7 +1133,11 @@
11418 static void xmlSecNssKeyDataRsaDebugXmlDump (xmlSecKeyDataPtr data,
11421 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
11422 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataRsaKlass = {
11424 static xmlSecKeyDataKlass xmlSecNssKeyDataRsaKlass = {
11426 sizeof(xmlSecKeyDataKlass),
11427 xmlSecNssPKIKeyDataSize,
11429 @@ -1181,13 +1234,13 @@
11433 - slot = PK11_GetBestSlot(CKM_RSA_PKCS, NULL);
11434 + slot = xmlSecNssSlotGet(CKM_RSA_PKCS);
11436 xmlSecError(XMLSEC_ERRORS_HERE,
11437 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11438 - "PK11_GetBestSlot",
11439 + "xmlSecNssSlotGet",
11440 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11441 - XMLSEC_ERRORS_NO_MESSAGE);
11442 + "error code=%d", PORT_GetError());
11446 @@ -1198,7 +1251,7 @@
11447 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11449 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11450 - XMLSEC_ERRORS_NO_MESSAGE);
11451 + "error code=%d", PORT_GetError());
11455 @@ -1210,7 +1263,7 @@
11456 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11457 "PORT_ArenaZAlloc",
11458 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11459 - XMLSEC_ERRORS_NO_MESSAGE);
11460 + "error code=%d", PORT_GetError());
11461 PORT_FreeArena(arena, PR_FALSE);
11464 @@ -1349,7 +1402,7 @@
11466 ctx = xmlSecNssPKIKeyDataGetCtx(xmlSecKeyGetValue(key));
11467 xmlSecAssert2(ctx != NULL, -1);
11468 - xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == rsaKey, -1);
11469 +/* xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == rsaKey, -1);*/
11472 if(((xmlSecKeyDataTypePublic | xmlSecKeyDataTypePrivate) & keyInfoCtx->keyReq.keyType) == 0) {
11473 @@ -1420,7 +1473,7 @@
11474 params.keySizeInBits = sizeBits;
11477 - slot = PK11_GetBestSlot(CKM_RSA_PKCS_KEY_PAIR_GEN, NULL);
11478 + slot = xmlSecNssSlotGet(CKM_RSA_PKCS_KEY_PAIR_GEN);
11479 PK11_Authenticate(slot, PR_TRUE, NULL /* default pwd callback */);
11480 privkey = PK11_GenerateKeyPair(slot, CKM_RSA_PKCS_KEY_PAIR_GEN, ¶ms,
11481 &pubkey, PR_FALSE, PR_TRUE, NULL);
11482 @@ -1430,7 +1483,7 @@
11483 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
11484 "PK11_GenerateKeyPair",
11485 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11486 - XMLSEC_ERRORS_NO_MESSAGE);
11487 + "error code=%d", PORT_GetError());
11491 @@ -1472,7 +1525,7 @@
11493 ctx = xmlSecNssPKIKeyDataGetCtx(data);
11494 xmlSecAssert2(ctx != NULL, -1);
11495 - xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == rsaKey, -1);
11496 +/* xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == rsaKey, -1);*/
11497 if (ctx->privkey != NULL) {
11498 return(xmlSecKeyDataTypePrivate | xmlSecKeyDataTypePublic);
11500 @@ -1490,7 +1543,7 @@
11502 ctx = xmlSecNssPKIKeyDataGetCtx(data);
11503 xmlSecAssert2(ctx != NULL, -1);
11504 - xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == rsaKey, -1);
11505 +/* xmlSecAssert2(SECKEY_GetPublicKeyType(ctx->pubkey) == rsaKey, -1);*/
11507 return(8 * SECKEY_PublicKeyStrength(ctx->pubkey));
11509 --- misc/xmlsec1-1.2.6/src/nss/signatures.c 2003-09-26 02:58:15.000000000 +0200
11510 +++ misc/build/xmlsec1-1.2.6/src/nss/signatures.c 2008-06-29 23:44:19.000000000 +0200
11511 @@ -199,7 +199,7 @@
11512 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11514 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11515 - XMLSEC_ERRORS_NO_MESSAGE);
11516 + "error code=%d", PORT_GetError());
11520 @@ -222,7 +222,7 @@
11521 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11522 "VFY_CreateContext",
11523 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11524 - XMLSEC_ERRORS_NO_MESSAGE);
11525 + "error code=%d", PORT_GetError());
11529 @@ -282,7 +282,7 @@
11530 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11531 "VFY_Update, VFY_End",
11532 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11533 - XMLSEC_ERRORS_NO_MESSAGE);
11534 + "error code=%d", PORT_GetError());
11536 if (PORT_GetError() == SEC_ERROR_PKCS7_BAD_SIGNATURE) {
11537 xmlSecError(XMLSEC_ERRORS_HERE,
11538 @@ -341,7 +341,7 @@
11539 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11541 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11542 - XMLSEC_ERRORS_NO_MESSAGE);
11543 + "error code=%d", PORT_GetError());
11547 @@ -351,7 +351,7 @@
11548 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11550 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11551 - XMLSEC_ERRORS_NO_MESSAGE);
11552 + "error code=%d", PORT_GetError());
11556 @@ -368,7 +368,7 @@
11557 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11559 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11560 - XMLSEC_ERRORS_NO_MESSAGE);
11561 + "error code=%d", PORT_GetError());
11565 @@ -378,7 +378,7 @@
11566 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11568 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11569 - XMLSEC_ERRORS_NO_MESSAGE);
11570 + "error code=%d", PORT_GetError());
11574 @@ -404,7 +404,7 @@
11575 xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
11577 XMLSEC_ERRORS_R_CRYPTO_FAILED,
11578 - XMLSEC_ERRORS_NO_MESSAGE);
11579 + "error code=%d", PORT_GetError());
11583 @@ -459,7 +459,11 @@
11585 ***************************************************************************/
11587 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
11588 +static struct _xmlSecTransformKlass xmlSecNssDsaSha1Klass = {
11590 static xmlSecTransformKlass xmlSecNssDsaSha1Klass = {
11592 /* klass/object sizes */
11593 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
11594 xmlSecNssSignatureSize, /* xmlSecSize objSize */
11595 @@ -506,7 +510,11 @@
11596 * RSA-SHA1 signature transform
11598 ***************************************************************************/
11599 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
11600 +static struct _xmlSecTransformKlass xmlSecNssRsaSha1Klass = {
11602 static xmlSecTransformKlass xmlSecNssRsaSha1Klass = {
11604 /* klass/object sizes */
11605 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
11606 xmlSecNssSignatureSize, /* xmlSecSize objSize */
11607 --- misc/xmlsec1-1.2.6/src/nss/symkeys.c 2003-07-21 05:12:52.000000000 +0200
11608 +++ misc/build/xmlsec1-1.2.6/src/nss/symkeys.c 2008-06-29 23:44:19.000000000 +0200
11609 @@ -15,178 +15,837 @@
11611 #include <string.h>
11613 +#include <pk11func.h>
11616 #include <xmlsec/xmlsec.h>
11617 #include <xmlsec/xmltree.h>
11618 +#include <xmlsec/base64.h>
11619 #include <xmlsec/keys.h>
11620 #include <xmlsec/keyinfo.h>
11621 #include <xmlsec/transforms.h>
11622 #include <xmlsec/errors.h>
11624 #include <xmlsec/nss/crypto.h>
11625 +#include <xmlsec/nss/ciphers.h>
11626 +#include <xmlsec/nss/tokens.h>
11628 /*****************************************************************************
11630 - * Symmetic (binary) keys - just a wrapper for xmlSecKeyDataBinary
11631 + * Symmetic (binary) keys - a wrapper over slot information and PK11SymKey
11633 ****************************************************************************/
11634 -static int xmlSecNssSymKeyDataInitialize (xmlSecKeyDataPtr data);
11635 -static int xmlSecNssSymKeyDataDuplicate (xmlSecKeyDataPtr dst,
11636 - xmlSecKeyDataPtr src);
11637 -static void xmlSecNssSymKeyDataFinalize (xmlSecKeyDataPtr data);
11638 -static int xmlSecNssSymKeyDataXmlRead (xmlSecKeyDataId id,
11639 - xmlSecKeyPtr key,
11641 - xmlSecKeyInfoCtxPtr keyInfoCtx);
11642 -static int xmlSecNssSymKeyDataXmlWrite (xmlSecKeyDataId id,
11643 - xmlSecKeyPtr key,
11645 - xmlSecKeyInfoCtxPtr keyInfoCtx);
11646 -static int xmlSecNssSymKeyDataBinRead (xmlSecKeyDataId id,
11647 - xmlSecKeyPtr key,
11648 - const xmlSecByte* buf,
11649 - xmlSecSize bufSize,
11650 - xmlSecKeyInfoCtxPtr keyInfoCtx);
11651 -static int xmlSecNssSymKeyDataBinWrite (xmlSecKeyDataId id,
11652 - xmlSecKeyPtr key,
11653 - xmlSecByte** buf,
11654 - xmlSecSize* bufSize,
11655 - xmlSecKeyInfoCtxPtr keyInfoCtx);
11656 -static int xmlSecNssSymKeyDataGenerate (xmlSecKeyDataPtr data,
11657 - xmlSecSize sizeBits,
11658 - xmlSecKeyDataType type);
11660 -static xmlSecKeyDataType xmlSecNssSymKeyDataGetType (xmlSecKeyDataPtr data);
11661 -static xmlSecSize xmlSecNssSymKeyDataGetSize (xmlSecKeyDataPtr data);
11662 -static void xmlSecNssSymKeyDataDebugDump (xmlSecKeyDataPtr data,
11664 -static void xmlSecNssSymKeyDataDebugXmlDump (xmlSecKeyDataPtr data,
11666 -static int xmlSecNssSymKeyDataKlassCheck (xmlSecKeyDataKlass* klass);
11667 +typedef struct _xmlSecNssSymKeyDataCtx xmlSecNssSymKeyDataCtx ;
11668 +typedef struct _xmlSecNssSymKeyDataCtx* xmlSecNssSymKeyDataCtxPtr ;
11670 +struct _xmlSecNssSymKeyDataCtx {
11671 + CK_MECHANISM_TYPE cipher ; /* the symmetic key mechanism */
11672 + PK11SlotInfo* slot ; /* the key resident slot */
11673 + PK11SymKey* symkey ; /* the symmetic key */
11676 +#define xmlSecNssSymKeyDataSize \
11677 + ( sizeof( xmlSecKeyData ) + sizeof( xmlSecNssSymKeyDataCtx ) )
11679 +#define xmlSecNssSymKeyDataGetCtx( data ) \
11680 + ( ( xmlSecNssSymKeyDataCtxPtr )( ( ( xmlSecByte* )( data ) ) + sizeof( xmlSecKeyData ) ) )
11683 +static int xmlSecNssSymKeyDataInitialize (xmlSecKeyDataPtr data);
11684 +static int xmlSecNssSymKeyDataDuplicate (xmlSecKeyDataPtr dst,
11685 + xmlSecKeyDataPtr src);
11686 +static void xmlSecNssSymKeyDataFinalize (xmlSecKeyDataPtr data);
11687 +static int xmlSecNssSymKeyDataXmlRead (xmlSecKeyDataId id,
11688 + xmlSecKeyPtr key,
11690 + xmlSecKeyInfoCtxPtr keyInfoCtx);
11691 +static int xmlSecNssSymKeyDataXmlWrite (xmlSecKeyDataId id,
11692 + xmlSecKeyPtr key,
11694 + xmlSecKeyInfoCtxPtr keyInfoCtx);
11695 +static int xmlSecNssSymKeyDataBinRead (xmlSecKeyDataId id,
11696 + xmlSecKeyPtr key,
11697 + const xmlSecByte* buf,
11698 + xmlSecSize bufSize,
11699 + xmlSecKeyInfoCtxPtr keyInfoCtx);
11700 +static int xmlSecNssSymKeyDataBinWrite (xmlSecKeyDataId id,
11701 + xmlSecKeyPtr key,
11702 + xmlSecByte** buf,
11703 + xmlSecSize* bufSize,
11704 + xmlSecKeyInfoCtxPtr keyInfoCtx);
11705 +static int xmlSecNssSymKeyDataGenerate (xmlSecKeyDataPtr data,
11706 + xmlSecSize sizeBits,
11707 + xmlSecKeyDataType type);
11709 +static xmlSecKeyDataType xmlSecNssSymKeyDataGetType (xmlSecKeyDataPtr data);
11710 +static xmlSecSize xmlSecNssSymKeyDataGetSize (xmlSecKeyDataPtr data);
11711 +static void xmlSecNssSymKeyDataDebugDump (xmlSecKeyDataPtr data,
11713 +static void xmlSecNssSymKeyDataDebugXmlDump (xmlSecKeyDataPtr data,
11715 +static int xmlSecNssSymKeyDataKlassCheck (xmlSecKeyDataKlass* klass);
11717 #define xmlSecNssSymKeyDataCheckId(data) \
11718 (xmlSecKeyDataIsValid((data)) && \
11719 xmlSecNssSymKeyDataKlassCheck((data)->id))
11722 + * xmlSecNssSymKeyDataAdoptKey:
11723 + * @data: the pointer to symmetric key data.
11724 + * @symkey: the symmetric key
11726 + * Set the value of symmetric key data.
11728 + * Returns 0 on success or a negative value if an error occurs.
11731 +xmlSecNssSymKeyDataAdoptKey(
11732 + xmlSecKeyDataPtr data ,
11733 + PK11SymKey* symkey
11735 + xmlSecNssSymKeyDataCtxPtr context = NULL ;
11737 + xmlSecAssert2( xmlSecNssSymKeyDataCheckId( data ), -1 ) ;
11738 + xmlSecAssert2( xmlSecKeyDataCheckSize( data, xmlSecNssSymKeyDataSize ), -1 ) ;
11739 + xmlSecAssert2( symkey != NULL, -1 ) ;
11741 + context = xmlSecNssSymKeyDataGetCtx( data ) ;
11742 + xmlSecAssert2(context != NULL, -1);
11744 + context->cipher = PK11_GetMechanism( symkey ) ;
11746 + if( context->slot != NULL ) {
11747 + PK11_FreeSlot( context->slot ) ;
11748 + context->slot = NULL ;
11750 + context->slot = PK11_GetSlotFromKey( symkey ) ;
11752 + if( context->symkey != NULL ) {
11753 + PK11_FreeSymKey( context->symkey ) ;
11754 + context->symkey = NULL ;
11756 + context->symkey = PK11_ReferenceSymKey( symkey ) ;
11761 +xmlSecKeyDataPtr xmlSecNssSymKeyDataKeyAdopt(
11762 + PK11SymKey* symKey
11764 + xmlSecKeyDataPtr data = NULL ;
11765 + CK_MECHANISM_TYPE mechanism = CKM_INVALID_MECHANISM ;
11767 + xmlSecAssert2( symKey != NULL , NULL ) ;
11769 + mechanism = PK11_GetMechanism( symKey ) ;
11770 + switch( mechanism ) {
11771 + case CKM_DES3_KEY_GEN :
11772 + case CKM_DES3_CBC :
11773 + case CKM_DES3_MAC :
11774 + data = xmlSecKeyDataCreate( xmlSecNssKeyDataDesId ) ;
11775 + if( data == NULL ) {
11776 + xmlSecError( XMLSEC_ERRORS_HERE ,
11778 + "xmlSecKeyDataCreate" ,
11779 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
11780 + "xmlSecNssKeyDataDesId" ) ;
11784 + case CKM_AES_KEY_GEN :
11785 + case CKM_AES_CBC :
11786 + case CKM_AES_MAC :
11787 + data = xmlSecKeyDataCreate( xmlSecNssKeyDataAesId ) ;
11788 + if( data == NULL ) {
11789 + xmlSecError( XMLSEC_ERRORS_HERE ,
11791 + "xmlSecKeyDataCreate" ,
11792 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
11793 + "xmlSecNssKeyDataDesId" ) ;
11798 + xmlSecError( XMLSEC_ERRORS_HERE ,
11801 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
11802 + "Unsupported mechanism" ) ;
11806 + if( xmlSecNssSymKeyDataAdoptKey( data , symKey ) < 0 ) {
11807 + xmlSecError( XMLSEC_ERRORS_HERE ,
11809 + "xmlSecNssSymKeyDataAdoptKey" ,
11810 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
11811 + XMLSEC_ERRORS_NO_MESSAGE ) ;
11813 + xmlSecKeyDataDestroy( data ) ;
11822 +xmlSecNssSymKeyDataGetKey(
11823 + xmlSecKeyDataPtr data
11825 + xmlSecNssSymKeyDataCtxPtr ctx;
11826 + PK11SymKey* symkey ;
11828 + xmlSecAssert2(xmlSecNssSymKeyDataCheckId(data), NULL);
11829 + xmlSecAssert2(xmlSecKeyDataCheckSize(data, xmlSecNssSymKeyDataSize), NULL);
11831 + ctx = xmlSecNssSymKeyDataGetCtx(data);
11832 + xmlSecAssert2(ctx != NULL, NULL);
11834 + if( ctx->symkey != NULL ) {
11835 + symkey = PK11_ReferenceSymKey( ctx->symkey ) ;
11844 xmlSecNssSymKeyDataInitialize(xmlSecKeyDataPtr data) {
11845 + xmlSecNssSymKeyDataCtxPtr ctx;
11847 xmlSecAssert2(xmlSecNssSymKeyDataCheckId(data), -1);
11849 - return(xmlSecKeyDataBinaryValueInitialize(data));
11850 + xmlSecAssert2(xmlSecKeyDataCheckSize(data, xmlSecNssSymKeyDataSize), -1);
11852 + ctx = xmlSecNssSymKeyDataGetCtx(data);
11853 + xmlSecAssert2(ctx != NULL, -1);
11855 + memset( ctx, 0, sizeof(xmlSecNssSymKeyDataCtx));
11857 + /* Set the block cipher mechanism */
11858 +#ifndef XMLSEC_NO_DES
11859 + if(xmlSecKeyDataCheckId(data, xmlSecNssKeyDataDesId)) {
11860 + ctx->cipher = CKM_DES3_KEY_GEN;
11862 +#endif /* XMLSEC_NO_DES */
11864 +#ifndef XMLSEC_NO_AES
11865 + if(xmlSecKeyDataCheckId(data, xmlSecNssKeyDataDesId)) {
11866 + ctx->cipher = CKM_AES_KEY_GEN;
11868 +#endif /* XMLSEC_NO_AES */
11871 + xmlSecError( XMLSEC_ERRORS_HERE ,
11872 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
11874 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
11875 + "Unsupported block cipher" ) ;
11883 xmlSecNssSymKeyDataDuplicate(xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src) {
11884 + xmlSecNssSymKeyDataCtxPtr ctxDst;
11885 + xmlSecNssSymKeyDataCtxPtr ctxSrc;
11887 xmlSecAssert2(xmlSecNssSymKeyDataCheckId(dst), -1);
11888 + xmlSecAssert2(xmlSecKeyDataCheckSize(dst, xmlSecNssSymKeyDataSize), -1);
11889 xmlSecAssert2(xmlSecNssSymKeyDataCheckId(src), -1);
11890 + xmlSecAssert2(xmlSecKeyDataCheckSize(src, xmlSecNssSymKeyDataSize), -1);
11891 xmlSecAssert2(dst->id == src->id, -1);
11893 - return(xmlSecKeyDataBinaryValueDuplicate(dst, src));
11895 + ctxDst = xmlSecNssSymKeyDataGetCtx(dst);
11896 + xmlSecAssert2(ctxDst != NULL, -1);
11898 + ctxSrc = xmlSecNssSymKeyDataGetCtx(src);
11899 + xmlSecAssert2(ctxSrc != NULL, -1);
11901 + ctxDst->cipher = ctxSrc->cipher ;
11903 + if( ctxSrc->slot != NULL ) {
11904 + if( ctxDst->slot != NULL && ctxDst->slot != ctxSrc->slot ) {
11905 + PK11_FreeSlot( ctxDst->slot ) ;
11906 + ctxDst->slot = NULL ;
11909 + if( ctxDst->slot == NULL && ctxSrc->slot != NULL )
11910 + ctxDst->slot = PK11_ReferenceSlot( ctxSrc->slot ) ;
11912 + if( ctxDst->slot != NULL ) {
11913 + PK11_FreeSlot( ctxDst->slot ) ;
11914 + ctxDst->slot = NULL ;
11918 + if( ctxSrc->symkey != NULL ) {
11919 + if( ctxDst->symkey != NULL && ctxDst->symkey != ctxSrc->symkey ) {
11920 + PK11_FreeSymKey( ctxDst->symkey ) ;
11921 + ctxDst->symkey = NULL ;
11924 + if( ctxDst->symkey == NULL && ctxSrc->symkey != NULL )
11925 + ctxDst->symkey = PK11_ReferenceSymKey( ctxSrc->symkey ) ;
11927 + if( ctxDst->symkey != NULL ) {
11928 + PK11_FreeSymKey( ctxDst->symkey ) ;
11929 + ctxDst->symkey = NULL ;
11937 xmlSecNssSymKeyDataFinalize(xmlSecKeyDataPtr data) {
11938 + xmlSecNssSymKeyDataCtxPtr ctx;
11940 xmlSecAssert(xmlSecNssSymKeyDataCheckId(data));
11942 - xmlSecKeyDataBinaryValueFinalize(data);
11943 + xmlSecAssert(xmlSecKeyDataCheckSize(data, xmlSecNssSymKeyDataSize));
11945 + ctx = xmlSecNssSymKeyDataGetCtx(data);
11946 + xmlSecAssert(ctx != NULL);
11948 + if( ctx->slot != NULL ) {
11949 + PK11_FreeSlot( ctx->slot ) ;
11950 + ctx->slot = NULL ;
11953 + if( ctx->symkey != NULL ) {
11954 + PK11_FreeSymKey( ctx->symkey ) ;
11955 + ctx->symkey = NULL ;
11958 + ctx->cipher = CKM_INVALID_MECHANISM ;
11962 xmlSecNssSymKeyDataXmlRead(xmlSecKeyDataId id, xmlSecKeyPtr key,
11963 - xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
11964 - xmlSecAssert2(xmlSecNssSymKeyDataKlassCheck(id), -1);
11965 + xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
11966 + PK11SymKey* symKey ;
11967 + PK11SlotInfo* slot ;
11968 + xmlSecBufferPtr keyBuf;
11970 + xmlSecKeyDataPtr data;
11971 + xmlSecNssSymKeyDataCtxPtr ctx;
11972 + SECItem keyItem ;
11975 + xmlSecAssert2(id != xmlSecKeyDataIdUnknown, -1);
11976 + xmlSecAssert2(key != NULL, -1);
11977 + xmlSecAssert2(node != NULL, -1);
11978 + xmlSecAssert2(keyInfoCtx != NULL, -1);
11980 + /* Create a new KeyData from a id */
11981 + data = xmlSecKeyDataCreate(id);
11982 + if(data == NULL ) {
11983 + xmlSecError(XMLSEC_ERRORS_HERE,
11984 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11985 + "xmlSecKeyDataCreate",
11986 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
11987 + XMLSEC_ERRORS_NO_MESSAGE);
11991 + ctx = xmlSecNssSymKeyDataGetCtx(data);
11992 + xmlSecAssert2(ctx != NULL, -1);
11994 + /* Create a buffer for raw symmetric key value */
11995 + if( ( keyBuf = xmlSecBufferCreate( 128 ) ) == NULL ) {
11996 + xmlSecError( XMLSEC_ERRORS_HERE ,
11997 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
11998 + "xmlSecBufferCreate" ,
11999 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12000 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12001 + xmlSecKeyDataDestroy( data ) ;
12005 + /* Read the raw key value */
12006 + if( xmlSecBufferBase64NodeContentRead( keyBuf , node ) < 0 ) {
12007 + xmlSecError( XMLSEC_ERRORS_HERE ,
12008 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12009 + xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
12010 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12011 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12013 + xmlSecBufferDestroy( keyBuf ) ;
12014 + xmlSecKeyDataDestroy( data ) ;
12019 + slot = xmlSecNssSlotGet(ctx->cipher);
12020 + if( slot == NULL ) {
12021 + xmlSecError( XMLSEC_ERRORS_HERE ,
12022 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12023 + "xmlSecNssSlotGet" ,
12024 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12025 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12027 + xmlSecBufferDestroy( keyBuf ) ;
12028 + xmlSecKeyDataDestroy( data ) ;
12032 + /* Wrap the raw key value SECItem */
12033 + keyItem.type = siBuffer ;
12034 + keyItem.data = xmlSecBufferGetData( keyBuf ) ;
12035 + keyItem.len = xmlSecBufferGetSize( keyBuf ) ;
12037 + /* Import the raw key into slot temporalily and get the key handler*/
12038 + symKey = PK11_ImportSymKey(slot, ctx->cipher, PK11_OriginGenerated, CKA_VALUE, &keyItem, NULL ) ;
12039 + if( symKey == NULL ) {
12040 + xmlSecError( XMLSEC_ERRORS_HERE ,
12041 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12042 + "PK11_ImportSymKey" ,
12043 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12044 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12046 + PK11_FreeSlot( slot ) ;
12047 + xmlSecBufferDestroy( keyBuf ) ;
12048 + xmlSecKeyDataDestroy( data ) ;
12051 + PK11_FreeSlot( slot ) ;
12053 + /* raw key material has been copied into symKey, it isn't used any more */
12054 + xmlSecBufferDestroy( keyBuf ) ;
12056 - return(xmlSecKeyDataBinaryValueXmlRead(id, key, node, keyInfoCtx));
12057 + /* Adopt the symmetric key into key data */
12058 + ret = xmlSecNssSymKeyDataAdoptKey(data, symKey);
12060 + xmlSecError(XMLSEC_ERRORS_HERE,
12061 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12062 + "xmlSecKeyDataBinaryValueSetBuffer",
12063 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12064 + XMLSEC_ERRORS_NO_MESSAGE);
12065 + PK11_FreeSymKey( symKey ) ;
12066 + xmlSecKeyDataDestroy( data ) ;
12069 + /* symKey has been duplicated into data, it isn't used any more */
12070 + PK11_FreeSymKey( symKey ) ;
12072 + /* Check value */
12073 + if(xmlSecKeyReqMatchKeyValue(&(keyInfoCtx->keyReq), data) != 1) {
12074 + xmlSecError(XMLSEC_ERRORS_HERE,
12075 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12076 + "xmlSecKeyReqMatchKeyValue",
12077 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12078 + XMLSEC_ERRORS_NO_MESSAGE);
12079 + xmlSecKeyDataDestroy( data ) ;
12083 + ret = xmlSecKeySetValue(key, data);
12085 + xmlSecError(XMLSEC_ERRORS_HERE,
12086 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12087 + "xmlSecKeySetValue",
12088 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12089 + XMLSEC_ERRORS_NO_MESSAGE);
12090 + xmlSecKeyDataDestroy( data ) ;
12098 xmlSecNssSymKeyDataXmlWrite(xmlSecKeyDataId id, xmlSecKeyPtr key,
12099 - xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
12100 + xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
12101 + PK11SymKey* symKey ;
12103 xmlSecAssert2(xmlSecNssSymKeyDataKlassCheck(id), -1);
12104 + xmlSecAssert2(key != NULL, -1);
12105 + xmlSecAssert2(node != NULL, -1);
12106 + xmlSecAssert2(keyInfoCtx != NULL, -1);
12108 + /* Get symmetric key from "key" */
12109 + symKey = xmlSecNssSymKeyDataGetKey(xmlSecKeyGetValue(key));
12110 + if( symKey != NULL ) {
12111 + SECItem* keyItem ;
12112 + xmlSecBufferPtr keyBuf ;
12114 + /* Extract raw key data from symmetric key */
12115 + if( PK11_ExtractKeyValue( symKey ) != SECSuccess ) {
12116 + xmlSecError(XMLSEC_ERRORS_HERE,
12117 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12118 + "PK11_ExtractKeyValue",
12119 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12120 + XMLSEC_ERRORS_NO_MESSAGE);
12121 + PK11_FreeSymKey( symKey ) ;
12125 + /* Get raw key data from "symKey" */
12126 + keyItem = PK11_GetKeyData( symKey ) ;
12127 + if(keyItem == NULL) {
12128 + xmlSecError(XMLSEC_ERRORS_HERE,
12129 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12130 + "PK11_GetKeyData",
12131 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12132 + XMLSEC_ERRORS_NO_MESSAGE);
12133 + PK11_FreeSymKey( symKey ) ;
12137 + /* Create key data buffer with raw kwy material */
12138 + keyBuf = xmlSecBufferCreate(keyItem->len) ;
12139 + if(keyBuf == NULL) {
12140 + xmlSecError(XMLSEC_ERRORS_HERE,
12141 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12142 + "xmlSecBufferCreate",
12143 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12144 + XMLSEC_ERRORS_NO_MESSAGE);
12145 + PK11_FreeSymKey( symKey ) ;
12149 + xmlSecBufferSetData( keyBuf , keyItem->data , keyItem->len ) ;
12151 + /* Write raw key material into current xml node */
12152 + if( xmlSecBufferBase64NodeContentWrite( keyBuf, node, XMLSEC_BASE64_LINESIZE ) < 0 ) {
12153 + xmlSecError(XMLSEC_ERRORS_HERE,
12154 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12155 + "xmlSecBufferBase64NodeContentWrite",
12156 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12157 + XMLSEC_ERRORS_NO_MESSAGE);
12158 + xmlSecBufferDestroy(keyBuf);
12159 + PK11_FreeSymKey( symKey ) ;
12162 + xmlSecBufferDestroy(keyBuf);
12163 + PK11_FreeSymKey( symKey ) ;
12166 - return(xmlSecKeyDataBinaryValueXmlWrite(id, key, node, keyInfoCtx));
12171 xmlSecNssSymKeyDataBinRead(xmlSecKeyDataId id, xmlSecKeyPtr key,
12172 - const xmlSecByte* buf, xmlSecSize bufSize,
12173 - xmlSecKeyInfoCtxPtr keyInfoCtx) {
12174 - xmlSecAssert2(xmlSecNssSymKeyDataKlassCheck(id), -1);
12175 + const xmlSecByte* buf, xmlSecSize bufSize,
12176 + xmlSecKeyInfoCtxPtr keyInfoCtx) {
12177 + PK11SymKey* symKey ;
12178 + PK11SlotInfo* slot ;
12179 + xmlSecKeyDataPtr data;
12180 + xmlSecNssSymKeyDataCtxPtr ctx;
12181 + SECItem keyItem ;
12184 - return(xmlSecKeyDataBinaryValueBinRead(id, key, buf, bufSize, keyInfoCtx));
12185 + xmlSecAssert2(id != xmlSecKeyDataIdUnknown, -1);
12186 + xmlSecAssert2(key != NULL, -1);
12187 + xmlSecAssert2(buf != NULL, -1);
12188 + xmlSecAssert2(bufSize != 0, -1);
12189 + xmlSecAssert2(keyInfoCtx != NULL, -1);
12191 + /* Create a new KeyData from a id */
12192 + data = xmlSecKeyDataCreate(id);
12193 + if(data == NULL ) {
12194 + xmlSecError(XMLSEC_ERRORS_HERE,
12195 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12196 + "xmlSecKeyDataCreate",
12197 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12198 + XMLSEC_ERRORS_NO_MESSAGE);
12202 + ctx = xmlSecNssSymKeyDataGetCtx(data);
12203 + xmlSecAssert2(ctx != NULL, -1);
12206 + slot = xmlSecNssSlotGet(ctx->cipher);
12207 + if( slot == NULL ) {
12208 + xmlSecError( XMLSEC_ERRORS_HERE ,
12209 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12210 + "xmlSecNssSlotGet" ,
12211 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12212 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12213 + xmlSecKeyDataDestroy( data ) ;
12217 + /* Wrap the raw key value SECItem */
12218 + keyItem.type = siBuffer ;
12219 + keyItem.data = buf ;
12220 + keyItem.len = bufSize ;
12222 + /* Import the raw key into slot temporalily and get the key handler*/
12223 + symKey = PK11_ImportSymKey(slot, ctx->cipher, PK11_OriginGenerated, CKA_VALUE, &keyItem, NULL ) ;
12224 + if( symKey == NULL ) {
12225 + xmlSecError( XMLSEC_ERRORS_HERE ,
12226 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12227 + "PK11_ImportSymKey" ,
12228 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12229 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12230 + PK11_FreeSlot( slot ) ;
12231 + xmlSecKeyDataDestroy( data ) ;
12235 + /* Adopt the symmetric key into key data */
12236 + ret = xmlSecNssSymKeyDataAdoptKey(data, symKey);
12238 + xmlSecError(XMLSEC_ERRORS_HERE,
12239 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12240 + "xmlSecKeyDataBinaryValueSetBuffer",
12241 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12242 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12243 + PK11_FreeSymKey( symKey ) ;
12244 + PK11_FreeSlot( slot ) ;
12245 + xmlSecKeyDataDestroy( data ) ;
12248 + /* symKey has been duplicated into data, it isn't used any more */
12249 + PK11_FreeSymKey( symKey ) ;
12250 + PK11_FreeSlot( slot ) ;
12252 + /* Check value */
12253 + if(xmlSecKeyReqMatchKeyValue(&(keyInfoCtx->keyReq), data) != 1) {
12254 + xmlSecError(XMLSEC_ERRORS_HERE,
12255 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12256 + "xmlSecKeyReqMatchKeyValue",
12257 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12258 + XMLSEC_ERRORS_NO_MESSAGE);
12259 + xmlSecKeyDataDestroy( data ) ;
12263 + ret = xmlSecKeySetValue(key, data);
12265 + xmlSecError(XMLSEC_ERRORS_HERE,
12266 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12267 + "xmlSecKeySetValue",
12268 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12269 + XMLSEC_ERRORS_NO_MESSAGE);
12270 + xmlSecKeyDataDestroy( data ) ;
12278 xmlSecNssSymKeyDataBinWrite(xmlSecKeyDataId id, xmlSecKeyPtr key,
12279 - xmlSecByte** buf, xmlSecSize* bufSize,
12280 - xmlSecKeyInfoCtxPtr keyInfoCtx) {
12281 + xmlSecByte** buf, xmlSecSize* bufSize,
12282 + xmlSecKeyInfoCtxPtr keyInfoCtx) {
12283 + PK11SymKey* symKey ;
12285 xmlSecAssert2(xmlSecNssSymKeyDataKlassCheck(id), -1);
12286 + xmlSecAssert2(key != NULL, -1);
12287 + xmlSecAssert2(buf != NULL, -1);
12288 + xmlSecAssert2(bufSize != 0, -1);
12289 + xmlSecAssert2(keyInfoCtx != NULL, -1);
12291 + /* Get symmetric key from "key" */
12292 + symKey = xmlSecNssSymKeyDataGetKey(xmlSecKeyGetValue(key));
12293 + if( symKey != NULL ) {
12294 + SECItem* keyItem ;
12296 + /* Extract raw key data from symmetric key */
12297 + if( PK11_ExtractKeyValue( symKey ) != SECSuccess ) {
12298 + xmlSecError(XMLSEC_ERRORS_HERE,
12299 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12300 + "PK11_ExtractKeyValue",
12301 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12302 + XMLSEC_ERRORS_NO_MESSAGE);
12303 + PK11_FreeSymKey( symKey ) ;
12307 + /* Get raw key data from "symKey" */
12308 + keyItem = PK11_GetKeyData( symKey ) ;
12309 + if(keyItem == NULL) {
12310 + xmlSecError(XMLSEC_ERRORS_HERE,
12311 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12312 + "PK11_GetKeyData",
12313 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12314 + XMLSEC_ERRORS_NO_MESSAGE);
12315 + PK11_FreeSymKey( symKey ) ;
12319 + *bufSize = keyItem->len;
12320 + *buf = ( xmlSecByte* )xmlMalloc( *bufSize );
12321 + if( *buf == NULL ) {
12322 + xmlSecError(XMLSEC_ERRORS_HERE,
12323 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
12325 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12326 + XMLSEC_ERRORS_NO_MESSAGE);
12327 + PK11_FreeSymKey( symKey ) ;
12331 + memcpy((*buf), keyItem->data, (*bufSize));
12332 + PK11_FreeSymKey( symKey ) ;
12335 - return(xmlSecKeyDataBinaryValueBinWrite(id, key, buf, bufSize, keyInfoCtx));
12340 xmlSecNssSymKeyDataGenerate(xmlSecKeyDataPtr data, xmlSecSize sizeBits, xmlSecKeyDataType type ATTRIBUTE_UNUSED) {
12341 - xmlSecBufferPtr buffer;
12343 + PK11SymKey* symkey ;
12344 + PK11SlotInfo* slot ;
12345 + xmlSecNssSymKeyDataCtxPtr ctx;
12348 xmlSecAssert2(xmlSecNssSymKeyDataCheckId(data), -1);
12349 xmlSecAssert2(sizeBits > 0, -1);
12351 - buffer = xmlSecKeyDataBinaryValueGetBuffer(data);
12352 - xmlSecAssert2(buffer != NULL, -1);
12354 - return(xmlSecNssGenerateRandom(buffer, (sizeBits + 7) / 8));
12355 + ctx = xmlSecNssSymKeyDataGetCtx(data);
12356 + xmlSecAssert2(ctx != NULL, -1);
12358 + if( sizeBits % 8 != 0 ) {
12359 + xmlSecError(XMLSEC_ERRORS_HERE,
12360 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
12362 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
12363 + "Symmetric key size must be octuple");
12368 + slot = xmlSecNssSlotGet(ctx->cipher);
12369 + if( slot == NULL ) {
12370 + xmlSecError( XMLSEC_ERRORS_HERE ,
12371 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
12372 + "xmlSecNssSlotGet" ,
12373 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12374 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12378 + if( PK11_Authenticate( slot, PR_FALSE , NULL ) != SECSuccess ) {
12379 + xmlSecError( XMLSEC_ERRORS_HERE ,
12380 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
12381 + "PK11_Authenticate" ,
12382 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
12383 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12384 + PK11_FreeSlot( slot ) ;
12388 + symkey = PK11_KeyGen( slot , ctx->cipher , NULL , sizeBits/8 , NULL ) ;
12389 + if( symkey == NULL ) {
12390 + xmlSecError( XMLSEC_ERRORS_HERE ,
12391 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
12393 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
12394 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12395 + PK11_FreeSlot( slot ) ;
12399 + if( ctx->slot != NULL ) {
12400 + PK11_FreeSlot( ctx->slot ) ;
12401 + ctx->slot = NULL ;
12403 + ctx->slot = slot ;
12405 + if( ctx->symkey != NULL ) {
12406 + PK11_FreeSymKey( ctx->symkey ) ;
12407 + ctx->symkey = NULL ;
12409 + ctx->symkey = symkey ;
12414 static xmlSecKeyDataType
12415 xmlSecNssSymKeyDataGetType(xmlSecKeyDataPtr data) {
12416 - xmlSecBufferPtr buffer;
12417 + xmlSecNssSymKeyDataCtxPtr context = NULL ;
12418 + xmlSecKeyDataType type = xmlSecKeyDataTypeUnknown ;
12420 xmlSecAssert2(xmlSecNssSymKeyDataCheckId(data), xmlSecKeyDataTypeUnknown);
12421 + xmlSecAssert2( xmlSecKeyDataCheckSize( data, xmlSecNssSymKeyDataSize ), xmlSecKeyDataTypeUnknown ) ;
12423 - buffer = xmlSecKeyDataBinaryValueGetBuffer(data);
12424 - xmlSecAssert2(buffer != NULL, xmlSecKeyDataTypeUnknown);
12425 + context = xmlSecNssSymKeyDataGetCtx( data ) ;
12426 + if( context == NULL ) {
12427 + xmlSecError( XMLSEC_ERRORS_HERE ,
12428 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
12429 + "xmlSecNssSymKeyDataGetCtx" ,
12430 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
12431 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12432 + return xmlSecKeyDataTypeUnknown ;
12435 + if( context->symkey != NULL ) {
12436 + type |= xmlSecKeyDataTypeSymmetric ;
12438 + type |= xmlSecKeyDataTypeUnknown ;
12441 - return((xmlSecBufferGetSize(buffer) > 0) ? xmlSecKeyDataTypeSymmetric : xmlSecKeyDataTypeUnknown);
12446 xmlSecNssSymKeyDataGetSize(xmlSecKeyDataPtr data) {
12447 + xmlSecNssSymKeyDataCtxPtr context ;
12448 + unsigned int length = 0 ;
12450 xmlSecAssert2(xmlSecNssSymKeyDataCheckId(data), 0);
12452 - return(xmlSecKeyDataBinaryValueGetSize(data));
12453 + xmlSecAssert2( xmlSecKeyDataCheckSize( data, xmlSecNssSymKeyDataSize ), 0 ) ;
12455 + context = xmlSecNssSymKeyDataGetCtx( data ) ;
12456 + if( context == NULL ) {
12457 + xmlSecError( XMLSEC_ERRORS_HERE ,
12458 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
12459 + "xmlSecNssSymKeyDataGetCtx" ,
12460 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
12461 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12465 + if( context->symkey != NULL ) {
12466 + length = PK11_GetKeyLength( context->symkey ) ;
12474 xmlSecNssSymKeyDataDebugDump(xmlSecKeyDataPtr data, FILE* output) {
12475 xmlSecAssert(xmlSecNssSymKeyDataCheckId(data));
12477 - xmlSecKeyDataBinaryValueDebugDump(data, output);
12478 + /* print only size, everything else is sensitive */
12479 + fprintf( output , "=== %s: size=%d\n" , data->id->dataNodeName ,
12480 + xmlSecKeyDataGetSize(data)) ;
12484 xmlSecNssSymKeyDataDebugXmlDump(xmlSecKeyDataPtr data, FILE* output) {
12485 xmlSecAssert(xmlSecNssSymKeyDataCheckId(data));
12487 - xmlSecKeyDataBinaryValueDebugXmlDump(data, output);
12488 + /* print only size, everything else is sensitive */
12489 + fprintf( output , "<%s size=\"%d\" />\n" , data->id->dataNodeName ,
12490 + xmlSecKeyDataGetSize(data)) ;
12494 xmlSecNssSymKeyDataKlassCheck(xmlSecKeyDataKlass* klass) {
12495 #ifndef XMLSEC_NO_DES
12496 if(klass == xmlSecNssKeyDataDesId) {
12500 #endif /* XMLSEC_NO_DES */
12502 #ifndef XMLSEC_NO_AES
12503 if(klass == xmlSecNssKeyDataAesId) {
12507 #endif /* XMLSEC_NO_AES */
12509 #ifndef XMLSEC_NO_HMAC
12510 if(klass == xmlSecNssKeyDataHmacId) {
12514 #endif /* XMLSEC_NO_HMAC */
12516 @@ -199,42 +858,46 @@
12517 * <xmlsec:AESKeyValue> processing
12519 *************************************************************************/
12520 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
12521 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataAesKlass = {
12523 static xmlSecKeyDataKlass xmlSecNssKeyDataAesKlass = {
12525 sizeof(xmlSecKeyDataKlass),
12526 - xmlSecKeyDataBinarySize,
12527 + xmlSecNssSymKeyDataSize,
12530 xmlSecNameAESKeyValue,
12531 xmlSecKeyDataUsageKeyValueNode | xmlSecKeyDataUsageRetrievalMethodNodeXml,
12532 - /* xmlSecKeyDataUsage usage; */
12533 - xmlSecHrefAESKeyValue, /* const xmlChar* href; */
12534 - xmlSecNodeAESKeyValue, /* const xmlChar* dataNodeName; */
12535 - xmlSecNs, /* const xmlChar* dataNodeNs; */
12536 + /* xmlSecKeyDataUsage usage; */
12537 + xmlSecHrefAESKeyValue, /* const xmlChar* href; */
12538 + xmlSecNodeAESKeyValue, /* const xmlChar* dataNodeName; */
12539 + xmlSecNs, /* const xmlChar* dataNodeNs; */
12541 /* constructors/destructor */
12542 - xmlSecNssSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */
12543 - xmlSecNssSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */
12544 - xmlSecNssSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */
12545 - xmlSecNssSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */
12546 + xmlSecNssSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */
12547 + xmlSecNssSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */
12548 + xmlSecNssSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */
12549 + xmlSecNssSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */
12552 - xmlSecNssSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */
12553 - xmlSecNssSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */
12554 - NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */
12555 + xmlSecNssSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */
12556 + xmlSecNssSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */
12557 + NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */
12560 - xmlSecNssSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */
12561 - xmlSecNssSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */
12562 - xmlSecNssSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */
12563 - xmlSecNssSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */
12564 + xmlSecNssSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */
12565 + xmlSecNssSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */
12566 + xmlSecNssSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */
12567 + xmlSecNssSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */
12570 - xmlSecNssSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */
12571 - xmlSecNssSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */
12572 + xmlSecNssSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */
12573 + xmlSecNssSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */
12575 /* reserved for the future */
12576 - NULL, /* void* reserved0; */
12577 - NULL, /* void* reserved1; */
12578 + NULL, /* void* reserved0; */
12579 + NULL, /* void* reserved1; */
12583 @@ -251,9 +914,9 @@
12586 * xmlSecNssKeyDataAesSet:
12587 - * @data: the pointer to AES key data.
12588 - * @buf: the pointer to key value.
12589 - * @bufSize: the key value size (in bytes).
12590 + * @data: the pointer to AES key data.
12591 + * @buf: the pointer to key value.
12592 + * @bufSize: the key value size (in bytes).
12594 * Sets the value of AES key data.
12596 @@ -280,42 +943,46 @@
12597 * <xmlsec:DESKeyValue> processing
12599 *************************************************************************/
12600 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
12601 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataDesKlass = {
12603 static xmlSecKeyDataKlass xmlSecNssKeyDataDesKlass = {
12605 sizeof(xmlSecKeyDataKlass),
12606 - xmlSecKeyDataBinarySize,
12607 + xmlSecNssSymKeyDataSize,
12610 xmlSecNameDESKeyValue,
12611 xmlSecKeyDataUsageKeyValueNode | xmlSecKeyDataUsageRetrievalMethodNodeXml,
12612 - /* xmlSecKeyDataUsage usage; */
12613 - xmlSecHrefDESKeyValue, /* const xmlChar* href; */
12614 - xmlSecNodeDESKeyValue, /* const xmlChar* dataNodeName; */
12615 - xmlSecNs, /* const xmlChar* dataNodeNs; */
12616 + /* xmlSecKeyDataUsage usage; */
12617 + xmlSecHrefDESKeyValue, /* const xmlChar* href; */
12618 + xmlSecNodeDESKeyValue, /* const xmlChar* dataNodeName; */
12619 + xmlSecNs, /* const xmlChar* dataNodeNs; */
12621 /* constructors/destructor */
12622 - xmlSecNssSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */
12623 - xmlSecNssSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */
12624 - xmlSecNssSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */
12625 - xmlSecNssSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */
12626 + xmlSecNssSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */
12627 + xmlSecNssSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */
12628 + xmlSecNssSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */
12629 + xmlSecNssSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */
12632 - xmlSecNssSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */
12633 - xmlSecNssSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */
12634 - NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */
12635 + xmlSecNssSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */
12636 + xmlSecNssSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */
12637 + NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */
12640 - xmlSecNssSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */
12641 - xmlSecNssSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */
12642 - xmlSecNssSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */
12643 - xmlSecNssSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */
12644 + xmlSecNssSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */
12645 + xmlSecNssSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */
12646 + xmlSecNssSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */
12647 + xmlSecNssSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */
12650 - xmlSecNssSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */
12651 - xmlSecNssSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */
12652 + xmlSecNssSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */
12653 + xmlSecNssSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */
12655 /* reserved for the future */
12656 - NULL, /* void* reserved0; */
12657 - NULL, /* void* reserved1; */
12658 + NULL, /* void* reserved0; */
12659 + NULL, /* void* reserved1; */
12663 @@ -332,9 +999,9 @@
12666 * xmlSecNssKeyDataDesSet:
12667 - * @data: the pointer to DES key data.
12668 - * @buf: the pointer to key value.
12669 - * @bufSize: the key value size (in bytes).
12670 + * @data: the pointer to DES key data.
12671 + * @buf: the pointer to key value.
12672 + * @bufSize: the key value size (in bytes).
12674 * Sets the value of DES key data.
12676 @@ -362,42 +1029,46 @@
12677 * <xmlsec:HMACKeyValue> processing
12679 *************************************************************************/
12680 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
12681 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataHmacKlass = {
12683 static xmlSecKeyDataKlass xmlSecNssKeyDataHmacKlass = {
12685 sizeof(xmlSecKeyDataKlass),
12686 - xmlSecKeyDataBinarySize,
12687 + xmlSecNssSymKeyDataSize,
12690 xmlSecNameHMACKeyValue,
12691 xmlSecKeyDataUsageKeyValueNode | xmlSecKeyDataUsageRetrievalMethodNodeXml,
12692 - /* xmlSecKeyDataUsage usage; */
12693 - xmlSecHrefHMACKeyValue, /* const xmlChar* href; */
12694 - xmlSecNodeHMACKeyValue, /* const xmlChar* dataNodeName; */
12695 - xmlSecNs, /* const xmlChar* dataNodeNs; */
12696 + /* xmlSecKeyDataUsage usage; */
12697 + xmlSecHrefHMACKeyValue, /* const xmlChar* href; */
12698 + xmlSecNodeHMACKeyValue, /* const xmlChar* dataNodeName; */
12699 + xmlSecNs, /* const xmlChar* dataNodeNs; */
12701 /* constructors/destructor */
12702 - xmlSecNssSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */
12703 - xmlSecNssSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */
12704 - xmlSecNssSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */
12705 - xmlSecNssSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */
12706 + xmlSecNssSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */
12707 + xmlSecNssSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */
12708 + xmlSecNssSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */
12709 + xmlSecNssSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */
12712 - xmlSecNssSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */
12713 - xmlSecNssSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */
12714 - NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */
12715 + xmlSecNssSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */
12716 + xmlSecNssSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */
12717 + NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */
12720 - xmlSecNssSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */
12721 - xmlSecNssSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */
12722 - xmlSecNssSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */
12723 - xmlSecNssSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */
12724 + xmlSecNssSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */
12725 + xmlSecNssSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */
12726 + xmlSecNssSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */
12727 + xmlSecNssSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */
12730 - xmlSecNssSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */
12731 - xmlSecNssSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */
12732 + xmlSecNssSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */
12733 + xmlSecNssSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */
12735 /* reserved for the future */
12736 - NULL, /* void* reserved0; */
12737 - NULL, /* void* reserved1; */
12738 + NULL, /* void* reserved0; */
12739 + NULL, /* void* reserved1; */
12743 @@ -414,9 +1085,9 @@
12746 * xmlSecNssKeyDataHmacSet:
12747 - * @data: the pointer to HMAC key data.
12748 - * @buf: the pointer to key value.
12749 - * @bufSize: the key value size (in bytes).
12750 + * @data: the pointer to HMAC key data.
12751 + * @buf: the pointer to key value.
12752 + * @bufSize: the key value size (in bytes).
12754 * Sets the value of HMAC key data.
12756 --- misc/xmlsec1-1.2.6/src/nss/tokens.c 2008-06-29 23:44:40.000000000 +0200
12757 +++ misc/build/xmlsec1-1.2.6/src/nss/tokens.c 2008-06-29 23:44:19.000000000 +0200
12763 + * This is free software; see Copyright file in the source
12764 + * distribution for preciese wording.
12766 + * Copyright..................................
12768 + * Contributor(s): _____________________________
12773 + * In order to ensure that particular crypto operation is performed on
12774 + * particular crypto device, a subclass of xmlSecList is used to store slot and
12775 + * mechanism information.
12777 + * In the list, a slot is bound with a mechanism. If the mechanism is available,
12778 + * this mechanism only can perform on the slot; otherwise, it can perform on
12779 + * every eligibl slot in the list.
12781 + * When try to find a slot for a particular mechanism, the slot bound with
12782 + * avaliable mechanism will be looked up firstly.
12784 +#include "globals.h"
12785 +#include <string.h>
12787 +#include <xmlsec/xmlsec.h>
12788 +#include <xmlsec/errors.h>
12789 +#include <xmlsec/list.h>
12791 +#include <xmlsec/nss/tokens.h>
12794 +xmlSecNssKeySlotSetMechList(
12795 + xmlSecNssKeySlotPtr keySlot ,
12796 + CK_MECHANISM_TYPE_PTR mechanismList
12800 + xmlSecAssert2( keySlot != NULL , -1 ) ;
12802 + if( keySlot->mechanismList != CK_NULL_PTR ) {
12803 + xmlFree( keySlot->mechanismList ) ;
12805 + for( counter = 0 ; *( mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) ;
12806 + keySlot->mechanismList = ( CK_MECHANISM_TYPE_PTR )xmlMalloc( ( counter + 1 ) * sizeof( CK_MECHANISM_TYPE ) ) ;
12807 + if( keySlot->mechanismList == NULL ) {
12808 + xmlSecError( XMLSEC_ERRORS_HERE ,
12811 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12812 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12815 + for( ; counter >= 0 ; counter -- )
12816 + *( keySlot->mechanismList + counter ) = *( mechanismList + counter ) ;
12823 +xmlSecNssKeySlotEnableMech(
12824 + xmlSecNssKeySlotPtr keySlot ,
12825 + CK_MECHANISM_TYPE mechanism
12828 + CK_MECHANISM_TYPE_PTR newList ;
12830 + xmlSecAssert2( keySlot != NULL , -1 ) ;
12832 + if( mechanism != CKM_INVALID_MECHANISM ) {
12833 + for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) ;
12834 + newList = ( CK_MECHANISM_TYPE_PTR )xmlMalloc( ( counter + 1 + 1 ) * sizeof( CK_MECHANISM_TYPE ) ) ;
12835 + if( newList == NULL ) {
12836 + xmlSecError( XMLSEC_ERRORS_HERE ,
12839 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12840 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12843 + *( newList + counter + 1 ) = CKM_INVALID_MECHANISM ;
12844 + *( newList + counter ) = mechanism ;
12845 + for( counter -= 1 ; counter >= 0 ; counter -- )
12846 + *( newList + counter ) = *( keySlot->mechanismList + counter ) ;
12848 + xmlFree( keySlot->mechanismList ) ;
12849 + keySlot->mechanismList = newList ;
12856 +xmlSecNssKeySlotDisableMech(
12857 + xmlSecNssKeySlotPtr keySlot ,
12858 + CK_MECHANISM_TYPE mechanism
12862 + xmlSecAssert2( keySlot != NULL , -1 ) ;
12864 + for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) {
12865 + if( *( keySlot->mechanismList + counter ) == mechanism ) {
12866 + for( ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) {
12867 + *( keySlot->mechanismList + counter ) = *( keySlot->mechanismList + counter + 1 ) ;
12877 +CK_MECHANISM_TYPE_PTR
12878 +xmlSecNssKeySlotGetMechList(
12879 + xmlSecNssKeySlotPtr keySlot
12881 + if( keySlot != NULL )
12882 + return keySlot->mechanismList ;
12888 +xmlSecNssKeySlotSetSlot(
12889 + xmlSecNssKeySlotPtr keySlot ,
12890 + PK11SlotInfo* slot
12892 + xmlSecAssert2( keySlot != NULL , -1 ) ;
12894 + if( slot != NULL && keySlot->slot != slot ) {
12895 + if( keySlot->slot != NULL )
12896 + PK11_FreeSlot( keySlot->slot ) ;
12898 + if( keySlot->mechanismList != NULL ) {
12899 + xmlFree( keySlot->mechanismList ) ;
12900 + keySlot->mechanismList = NULL ;
12903 + keySlot->slot = PK11_ReferenceSlot( slot ) ;
12910 +xmlSecNssKeySlotInitialize(
12911 + xmlSecNssKeySlotPtr keySlot ,
12912 + PK11SlotInfo* slot
12914 + xmlSecAssert2( keySlot != NULL , -1 ) ;
12915 + xmlSecAssert2( keySlot->slot == NULL , -1 ) ;
12916 + xmlSecAssert2( keySlot->mechanismList == NULL , -1 ) ;
12918 + if( slot != NULL ) {
12919 + keySlot->slot = PK11_ReferenceSlot( slot ) ;
12926 +xmlSecNssKeySlotFinalize(
12927 + xmlSecNssKeySlotPtr keySlot
12929 + xmlSecAssert( keySlot != NULL ) ;
12931 + if( keySlot->mechanismList != NULL ) {
12932 + xmlFree( keySlot->mechanismList ) ;
12933 + keySlot->mechanismList = NULL ;
12936 + if( keySlot->slot != NULL ) {
12937 + PK11_FreeSlot( keySlot->slot ) ;
12938 + keySlot->slot = NULL ;
12944 +xmlSecNssKeySlotGetSlot(
12945 + xmlSecNssKeySlotPtr keySlot
12947 + if( keySlot != NULL )
12948 + return keySlot->slot ;
12953 +xmlSecNssKeySlotPtr
12954 +xmlSecNssKeySlotCreate() {
12955 + xmlSecNssKeySlotPtr keySlot ;
12957 + /* Allocates a new xmlSecNssKeySlot and fill the fields */
12958 + keySlot = ( xmlSecNssKeySlotPtr )xmlMalloc( sizeof( xmlSecNssKeySlot ) ) ;
12959 + if( keySlot == NULL ) {
12960 + xmlSecError( XMLSEC_ERRORS_HERE ,
12963 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
12964 + XMLSEC_ERRORS_NO_MESSAGE ) ;
12967 + memset( keySlot, 0, sizeof( xmlSecNssKeySlot ) ) ;
12969 + return( keySlot ) ;
12973 +xmlSecNssKeySlotCopy(
12974 + xmlSecNssKeySlotPtr newKeySlot ,
12975 + xmlSecNssKeySlotPtr keySlot
12977 + CK_MECHANISM_TYPE_PTR mech ;
12980 + xmlSecAssert2( newKeySlot != NULL , -1 ) ;
12981 + xmlSecAssert2( keySlot != NULL , -1 ) ;
12983 + if( keySlot->slot != NULL && newKeySlot->slot != keySlot->slot ) {
12984 + if( newKeySlot->slot != NULL )
12985 + PK11_FreeSlot( newKeySlot->slot ) ;
12987 + newKeySlot->slot = PK11_ReferenceSlot( keySlot->slot ) ;
12990 + if( keySlot->mechanismList != CK_NULL_PTR ) {
12991 + xmlFree( newKeySlot->mechanismList ) ;
12993 + for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) ;
12994 + newKeySlot->mechanismList = ( CK_MECHANISM_TYPE_PTR )xmlMalloc( ( counter + 1 ) * sizeof( CK_MECHANISM_TYPE ) ) ;
12995 + if( newKeySlot->mechanismList == NULL ) {
12996 + xmlSecError( XMLSEC_ERRORS_HERE ,
12999 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13000 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13003 + for( ; counter >= 0 ; counter -- )
13004 + *( newKeySlot->mechanismList + counter ) = *( keySlot->mechanismList + counter ) ;
13010 +xmlSecNssKeySlotPtr
13011 +xmlSecNssKeySlotDuplicate(
13012 + xmlSecNssKeySlotPtr keySlot
13014 + xmlSecNssKeySlotPtr newKeySlot ;
13017 + xmlSecAssert2( keySlot != NULL , NULL ) ;
13019 + newKeySlot = xmlSecNssKeySlotCreate() ;
13020 + if( newKeySlot == NULL ) {
13021 + xmlSecError( XMLSEC_ERRORS_HERE ,
13024 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13025 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13029 + if( xmlSecNssKeySlotCopy( newKeySlot, keySlot ) < 0 ) {
13030 + xmlSecError( XMLSEC_ERRORS_HERE ,
13033 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13034 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13038 + return( newKeySlot );
13042 +xmlSecNssKeySlotDestroy(
13043 + xmlSecNssKeySlotPtr keySlot
13045 + xmlSecAssert( keySlot != NULL ) ;
13047 + if( keySlot->mechanismList != NULL )
13048 + xmlFree( keySlot->mechanismList ) ;
13050 + if( keySlot->slot != NULL )
13051 + PK11_FreeSlot( keySlot->slot ) ;
13053 + xmlFree( keySlot ) ;
13057 +xmlSecNssKeySlotBindMech(
13058 + xmlSecNssKeySlotPtr keySlot ,
13059 + CK_MECHANISM_TYPE type
13063 + xmlSecAssert2( keySlot != NULL , 0 ) ;
13064 + xmlSecAssert2( keySlot->slot != NULL , 0 ) ;
13065 + xmlSecAssert2( type != CKM_INVALID_MECHANISM , 0 ) ;
13067 + for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) {
13068 + if( *( keySlot->mechanismList + counter ) == type )
13076 +xmlSecNssKeySlotSupportMech(
13077 + xmlSecNssKeySlotPtr keySlot ,
13078 + CK_MECHANISM_TYPE type
13080 + xmlSecAssert2( keySlot != NULL , 0 ) ;
13081 + xmlSecAssert2( keySlot->slot != NULL , 0 ) ;
13082 + xmlSecAssert2( type != CKM_INVALID_MECHANISM , 0 ) ;
13084 + if( PK11_DoesMechanism( keySlot->slot , type ) == PR_TRUE ) {
13091 +xmlSecNssKeySlotDebugDump(
13092 + xmlSecNssKeySlotPtr keySlot ,
13095 + xmlSecAssert( keySlot != NULL ) ;
13096 + xmlSecAssert( output != NULL ) ;
13098 + fprintf( output, "== KEY SLOT\n" );
13102 +xmlSecNssKeySlotDebugXmlDump(
13103 + xmlSecNssKeySlotPtr keySlot ,
13111 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
13112 +static struct _xmlSecPtrListKlass xmlSecNssKeySlotPtrListKlass = {
13114 +static xmlSecPtrListKlass xmlSecNssKeySlotPtrListKlass = {
13116 + BAD_CAST "mechanism-list",
13117 + (xmlSecPtrDuplicateItemMethod)xmlSecNssKeySlotDuplicate,
13118 + (xmlSecPtrDestroyItemMethod)xmlSecNssKeySlotDestroy,
13119 + (xmlSecPtrDebugDumpItemMethod)xmlSecNssKeySlotDebugDump,
13120 + (xmlSecPtrDebugDumpItemMethod)xmlSecNssKeySlotDebugXmlDump,
13124 +xmlSecNssKeySlotListGetKlass(void) {
13125 + return(&xmlSecNssKeySlotPtrListKlass);
13130 + * Global PKCS#11 crypto token repository -- Key slot list
13132 +static xmlSecPtrListPtr _xmlSecNssKeySlotList = NULL ;
13136 + CK_MECHANISM_TYPE type
13138 + PK11SlotInfo* slot = NULL ;
13139 + xmlSecNssKeySlotPtr keySlot ;
13140 + xmlSecSize ksSize ;
13141 + xmlSecSize ksPos ;
13144 + if( _xmlSecNssKeySlotList == NULL ) {
13145 + slot = PK11_GetBestSlot( type , NULL ) ;
13147 + ksSize = xmlSecPtrListGetSize( _xmlSecNssKeySlotList ) ;
13150 + * Firstly, checking whether the mechanism is bound with a special slot.
13151 + * If no bound slot, we try to find the first eligible slot in the list.
13153 + for( flag = 0, ksPos = 0 ; ksPos < ksSize ; ksPos ++ ) {
13154 + keySlot = ( xmlSecNssKeySlotPtr )xmlSecPtrListGetItem( _xmlSecNssKeySlotList, ksPos ) ;
13155 + if( keySlot != NULL && xmlSecNssKeySlotBindMech( keySlot, type ) ) {
13156 + slot = xmlSecNssKeySlotGetSlot( keySlot ) ;
13158 + } else if( flag == 0 && xmlSecNssKeySlotSupportMech( keySlot, type ) ) {
13159 + slot = xmlSecNssKeySlotGetSlot( keySlot ) ;
13166 + if( slot != NULL )
13167 + slot = PK11_ReferenceSlot( slot ) ;
13170 + if( slot != NULL && PK11_NeedLogin( slot ) ) {
13171 + if( PK11_Authenticate( slot , PR_TRUE , NULL ) != SECSuccess ) {
13172 + xmlSecError( XMLSEC_ERRORS_HERE ,
13175 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13176 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13177 + PK11_FreeSlot( slot ) ;
13186 +xmlSecNssSlotInitialize(
13189 + if( _xmlSecNssKeySlotList != NULL ) {
13190 + xmlSecPtrListDestroy( _xmlSecNssKeySlotList ) ;
13191 + _xmlSecNssKeySlotList = NULL ;
13194 + _xmlSecNssKeySlotList = xmlSecPtrListCreate( xmlSecNssKeySlotListId ) ;
13195 + if( _xmlSecNssKeySlotList == NULL ) {
13196 + xmlSecError( XMLSEC_ERRORS_HERE ,
13199 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13200 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13208 +xmlSecNssSlotShutdown(
13211 + if( _xmlSecNssKeySlotList != NULL ) {
13212 + xmlSecPtrListDestroy( _xmlSecNssKeySlotList ) ;
13213 + _xmlSecNssKeySlotList = NULL ;
13218 +xmlSecNssSlotAdopt(
13219 + PK11SlotInfo* slot,
13220 + CK_MECHANISM_TYPE type
13222 + xmlSecNssKeySlotPtr keySlot ;
13223 + xmlSecSize ksSize ;
13224 + xmlSecSize ksPos ;
13227 + xmlSecAssert2( _xmlSecNssKeySlotList != NULL, -1 ) ;
13228 + xmlSecAssert2( slot != NULL, -1 ) ;
13230 + ksSize = xmlSecPtrListGetSize( _xmlSecNssKeySlotList ) ;
13233 + * Firstly, checking whether the slot is in the repository already.
13236 + for( ksPos = 0 ; ksPos < ksSize ; ksPos ++ ) {
13237 + keySlot = ( xmlSecNssKeySlotPtr )xmlSecPtrListGetItem( _xmlSecNssKeySlotList, ksPos ) ;
13238 + /* If find the slot in the list */
13239 + if( keySlot != NULL && xmlSecNssKeySlotGetSlot( keySlot ) == slot ) {
13240 + /* If mechnism type is valid, bind the slot with the mechanism */
13241 + if( type != CKM_INVALID_MECHANISM ) {
13242 + if( xmlSecNssKeySlotEnableMech( keySlot, type ) < 0 ) {
13243 + xmlSecError( XMLSEC_ERRORS_HERE ,
13246 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13247 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13256 + /* If the slot do not in the list, add a new item to the list */
13257 + if( flag == 0 ) {
13258 + /* Create a new KeySlot */
13259 + keySlot = xmlSecNssKeySlotCreate() ;
13260 + if( keySlot == NULL ) {
13261 + xmlSecError( XMLSEC_ERRORS_HERE ,
13264 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13265 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13269 + /* Initialize the keySlot with a slot */
13270 + if( xmlSecNssKeySlotInitialize( keySlot, slot ) < 0 ) {
13271 + xmlSecError( XMLSEC_ERRORS_HERE ,
13274 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13275 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13276 + xmlSecNssKeySlotDestroy( keySlot ) ;
13280 + /* If mechnism type is valid, bind the slot with the mechanism */
13281 + if( type != CKM_INVALID_MECHANISM ) {
13282 + if( xmlSecNssKeySlotEnableMech( keySlot, type ) < 0 ) {
13283 + xmlSecError( XMLSEC_ERRORS_HERE ,
13286 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13287 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13288 + xmlSecNssKeySlotDestroy( keySlot ) ;
13293 + /* Add keySlot into the list */
13294 + if( xmlSecPtrListAdd( _xmlSecNssKeySlotList, keySlot ) < 0 ) {
13295 + xmlSecError( XMLSEC_ERRORS_HERE ,
13298 + XMLSEC_ERRORS_R_XMLSEC_FAILED ,
13299 + XMLSEC_ERRORS_NO_MESSAGE ) ;
13300 + xmlSecNssKeySlotDestroy( keySlot ) ;
13308 --- misc/xmlsec1-1.2.6/src/nss/x509.c 2003-09-26 05:53:09.000000000 +0200
13309 +++ misc/build/xmlsec1-1.2.6/src/nss/x509.c 2008-06-29 23:44:19.000000000 +0200
13311 #include <xmlsec/keys.h>
13312 #include <xmlsec/keyinfo.h>
13313 #include <xmlsec/keysmngr.h>
13314 -#include <xmlsec/x509.h>
13315 #include <xmlsec/base64.h>
13316 #include <xmlsec/errors.h>
13318 @@ -61,37 +60,21 @@
13319 static int xmlSecNssX509CertificateNodeRead (xmlSecKeyDataPtr data,
13321 xmlSecKeyInfoCtxPtr keyInfoCtx);
13322 -static int xmlSecNssX509CertificateNodeWrite (CERTCertificate* cert,
13324 - xmlSecKeyInfoCtxPtr keyInfoCtx);
13325 static int xmlSecNssX509SubjectNameNodeRead (xmlSecKeyDataPtr data,
13327 xmlSecKeyInfoCtxPtr keyInfoCtx);
13328 -static int xmlSecNssX509SubjectNameNodeWrite (CERTCertificate* cert,
13330 - xmlSecKeyInfoCtxPtr keyInfoCtx);
13331 static int xmlSecNssX509IssuerSerialNodeRead (xmlSecKeyDataPtr data,
13333 xmlSecKeyInfoCtxPtr keyInfoCtx);
13334 -static int xmlSecNssX509IssuerSerialNodeWrite (CERTCertificate* cert,
13336 - xmlSecKeyInfoCtxPtr keyInfoCtx);
13337 static int xmlSecNssX509SKINodeRead (xmlSecKeyDataPtr data,
13339 xmlSecKeyInfoCtxPtr keyInfoCtx);
13340 -static int xmlSecNssX509SKINodeWrite (CERTCertificate* cert,
13342 - xmlSecKeyInfoCtxPtr keyInfoCtx);
13343 static int xmlSecNssX509CRLNodeRead (xmlSecKeyDataPtr data,
13345 xmlSecKeyInfoCtxPtr keyInfoCtx);
13346 -static int xmlSecNssX509CRLNodeWrite (CERTSignedCrl* crl,
13348 - xmlSecKeyInfoCtxPtr keyInfoCtx);
13349 static int xmlSecNssKeyDataX509VerifyAndExtractKey(xmlSecKeyDataPtr data,
13351 xmlSecKeyInfoCtxPtr keyInfoCtx);
13353 static CERTCertificate* xmlSecNssX509CertDerRead (const xmlSecByte* buf,
13355 static CERTCertificate* xmlSecNssX509CertBase64DerRead (xmlChar* buf);
13357 xmlSecKeyInfoCtxPtr keyInfoCtx);
13358 static xmlChar* xmlSecNssX509CrlBase64DerWrite (CERTSignedCrl* crl,
13359 int base64LineWrap);
13360 -static xmlChar* xmlSecNssX509NameWrite (CERTName* nm);
13361 -static xmlChar* xmlSecNssASN1IntegerWrite (SECItem *num);
13362 -static xmlChar* xmlSecNssX509SKIWrite (CERTCertificate* cert);
13363 static void xmlSecNssX509CertDebugDump (CERTCertificate* cert,
13365 static void xmlSecNssX509CertDebugXmlDump (CERTCertificate* cert,
13366 @@ -254,7 +234,11 @@
13370 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
13371 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataX509Klass = {
13373 static xmlSecKeyDataKlass xmlSecNssKeyDataX509Klass = {
13375 sizeof(xmlSecKeyDataKlass),
13376 xmlSecNssX509DataSize,
13378 @@ -378,7 +362,7 @@
13379 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13380 "CERT_NewCertList",
13381 XMLSEC_ERRORS_R_CRYPTO_FAILED,
13382 - XMLSEC_ERRORS_NO_MESSAGE);
13383 + "error code=%d", PORT_GetError());
13387 @@ -389,7 +373,7 @@
13388 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13389 "CERT_AddCertToListTail",
13390 XMLSEC_ERRORS_R_CRYPTO_FAILED,
13391 - XMLSEC_ERRORS_NO_MESSAGE);
13392 + "error code=%d", PORT_GetError());
13396 @@ -588,7 +572,7 @@
13397 xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
13398 "CERT_DupCertificate",
13399 XMLSEC_ERRORS_R_CRYPTO_FAILED,
13400 - XMLSEC_ERRORS_NO_MESSAGE);
13401 + "error code=%d", PORT_GetError());
13405 @@ -627,7 +611,7 @@
13406 xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
13408 XMLSEC_ERRORS_R_CRYPTO_FAILED,
13409 - XMLSEC_ERRORS_NO_MESSAGE);
13410 + "error code=%d", PORT_GetError());
13414 @@ -652,7 +636,7 @@
13415 xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)),
13416 "CERT_DupCertificate",
13417 XMLSEC_ERRORS_R_CRYPTO_FAILED,
13418 - XMLSEC_ERRORS_NO_MESSAGE);
13419 + "error code=%d", PORT_GetError());
13422 ret = xmlSecNssKeyDataX509AdoptKeyCert(dst, certDst);
13423 @@ -752,31 +736,22 @@
13424 xmlSecNssKeyDataX509XmlWrite(xmlSecKeyDataId id, xmlSecKeyPtr key,
13425 xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13426 xmlSecKeyDataPtr data;
13429 CERTCertificate* cert;
13430 CERTSignedCrl* crl;
13431 xmlSecSize size, pos;
13435 xmlSecAssert2(id == xmlSecNssKeyDataX509Id, -1);
13436 xmlSecAssert2(key != NULL, -1);
13437 xmlSecAssert2(node != NULL, -1);
13438 xmlSecAssert2(keyInfoCtx != NULL, -1);
13440 - content = xmlSecX509DataGetNodeContent (node, 1, keyInfoCtx);
13441 - if (content < 0) {
13442 - xmlSecError(XMLSEC_ERRORS_HERE,
13443 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13444 - "xmlSecX509DataGetNodeContent",
13445 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13446 - "content=%d", content);
13448 - } else if(content == 0) {
13449 - /* by default we are writing certificates and crls */
13450 - content = XMLSEC_X509DATA_DEFAULT;
13451 + /* todo: flag in ctx remove all existing content */
13453 + xmlNodeSetContent(node, NULL);
13456 - /* get x509 data */
13457 data = xmlSecKeyGetData(key, id);
13459 /* no x509 data in the key */
13460 @@ -795,80 +770,75 @@
13465 - if((content & XMLSEC_X509DATA_CERTIFICATE_NODE) != 0) {
13466 - ret = xmlSecNssX509CertificateNodeWrite(cert, node, keyInfoCtx);
13468 - xmlSecError(XMLSEC_ERRORS_HERE,
13469 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13470 - "xmlSecNssX509CertificateNodeWrite",
13471 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13476 + /* set base64 lines size from context */
13477 + buf = xmlSecNssX509CertBase64DerWrite(cert, keyInfoCtx->base64LineSize);
13478 + if(buf == NULL) {
13479 + xmlSecError(XMLSEC_ERRORS_HERE,
13480 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13481 + "xmlSecNssX509CertBase64DerWrite",
13482 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
13483 + XMLSEC_ERRORS_NO_MESSAGE);
13487 - if((content & XMLSEC_X509DATA_SUBJECTNAME_NODE) != 0) {
13488 - ret = xmlSecNssX509SubjectNameNodeWrite(cert, node, keyInfoCtx);
13490 - xmlSecError(XMLSEC_ERRORS_HERE,
13491 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13492 - "xmlSecNssX509SubjectNameNodeWrite",
13493 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13498 + cur = xmlSecAddChild(node, xmlSecNodeX509Certificate, xmlSecDSigNs);
13499 + if(cur == NULL) {
13500 + xmlSecError(XMLSEC_ERRORS_HERE,
13501 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13502 + "xmlSecAddChild",
13503 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
13505 + xmlSecErrorsSafeString(xmlSecNodeX509Certificate));
13509 + /* todo: add \n around base64 data - from context */
13510 + /* todo: add errors check */
13511 + xmlNodeSetContent(cur, xmlSecStringCR);
13512 + xmlNodeSetContent(cur, buf);
13516 - if((content & XMLSEC_X509DATA_ISSUERSERIAL_NODE) != 0) {
13517 - ret = xmlSecNssX509IssuerSerialNodeWrite(cert, node, keyInfoCtx);
13519 - xmlSecError(XMLSEC_ERRORS_HERE,
13520 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13521 - "xmlSecNssX509IssuerSerialNodeWrite",
13522 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13528 + size = xmlSecNssKeyDataX509GetCrlsSize(data);
13529 + for(pos = 0; pos < size; ++pos) {
13530 + crl = xmlSecNssKeyDataX509GetCrl(data, pos);
13531 + if(crl == NULL) {
13532 + xmlSecError(XMLSEC_ERRORS_HERE,
13533 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13534 + "xmlSecNssKeyDataX509GetCrl",
13535 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
13540 - if((content & XMLSEC_X509DATA_SKI_NODE) != 0) {
13541 - ret = xmlSecNssX509SKINodeWrite(cert, node, keyInfoCtx);
13543 - xmlSecError(XMLSEC_ERRORS_HERE,
13544 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13545 - "xmlSecNssX509SKINodeWrite",
13546 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13552 + /* set base64 lines size from context */
13553 + buf = xmlSecNssX509CrlBase64DerWrite(crl, keyInfoCtx->base64LineSize);
13554 + if(buf == NULL) {
13555 + xmlSecError(XMLSEC_ERRORS_HERE,
13556 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13557 + "xmlSecNssX509CrlBase64DerWrite",
13558 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
13559 + XMLSEC_ERRORS_NO_MESSAGE);
13563 - /* write crls if needed */
13564 - if((content & XMLSEC_X509DATA_CRL_NODE) != 0) {
13565 - size = xmlSecNssKeyDataX509GetCrlsSize(data);
13566 - for(pos = 0; pos < size; ++pos) {
13567 - crl = xmlSecNssKeyDataX509GetCrl(data, pos);
13568 - if(crl == NULL) {
13569 - xmlSecError(XMLSEC_ERRORS_HERE,
13570 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13571 - "xmlSecNssKeyDataX509GetCrl",
13572 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13577 - ret = xmlSecNssX509CRLNodeWrite(crl, node, keyInfoCtx);
13579 - xmlSecError(XMLSEC_ERRORS_HERE,
13580 - xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13581 - "xmlSecNssX509CRLNodeWrite",
13582 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13587 + cur = xmlSecAddChild(node, xmlSecNodeX509CRL, xmlSecDSigNs);
13588 + if(cur == NULL) {
13589 + xmlSecError(XMLSEC_ERRORS_HERE,
13590 + xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
13591 + "xmlSecAddChild",
13592 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
13594 + xmlSecErrorsSafeString(xmlSecNodeX509CRL));
13598 + /* todo: add \n around base64 data - from context */
13599 + /* todo: add errors check */
13600 + xmlNodeSetContent(cur, xmlSecStringCR);
13601 + xmlNodeSetContent(cur, buf);
13605 @@ -1015,19 +985,13 @@
13606 xmlSecAssert2(keyInfoCtx != NULL, -1);
13608 content = xmlNodeGetContent(node);
13609 - if((content == NULL) || (xmlSecIsEmptyString(content) == 1)) {
13610 - if(content != NULL) {
13611 - xmlFree(content);
13613 - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_STOP_ON_EMPTY_NODE) != 0) {
13614 - xmlSecError(XMLSEC_ERRORS_HERE,
13615 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13616 - xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13617 - XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13618 - XMLSEC_ERRORS_NO_MESSAGE);
13622 + if(content == NULL){
13623 + xmlSecError(XMLSEC_ERRORS_HERE,
13624 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13625 + xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13626 + XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13627 + XMLSEC_ERRORS_NO_MESSAGE);
13631 cert = xmlSecNssX509CertBase64DerRead(content);
13632 @@ -1057,46 +1021,6 @@
13637 -xmlSecNssX509CertificateNodeWrite(CERTCertificate* cert, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13641 - xmlSecAssert2(cert != NULL, -1);
13642 - xmlSecAssert2(node != NULL, -1);
13643 - xmlSecAssert2(keyInfoCtx != NULL, -1);
13645 - /* set base64 lines size from context */
13646 - buf = xmlSecNssX509CertBase64DerWrite(cert, keyInfoCtx->base64LineSize);
13647 - if(buf == NULL) {
13648 - xmlSecError(XMLSEC_ERRORS_HERE,
13650 - "xmlSecNssX509CertBase64DerWrite",
13651 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13652 - XMLSEC_ERRORS_NO_MESSAGE);
13656 - cur = xmlSecAddChild(node, xmlSecNodeX509Certificate, xmlSecDSigNs);
13657 - if(cur == NULL) {
13658 - xmlSecError(XMLSEC_ERRORS_HERE,
13660 - "xmlSecAddChild",
13661 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13663 - xmlSecErrorsSafeString(xmlSecNodeX509Certificate));
13668 - /* todo: add \n around base64 data - from context */
13669 - /* todo: add errors check */
13670 - xmlNodeSetContent(cur, xmlSecStringCR);
13671 - xmlNodeSetContent(cur, buf);
13677 xmlSecNssX509SubjectNameNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13678 xmlSecKeyDataStorePtr x509Store;
13679 @@ -1120,19 +1044,13 @@
13682 subject = xmlNodeGetContent(node);
13683 - if((subject == NULL) || (xmlSecIsEmptyString(subject) == 1)) {
13684 - if(subject != NULL) {
13685 - xmlFree(subject);
13687 - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_STOP_ON_EMPTY_NODE) != 0) {
13688 - xmlSecError(XMLSEC_ERRORS_HERE,
13689 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13690 - xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13691 - XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13692 - XMLSEC_ERRORS_NO_MESSAGE);
13696 + if(subject == NULL) {
13697 + xmlSecError(XMLSEC_ERRORS_HERE,
13698 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13699 + xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13700 + XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13701 + XMLSEC_ERRORS_NO_MESSAGE);
13705 cert = xmlSecNssX509StoreFindCert(x509Store, subject, NULL, NULL, NULL, keyInfoCtx);
13706 @@ -1167,40 +1085,6 @@
13711 -xmlSecNssX509SubjectNameNodeWrite(CERTCertificate* cert, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx ATTRIBUTE_UNUSED) {
13712 - xmlChar* buf = NULL;
13713 - xmlNodePtr cur = NULL;
13715 - xmlSecAssert2(cert != NULL, -1);
13716 - xmlSecAssert2(node != NULL, -1);
13718 - buf = xmlSecNssX509NameWrite(&(cert->subject));
13719 - if(buf == NULL) {
13720 - xmlSecError(XMLSEC_ERRORS_HERE,
13722 - "xmlSecNssX509NameWrite(&(cert->subject))",
13723 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13724 - XMLSEC_ERRORS_NO_MESSAGE);
13728 - cur = xmlSecAddChild(node, xmlSecNodeX509SubjectName, xmlSecDSigNs);
13729 - if(cur == NULL) {
13730 - xmlSecError(XMLSEC_ERRORS_HERE,
13732 - "xmlSecAddChild",
13733 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13735 - xmlSecErrorsSafeString(xmlSecNodeX509SubjectName));
13739 - xmlNodeSetContent(cur, buf);
13745 xmlSecNssX509IssuerSerialNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13746 xmlSecKeyDataStorePtr x509Store;
13747 @@ -1226,21 +1110,9 @@
13750 cur = xmlSecGetNextElementNode(node->children);
13751 - if(cur == NULL) {
13752 - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_STOP_ON_EMPTY_NODE) != 0) {
13753 - xmlSecError(XMLSEC_ERRORS_HERE,
13754 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13755 - xmlSecErrorsSafeString(xmlSecNodeX509IssuerName),
13756 - XMLSEC_ERRORS_R_NODE_NOT_FOUND,
13758 - xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
13765 /* the first is required node X509IssuerName */
13766 - if(!xmlSecCheckNodeName(cur, xmlSecNodeX509IssuerName, xmlSecDSigNs)) {
13767 + if((cur == NULL) || !xmlSecCheckNodeName(cur, xmlSecNodeX509IssuerName, xmlSecDSigNs)) {
13768 xmlSecError(XMLSEC_ERRORS_HERE,
13769 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13770 xmlSecErrorsSafeString(xmlSecNodeX509IssuerName),
13771 @@ -1332,78 +1204,6 @@
13776 -xmlSecNssX509IssuerSerialNodeWrite(CERTCertificate* cert, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx ATTRIBUTE_UNUSED) {
13778 - xmlNodePtr issuerNameNode;
13779 - xmlNodePtr issuerNumberNode;
13782 - xmlSecAssert2(cert != NULL, -1);
13783 - xmlSecAssert2(node != NULL, -1);
13785 - /* create xml nodes */
13786 - cur = xmlSecAddChild(node, xmlSecNodeX509IssuerSerial, xmlSecDSigNs);
13787 - if(cur == NULL) {
13788 - xmlSecError(XMLSEC_ERRORS_HERE,
13790 - "xmlSecAddChild",
13791 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13793 - xmlSecErrorsSafeString(xmlSecNodeX509IssuerSerial));
13797 - issuerNameNode = xmlSecAddChild(cur, xmlSecNodeX509IssuerName, xmlSecDSigNs);
13798 - if(issuerNameNode == NULL) {
13799 - xmlSecError(XMLSEC_ERRORS_HERE,
13801 - "xmlSecAddChild",
13802 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13804 - xmlSecErrorsSafeString(xmlSecNodeX509IssuerName));
13808 - issuerNumberNode = xmlSecAddChild(cur, xmlSecNodeX509SerialNumber, xmlSecDSigNs);
13809 - if(issuerNumberNode == NULL) {
13810 - xmlSecError(XMLSEC_ERRORS_HERE,
13812 - "xmlSecAddChild",
13813 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13815 - xmlSecErrorsSafeString(xmlSecNodeX509SerialNumber));
13820 - buf = xmlSecNssX509NameWrite(&(cert->issuer));
13821 - if(buf == NULL) {
13822 - xmlSecError(XMLSEC_ERRORS_HERE,
13824 - "xmlSecNssX509NameWrite(&(cert->issuer))",
13825 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13826 - XMLSEC_ERRORS_NO_MESSAGE);
13829 - xmlNodeSetContent(issuerNameNode, buf);
13832 - buf = xmlSecNssASN1IntegerWrite(&(cert->serialNumber));
13833 - if(buf == NULL) {
13834 - xmlSecError(XMLSEC_ERRORS_HERE,
13836 - "xmlSecNssASN1IntegerWrite(&(cert->serialNumber))",
13837 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13838 - XMLSEC_ERRORS_NO_MESSAGE);
13841 - xmlNodeSetContent(issuerNumberNode, buf);
13848 xmlSecNssX509SKINodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13849 xmlSecKeyDataStorePtr x509Store;
13850 @@ -1427,20 +1227,14 @@
13853 ski = xmlNodeGetContent(node);
13854 - if((ski == NULL) || (xmlSecIsEmptyString(ski) == 1)) {
13855 - if(ski != NULL) {
13858 - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_STOP_ON_EMPTY_NODE) != 0) {
13859 - xmlSecError(XMLSEC_ERRORS_HERE,
13860 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13861 - xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13862 - XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13864 - xmlSecErrorsSafeString(xmlSecNodeX509SKI));
13868 + if(ski == NULL) {
13869 + xmlSecError(XMLSEC_ERRORS_HERE,
13870 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13871 + xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13872 + XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13874 + xmlSecErrorsSafeString(xmlSecNodeX509SKI));
13878 cert = xmlSecNssX509StoreFindCert(x509Store, NULL, NULL, NULL, ski, keyInfoCtx);
13879 @@ -1475,41 +1269,6 @@
13884 -xmlSecNssX509SKINodeWrite(CERTCertificate* cert, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx ATTRIBUTE_UNUSED) {
13885 - xmlChar *buf = NULL;
13886 - xmlNodePtr cur = NULL;
13888 - xmlSecAssert2(cert != NULL, -1);
13889 - xmlSecAssert2(node != NULL, -1);
13891 - buf = xmlSecNssX509SKIWrite(cert);
13892 - if(buf == NULL) {
13893 - xmlSecError(XMLSEC_ERRORS_HERE,
13895 - "xmlSecNssX509SKIWrite",
13896 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13897 - XMLSEC_ERRORS_NO_MESSAGE);
13901 - cur = xmlSecAddChild(node, xmlSecNodeX509SKI, xmlSecDSigNs);
13902 - if(cur == NULL) {
13903 - xmlSecError(XMLSEC_ERRORS_HERE,
13905 - "xmlSecAddChild",
13906 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13908 - xmlSecErrorsSafeString(xmlSecNodeX509SKI));
13912 - xmlNodeSetContent(cur, buf);
13919 xmlSecNssX509CRLNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13921 @@ -1520,19 +1279,13 @@
13922 xmlSecAssert2(keyInfoCtx != NULL, -1);
13924 content = xmlNodeGetContent(node);
13925 - if((content == NULL) || (xmlSecIsEmptyString(content) == 1)) {
13926 - if(content != NULL) {
13927 - xmlFree(content);
13929 - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_STOP_ON_EMPTY_NODE) != 0) {
13930 - xmlSecError(XMLSEC_ERRORS_HERE,
13931 - xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13932 - xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13933 - XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13934 - XMLSEC_ERRORS_NO_MESSAGE);
13938 + if(content == NULL){
13939 + xmlSecError(XMLSEC_ERRORS_HERE,
13940 + xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
13941 + xmlSecErrorsSafeString(xmlSecNodeGetName(node)),
13942 + XMLSEC_ERRORS_R_INVALID_NODE_CONTENT,
13943 + XMLSEC_ERRORS_NO_MESSAGE);
13947 crl = xmlSecNssX509CrlBase64DerRead(content, keyInfoCtx);
13948 @@ -1552,47 +1305,6 @@
13952 -xmlSecNssX509CRLNodeWrite(CERTSignedCrl* crl, xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) {
13953 - xmlChar* buf = NULL;
13954 - xmlNodePtr cur = NULL;
13956 - xmlSecAssert2(crl != NULL, -1);
13957 - xmlSecAssert2(node != NULL, -1);
13958 - xmlSecAssert2(keyInfoCtx != NULL, -1);
13960 - /* set base64 lines size from context */
13961 - buf = xmlSecNssX509CrlBase64DerWrite(crl, keyInfoCtx->base64LineSize);
13962 - if(buf == NULL) {
13963 - xmlSecError(XMLSEC_ERRORS_HERE,
13965 - "xmlSecNssX509CrlBase64DerWrite",
13966 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13967 - XMLSEC_ERRORS_NO_MESSAGE);
13971 - cur = xmlSecAddChild(node, xmlSecNodeX509CRL, xmlSecDSigNs);
13972 - if(cur == NULL) {
13973 - xmlSecError(XMLSEC_ERRORS_HERE,
13975 - "xmlSecAddChild",
13976 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
13978 - xmlSecErrorsSafeString(xmlSecNodeX509CRL));
13982 - /* todo: add \n around base64 data - from context */
13983 - /* todo: add errors check */
13984 - xmlNodeSetContent(cur, xmlSecStringCR);
13985 - xmlNodeSetContent(cur, buf);
13993 xmlSecNssKeyDataX509VerifyAndExtractKey(xmlSecKeyDataPtr data, xmlSecKeyPtr key,
13994 xmlSecKeyInfoCtxPtr keyInfoCtx) {
13995 xmlSecNssX509DataCtxPtr ctx;
13996 @@ -1600,6 +1312,10 @@
13999 PRTime notBefore, notAfter;
14001 + PK11SlotInfo* slot ;
14002 + SECKEYPublicKey *pubKey = NULL;
14003 + SECKEYPrivateKey *priKey = NULL;
14005 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecNssKeyDataX509Id), -1);
14006 xmlSecAssert2(key != NULL, -1);
14007 @@ -1632,10 +1348,13 @@
14008 xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
14009 "CERT_DupCertificate",
14010 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14011 - XMLSEC_ERRORS_NO_MESSAGE);
14012 + "error code=%d", PORT_GetError());
14017 + * Get Public key from cert, which does not always work for sign action.
14019 keyValue = xmlSecNssX509CertGetKey(ctx->keyCert);
14020 if(keyValue == NULL) {
14021 xmlSecError(XMLSEC_ERRORS_HERE,
14022 @@ -1645,6 +1364,54 @@
14023 XMLSEC_ERRORS_NO_MESSAGE);
14029 + * I'll search key according to KeyReq.
14031 + slot = cert->slot ;
14032 + if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePrivate ) == xmlSecKeyDataTypePrivate ) {
14033 + if( ( priKey = PK11_FindKeyByAnyCert( cert , NULL ) ) == NULL ) {
14034 + xmlSecError( XMLSEC_ERRORS_HERE ,
14035 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
14036 + "PK11_FindPrivateKeyFromCert" ,
14037 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
14038 + XMLSEC_ERRORS_NO_MESSAGE ) ;
14043 + if( ( keyInfoCtx->keyReq.keyType & xmlSecKeyDataTypePublic ) == xmlSecKeyDataTypePublic ) {
14044 + if( ( pubKey = CERT_ExtractPublicKey( cert ) ) == NULL ) {
14045 + xmlSecError( XMLSEC_ERRORS_HERE ,
14046 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
14047 + "CERT_ExtractPublicKey" ,
14048 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
14049 + XMLSEC_ERRORS_NO_MESSAGE ) ;
14051 + if( priKey != NULL )
14052 + SECKEY_DestroyPrivateKey( priKey ) ;
14057 + keyValue = xmlSecNssPKIAdoptKey(priKey, pubKey);
14058 + if( keyValue == NULL ) {
14059 + xmlSecError( XMLSEC_ERRORS_HERE ,
14060 + xmlSecErrorsSafeString( xmlSecKeyDataGetName( data ) ) ,
14061 + "xmlSecNssPKIAdoptKey" ,
14062 + XMLSEC_ERRORS_R_CRYPTO_FAILED ,
14063 + XMLSEC_ERRORS_NO_MESSAGE ) ;
14065 + if( priKey != NULL )
14066 + SECKEY_DestroyPrivateKey( priKey ) ;
14068 + if( pubKey != NULL )
14069 + SECKEY_DestroyPublicKey( pubKey ) ;
14073 + /* Modify keyValue get Done */
14075 /* verify that the key matches our expectations */
14076 if(xmlSecKeyReqMatchKeyValue(&(keyInfoCtx->keyReq), keyValue) != 1) {
14077 @@ -1725,14 +1492,6 @@
14082 - * xmlSecNssX509CertGetKey:
14083 - * @cert: the certificate.
14085 - * Extracts public key from the @cert.
14087 - * Returns public key value or NULL if an error occurs.
14090 xmlSecNssX509CertGetKey(CERTCertificate* cert) {
14091 xmlSecKeyDataPtr data;
14092 @@ -1746,7 +1505,7 @@
14094 "CERT_ExtractPublicKey",
14095 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14096 - XMLSEC_ERRORS_NO_MESSAGE);
14097 + "error code=%d", PORT_GetError());
14101 @@ -1804,7 +1563,7 @@
14103 "__CERT_NewTempCertificate",
14104 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14105 - XMLSEC_ERRORS_NO_MESSAGE);
14106 + "error code=%d", PORT_GetError());
14110 @@ -1827,7 +1586,7 @@
14113 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14114 - XMLSEC_ERRORS_NO_MESSAGE);
14115 + "error code=%d", PORT_GetError());
14119 @@ -1890,7 +1649,7 @@
14121 "PK11_GetInternalKeySlot",
14122 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14123 - XMLSEC_ERRORS_NO_MESSAGE);
14124 + "error code=%d", PORT_GetError());
14128 @@ -1905,7 +1664,7 @@
14131 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14132 - XMLSEC_ERRORS_NO_MESSAGE);
14133 + "error code=%d", PORT_GetError());
14134 PK11_FreeSlot(slot);
14137 @@ -1929,7 +1688,7 @@
14140 XMLSEC_ERRORS_R_CRYPTO_FAILED,
14141 - XMLSEC_ERRORS_NO_MESSAGE);
14142 + "error code=%d", PORT_GetError());
14146 @@ -1946,86 +1705,6 @@
14151 -xmlSecNssX509NameWrite(CERTName* nm) {
14152 - xmlChar *res = NULL;
14155 - xmlSecAssert2(nm != NULL, NULL);
14157 - str = CERT_NameToAscii(nm);
14158 - if (str == NULL) {
14159 - xmlSecError(XMLSEC_ERRORS_HERE,
14161 - "CERT_NameToAscii",
14162 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
14163 - XMLSEC_ERRORS_NO_MESSAGE);
14167 - res = xmlStrdup(BAD_CAST str);
14168 - if(res == NULL) {
14169 - xmlSecError(XMLSEC_ERRORS_HERE,
14172 - XMLSEC_ERRORS_R_MALLOC_FAILED,
14173 - XMLSEC_ERRORS_NO_MESSAGE);
14182 -xmlSecNssASN1IntegerWrite(SECItem *num) {
14183 - xmlChar *res = NULL;
14185 - xmlSecAssert2(num != NULL, NULL);
14187 - /* TODO : to be implemented after
14188 - * NSS bug http://bugzilla.mozilla.org/show_bug.cgi?id=212864 is fixed
14194 -xmlSecNssX509SKIWrite(CERTCertificate* cert) {
14195 - xmlChar *res = NULL;
14199 - xmlSecAssert2(cert != NULL, NULL);
14201 - memset(&ski, 0, sizeof(ski));
14203 - rv = CERT_FindSubjectKeyIDExtension(cert, &ski);
14204 - if (rv != SECSuccess) {
14205 - xmlSecError(XMLSEC_ERRORS_HERE,
14207 - "CERT_FindSubjectKeyIDExtension",
14208 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
14209 - XMLSEC_ERRORS_NO_MESSAGE);
14210 - SECITEM_FreeItem(&ski, PR_FALSE);
14214 - res = xmlSecBase64Encode(ski.data, ski.len, 0);
14215 - if(res == NULL) {
14216 - xmlSecError(XMLSEC_ERRORS_HERE,
14218 - "xmlSecBase64Encode",
14219 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14220 - XMLSEC_ERRORS_NO_MESSAGE);
14221 - SECITEM_FreeItem(&ski, PR_FALSE);
14224 - SECITEM_FreeItem(&ski, PR_FALSE);
14231 xmlSecNssX509CertDebugDump(CERTCertificate* cert, FILE* output) {
14233 @@ -2084,7 +1763,11 @@
14234 xmlSecSize bufSize,
14235 xmlSecKeyInfoCtxPtr keyInfoCtx);
14237 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
14238 +static struct _xmlSecKeyDataKlass xmlSecNssKeyDataRawX509CertKlass = {
14240 static xmlSecKeyDataKlass xmlSecNssKeyDataRawX509CertKlass = {
14242 sizeof(xmlSecKeyDataKlass),
14243 sizeof(xmlSecKeyData),
14245 --- misc/xmlsec1-1.2.6/src/nss/x509vfy.c 2003-09-26 02:58:15.000000000 +0200
14246 +++ misc/build/xmlsec1-1.2.6/src/nss/x509vfy.c 2008-06-29 23:44:19.000000000 +0200
14248 #include <xmlsec/keyinfo.h>
14249 #include <xmlsec/keysmngr.h>
14250 #include <xmlsec/base64.h>
14251 +#include <xmlsec/bn.h>
14252 #include <xmlsec/errors.h>
14254 #include <xmlsec/nss/crypto.h>
14256 typedef struct _xmlSecNssX509StoreCtx xmlSecNssX509StoreCtx,
14257 *xmlSecNssX509StoreCtxPtr;
14258 struct _xmlSecNssX509StoreCtx {
14259 - CERTCertList* certsList; /* just keeping a reference to destroy later */
14261 + CERTCertList* certsList; /* just keeping a reference to destroy later */
14264 /****************************************************************************
14266 @@ -54,45 +55,40 @@
14268 ***************************************************************************/
14269 #define xmlSecNssX509StoreGetCtx(store) \
14270 - ((xmlSecNssX509StoreCtxPtr)(((xmlSecByte*)(store)) + \
14271 - sizeof(xmlSecKeyDataStoreKlass)))
14272 + ((xmlSecNssX509StoreCtxPtr)(((xmlSecByte*)(store)) + \
14273 + sizeof(xmlSecKeyDataStoreKlass)))
14274 #define xmlSecNssX509StoreSize \
14275 - (sizeof(xmlSecKeyDataStoreKlass) + sizeof(xmlSecNssX509StoreCtx))
14276 + (sizeof(xmlSecKeyDataStoreKlass) + sizeof(xmlSecNssX509StoreCtx))
14278 static int xmlSecNssX509StoreInitialize (xmlSecKeyDataStorePtr store);
14279 static void xmlSecNssX509StoreFinalize (xmlSecKeyDataStorePtr store);
14280 -static int xmlSecNssX509NameStringRead (xmlSecByte **str,
14284 - xmlSecByte delim,
14285 - int ingoreTrailingSpaces);
14286 -static xmlSecByte * xmlSecNssX509NameRead (xmlSecByte *str,
14289 -static void xmlSecNssNumToItem(SECItem *it, unsigned long num);
14291 +static int xmlSecNssIntegerToItem( const xmlChar* integer , SECItem *it ) ;
14293 +#ifdef __MINGW32__ // for runtime-pseudo-reloc
14294 +static struct _xmlSecKeyDataStoreKlass xmlSecNssX509StoreKlass = {
14296 static xmlSecKeyDataStoreKlass xmlSecNssX509StoreKlass = {
14297 - sizeof(xmlSecKeyDataStoreKlass),
14298 - xmlSecNssX509StoreSize,
14301 - xmlSecNameX509Store, /* const xmlChar* name; */
14303 - /* constructors/destructor */
14304 - xmlSecNssX509StoreInitialize, /* xmlSecKeyDataStoreInitializeMethod initialize; */
14305 - xmlSecNssX509StoreFinalize, /* xmlSecKeyDataStoreFinalizeMethod finalize; */
14307 - /* reserved for the future */
14308 - NULL, /* void* reserved0; */
14309 - NULL, /* void* reserved1; */
14311 + sizeof(xmlSecKeyDataStoreKlass),
14312 + xmlSecNssX509StoreSize,
14315 + xmlSecNameX509Store, /* const xmlChar* name; */
14317 + /* constructors/destructor */
14318 + xmlSecNssX509StoreInitialize, /* xmlSecKeyDataStoreInitializeMethod initialize; */
14319 + xmlSecNssX509StoreFinalize, /* xmlSecKeyDataStoreFinalizeMethod finalize; */
14321 + /* reserved for the future */
14322 + NULL, /* void* reserved0; */
14323 + NULL, /* void* reserved1; */
14326 static CERTCertificate* xmlSecNssX509FindCert(xmlChar *subjectName,
14327 - xmlChar *issuerName,
14328 - xmlChar *issuerSerial,
14330 + xmlChar *issuerName,
14331 + xmlChar *issuerSerial,
14336 @@ -104,7 +100,7 @@
14338 xmlSecKeyDataStoreId
14339 xmlSecNssX509StoreGetKlass(void) {
14340 - return(&xmlSecNssX509StoreKlass);
14341 + return(&xmlSecNssX509StoreKlass);
14345 @@ -125,15 +121,15 @@
14346 xmlSecNssX509StoreFindCert(xmlSecKeyDataStorePtr store, xmlChar *subjectName,
14347 xmlChar *issuerName, xmlChar *issuerSerial,
14348 xmlChar *ski, xmlSecKeyInfoCtx* keyInfoCtx) {
14349 - xmlSecNssX509StoreCtxPtr ctx;
14351 - xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), NULL);
14352 - xmlSecAssert2(keyInfoCtx != NULL, NULL);
14353 + xmlSecNssX509StoreCtxPtr ctx;
14355 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), NULL);
14356 + xmlSecAssert2(keyInfoCtx != NULL, NULL);
14358 - ctx = xmlSecNssX509StoreGetCtx(store);
14359 - xmlSecAssert2(ctx != NULL, NULL);
14360 + ctx = xmlSecNssX509StoreGetCtx(store);
14361 + xmlSecAssert2(ctx != NULL, NULL);
14363 - return(xmlSecNssX509FindCert(subjectName, issuerName, issuerSerial, ski));
14364 + return(xmlSecNssX509FindCert(subjectName, issuerName, issuerSerial, ski));
14368 @@ -148,116 +144,130 @@
14371 xmlSecNssX509StoreVerify(xmlSecKeyDataStorePtr store, CERTCertList* certs,
14372 - xmlSecKeyInfoCtx* keyInfoCtx) {
14373 - xmlSecNssX509StoreCtxPtr ctx;
14374 - CERTCertListNode* head;
14375 - CERTCertificate* cert = NULL;
14376 - CERTCertListNode* head1;
14377 - CERTCertificate* cert1 = NULL;
14378 - SECStatus status = SECFailure;
14379 - int64 timeboundary;
14380 - int64 tmp1, tmp2;
14382 - xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), NULL);
14383 - xmlSecAssert2(certs != NULL, NULL);
14384 - xmlSecAssert2(keyInfoCtx != NULL, NULL);
14386 - ctx = xmlSecNssX509StoreGetCtx(store);
14387 - xmlSecAssert2(ctx != NULL, NULL);
14389 - for (head = CERT_LIST_HEAD(certs);
14390 - !CERT_LIST_END(head, certs);
14391 - head = CERT_LIST_NEXT(head)) {
14392 - cert = head->cert;
14393 + xmlSecKeyInfoCtx* keyInfoCtx) {
14394 + xmlSecNssX509StoreCtxPtr ctx;
14395 + CERTCertListNode* head;
14396 + CERTCertificate* cert = NULL;
14397 + CERTCertListNode* head1;
14398 + CERTCertificate* cert1 = NULL;
14399 + SECStatus status = SECFailure;
14400 + int64 timeboundary;
14401 + int64 tmp1, tmp2;
14403 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), NULL);
14404 + xmlSecAssert2(certs != NULL, NULL);
14405 + xmlSecAssert2(keyInfoCtx != NULL, NULL);
14407 + ctx = xmlSecNssX509StoreGetCtx(store);
14408 + xmlSecAssert2(ctx != NULL, NULL);
14410 + for (head = CERT_LIST_HEAD(certs);
14411 + !CERT_LIST_END(head, certs);
14412 + head = CERT_LIST_NEXT(head)) {
14413 + cert = head->cert;
14414 if(keyInfoCtx->certsVerificationTime > 0) {
14415 - /* convert the time since epoch in seconds to microseconds */
14416 - LL_UI2L(timeboundary, keyInfoCtx->certsVerificationTime);
14417 - tmp1 = (int64)PR_USEC_PER_SEC;
14418 - tmp2 = timeboundary;
14419 - LL_MUL(timeboundary, tmp1, tmp2);
14420 + /* convert the time since epoch in seconds to microseconds */
14421 + LL_UI2L(timeboundary, keyInfoCtx->certsVerificationTime);
14422 + tmp1 = (int64)PR_USEC_PER_SEC;
14423 + tmp2 = timeboundary;
14424 + LL_MUL(timeboundary, tmp1, tmp2);
14426 - timeboundary = PR_Now();
14427 + timeboundary = PR_Now();
14430 /* if cert is the issuer of any other cert in the list, then it is
14432 for (head1 = CERT_LIST_HEAD(certs);
14433 - !CERT_LIST_END(head1, certs);
14434 - head1 = CERT_LIST_NEXT(head1)) {
14435 + !CERT_LIST_END(head1, certs);
14436 + head1 = CERT_LIST_NEXT(head1)) {
14438 - cert1 = head1->cert;
14439 - if (cert1 == cert) {
14440 + cert1 = head1->cert;
14441 + if (cert1 == cert) {
14446 - if (SECITEM_CompareItem(&cert1->derIssuer, &cert->derSubject)
14448 + if (SECITEM_CompareItem(&cert1->derIssuer, &cert->derSubject)
14455 if (!CERT_LIST_END(head1, certs)) {
14460 - status = CERT_VerifyCertificate(CERT_GetDefaultCertDB(),
14462 - (SECCertificateUsage)0,
14463 - timeboundary , NULL, NULL, NULL);
14464 - if (status == SECSuccess) {
14466 + /* JL: OpenOffice.org implements its own certificate verification routine.
14467 + The goal is to seperate validation of the signature
14468 + and the certificate. For example, OOo could show that the document signature is valid,
14469 + but the certificate could not be verified. If we do not prevent the verification of
14470 + the certificate by libxmlsec and the verification fails, then the XML signature may not be
14471 + verified. This would happen, for example, if the root certificate is not installed.
14473 + In the store schould only be the certificate from the X509Certificate element
14474 + and the X509IssuerSerial element. The latter is only there
14475 + if the certificate is installed. Both certificates must be the same!
14476 + In case of writing the signature, the store contains only the certificate that
14477 + was created based on the information from the X509IssuerSerial element. */
14478 + status = SECSuccess;
14480 +/* status = CERT_VerifyCertificate(CERT_GetDefaultCertDB(),
14482 + (SECCertificateUsage)0,
14483 + timeboundary , NULL, NULL, NULL);
14484 + if (status == SECSuccess) {
14490 - if (status == SECSuccess) {
14491 + if (status == SECSuccess) {
14495 - switch(PORT_GetError()) {
14498 + switch(PORT_GetError()) {
14499 case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE:
14500 case SEC_ERROR_CA_CERT_INVALID:
14501 case SEC_ERROR_UNKNOWN_SIGNER:
14502 - xmlSecError(XMLSEC_ERRORS_HERE,
14503 - xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14505 - XMLSEC_ERRORS_R_CERT_ISSUER_FAILED,
14506 - "cert with subject name %s could not be verified because the issuer's cert is expired/invalid or not found",
14507 - cert->subjectName);
14509 + xmlSecError(XMLSEC_ERRORS_HERE,
14510 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14512 + XMLSEC_ERRORS_R_CERT_ISSUER_FAILED,
14513 + "cert with subject name %s could not be verified because the issuer's cert is expired/invalid or not found",
14514 + cert->subjectName);
14516 case SEC_ERROR_EXPIRED_CERTIFICATE:
14517 - xmlSecError(XMLSEC_ERRORS_HERE,
14518 - xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14520 - XMLSEC_ERRORS_R_CERT_HAS_EXPIRED,
14521 - "cert with subject name %s has expired",
14522 - cert->subjectName);
14524 + xmlSecError(XMLSEC_ERRORS_HERE,
14525 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14527 + XMLSEC_ERRORS_R_CERT_HAS_EXPIRED,
14528 + "cert with subject name %s has expired",
14529 + cert->subjectName);
14531 case SEC_ERROR_REVOKED_CERTIFICATE:
14532 - xmlSecError(XMLSEC_ERRORS_HERE,
14533 - xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14535 - XMLSEC_ERRORS_R_CERT_REVOKED,
14536 - "cert with subject name %s has been revoked",
14537 - cert->subjectName);
14539 + xmlSecError(XMLSEC_ERRORS_HERE,
14540 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14542 + XMLSEC_ERRORS_R_CERT_REVOKED,
14543 + "cert with subject name %s has been revoked",
14544 + cert->subjectName);
14547 - xmlSecError(XMLSEC_ERRORS_HERE,
14548 - xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14550 - XMLSEC_ERRORS_R_CERT_VERIFY_FAILED,
14551 - "cert with subject name %s could not be verified",
14552 - cert->subjectName);
14555 + xmlSecError(XMLSEC_ERRORS_HERE,
14556 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14558 + XMLSEC_ERRORS_R_CERT_VERIFY_FAILED,
14559 + "cert with subject name %s could not be verified, errcode %d",
14560 + cert->subjectName,
14561 + PORT_GetError());
14570 * xmlSecNssX509StoreAdoptCert:
14571 - * @store: the pointer to X509 key data store klass.
14572 - * @cert: the pointer to NSS X509 certificate.
14573 - * @type: the certificate type (trusted/untrusted).
14574 + * @store: the pointer to X509 key data store klass.
14575 + * @cert: the pointer to NSS X509 certificate.
14576 + * @type: the certificate type (trusted/untrusted).
14578 * Adds trusted (root) or untrusted certificate to the store.
14580 @@ -265,67 +275,67 @@
14583 xmlSecNssX509StoreAdoptCert(xmlSecKeyDataStorePtr store, CERTCertificate* cert, xmlSecKeyDataType type ATTRIBUTE_UNUSED) {
14584 - xmlSecNssX509StoreCtxPtr ctx;
14586 + xmlSecNssX509StoreCtxPtr ctx;
14589 - xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), -1);
14590 - xmlSecAssert2(cert != NULL, -1);
14591 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), -1);
14592 + xmlSecAssert2(cert != NULL, -1);
14594 - ctx = xmlSecNssX509StoreGetCtx(store);
14595 - xmlSecAssert2(ctx != NULL, -1);
14596 + ctx = xmlSecNssX509StoreGetCtx(store);
14597 + xmlSecAssert2(ctx != NULL, -1);
14599 - if(ctx->certsList == NULL) {
14600 - ctx->certsList = CERT_NewCertList();
14601 - if(ctx->certsList == NULL) {
14602 - xmlSecError(XMLSEC_ERRORS_HERE,
14603 - xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14604 - "CERT_NewCertList",
14605 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
14606 - XMLSEC_ERRORS_NO_MESSAGE);
14611 - ret = CERT_AddCertToListTail(ctx->certsList, cert);
14612 - if(ret != SECSuccess) {
14613 - xmlSecError(XMLSEC_ERRORS_HERE,
14614 - xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14615 - "CERT_AddCertToListTail",
14616 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
14617 - XMLSEC_ERRORS_NO_MESSAGE);
14620 + if(ctx->certsList == NULL) {
14621 + ctx->certsList = CERT_NewCertList();
14622 + if(ctx->certsList == NULL) {
14623 + xmlSecError(XMLSEC_ERRORS_HERE,
14624 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14625 + "CERT_NewCertList",
14626 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
14627 + "error code=%d", PORT_GetError());
14633 + ret = CERT_AddCertToListTail(ctx->certsList, cert);
14634 + if(ret != SECSuccess) {
14635 + xmlSecError(XMLSEC_ERRORS_HERE,
14636 + xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
14637 + "CERT_AddCertToListTail",
14638 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
14639 + "error code=%d", PORT_GetError());
14647 xmlSecNssX509StoreInitialize(xmlSecKeyDataStorePtr store) {
14648 - xmlSecNssX509StoreCtxPtr ctx;
14649 - xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), -1);
14650 + xmlSecNssX509StoreCtxPtr ctx;
14651 + xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId), -1);
14653 - ctx = xmlSecNssX509StoreGetCtx(store);
14654 - xmlSecAssert2(ctx != NULL, -1);
14655 + ctx = xmlSecNssX509StoreGetCtx(store);
14656 + xmlSecAssert2(ctx != NULL, -1);
14658 - memset(ctx, 0, sizeof(xmlSecNssX509StoreCtx));
14659 + memset(ctx, 0, sizeof(xmlSecNssX509StoreCtx));
14666 xmlSecNssX509StoreFinalize(xmlSecKeyDataStorePtr store) {
14667 - xmlSecNssX509StoreCtxPtr ctx;
14668 - xmlSecAssert(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId));
14669 + xmlSecNssX509StoreCtxPtr ctx;
14670 + xmlSecAssert(xmlSecKeyDataStoreCheckId(store, xmlSecNssX509StoreId));
14672 - ctx = xmlSecNssX509StoreGetCtx(store);
14673 - xmlSecAssert(ctx != NULL);
14675 - if (ctx->certsList) {
14676 + ctx = xmlSecNssX509StoreGetCtx(store);
14677 + xmlSecAssert(ctx != NULL);
14679 + if (ctx->certsList) {
14680 CERT_DestroyCertList(ctx->certsList);
14681 ctx->certsList = NULL;
14685 - memset(ctx, 0, sizeof(xmlSecNssX509StoreCtx));
14686 + memset(ctx, 0, sizeof(xmlSecNssX509StoreCtx));
14690 @@ -340,376 +350,213 @@
14692 static CERTCertificate*
14693 xmlSecNssX509FindCert(xmlChar *subjectName, xmlChar *issuerName,
14694 - xmlChar *issuerSerial, xmlChar *ski) {
14695 - CERTCertificate *cert = NULL;
14696 - xmlChar *p = NULL;
14697 - CERTName *name = NULL;
14698 - SECItem *nameitem = NULL;
14699 - PRArenaPool *arena = NULL;
14701 - if (subjectName != NULL) {
14702 - p = xmlSecNssX509NameRead(subjectName, xmlStrlen(subjectName));
14704 - xmlSecError(XMLSEC_ERRORS_HERE,
14706 - "xmlSecNssX509NameRead",
14707 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14709 - xmlSecErrorsSafeString(subjectName));
14713 - arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
14714 - if (arena == NULL) {
14715 - xmlSecError(XMLSEC_ERRORS_HERE,
14718 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
14719 - XMLSEC_ERRORS_NO_MESSAGE);
14723 - name = CERT_AsciiToName((char*)p);
14724 - if (name == NULL) {
14725 - xmlSecError(XMLSEC_ERRORS_HERE,
14727 - "CERT_AsciiToName",
14728 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14729 - XMLSEC_ERRORS_NO_MESSAGE);
14733 - nameitem = SEC_ASN1EncodeItem(arena, NULL, (void *)name,
14734 - SEC_ASN1_GET(CERT_NameTemplate));
14735 - if (nameitem == NULL) {
14736 - xmlSecError(XMLSEC_ERRORS_HERE,
14738 - "SEC_ASN1EncodeItem",
14739 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14740 - XMLSEC_ERRORS_NO_MESSAGE);
14744 - cert = CERT_FindCertByName(CERT_GetDefaultCertDB(), nameitem);
14748 - if((issuerName != NULL) && (issuerSerial != NULL)) {
14749 - CERTIssuerAndSN issuerAndSN;
14751 - p = xmlSecNssX509NameRead(issuerName, xmlStrlen(issuerName));
14753 - xmlSecError(XMLSEC_ERRORS_HERE,
14755 - "xmlSecNssX509NameRead",
14756 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14758 - xmlSecErrorsSafeString(issuerName));
14762 - arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
14763 - if (arena == NULL) {
14764 - xmlSecError(XMLSEC_ERRORS_HERE,
14767 - XMLSEC_ERRORS_R_CRYPTO_FAILED,
14768 - XMLSEC_ERRORS_NO_MESSAGE);
14772 - name = CERT_AsciiToName((char*)p);
14773 - if (name == NULL) {
14774 - xmlSecError(XMLSEC_ERRORS_HERE,
14776 - "CERT_AsciiToName",
14777 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14778 - XMLSEC_ERRORS_NO_MESSAGE);
14782 - nameitem = SEC_ASN1EncodeItem(arena, NULL, (void *)name,
14783 - SEC_ASN1_GET(CERT_NameTemplate));
14784 - if (nameitem == NULL) {
14785 - xmlSecError(XMLSEC_ERRORS_HERE,
14787 - "SEC_ASN1EncodeItem",
14788 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14789 - XMLSEC_ERRORS_NO_MESSAGE);
14793 - memset(&issuerAndSN, 0, sizeof(issuerAndSN));
14794 + xmlChar *issuerSerial, xmlChar *ski) {
14795 + CERTCertificate *cert = NULL;
14796 + CERTName *name = NULL;
14797 + SECItem *nameitem = NULL;
14798 + PRArenaPool *arena = NULL;
14800 + if (subjectName != NULL) {
14801 + arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
14802 + if (arena == NULL) {
14803 + xmlSecError(XMLSEC_ERRORS_HERE,
14806 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
14807 + "error code=%d", PORT_GetError());
14811 - issuerAndSN.derIssuer.data = nameitem->data;
14812 - issuerAndSN.derIssuer.len = nameitem->len;
14813 + name = CERT_AsciiToName((char*)subjectName);
14814 + if (name == NULL) {
14815 + xmlSecError(XMLSEC_ERRORS_HERE,
14817 + "CERT_AsciiToName",
14818 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
14819 + "error code=%d", PORT_GetError());
14823 - /* TBD: serial num can be arbitrarily long */
14824 - xmlSecNssNumToItem(&issuerAndSN.serialNumber, PORT_Atoi((char *)issuerSerial));
14825 + nameitem = SEC_ASN1EncodeItem(arena, NULL, (void *)name,
14826 + SEC_ASN1_GET(CERT_NameTemplate));
14827 + if (nameitem == NULL) {
14828 + xmlSecError(XMLSEC_ERRORS_HERE,
14830 + "SEC_ASN1EncodeItem",
14831 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
14832 + "error code=%d", PORT_GetError());
14836 - cert = CERT_FindCertByIssuerAndSN(CERT_GetDefaultCertDB(),
14838 - SECITEM_FreeItem(&issuerAndSN.serialNumber, PR_FALSE);
14842 - if(ski != NULL) {
14843 - SECItem subjKeyID;
14846 - len = xmlSecBase64Decode(ski, (xmlSecByte*)ski, xmlStrlen(ski));
14848 - xmlSecError(XMLSEC_ERRORS_HERE,
14850 - "xmlSecBase64Decode",
14851 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14853 - xmlSecErrorsSafeString(ski));
14857 - memset(&subjKeyID, 0, sizeof(subjKeyID));
14858 - subjKeyID.data = ski;
14859 - subjKeyID.len = xmlStrlen(ski);
14860 - cert = CERT_FindCertBySubjectKeyID(CERT_GetDefaultCertDB(),
14863 + cert = CERT_FindCertByName(CERT_GetDefaultCertDB(), nameitem);
14871 - if (arena != NULL) {
14872 - PORT_FreeArena(arena, PR_FALSE);
14874 - if (name != NULL) {
14875 - CERT_DestroyName(name);
14877 + if((issuerName != NULL) && (issuerSerial != NULL)) {
14878 + CERTIssuerAndSN issuerAndSN;
14882 + arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
14883 + if (arena == NULL) {
14884 + xmlSecError(XMLSEC_ERRORS_HERE,
14887 + XMLSEC_ERRORS_R_CRYPTO_FAILED,
14888 + "error code=%d", PORT_GetError());
14893 - * xmlSecNssX509NameRead:
14895 -static xmlSecByte *
14896 -xmlSecNssX509NameRead(xmlSecByte *str, int len) {
14897 - xmlSecByte name[256];
14898 - xmlSecByte value[256];
14899 - xmlSecByte *retval = NULL;
14900 - xmlSecByte *p = NULL;
14901 - int nameLen, valueLen;
14903 - xmlSecAssert2(str != NULL, NULL);
14905 - /* return string should be no longer than input string */
14906 - retval = (xmlSecByte *)PORT_Alloc(len+1);
14907 - if(retval == NULL) {
14908 - xmlSecError(XMLSEC_ERRORS_HERE,
14911 - XMLSEC_ERRORS_R_MALLOC_FAILED,
14912 - XMLSEC_ERRORS_NO_MESSAGE);
14918 - /* skip spaces after comma or semicolon */
14919 - while((len > 0) && isspace(*str)) {
14923 - nameLen = xmlSecNssX509NameStringRead(&str, &len, name, sizeof(name), '=', 0);
14924 - if(nameLen < 0) {
14925 - xmlSecError(XMLSEC_ERRORS_HERE,
14927 - "xmlSecNssX509NameStringRead",
14928 - XMLSEC_ERRORS_R_XMLSEC_FAILED,
14929 - XMLSEC_ERRORS_NO_MESSAGE);
14932 - memcpy(p, name, nameLen);
14937 - if((*str) == '\"') {
14938 - valueLen = xmlSecNssX509NameStringRead(&str, &len,
14939 - value, sizeof(value), '"', 1);
14940 - if(valueLen < 0) {
14941 - xmlSecError(XMLSEC_ERRORS_HERE,
14942 + name = CERT_AsciiToName((char*)issuerName);
14943 + if (name == NULL) {
14944 + xmlSecError(XMLSEC_ERRORS_HERE,
14946 - "xmlSecNssX509NameStringRead",
14947 + "CERT_AsciiToName",
14948 XMLSEC_ERRORS_R_XMLSEC_FAILED,
14949 - XMLSEC_ERRORS_NO_MESSAGE);
14952 - /* skip spaces before comma or semicolon */
14953 - while((len > 0) && isspace(*str)) {
14955 + "error code=%d", PORT_GetError());
14958 - if((len > 0) && ((*str) != ',')) {
14959 - xmlSecError(XMLSEC_ERRORS_HERE,
14962 - XMLSEC_ERRORS_R_INVALID_DATA,
14963 - "comma is expected");
14969 + nameitem = SEC_ASN1EncodeItem(arena, NULL, (void *)name,
14970 + SEC_ASN1_GET(CERT_NameTemplate));
14971 + if (nameitem == NULL) {
14972 + xmlSecError(XMLSEC_ERRORS_HERE,
14974 + "SEC_ASN1EncodeItem",
14975 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
14976 + "error code=%d", PORT_GetError());
14980 - memcpy(p, value, valueLen);
14983 - } else if((*str) == '#') {
14984 - /* TODO: read octect values */
14985 - xmlSecError(XMLSEC_ERRORS_HERE,
14988 - XMLSEC_ERRORS_R_INVALID_DATA,
14989 - "reading octect values is not implemented yet");
14992 - valueLen = xmlSecNssX509NameStringRead(&str, &len,
14993 - value, sizeof(value), ',', 1);
14994 - if(valueLen < 0) {
14995 - xmlSecError(XMLSEC_ERRORS_HERE,
14997 + memset(&issuerAndSN, 0, sizeof(issuerAndSN));
14999 + issuerAndSN.derIssuer.data = nameitem->data;
15000 + issuerAndSN.derIssuer.len = nameitem->len;
15002 + if( xmlSecNssIntegerToItem( issuerSerial, &issuerAndSN.serialNumber ) < 0 ) {
15003 + xmlSecError(XMLSEC_ERRORS_HERE,
15005 - "xmlSecNssX509NameStringRead",
15006 + "xmlSecNssIntegerToItem",
15007 XMLSEC_ERRORS_R_XMLSEC_FAILED,
15008 - XMLSEC_ERRORS_NO_MESSAGE);
15011 - memcpy(p, value, valueLen);
15018 + "serial number=%s",
15019 + xmlSecErrorsSafeString(issuerSerial));
15023 + cert = CERT_FindCertByIssuerAndSN(CERT_GetDefaultCertDB(),
15025 + SECITEM_FreeItem(&issuerAndSN.serialNumber, PR_FALSE);
15029 + if(ski != NULL) {
15030 + SECItem subjKeyID;
15033 + len = xmlSecBase64Decode(ski, (xmlSecByte*)ski, xmlStrlen(ski));
15035 + xmlSecError(XMLSEC_ERRORS_HERE,
15037 + "xmlSecBase64Decode",
15038 + XMLSEC_ERRORS_R_XMLSEC_FAILED,
15040 + xmlSecErrorsSafeString(ski));
15044 + memset(&subjKeyID, 0, sizeof(subjKeyID));
15045 + subjKeyID.data = ski;
15046 + subjKeyID.len = xmlStrlen(ski);
15047 + cert = CERT_FindCertBySubjectKeyID(CERT_GetDefaultCertDB(),
15060 - PORT_Free(retval);
15062 + if (arena != NULL) {
15063 + PORT_FreeArena(arena, PR_FALSE);
15065 + if (name != NULL) {
15066 + CERT_DestroyName(name);
15073 +xmlSecNssIntegerToItem(
15074 + const xmlChar* integer ,
15078 + xmlSecSize i, length ;
15079 + const xmlSecByte* bnInteger ;
15081 + xmlSecAssert2( integer != NULL, -1 ) ;
15082 + xmlSecAssert2( item != NULL, -1 ) ;
15085 - * xmlSecNssX509NameStringRead:
15088 -xmlSecNssX509NameStringRead(xmlSecByte **str, int *strLen,
15089 - xmlSecByte *res, int resLen,
15090 - xmlSecByte delim, int ingoreTrailingSpaces) {
15091 - xmlSecByte *p, *q, *nonSpace;
15093 - xmlSecAssert2(str != NULL, -1);
15094 - xmlSecAssert2(strLen != NULL, -1);
15095 - xmlSecAssert2(res != NULL, -1);
15098 - nonSpace = q = res;
15099 - while(((p - (*str)) < (*strLen)) && ((*p) != delim) && ((q - res) < resLen)) {
15100 - if((*p) != '\\') {
15101 - if(ingoreTrailingSpaces && !isspace(*p)) {
15108 - if(xmlSecIsHex((*p))) {
15109 - if((p - (*str) + 1) >= (*strLen)) {
15110 - xmlSecError(XMLSEC_ERRORS_HERE,
15113 - XMLSEC_ERRORS_R_INVALID_DATA,
15114 - "two hex digits expected");
15117 - *(q++) = xmlSecGetHex(p[0]) * 16 + xmlSecGetHex(p[1]);
15120 - if(((++p) - (*str)) >= (*strLen)) {
15121 - xmlSecError(XMLSEC_ERRORS_HERE,
15124 - XMLSEC_ERRORS_R_INVALID_DATA,
15125 - "escaped symbol missed");
15132 - if(((p - (*str)) < (*strLen)) && ((*p) != delim)) {
15133 - xmlSecError(XMLSEC_ERRORS_HERE,
15136 - XMLSEC_ERRORS_R_INVALID_SIZE,
15137 - "buffer is too small");
15140 - (*strLen) -= (p - (*str));
15142 - return((ingoreTrailingSpaces) ? nonSpace - res + 1 : q - res);
15144 + if( xmlSecBnInitialize( &bn, 0 ) < 0 ) {
15145 + xmlSecError( XMLSEC_ERRORS_HERE,
15147 + "xmlSecBnInitialize",
15148 + XMLSEC_ERRORS_R_INVALID_DATA,
15149 + XMLSEC_ERRORS_NO_MESSAGE ) ;
15153 -/* code lifted from NSS */
15155 -xmlSecNssNumToItem(SECItem *it, unsigned long ui)
15157 - unsigned char bb[5];
15161 - bb[1] = (unsigned char) (ui >> 24);
15162 - bb[2] = (unsigned char) (ui >> 16);
15163 - bb[3] = (unsigned char) (ui >> 8);
15164 - bb[4] = (unsigned char) (ui);
15167 - ** Small integers are encoded in a single byte. Larger integers
15168 - ** require progressively more space.
15171 - if (ui > 0x7fff) {
15172 - if (ui > 0x7fffffL) {
15173 - if (ui >= 0x80000000L) {
15188 - it->data = (unsigned char *)PORT_Alloc(len);
15189 - if (it->data == NULL) {
15192 + if( xmlSecBnFromDecString( &bn, integer ) < 0 ) {
15193 + xmlSecError( XMLSEC_ERRORS_HERE,
15195 + "xmlSecBnFromDecString",
15196 + XMLSEC_ERRORS_R_INVALID_DATA,
15197 + XMLSEC_ERRORS_NO_MESSAGE ) ;
15199 + xmlSecBnFinalize( &bn ) ;
15203 + length = xmlSecBnGetSize( &bn ) ;
15204 + if( length <= 0 ) {
15205 + xmlSecError( XMLSEC_ERRORS_HERE,
15207 + "xmlSecBnGetSize",
15208 + XMLSEC_ERRORS_R_INVALID_DATA,
15209 + XMLSEC_ERRORS_NO_MESSAGE ) ;
15211 + xmlSecBnFinalize( &bn ) ;
15215 + bnInteger = xmlSecBnGetData( &bn ) ;
15216 + if( bnInteger == NULL ) {
15217 + xmlSecError( XMLSEC_ERRORS_HERE,
15219 + "xmlSecBnGetData",
15220 + XMLSEC_ERRORS_R_INVALID_DATA,
15221 + XMLSEC_ERRORS_NO_MESSAGE ) ;
15224 - PORT_Memcpy(it->data, bb + (sizeof(bb) - len), len);
15225 + xmlSecBnFinalize( &bn ) ;
15229 + item->data = ( unsigned char * )PORT_Alloc( length );
15230 + if( item->data == NULL ) {
15231 + xmlSecError( XMLSEC_ERRORS_HERE,
15234 + XMLSEC_ERRORS_R_INVALID_DATA,
15235 + XMLSEC_ERRORS_NO_MESSAGE ) ;
15237 + xmlSecBnFinalize( &bn ) ;
15241 + item->len = length;
15243 + for( i = 0 ; i < length ; i ++ )
15244 + item->data[i] = *( bnInteger + i ) ;
15246 + xmlSecBnFinalize( &bn ) ;
15250 -#endif /* XMLSEC_NO_X509 */
15252 +#endif /* XMLSEC_NO_X509 */
15254 --- misc/xmlsec1-1.2.6/win32/Makefile.msvc 2004-06-09 16:35:12.000000000 +0200
15255 +++ misc/build/xmlsec1-1.2.6/win32/Makefile.msvc 2008-06-29 23:44:19.000000000 +0200
15256 @@ -223,6 +223,10 @@
15257 $(XMLSEC_OPENSSL_INTDIR_A)\x509vfy.obj
15259 XMLSEC_NSS_OBJS = \
15260 + $(XMLSEC_NSS_INTDIR)\akmngr.obj\
15261 + $(XMLSEC_NSS_INTDIR)\keytrans.obj\
15262 + $(XMLSEC_NSS_INTDIR)\keywrapers.obj\
15263 + $(XMLSEC_NSS_INTDIR)\tokens.obj\
15264 $(XMLSEC_NSS_INTDIR)\app.obj\
15265 $(XMLSEC_NSS_INTDIR)\bignum.obj\
15266 $(XMLSEC_NSS_INTDIR)\ciphers.obj \
15267 @@ -235,9 +239,6 @@
15268 $(XMLSEC_NSS_INTDIR)\x509.obj\
15269 $(XMLSEC_NSS_INTDIR)\x509vfy.obj\
15270 $(XMLSEC_NSS_INTDIR)\keysstore.obj\
15271 - $(XMLSEC_NSS_INTDIR)\kt_rsa.obj\
15272 - $(XMLSEC_NSS_INTDIR)\kw_des.obj\
15273 - $(XMLSEC_NSS_INTDIR)\kw_aes.obj\
15274 $(XMLSEC_NSS_INTDIR)\strings.obj
15275 XMLSEC_NSS_OBJS_A = \
15276 $(XMLSEC_NSS_INTDIR_A)\app.obj\
15277 @@ -258,6 +259,7 @@
15278 $(XMLSEC_NSS_INTDIR_A)\strings.obj
15280 XMLSEC_MSCRYPTO_OBJS = \
15281 + $(XMLSEC_MSCRYPTO_INTDIR)\akmngr.obj\
15282 $(XMLSEC_MSCRYPTO_INTDIR)\app.obj\
15283 $(XMLSEC_MSCRYPTO_INTDIR)\crypto.obj \
15284 $(XMLSEC_MSCRYPTO_INTDIR)\ciphers.obj \
15285 @@ -376,7 +378,7 @@
15286 XMLSEC_OPENSSL_SOLIBS = libeay32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib
15287 XMLSEC_OPENSSL_ALIBS = libeay32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib
15289 -XMLSEC_NSS_SOLIBS = smime3.lib ssl3.lib nss3.lib libnspr4.lib libplds4.lib libplc4.lib kernel32.lib user32.lib gdi32.lib
15290 +XMLSEC_NSS_SOLIBS = smime3.lib nss3.lib nspr4.lib kernel32.lib user32.lib gdi32.lib
15291 XMLSEC_NSS_ALIBS = smime3.lib ssl3.lib nss3.lib libnspr4_s.lib libplds4_s.lib libplc4_s.lib kernel32.lib user32.lib gdi32.lib
15293 XMLSEC_MSCRYPTO_SOLIBS = kernel32.lib user32.lib gdi32.lib Crypt32.lib Advapi32.lib