convert libxmlsec to gbuild
Change-Id: Id0ad4e1c8e3e1ac03c625fb77b70fe0aa8ddfcdc
This commit is contained in:
@@ -107,6 +107,7 @@ $(eval $(call gb_Module_add_moduledirs,tail_end,\
|
||||
libwpd \
|
||||
libwpg \
|
||||
libwps \
|
||||
libxmlsec \
|
||||
lingucomponent \
|
||||
linguistic \
|
||||
lotuswordpro \
|
||||
|
@@ -116,6 +116,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
|
||||
libwpd \
|
||||
libwpg \
|
||||
libwps \
|
||||
libxmlsec \
|
||||
lingucomponent \
|
||||
linguistic \
|
||||
lotuswordpro \
|
||||
|
32
libxmlsec/ExternalPackage_xmlsec.mk
Normal file
32
libxmlsec/ExternalPackage_xmlsec.mk
Normal file
@@ -0,0 +1,32 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
$(eval $(call gb_ExternalPackage_ExternalPackage,xmlsec,xmlsec))
|
||||
|
||||
$(eval $(call gb_ExternalPackage_use_external_project,xmlsec,xmlsec))
|
||||
|
||||
ifeq ($(OS),WNT)
|
||||
ifeq ($(COM),GCC)
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec1.dll.a,src/nss/.libs/libxmlsec1-nss.dll.a))
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec1.dll,src/nss/.libs/libxmlsec1-nss.dll))
|
||||
else
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec-mscrypto.lib,win32/binaries/libxmlsec-mscrypto.lib))
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec.lib,win32/binaries/libxmlsec.lib))
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,bin/libxmlsec-mscrypto.dll,win32/binaries/libxmlsec-mscrypto.dll))
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,bin/libxmlsec.dll,win32/binaries/libxmlsec.dll))
|
||||
endif
|
||||
else ifeq ($(OS),ANDROID)
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec1.a,src/.libs/libxmlsec1.a))
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec1-openssl.a,src/openssl/.libs/libxmlsec1-openssl.a))
|
||||
else
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec1.a,src/.libs/libxmlsec1.a))
|
||||
$(eval $(call gb_ExternalPackage_add_file,xmlsec,lib/libxmlsec1-nss.a,src/nss/.libs/libxmlsec1-nss.a))
|
||||
endif
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
63
libxmlsec/ExternalProject_xmlsec.mk
Normal file
63
libxmlsec/ExternalProject_xmlsec.mk
Normal file
@@ -0,0 +1,63 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
$(eval $(call gb_ExternalProject_ExternalProject,xmlsec))
|
||||
|
||||
$(eval $(call gb_ExternalProject_use_unpacked,xmlsec,xmlsec))
|
||||
|
||||
$(eval $(call gb_ExternalProject_register_targets,xmlsec,\
|
||||
build \
|
||||
))
|
||||
|
||||
ifeq ($(OS),WNT)
|
||||
|
||||
ifeq ($(COM),GCC)
|
||||
$(call gb_ExternalProject_get_state_target,xmlsec,build) :
|
||||
cd $(EXTERNAL_WORKDIR) \
|
||||
&& autoreconf \
|
||||
&& ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) \
|
||||
--without-libxslt --without-openssl --without-gnutls --disable-crypto-dl \
|
||||
$(if $(filter NO,$(SYSTEM_NSS)),--disable-pkgconfig) \
|
||||
CC="$(CC) -mthreads $(if $(filter YES,$(MINGW_SHARED_GCCLIB)),-shared-libgcc)" \
|
||||
LDFLAGS="-Wl,--no-undefined $(ILIB:;= -L)" \
|
||||
LIBS="$(if $(filter YES,$(MINGW_SHARED_GXXLIB)),$(MINGW_SHARED__LIBSTDCPP))"
|
||||
$(MAKE) \
|
||||
&& touch $@
|
||||
|
||||
else
|
||||
$(call gb_ExternalProject_get_state_target,xmlsec,build) :
|
||||
cd $(EXTERNAL_WORKDIR)/win32 \
|
||||
&& cscript configure.js crypto=mscrypto xslt=no iconv=no static=no \
|
||||
$(if $(filter-out full,$(PRODUCT)),debug=yes) \
|
||||
&& unset MAKEFLAGS \
|
||||
&& LIB="$(ILIB)" nmake \
|
||||
&& touch $@
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
$(call gb_ExternalProject_get_state_target,xmlsec,build) :
|
||||
cd $(EXTERNAL_WORKDIR) \
|
||||
&& autoreconf \
|
||||
&& $(if $(filter MACOSX,$(OS)),ACLOCAL="aclocal -I $(EXTERNAL_WORKDIR)/m4/mac") \
|
||||
./configure \
|
||||
--with-pic --disable-shared --disable-crypto-dl --without-libxslt --without-gnutls \
|
||||
$(if $(filter ANDROID,$(OS)),--with-openssl=$(OUTDIR),--without-openssl) \
|
||||
$(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
|
||||
$(if $(filter NO,$(SYSTEM_NSS))$(filter MACOSX,$(OS)),--disable-pkgconfig) \
|
||||
$(if $(filter YES,$(CROSS_COMPILING)),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
|
||||
$(if $(SYSBASE),CFLAGS="-I$(SYSBASE)/usr/include" \
|
||||
LDFLAGS="-L$(SYSBASE)/usr/lib $(if $(filter-out LINUX FREEBSD,$(OS)),,-Wl,-z,origin -Wl,-rpath,'$$$$ORIGIN:$$$$ORIGIN/../ure-link/lib')",\
|
||||
$(if $(filter-out MACOSX,$(OS)),,LDFLAGS="-Wl,-dylib_file,@executable_path/libnssutil3.dylib:$(OUTDIR)/lib/libnssutil3.dylib")) \
|
||||
&& $(MAKE) \
|
||||
&& touch $@
|
||||
|
||||
endif
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
7
libxmlsec/Makefile
Normal file
7
libxmlsec/Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
|
||||
module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
include $(module_directory)/../solenv/gbuild/partial_build.mk
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
20
libxmlsec/Module_libxmlsec.mk
Normal file
20
libxmlsec/Module_libxmlsec.mk
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
$(eval $(call gb_Module_Module,libxmlsec))
|
||||
|
||||
ifneq ($(filter-out ANDROID IOS,$(OS)),)
|
||||
$(eval $(call gb_Module_add_targets,libxmlsec,\
|
||||
UnpackedTarball_xmlsec \
|
||||
ExternalPackage_xmlsec \
|
||||
ExternalProject_xmlsec \
|
||||
))
|
||||
endif
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
50
libxmlsec/UnpackedTarball_xmlsec.mk
Normal file
50
libxmlsec/UnpackedTarball_xmlsec.mk
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
$(eval $(call gb_UnpackedTarball_UnpackedTarball,xmlsec))
|
||||
|
||||
$(eval $(call gb_UnpackedTarball_set_tarball,xmlsec,$(LIBXMLSEC_TARBALL)))
|
||||
|
||||
$(eval $(call gb_UnpackedTarball_add_patches,xmlsec,\
|
||||
libxmlsec/xmlsec1-configure.patch \
|
||||
libxmlsec/xmlsec1-configure-libxml-libxslt.patch \
|
||||
libxmlsec/xmlsec1-olderlibxml2.patch \
|
||||
libxmlsec/xmlsec1-nssdisablecallbacks.patch \
|
||||
libxmlsec/xmlsec1-nssmangleciphers.patch \
|
||||
libxmlsec/xmlsec1-noverify.patch \
|
||||
libxmlsec/xmlsec1-mingw-keymgr-mscrypto.patch \
|
||||
libxmlsec/xmlsec1-vc.patch \
|
||||
libxmlsec/xmlsec1-1.2.14_fix_extern_c.patch \
|
||||
libxmlsec/xmlsec1-android.patch \
|
||||
libxmlsec/xmlsec1-1.2.14-ansi.patch \
|
||||
libxmlsec/xmlsec1-customkeymanage.patch \
|
||||
))
|
||||
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,include/xmlsec/mscrypto/akmngr.h,libxmlsec/include/akmngr_mscrypto.h))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,src/mscrypto/akmngr.c,libxmlsec/src/akmngr_mscrypto.c))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,include/xmlsec/nss/akmngr.h,libxmlsec/include/akmngr_nss.h))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,include/xmlsec/nss/ciphers.h,libxmlsec/include/ciphers.h))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,include/xmlsec/nss/tokens.h,libxmlsec/include/tokens.h))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,src/nss/akmngr.c,libxmlsec/src/akmngr_nss.c))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,src/nss/keywrapers.c,libxmlsec/src/keywrapers.c))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,xmlsec,src/nss/tokens.c,libxmlsec/src/tokens.c))
|
||||
|
||||
ifeq ($(OS)$(COM),WNTGCC)
|
||||
$(eval $(call gb_UnpackedTarball_add_patches,xmlsec,\
|
||||
libxmlsec/xmlsec1-mingw32.patch \
|
||||
))
|
||||
endif
|
||||
|
||||
ifeq ($(OS)$(CPU),MACOSXP)
|
||||
$(eval $(call gb_UnpackedTarball_add_patches,xmlsec,\
|
||||
libxmlsec/xmlsec1-1.2.14_old_automake.patch \
|
||||
))
|
||||
endif
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
72
libxmlsec/include/akmngr_mscrypto.h
Normal file
72
libxmlsec/include/akmngr_mscrypto.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright ..........................
|
||||
*/
|
||||
#ifndef __XMLSEC_MSCRYPTO_AKMNGR_H__
|
||||
#define __XMLSEC_MSCRYPTO_AKMNGR_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/keys.h>
|
||||
#include <xmlsec/transforms.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT xmlSecKeysMngrPtr
|
||||
xmlSecMSCryptoAppliedKeysMngrCreate(
|
||||
HCERTSTORE keyStore ,
|
||||
HCERTSTORE certStore
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecMSCryptoAppliedKeysMngrSymKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCRYPTKEY symKey
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecMSCryptoAppliedKeysMngrPubKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCRYPTKEY pubKey
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecMSCryptoAppliedKeysMngrPriKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCRYPTKEY priKey
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore (
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCERTSTORE keyStore
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore (
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCERTSTORE trustedStore
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore (
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCERTSTORE untrustedStore
|
||||
) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __XMLSEC_MSCRYPTO_AKMNGR_H__ */
|
||||
|
||||
|
||||
|
57
libxmlsec/include/akmngr_nss.h
Normal file
57
libxmlsec/include/akmngr_nss.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright ..........................
|
||||
*/
|
||||
#ifndef __XMLSEC_NSS_AKMNGR_H__
|
||||
#define __XMLSEC_NSS_AKMNGR_H__
|
||||
|
||||
#include <nss.h>
|
||||
#include <nspr.h>
|
||||
#include <pk11func.h>
|
||||
#include <cert.h>
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/keys.h>
|
||||
#include <xmlsec/transforms.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT xmlSecKeysMngrPtr
|
||||
xmlSecNssAppliedKeysMngrCreate(
|
||||
PK11SlotInfo** slots,
|
||||
int cSlots,
|
||||
CERTCertDBHandle* handler
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssAppliedKeysMngrSymKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
PK11SymKey* symKey
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssAppliedKeysMngrPubKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
SECKEYPublicKey* pubKey
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssAppliedKeysMngrPriKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
SECKEYPrivateKey* priKey
|
||||
) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __XMLSEC_NSS_AKMNGR_H__ */
|
||||
|
||||
|
||||
|
36
libxmlsec/include/ciphers.h
Normal file
36
libxmlsec/include/ciphers.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright ..........................
|
||||
*/
|
||||
#ifndef __XMLSEC_NSS_CIPHERS_H__
|
||||
#define __XMLSEC_NSS_CIPHERS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/keys.h>
|
||||
#include <xmlsec/transforms.h>
|
||||
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int xmlSecNssSymKeyDataAdoptKey( xmlSecKeyDataPtr data,
|
||||
PK11SymKey* symkey ) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT xmlSecKeyDataPtr xmlSecNssSymKeyDataKeyAdopt( PK11SymKey* symKey ) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT PK11SymKey* xmlSecNssSymKeyDataGetKey(xmlSecKeyDataPtr data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __XMLSEC_NSS_CIPHERS_H__ */
|
||||
|
||||
|
||||
|
183
libxmlsec/include/tokens.h
Normal file
183
libxmlsec/include/tokens.h
Normal file
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright (c) 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Contributor(s): _____________________________
|
||||
*
|
||||
*/
|
||||
#ifndef __XMLSEC_NSS_TOKENS_H__
|
||||
#define __XMLSEC_NSS_TOKENS_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <nss.h>
|
||||
#include <pk11func.h>
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/list.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* xmlSecNssKeySlotListId
|
||||
*
|
||||
* The crypto mechanism list klass
|
||||
*/
|
||||
#define xmlSecNssKeySlotListId xmlSecNssKeySlotListGetKlass()
|
||||
XMLSEC_CRYPTO_EXPORT xmlSecPtrListId xmlSecNssKeySlotListGetKlass( void ) ;
|
||||
|
||||
/*******************************************
|
||||
* KeySlot interfaces
|
||||
*******************************************/
|
||||
/**
|
||||
* Internal NSS key slot data
|
||||
* @mechanismList: the mechanisms that the slot bound with.
|
||||
* @slot: the pkcs slot
|
||||
*
|
||||
* This context is located after xmlSecPtrList
|
||||
*/
|
||||
typedef struct _xmlSecNssKeySlot xmlSecNssKeySlot ;
|
||||
typedef struct _xmlSecNssKeySlot* xmlSecNssKeySlotPtr ;
|
||||
|
||||
struct _xmlSecNssKeySlot {
|
||||
CK_MECHANISM_TYPE_PTR mechanismList ; /* mech. array, NULL ternimated */
|
||||
PK11SlotInfo* slot ;
|
||||
} ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotSetMechList(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE_PTR mechanismList
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotEnableMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE mechanism
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotDisableMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE mechanism
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT CK_MECHANISM_TYPE_PTR
|
||||
xmlSecNssKeySlotGetMechList(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotSetSlot(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
PK11SlotInfo* slot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotInitialize(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
PK11SlotInfo* slot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT void
|
||||
xmlSecNssKeySlotFinalize(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT PK11SlotInfo*
|
||||
xmlSecNssKeySlotGetSlot(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT xmlSecNssKeySlotPtr
|
||||
xmlSecNssKeySlotCreate() ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotCopy(
|
||||
xmlSecNssKeySlotPtr newKeySlot ,
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT xmlSecNssKeySlotPtr
|
||||
xmlSecNssKeySlotDuplicate(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT void
|
||||
xmlSecNssKeySlotDestroy(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotBindMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE type
|
||||
) ;
|
||||
|
||||
XMLSEC_CRYPTO_EXPORT int
|
||||
xmlSecNssKeySlotSupportMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE type
|
||||
) ;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* PKCS#11 crypto token interfaces
|
||||
*
|
||||
* A PKCS#11 slot repository will be defined internally. From the
|
||||
* repository, a user can specify a particular slot for a certain crypto
|
||||
* mechanism.
|
||||
*
|
||||
* In some situation, some cryptographic operation should act in a user
|
||||
* designated devices. The interfaces defined here provide the way. If
|
||||
* the user do not initialize the repository distinctly, the interfaces
|
||||
* use the default functions provided by NSS itself.
|
||||
*
|
||||
************************************************************************/
|
||||
/**
|
||||
* Initialize NSS pkcs#11 slot repository
|
||||
*
|
||||
* Returns 0 if success or -1 if an error occurs.
|
||||
*/
|
||||
XMLSEC_CRYPTO_EXPORT int xmlSecNssSlotInitialize( void ) ;
|
||||
|
||||
/**
|
||||
* Shutdown and destroy NSS pkcs#11 slot repository
|
||||
*/
|
||||
XMLSEC_CRYPTO_EXPORT void xmlSecNssSlotShutdown() ;
|
||||
|
||||
/**
|
||||
* Get PKCS#11 slot handler
|
||||
* @type the mechanism that the slot must support.
|
||||
*
|
||||
* Returns a pointer to PKCS#11 slot or NULL if an error occurs.
|
||||
*
|
||||
* Notes: The returned handler must be destroied distinctly.
|
||||
*/
|
||||
XMLSEC_CRYPTO_EXPORT PK11SlotInfo* xmlSecNssSlotGet( CK_MECHANISM_TYPE type ) ;
|
||||
|
||||
/**
|
||||
* Adopt a pkcs#11 slot with a mechanism into the repository
|
||||
* @slot: the pkcs#11 slot.
|
||||
* @mech: the mechanism.
|
||||
*
|
||||
* If @mech is available( @mech != CKM_INVALID_MECHANISM ), every operation with
|
||||
* this mechanism only can perform on the @slot.
|
||||
*
|
||||
* Returns 0 if success or -1 if an error occurs.
|
||||
*/
|
||||
XMLSEC_CRYPTO_EXPORT int xmlSecNssSlotAdopt( PK11SlotInfo* slot, CK_MECHANISM_TYPE mech ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __XMLSEC_NSS_TOKENS_H__ */
|
||||
|
||||
|
@@ -1,249 +0,0 @@
|
||||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=.
|
||||
|
||||
PRJNAME=xmlsec1
|
||||
TARGET=so_xmlsec1
|
||||
EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE : settings.mk
|
||||
|
||||
.IF "$(OS)" == "ANDROID" || "$(OS)" == "IOS"
|
||||
@all:
|
||||
@echo "FIXME: XMLSec module not buildable yet on this platform"
|
||||
.ENDIF
|
||||
|
||||
# --- Files --------------------------------------------------------
|
||||
|
||||
XMLSEC1VERSION=1.2.14
|
||||
|
||||
TARFILE_NAME=$(PRJNAME)-$(XMLSEC1VERSION)
|
||||
TARFILE_MD5=1f24ab1d39f4a51faf22244c94a6203f
|
||||
|
||||
#xmlsec1-configure.patch: Set up the build. Straightforward configuration
|
||||
#xmlsec1-configure-libxml-libxslt.patch: empty "$with_libxml" prepends /bin :-(
|
||||
#xmlsec1-olderlibxml2.patch: Allow build against older libxml2, for macosx
|
||||
#xmlsec1-nssdisablecallbacks.patch: Disable use of smime3 so don't need to package it
|
||||
#xmlsec1-customkeymanage.patch: Could we do this alternatively outside xmlsec
|
||||
#xmlsec1-nssmangleciphers.patch: Dubious, do we still need this ?
|
||||
#xmlsec1-noverify.patch: As per readme.txt.
|
||||
#xmlsec1-mingw32.patch: Mingw32 support.
|
||||
#xmlsec1-mingw-customkeymanage-addmscrypto.patch: builds the custom keymanager on mingw
|
||||
#xmlsec1-vc.path: support for Visual C++ 10
|
||||
#xmlsec1-1.2.14-ansi.patch: otherwise, at least MacPorts autoreconf (GNU
|
||||
# Autoconf) 2.69 fails with "configure.in:50: error: automatic de-ANSI-fication
|
||||
# support has been removed" (cf. upstream <http://git.gnome.org/browse/xmlsec/
|
||||
# commit/?id=6a4968bc33f83aaf61efc0a80333350ce9c372f5> "error in macro
|
||||
# AM_C_PROTOTYPES (Roumen)")
|
||||
PATCH_FILES=\
|
||||
xmlsec1-configure.patch \
|
||||
xmlsec1-configure-libxml-libxslt.patch \
|
||||
xmlsec1-olderlibxml2.patch \
|
||||
xmlsec1-nssdisablecallbacks.patch \
|
||||
xmlsec1-customkeymanage.patch \
|
||||
xmlsec1-nssmangleciphers.patch \
|
||||
xmlsec1-noverify.patch \
|
||||
xmlsec1-mingw-keymgr-mscrypto.patch \
|
||||
xmlsec1-vc10.patch \
|
||||
xmlsec1-1.2.14_fix_extern_c.patch \
|
||||
xmlsec1-android.patch \
|
||||
xmlsec1-1.2.14-ansi.patch \
|
||||
xmlsec1-oldlibtool.patch
|
||||
|
||||
.IF "$(GUI)$(COM)"=="WNTGCC"
|
||||
PATCH_FILES+=xmlsec1-mingw32.patch
|
||||
.ENDIF
|
||||
|
||||
.IF "$(OS)$(CPU)"=="MACOSXP"
|
||||
PATCH_FILES+=xmlsec1-1.2.14_old_automake.patch
|
||||
EXTRA_LINKFLAGS+=-Wl,-dylib_file,@executable_path/libnssutil3.dylib:$(SOLARLIBDIR)/libnssutil3.dylib
|
||||
.ENDIF
|
||||
|
||||
ADDITIONAL_FILES= \
|
||||
include/xmlsec/mscrypto/akmngr.h \
|
||||
src/mscrypto/akmngr.c \
|
||||
include/xmlsec/nss/akmngr.h \
|
||||
include/xmlsec/nss/ciphers.h \
|
||||
include/xmlsec/nss/tokens.h \
|
||||
src/nss/akmngr.c \
|
||||
src/nss/keywrapers.c \
|
||||
src/nss/tokens.c
|
||||
|
||||
.IF "$(GUI)"=="WNT"
|
||||
CRYPTOLIB=mscrypto
|
||||
.ELSE
|
||||
CRYPTOLIB=nss
|
||||
.ENDIF
|
||||
|
||||
.IF "$(OS)"=="WNT"
|
||||
.IF "$(COM)"=="GCC"
|
||||
xmlsec_CC=$(CC) -mthreads
|
||||
.IF "$(MINGW_SHARED_GCCLIB)"=="YES"
|
||||
xmlsec_CC+=-shared-libgcc
|
||||
.ENDIF
|
||||
xmlsec_LIBS=
|
||||
.IF "$(MINGW_SHARED_GXXLIB)"=="YES"
|
||||
xmlsec_LIBS+=$(MINGW_SHARED_LIBSTDCPP)
|
||||
.ENDIF
|
||||
CONF_ILIB=
|
||||
.IF "$(ILIB)" != ""
|
||||
CONF_ILIB=-L$(ILIB:s/;/ -L/)
|
||||
.ENDIF
|
||||
|
||||
CONFIGURE_DIR=
|
||||
CONFIGURE_ACTION=autoreconf; ./configure
|
||||
|
||||
BUILD_AND_HOST=--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) MINGW_SYSROOT=$(MINGW_SYSROOT) OBJDUMP="$(OBJDUMP)"
|
||||
|
||||
CONFIGURE_FLAGS=--with-libxslt=no --with-openssl=no --with-gnutls=no --disable-crypto-dl $(BUILD_AND_HOST) CC="$(xmlsec_CC)" LDFLAGS="-Wl,--no-undefined $(CONF_ILIB)" LIBS="$(xmlsec_LIBS)" LIBXML2LIB="$(LIBXML2LIB)" ZLIB3RDLIB=$(ZLIB3RDLIB)
|
||||
|
||||
.IF "$(SYSTEM_NSS)" != "YES"
|
||||
CONFIGURE_FLAGS+=--enable-pkgconfig=no
|
||||
.ENDIF
|
||||
BUILD_ACTION=$(GNUMAKE) -j$(GMAKE_MODULE_PARALLELISM)
|
||||
BUILD_DIR=$(CONFIGURE_DIR)
|
||||
|
||||
.ELSE # "$(COM)"!="GCC"
|
||||
|
||||
CONFIGURE_DIR=win32
|
||||
CONFIGURE_ACTION=cscript configure.js
|
||||
.IF "$(product)"!="full" && "$(CCNUMVER)" >= "001399999999"
|
||||
CONFIGURE_FLAGS=crypto=$(CRYPTOLIB) debug=yes xslt=no iconv=no static=no include=$(BASEINC) lib=$(BASELIB)
|
||||
.ELSE
|
||||
CONFIGURE_FLAGS=crypto=$(CRYPTOLIB) xslt=no iconv=no static=no include=$(BASEINC) lib=$(BASELIB)
|
||||
.ENDIF
|
||||
BUILD_ACTION=nmake
|
||||
BUILD_DIR=$(CONFIGURE_DIR)
|
||||
.ENDIF # "$(COM)"=="GCC"
|
||||
|
||||
.ELSE # "$(OS)"!="WNT"
|
||||
|
||||
.IF "$(GUI)"=="UNX"
|
||||
|
||||
.IF "$(COM)"=="C52" && "$(CPU)"=="U"
|
||||
xmlsec_CFLAGS+=-m64
|
||||
.ENDIF
|
||||
|
||||
.IF "$(SYSBASE)"!=""
|
||||
xmlsec_CFLAGS+=-I$(SYSBASE)/usr/include
|
||||
.IF "$(COMNAME)"=="sunpro5"
|
||||
xmlsec_CFLAGS+=$(C_RESTRICTIONFLAGS)
|
||||
.ENDIF # "$(COMNAME)"=="sunpro5"
|
||||
.IF "$(EXTRA_CFLAGS)"!=""
|
||||
xmlsec_CFLAGS+=$(EXTRA_CFLAGS)
|
||||
xmlsec_CPPFLAGS+=$(EXTRA_CFLAGS)
|
||||
.ENDIF # "$(EXTRA_CFLAGS)"!=""
|
||||
xmlsec_LDFLAGS+=-L$(SYSBASE)/usr/lib
|
||||
.ELIF "$(OS)"=="MACOSX" # "$(SYSBASE)"!=""
|
||||
xmlsec_CPPFLAGS+=$(EXTRA_CDEFS)
|
||||
.ENDIF
|
||||
|
||||
.IF "$(OS)$(COM)"=="LINUXGCC" || "$(OS)$(COM)"=="FREEBSDGCC"
|
||||
xmlsec_LDFLAGS+=-Wl,-z,origin -Wl,-rpath,'$$$$ORIGIN:$$$$ORIGIN/../ure-link/lib'
|
||||
.ENDIF # "$(OS)$(COM)"=="LINUXGCC" || "$(OS)$(COM)"=="FREEBSDGCC"
|
||||
.IF "$(OS)$(COM)"=="SOLARISC52"
|
||||
xmlsec_LDFLAGS+=-Wl,-R'$$$$ORIGIN:$$$$ORIGIN/../ure-link/lib'
|
||||
.ENDIF # "$(OS)$(COM)"=="SOLARISC52"
|
||||
|
||||
LDFLAGS:=$(xmlsec_LDFLAGS)
|
||||
.EXPORT: LDFLAGS
|
||||
|
||||
.ENDIF
|
||||
CONFIGURE_DIR=
|
||||
CONFIGURE_ACTION=autoreconf; ./configure ADDCFLAGS="$(xmlsec_CFLAGS)" CPPFLAGS="$(xmlsec_CPPFLAGS)"
|
||||
|
||||
.IF "$(OS)" == "MACOSX"
|
||||
.IF "$(ACLOCAL)" == ""
|
||||
ACLOCAL=aclocal
|
||||
.ENDIF
|
||||
CONFIGURE_ACTION:=ACLOCAL="$(ACLOCAL) -I $(SRCDIR)/m4/mac" $(CONFIGURE_ACTION)
|
||||
.ENDIF
|
||||
|
||||
CONFIGURE_FLAGS=--with-pic --disable-shared --disable-crypto-dl --with-libxslt=no --with-gnutls=no LIBXML2LIB="$(LIBXML2LIB)"
|
||||
|
||||
.IF "$(CROSS_COMPILING)"=="YES"
|
||||
CONFIGURE_FLAGS+= --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)
|
||||
.ENDIF
|
||||
|
||||
.IF "$(OS)" == "ANDROID"
|
||||
CONFIGURE_FLAGS+=--with-openssl=$(SOLARVER)/$(INPATH)
|
||||
.ELSE
|
||||
CONFIGURE_FLAGS+=--with-openssl=no
|
||||
.ENDIF
|
||||
|
||||
.IF "$(OS)" == "MACOSX"
|
||||
CONFIGURE_FLAGS += \
|
||||
--prefix=/@.__________________________________________________$(EXTRPATH)
|
||||
.END
|
||||
|
||||
# system-mozilla needs pkgconfig to get the information about nss
|
||||
# FIXME: This also will enable pkg-config usage for libxml2. It *seems*
|
||||
# that the internal headers still are used when they are there but....
|
||||
# (and that pkg-config is allowed to fail...)
|
||||
# I have no real good idea how to get mozilla (nss) pkg-config'ed and libxml2
|
||||
# not... We need mozilla-nss pkg-config'ed since we can *not* just use
|
||||
# --with-nss or parse -pkg-config --libs / cflags mozilla-nss since
|
||||
# the lib may a) be in /usr/lib (Debian) and be not in $with_nss/include
|
||||
# $with_nss/lib.
|
||||
.IF "$(SYSTEM_NSS)" != "YES" || "$(OS)" == "MACOSX"
|
||||
CONFIGURE_FLAGS+=--enable-pkgconfig=no
|
||||
.ENDIF
|
||||
BUILD_ACTION=$(GNUMAKE) -j$(EXTMAXPROCESS)
|
||||
BUILD_DIR=$(CONFIGURE_DIR)
|
||||
.ENDIF
|
||||
|
||||
|
||||
OUTDIR2INC=include/xmlsec
|
||||
|
||||
.IF "$(OS)"=="WNT"
|
||||
.IF "$(COM)"=="GCC"
|
||||
OUT2LIB+=src/.libs/libxmlsec1.dll.a src/nss/.libs/libxmlsec1-nss.dll.a
|
||||
OUT2BIN+=src/.libs/libxmlsec1.dll src/nss/.libs/libxmlsec1-nss.dll
|
||||
.IF "$(CROSS_COMPILING)" != "YES"
|
||||
OUT2LIB+=src/mscrypto/.libs/libxmlsec1-mscrypto.dll.a
|
||||
OUT2BIN+=src/mscrypto/.libs/libxmlsec1-mscrypto.dll
|
||||
.ENDIF
|
||||
.ELSE
|
||||
OUT2LIB+=win32/binaries/*.lib
|
||||
OUT2BIN+=win32/binaries/*.dll
|
||||
.ENDIF
|
||||
.ELIF "$(OS)" == "ANDROID"
|
||||
OUT2LIB+=src/.libs/libxmlsec1.a src/openssl/.libs/libxmlsec1-openssl.a
|
||||
.ELSE
|
||||
OUT2LIB+=src/.libs/libxmlsec1.a src/nss/.libs/libxmlsec1-nss.a
|
||||
.ENDIF
|
||||
|
||||
# --- Targets ------------------------------------------------------
|
||||
|
||||
.INCLUDE : set_ext.mk
|
||||
.INCLUDE : target.mk
|
||||
.INCLUDE : tg_ext.mk
|
||||
|
||||
|
@@ -1,9 +0,0 @@
|
||||
mkdir: %_DEST%\inc\external\xmlsec
|
||||
mkdir: %_DEST%\inc\external\xmlsec\nss
|
||||
mkdir: %_DEST%\inc\external\xmlsec\mscrypto
|
||||
..\%__SRC%\inc\xmlsec\*.h %_DEST%\inc\external\xmlsec\*.h
|
||||
..\%__SRC%\inc\xmlsec\nss\*.h %_DEST%\inc\external\xmlsec\nss\*.h
|
||||
..\%__SRC%\inc\xmlsec\mscrypto\*.h %_DEST%\inc\external\xmlsec\mscrypto\*.h
|
||||
..\%__SRC%\lib\lib*.a %_DEST%\lib
|
||||
..\%__SRC%\lib\*.lib %_DEST%\lib
|
||||
..\%__SRC%\bin\*.dll %_DEST%\bin
|
||||
|
237
libxmlsec/src/akmngr_mscrypto.c
Normal file
237
libxmlsec/src/akmngr_mscrypto.c
Normal file
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright.........................
|
||||
*/
|
||||
#include "globals.h"
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/keys.h>
|
||||
#include <xmlsec/keysmngr.h>
|
||||
#include <xmlsec/transforms.h>
|
||||
#include <xmlsec/errors.h>
|
||||
|
||||
#include <xmlsec/mscrypto/crypto.h>
|
||||
#include <xmlsec/mscrypto/keysstore.h>
|
||||
#include <xmlsec/mscrypto/akmngr.h>
|
||||
#include <xmlsec/mscrypto/x509.h>
|
||||
|
||||
/**
|
||||
* xmlSecMSCryptoAppliedKeysMngrCreate:
|
||||
* @hKeyStore: the pointer to key store.
|
||||
* @hCertStore: the pointer to certificate database.
|
||||
*
|
||||
* Create and load key store and certificate database into keys manager
|
||||
*
|
||||
* Returns keys manager pointer on success or NULL otherwise.
|
||||
*/
|
||||
xmlSecKeysMngrPtr
|
||||
xmlSecMSCryptoAppliedKeysMngrCreate(
|
||||
HCERTSTORE hKeyStore ,
|
||||
HCERTSTORE hCertStore
|
||||
) {
|
||||
xmlSecKeyDataStorePtr certStore = NULL ;
|
||||
xmlSecKeysMngrPtr keyMngr = NULL ;
|
||||
xmlSecKeyStorePtr keyStore = NULL ;
|
||||
|
||||
keyStore = xmlSecKeyStoreCreate( xmlSecMSCryptoKeysStoreId ) ;
|
||||
if( keyStore == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeyStoreCreate" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* At present, MS Crypto engine do not provide a way to setup a key store.
|
||||
*/
|
||||
if( keyStore != NULL ) {
|
||||
/*TODO: binding key store.*/
|
||||
}
|
||||
|
||||
keyMngr = xmlSecKeysMngrCreate() ;
|
||||
if( keyMngr == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrCreate" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Add key store to manager, from now on keys manager destroys the store if
|
||||
* needed
|
||||
*/
|
||||
if( xmlSecKeysMngrAdoptKeysStore( keyMngr, keyStore ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecKeysMngrAdoptKeyStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
xmlSecKeysMngrDestroy( keyMngr ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Initialize crypto library specific data in keys manager
|
||||
*/
|
||||
if( xmlSecMSCryptoKeysMngrInit( keyMngr ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecMSCryptoKeysMngrInit" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeysMngrDestroy( keyMngr ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Set certificate databse to X509 key data store
|
||||
*/
|
||||
/*-
|
||||
* At present, MS Crypto engine do not provide a way to setup a cert store.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Set the getKey callback
|
||||
*/
|
||||
keyMngr->getKey = xmlSecKeysMngrGetKey ;
|
||||
|
||||
return keyMngr ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecMSCryptoAppliedKeysMngrSymKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCRYPTKEY symKey
|
||||
) {
|
||||
/*TODO: import the key into keys manager.*/
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecMSCryptoAppliedKeysMngrPubKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCRYPTKEY pubKey
|
||||
) {
|
||||
/*TODO: import the key into keys manager.*/
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecMSCryptoAppliedKeysMngrPriKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCRYPTKEY priKey
|
||||
) {
|
||||
/*TODO: import the key into keys manager.*/
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore (
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCERTSTORE keyStore
|
||||
) {
|
||||
xmlSecKeyDataStorePtr x509Store ;
|
||||
|
||||
xmlSecAssert2( mngr != NULL, -1 ) ;
|
||||
xmlSecAssert2( keyStore != NULL, -1 ) ;
|
||||
|
||||
x509Store = xmlSecKeysMngrGetDataStore( mngr, xmlSecMSCryptoX509StoreId ) ;
|
||||
if( x509Store == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrGetDataStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 ) ;
|
||||
}
|
||||
|
||||
if( xmlSecMSCryptoX509StoreAdoptKeyStore( x509Store, keyStore ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyDataStoreGetName( x509Store ) ) ,
|
||||
"xmlSecMSCryptoX509StoreAdoptKeyStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 ) ;
|
||||
}
|
||||
|
||||
return( 0 ) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore (
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCERTSTORE trustedStore
|
||||
) {
|
||||
xmlSecKeyDataStorePtr x509Store ;
|
||||
|
||||
xmlSecAssert2( mngr != NULL, -1 ) ;
|
||||
xmlSecAssert2( trustedStore != NULL, -1 ) ;
|
||||
|
||||
x509Store = xmlSecKeysMngrGetDataStore( mngr, xmlSecMSCryptoX509StoreId ) ;
|
||||
if( x509Store == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrGetDataStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 ) ;
|
||||
}
|
||||
|
||||
if( xmlSecMSCryptoX509StoreAdoptTrustedStore( x509Store, trustedStore ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyDataStoreGetName( x509Store ) ) ,
|
||||
"xmlSecMSCryptoX509StoreAdoptKeyStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 ) ;
|
||||
}
|
||||
|
||||
return( 0 ) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore (
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
HCERTSTORE untrustedStore
|
||||
) {
|
||||
xmlSecKeyDataStorePtr x509Store ;
|
||||
|
||||
xmlSecAssert2( mngr != NULL, -1 ) ;
|
||||
xmlSecAssert2( untrustedStore != NULL, -1 ) ;
|
||||
|
||||
x509Store = xmlSecKeysMngrGetDataStore( mngr, xmlSecMSCryptoX509StoreId ) ;
|
||||
if( x509Store == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrGetDataStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 ) ;
|
||||
}
|
||||
|
||||
if( xmlSecMSCryptoX509StoreAdoptUntrustedStore( x509Store, untrustedStore ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyDataStoreGetName( x509Store ) ) ,
|
||||
"xmlSecMSCryptoX509StoreAdoptKeyStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 ) ;
|
||||
}
|
||||
|
||||
return( 0 ) ;
|
||||
}
|
||||
|
||||
|
384
libxmlsec/src/akmngr_nss.c
Normal file
384
libxmlsec/src/akmngr_nss.c
Normal file
@@ -0,0 +1,384 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright.........................
|
||||
*/
|
||||
#include "globals.h"
|
||||
|
||||
#include <nspr.h>
|
||||
#include <nss.h>
|
||||
#include <pk11func.h>
|
||||
#include <cert.h>
|
||||
#include <keyhi.h>
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/keys.h>
|
||||
#include <xmlsec/transforms.h>
|
||||
#include <xmlsec/errors.h>
|
||||
|
||||
#include <xmlsec/nss/crypto.h>
|
||||
#include <xmlsec/nss/tokens.h>
|
||||
#include <xmlsec/nss/akmngr.h>
|
||||
#include <xmlsec/nss/pkikeys.h>
|
||||
#include <xmlsec/nss/ciphers.h>
|
||||
#include <xmlsec/nss/keysstore.h>
|
||||
|
||||
/**
|
||||
* xmlSecNssAppliedKeysMngrCreate:
|
||||
* @slot: array of pointers to NSS PKCS#11 slot information.
|
||||
* @cSlots: number of slots in the array
|
||||
* @handler: the pointer to NSS certificate database.
|
||||
*
|
||||
* Create and load NSS crypto slot and certificate database into keys manager
|
||||
*
|
||||
* Returns keys manager pointer on success or NULL otherwise.
|
||||
*/
|
||||
xmlSecKeysMngrPtr
|
||||
xmlSecNssAppliedKeysMngrCreate(
|
||||
PK11SlotInfo** slots,
|
||||
int cSlots,
|
||||
CERTCertDBHandle* handler
|
||||
) {
|
||||
xmlSecKeyDataStorePtr certStore = NULL ;
|
||||
xmlSecKeysMngrPtr keyMngr = NULL ;
|
||||
xmlSecKeyStorePtr keyStore = NULL ;
|
||||
int islot = 0;
|
||||
keyStore = xmlSecKeyStoreCreate( xmlSecNssKeysStoreId ) ;
|
||||
if( keyStore == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeyStoreCreate" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
for (islot = 0; islot < cSlots; islot++)
|
||||
{
|
||||
xmlSecNssKeySlotPtr keySlot ;
|
||||
|
||||
/* Create a key slot */
|
||||
keySlot = xmlSecNssKeySlotCreate() ;
|
||||
if( keySlot == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecNssKeySlotCreate" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/* Set slot */
|
||||
if( xmlSecNssKeySlotSetSlot( keySlot , slots[islot] ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecNssKeySlotSetSlot" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
xmlSecNssKeySlotDestroy( keySlot ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/* Adopt keySlot */
|
||||
if( xmlSecNssKeysStoreAdoptKeySlot( keyStore , keySlot ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecNssKeysStoreAdoptKeySlot" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
xmlSecNssKeySlotDestroy( keySlot ) ;
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
keyMngr = xmlSecKeysMngrCreate() ;
|
||||
if( keyMngr == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrCreate" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Add key store to manager, from now on keys manager destroys the store if
|
||||
* needed
|
||||
*/
|
||||
if( xmlSecKeysMngrAdoptKeysStore( keyMngr, keyStore ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecKeysMngrAdoptKeyStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeyStoreDestroy( keyStore ) ;
|
||||
xmlSecKeysMngrDestroy( keyMngr ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Initialize crypto library specific data in keys manager
|
||||
*/
|
||||
if( xmlSecNssKeysMngrInit( keyMngr ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrCreate" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeysMngrDestroy( keyMngr ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Set certificate databse to X509 key data store
|
||||
*/
|
||||
/**
|
||||
* Because Tej's implementation of certDB use the default DB, so I ignore
|
||||
* the certDB handler at present. I'll modify the cert store sources to
|
||||
* accept particular certDB instead of default ones.
|
||||
certStore = xmlSecKeysMngrGetDataStore( keyMngr , xmlSecNssKeyDataStoreX509Id ) ;
|
||||
if( certStore == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecKeysMngrGetDataStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeysMngrDestroy( keyMngr ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
if( xmlSecNssKeyDataStoreX509SetCertDb( certStore , handler ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
xmlSecErrorsSafeString( xmlSecKeyStoreGetName( keyStore ) ) ,
|
||||
"xmlSecNssKeyDataStoreX509SetCertDb" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
|
||||
xmlSecKeysMngrDestroy( keyMngr ) ;
|
||||
return NULL ;
|
||||
}
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Set the getKey callback
|
||||
*/
|
||||
keyMngr->getKey = xmlSecKeysMngrGetKey ;
|
||||
|
||||
return keyMngr ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssAppliedKeysMngrSymKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
PK11SymKey* symKey
|
||||
) {
|
||||
xmlSecKeyPtr key ;
|
||||
xmlSecKeyDataPtr data ;
|
||||
xmlSecKeyStorePtr keyStore ;
|
||||
|
||||
xmlSecAssert2( mngr != NULL , -1 ) ;
|
||||
xmlSecAssert2( symKey != NULL , -1 ) ;
|
||||
|
||||
keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ;
|
||||
if( keyStore == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrGetKeysStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ;
|
||||
|
||||
data = xmlSecNssSymKeyDataKeyAdopt( symKey ) ;
|
||||
if( data == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
key = xmlSecKeyCreate() ;
|
||||
if( key == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDataDestroy( data ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
if( xmlSecKeySetValue( key , data ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDataDestroy( data ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDestroy( key ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssAppliedKeysMngrPubKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
SECKEYPublicKey* pubKey
|
||||
) {
|
||||
xmlSecKeyPtr key ;
|
||||
xmlSecKeyDataPtr data ;
|
||||
xmlSecKeyStorePtr keyStore ;
|
||||
|
||||
xmlSecAssert2( mngr != NULL , -1 ) ;
|
||||
xmlSecAssert2( pubKey != NULL , -1 ) ;
|
||||
|
||||
keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ;
|
||||
if( keyStore == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrGetKeysStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ;
|
||||
|
||||
data = xmlSecNssPKIAdoptKey( NULL, pubKey ) ;
|
||||
if( data == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssPKIAdoptKey" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
key = xmlSecKeyCreate() ;
|
||||
if( key == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDataDestroy( data ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
if( xmlSecKeySetValue( key , data ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDataDestroy( data ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDestroy( key ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssAppliedKeysMngrPriKeyLoad(
|
||||
xmlSecKeysMngrPtr mngr ,
|
||||
SECKEYPrivateKey* priKey
|
||||
) {
|
||||
xmlSecKeyPtr key ;
|
||||
xmlSecKeyDataPtr data ;
|
||||
xmlSecKeyStorePtr keyStore ;
|
||||
|
||||
xmlSecAssert2( mngr != NULL , -1 ) ;
|
||||
xmlSecAssert2( priKey != NULL , -1 ) ;
|
||||
|
||||
keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ;
|
||||
if( keyStore == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecKeysMngrGetKeysStore" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ;
|
||||
|
||||
data = xmlSecNssPKIAdoptKey( priKey, NULL ) ;
|
||||
if( data == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssPKIAdoptKey" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
key = xmlSecKeyCreate() ;
|
||||
if( key == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDataDestroy( data ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
if( xmlSecKeySetValue( key , data ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDataDestroy( data ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
"xmlSecNssSymKeyDataKeyAdopt" ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecKeyDestroy( key ) ;
|
||||
return(-1) ;
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
}
|
||||
|
1213
libxmlsec/src/keywrapers.c
Normal file
1213
libxmlsec/src/keywrapers.c
Normal file
File diff suppressed because it is too large
Load Diff
548
libxmlsec/src/tokens.c
Normal file
548
libxmlsec/src/tokens.c
Normal file
@@ -0,0 +1,548 @@
|
||||
/**
|
||||
* XMLSec library
|
||||
*
|
||||
* This is free software; see Copyright file in the source
|
||||
* distribution for preciese wording.
|
||||
*
|
||||
* Copyright..................................
|
||||
*
|
||||
* Contributor(s): _____________________________
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* In order to ensure that particular crypto operation is performed on
|
||||
* particular crypto device, a subclass of xmlSecList is used to store slot and
|
||||
* mechanism information.
|
||||
*
|
||||
* In the list, a slot is bound with a mechanism. If the mechanism is available,
|
||||
* this mechanism only can perform on the slot; otherwise, it can perform on
|
||||
* every eligibl slot in the list.
|
||||
*
|
||||
* When try to find a slot for a particular mechanism, the slot bound with
|
||||
* avaliable mechanism will be looked up firstly.
|
||||
*/
|
||||
#include "globals.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <xmlsec/xmlsec.h>
|
||||
#include <xmlsec/errors.h>
|
||||
#include <xmlsec/list.h>
|
||||
|
||||
#include <xmlsec/nss/tokens.h>
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotSetMechList(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE_PTR mechanismList
|
||||
) {
|
||||
int counter ;
|
||||
|
||||
xmlSecAssert2( keySlot != NULL , -1 ) ;
|
||||
|
||||
if( keySlot->mechanismList != CK_NULL_PTR ) {
|
||||
xmlFree( keySlot->mechanismList ) ;
|
||||
|
||||
for( counter = 0 ; *( mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) ;
|
||||
keySlot->mechanismList = ( CK_MECHANISM_TYPE_PTR )xmlMalloc( ( counter + 1 ) * sizeof( CK_MECHANISM_TYPE ) ) ;
|
||||
if( keySlot->mechanismList == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 );
|
||||
}
|
||||
for( ; counter >= 0 ; counter -- )
|
||||
*( keySlot->mechanismList + counter ) = *( mechanismList + counter ) ;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotEnableMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE mechanism
|
||||
) {
|
||||
int counter ;
|
||||
CK_MECHANISM_TYPE_PTR newList ;
|
||||
|
||||
xmlSecAssert2( keySlot != NULL , -1 ) ;
|
||||
|
||||
if( mechanism != CKM_INVALID_MECHANISM ) {
|
||||
for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) ;
|
||||
newList = ( CK_MECHANISM_TYPE_PTR )xmlMalloc( ( counter + 1 + 1 ) * sizeof( CK_MECHANISM_TYPE ) ) ;
|
||||
if( newList == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 );
|
||||
}
|
||||
*( newList + counter + 1 ) = CKM_INVALID_MECHANISM ;
|
||||
*( newList + counter ) = mechanism ;
|
||||
for( counter -= 1 ; counter >= 0 ; counter -- )
|
||||
*( newList + counter ) = *( keySlot->mechanismList + counter ) ;
|
||||
|
||||
xmlFree( keySlot->mechanismList ) ;
|
||||
keySlot->mechanismList = newList ;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotDisableMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE mechanism
|
||||
) {
|
||||
int counter ;
|
||||
|
||||
xmlSecAssert2( keySlot != NULL , -1 ) ;
|
||||
|
||||
for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) {
|
||||
if( *( keySlot->mechanismList + counter ) == mechanism ) {
|
||||
for( ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) {
|
||||
*( keySlot->mechanismList + counter ) = *( keySlot->mechanismList + counter + 1 ) ;
|
||||
}
|
||||
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
CK_MECHANISM_TYPE_PTR
|
||||
xmlSecNssKeySlotGetMechList(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) {
|
||||
if( keySlot != NULL )
|
||||
return keySlot->mechanismList ;
|
||||
else
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotSetSlot(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
PK11SlotInfo* slot
|
||||
) {
|
||||
xmlSecAssert2( keySlot != NULL , -1 ) ;
|
||||
|
||||
if( slot != NULL && keySlot->slot != slot ) {
|
||||
if( keySlot->slot != NULL )
|
||||
PK11_FreeSlot( keySlot->slot ) ;
|
||||
|
||||
if( keySlot->mechanismList != NULL ) {
|
||||
xmlFree( keySlot->mechanismList ) ;
|
||||
keySlot->mechanismList = NULL ;
|
||||
}
|
||||
|
||||
keySlot->slot = PK11_ReferenceSlot( slot ) ;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotInitialize(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
PK11SlotInfo* slot
|
||||
) {
|
||||
xmlSecAssert2( keySlot != NULL , -1 ) ;
|
||||
xmlSecAssert2( keySlot->slot == NULL , -1 ) ;
|
||||
xmlSecAssert2( keySlot->mechanismList == NULL , -1 ) ;
|
||||
|
||||
if( slot != NULL ) {
|
||||
keySlot->slot = PK11_ReferenceSlot( slot ) ;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
xmlSecNssKeySlotFinalize(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) {
|
||||
xmlSecAssert( keySlot != NULL ) ;
|
||||
|
||||
if( keySlot->mechanismList != NULL ) {
|
||||
xmlFree( keySlot->mechanismList ) ;
|
||||
keySlot->mechanismList = NULL ;
|
||||
}
|
||||
|
||||
if( keySlot->slot != NULL ) {
|
||||
PK11_FreeSlot( keySlot->slot ) ;
|
||||
keySlot->slot = NULL ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PK11SlotInfo*
|
||||
xmlSecNssKeySlotGetSlot(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) {
|
||||
if( keySlot != NULL )
|
||||
return keySlot->slot ;
|
||||
else
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
xmlSecNssKeySlotPtr
|
||||
xmlSecNssKeySlotCreate() {
|
||||
xmlSecNssKeySlotPtr keySlot ;
|
||||
|
||||
/* Allocates a new xmlSecNssKeySlot and fill the fields */
|
||||
keySlot = ( xmlSecNssKeySlotPtr )xmlMalloc( sizeof( xmlSecNssKeySlot ) ) ;
|
||||
if( keySlot == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( NULL );
|
||||
}
|
||||
memset( keySlot, 0, sizeof( xmlSecNssKeySlot ) ) ;
|
||||
|
||||
return( keySlot ) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotCopy(
|
||||
xmlSecNssKeySlotPtr newKeySlot ,
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) {
|
||||
CK_MECHANISM_TYPE_PTR mech ;
|
||||
int counter ;
|
||||
|
||||
xmlSecAssert2( newKeySlot != NULL , -1 ) ;
|
||||
xmlSecAssert2( keySlot != NULL , -1 ) ;
|
||||
|
||||
if( keySlot->slot != NULL && newKeySlot->slot != keySlot->slot ) {
|
||||
if( newKeySlot->slot != NULL )
|
||||
PK11_FreeSlot( newKeySlot->slot ) ;
|
||||
|
||||
newKeySlot->slot = PK11_ReferenceSlot( keySlot->slot ) ;
|
||||
}
|
||||
|
||||
if( keySlot->mechanismList != CK_NULL_PTR ) {
|
||||
xmlFree( newKeySlot->mechanismList ) ;
|
||||
|
||||
for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) ;
|
||||
newKeySlot->mechanismList = ( CK_MECHANISM_TYPE_PTR )xmlMalloc( ( counter + 1 ) * sizeof( CK_MECHANISM_TYPE ) ) ;
|
||||
if( newKeySlot->mechanismList == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 );
|
||||
}
|
||||
for( ; counter >= 0 ; counter -- )
|
||||
*( newKeySlot->mechanismList + counter ) = *( keySlot->mechanismList + counter ) ;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
xmlSecNssKeySlotPtr
|
||||
xmlSecNssKeySlotDuplicate(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) {
|
||||
xmlSecNssKeySlotPtr newKeySlot ;
|
||||
int ret ;
|
||||
|
||||
xmlSecAssert2( keySlot != NULL , NULL ) ;
|
||||
|
||||
newKeySlot = xmlSecNssKeySlotCreate() ;
|
||||
if( newKeySlot == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if( xmlSecNssKeySlotCopy( newKeySlot, keySlot ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
return( newKeySlot );
|
||||
}
|
||||
|
||||
void
|
||||
xmlSecNssKeySlotDestroy(
|
||||
xmlSecNssKeySlotPtr keySlot
|
||||
) {
|
||||
xmlSecAssert( keySlot != NULL ) ;
|
||||
|
||||
if( keySlot->mechanismList != NULL )
|
||||
xmlFree( keySlot->mechanismList ) ;
|
||||
|
||||
if( keySlot->slot != NULL )
|
||||
PK11_FreeSlot( keySlot->slot ) ;
|
||||
|
||||
xmlFree( keySlot ) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotBindMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE type
|
||||
) {
|
||||
int counter ;
|
||||
|
||||
xmlSecAssert2( keySlot != NULL , 0 ) ;
|
||||
xmlSecAssert2( keySlot->slot != NULL , 0 ) ;
|
||||
xmlSecAssert2( type != CKM_INVALID_MECHANISM , 0 ) ;
|
||||
|
||||
for( counter = 0 ; *( keySlot->mechanismList + counter ) != CKM_INVALID_MECHANISM ; counter ++ ) {
|
||||
if( *( keySlot->mechanismList + counter ) == type )
|
||||
return(1) ;
|
||||
}
|
||||
|
||||
return( 0 ) ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssKeySlotSupportMech(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
CK_MECHANISM_TYPE type
|
||||
) {
|
||||
xmlSecAssert2( keySlot != NULL , 0 ) ;
|
||||
xmlSecAssert2( keySlot->slot != NULL , 0 ) ;
|
||||
xmlSecAssert2( type != CKM_INVALID_MECHANISM , 0 ) ;
|
||||
|
||||
if( PK11_DoesMechanism( keySlot->slot , type ) == PR_TRUE ) {
|
||||
return(1);
|
||||
} else
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
xmlSecNssKeySlotDebugDump(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
FILE* output
|
||||
) {
|
||||
xmlSecAssert( keySlot != NULL ) ;
|
||||
xmlSecAssert( output != NULL ) ;
|
||||
|
||||
fprintf( output, "== KEY SLOT\n" );
|
||||
}
|
||||
|
||||
void
|
||||
xmlSecNssKeySlotDebugXmlDump(
|
||||
xmlSecNssKeySlotPtr keySlot ,
|
||||
FILE* output
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Key Slot List
|
||||
*/
|
||||
#ifdef __MINGW32__ // for runtime-pseudo-reloc
|
||||
static struct _xmlSecPtrListKlass xmlSecNssKeySlotPtrListKlass = {
|
||||
#else
|
||||
static xmlSecPtrListKlass xmlSecNssKeySlotPtrListKlass = {
|
||||
#endif
|
||||
BAD_CAST "mechanism-list",
|
||||
(xmlSecPtrDuplicateItemMethod)xmlSecNssKeySlotDuplicate,
|
||||
(xmlSecPtrDestroyItemMethod)xmlSecNssKeySlotDestroy,
|
||||
(xmlSecPtrDebugDumpItemMethod)xmlSecNssKeySlotDebugDump,
|
||||
(xmlSecPtrDebugDumpItemMethod)xmlSecNssKeySlotDebugXmlDump,
|
||||
};
|
||||
|
||||
xmlSecPtrListId
|
||||
xmlSecNssKeySlotListGetKlass(void) {
|
||||
return(&xmlSecNssKeySlotPtrListKlass);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
* Global PKCS#11 crypto token repository -- Key slot list
|
||||
*/
|
||||
static xmlSecPtrListPtr _xmlSecNssKeySlotList = NULL ;
|
||||
|
||||
PK11SlotInfo*
|
||||
xmlSecNssSlotGet(
|
||||
CK_MECHANISM_TYPE type
|
||||
) {
|
||||
PK11SlotInfo* slot = NULL ;
|
||||
xmlSecNssKeySlotPtr keySlot ;
|
||||
xmlSecSize ksSize ;
|
||||
xmlSecSize ksPos ;
|
||||
char flag ;
|
||||
|
||||
if( _xmlSecNssKeySlotList == NULL ) {
|
||||
slot = PK11_GetBestSlot( type , NULL ) ;
|
||||
} else {
|
||||
ksSize = xmlSecPtrListGetSize( _xmlSecNssKeySlotList ) ;
|
||||
|
||||
/*-
|
||||
* Firstly, checking whether the mechanism is bound with a special slot.
|
||||
* If no bound slot, we try to find the first eligible slot in the list.
|
||||
*/
|
||||
for( flag = 0, ksPos = 0 ; ksPos < ksSize ; ksPos ++ ) {
|
||||
keySlot = ( xmlSecNssKeySlotPtr )xmlSecPtrListGetItem( _xmlSecNssKeySlotList, ksPos ) ;
|
||||
if( keySlot != NULL && xmlSecNssKeySlotBindMech( keySlot, type ) ) {
|
||||
slot = xmlSecNssKeySlotGetSlot( keySlot ) ;
|
||||
flag = 2 ;
|
||||
} else if( flag == 0 && xmlSecNssKeySlotSupportMech( keySlot, type ) ) {
|
||||
slot = xmlSecNssKeySlotGetSlot( keySlot ) ;
|
||||
flag = 1 ;
|
||||
}
|
||||
|
||||
if( flag == 2 )
|
||||
break ;
|
||||
}
|
||||
if( slot != NULL )
|
||||
slot = PK11_ReferenceSlot( slot ) ;
|
||||
}
|
||||
|
||||
if( slot != NULL && PK11_NeedLogin( slot ) ) {
|
||||
if( PK11_Authenticate( slot , PR_TRUE , NULL ) != SECSuccess ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
PK11_FreeSlot( slot ) ;
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
return slot ;
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssSlotInitialize(
|
||||
void
|
||||
) {
|
||||
if( _xmlSecNssKeySlotList != NULL ) {
|
||||
xmlSecPtrListDestroy( _xmlSecNssKeySlotList ) ;
|
||||
_xmlSecNssKeySlotList = NULL ;
|
||||
}
|
||||
|
||||
_xmlSecNssKeySlotList = xmlSecPtrListCreate( xmlSecNssKeySlotListId ) ;
|
||||
if( _xmlSecNssKeySlotList == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
xmlSecNssSlotShutdown(
|
||||
void
|
||||
) {
|
||||
if( _xmlSecNssKeySlotList != NULL ) {
|
||||
xmlSecPtrListDestroy( _xmlSecNssKeySlotList ) ;
|
||||
_xmlSecNssKeySlotList = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
xmlSecNssSlotAdopt(
|
||||
PK11SlotInfo* slot,
|
||||
CK_MECHANISM_TYPE type
|
||||
) {
|
||||
xmlSecNssKeySlotPtr keySlot ;
|
||||
xmlSecSize ksSize ;
|
||||
xmlSecSize ksPos ;
|
||||
char flag ;
|
||||
|
||||
xmlSecAssert2( _xmlSecNssKeySlotList != NULL, -1 ) ;
|
||||
xmlSecAssert2( slot != NULL, -1 ) ;
|
||||
|
||||
ksSize = xmlSecPtrListGetSize( _xmlSecNssKeySlotList ) ;
|
||||
|
||||
/*-
|
||||
* Firstly, checking whether the slot is in the repository already.
|
||||
*/
|
||||
flag = 0 ;
|
||||
for( ksPos = 0 ; ksPos < ksSize ; ksPos ++ ) {
|
||||
keySlot = ( xmlSecNssKeySlotPtr )xmlSecPtrListGetItem( _xmlSecNssKeySlotList, ksPos ) ;
|
||||
/* If find the slot in the list */
|
||||
if( keySlot != NULL && xmlSecNssKeySlotGetSlot( keySlot ) == slot ) {
|
||||
/* If mechnism type is valid, bind the slot with the mechanism */
|
||||
if( type != CKM_INVALID_MECHANISM ) {
|
||||
if( xmlSecNssKeySlotEnableMech( keySlot, type ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
flag = 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the slot do not in the list, add a new item to the list */
|
||||
if( flag == 0 ) {
|
||||
/* Create a new KeySlot */
|
||||
keySlot = xmlSecNssKeySlotCreate() ;
|
||||
if( keySlot == NULL ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Initialize the keySlot with a slot */
|
||||
if( xmlSecNssKeySlotInitialize( keySlot, slot ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecNssKeySlotDestroy( keySlot ) ;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* If mechnism type is valid, bind the slot with the mechanism */
|
||||
if( type != CKM_INVALID_MECHANISM ) {
|
||||
if( xmlSecNssKeySlotEnableMech( keySlot, type ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecNssKeySlotDestroy( keySlot ) ;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add keySlot into the list */
|
||||
if( xmlSecPtrListAdd( _xmlSecNssKeySlotList, keySlot ) < 0 ) {
|
||||
xmlSecError( XMLSEC_ERRORS_HERE ,
|
||||
NULL ,
|
||||
NULL ,
|
||||
XMLSEC_ERRORS_R_XMLSEC_FAILED ,
|
||||
XMLSEC_ERRORS_NO_MESSAGE ) ;
|
||||
xmlSecNssKeySlotDestroy( keySlot ) ;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
--- misc/build/xmlsec1-1.2.14/include/xmlsec/xmlsec.h.ORIGINAL 2009-12-05 15:19:18.000000000 -0600
|
||||
+++ misc/build/xmlsec1-1.2.14/include/xmlsec/xmlsec.h 2011-02-13 03:09:42.917240245 -0600
|
||||
--- build/xmlsec1-1.2.14/include/xmlsec/xmlsec.h.ORIGINAL 2009-12-05 15:19:18.000000000 -0600
|
||||
+++ build/xmlsec1-1.2.14/include/xmlsec/xmlsec.h 2011-02-13 03:09:42.917240245 -0600
|
||||
@@ -11,16 +11,16 @@
|
||||
#ifndef __XMLSEC_H__
|
||||
#define __XMLSEC_H__
|
||||
|
@@ -1,5 +1,5 @@
|
||||
--- misc/build/xmlsec1-1.2.14/config.sub
|
||||
+++ misc/build/xmlsec1-1.2.14/config.sub
|
||||
--- build/xmlsec1-1.2.14/config.sub
|
||||
+++ build/xmlsec1-1.2.14/config.sub
|
||||
@@ -120,7 +120,7 @@
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
25
libxmlsec/xmlsec1-vc.patch
Normal file
25
libxmlsec/xmlsec1-vc.patch
Normal file
@@ -0,0 +1,25 @@
|
||||
--- build/xmlsec1-1.2.14/win32/Makefile.msvc.old 2010-10-20 00:49:04.671875000 +0200
|
||||
+++ build/xmlsec1-1.2.14/win32/Makefile.msvc 2010-10-20 00:49:23.406250000 +0200
|
||||
@@ -351,7 +351,11 @@
|
||||
!if "$(DEBUG)" == "1"
|
||||
LDFLAGS = $(LDFLAGS) /DEBUG
|
||||
!else
|
||||
-LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
|
||||
+!if "$(_NMAKE_VER)" >= "10.00.30319.01"
|
||||
+LDFLAGS = $(LDFLAGS)
|
||||
+!else
|
||||
+LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
|
||||
+!endif
|
||||
!endif
|
||||
|
||||
SOLIBS = $(LIBS) libxml2.lib
|
||||
--- build/xmlsec/win32/Makefile.msvc.old 2012-11-30 11:09:23.130479800 -0500
|
||||
+++ build/xmlsec/win32/Makefile.msvc 2012-11-30 11:11:06.037550700 -0500
|
||||
@@ -301,6 +301,7 @@
|
||||
CFLAGS = $(CFLAGS) /D "HAVE_STDIO_H" /D "HAVE_STDLIB_H"
|
||||
CFLAGS = $(CFLAGS) /D "HAVE_STRING_H" /D "HAVE_CTYPE_H"
|
||||
CFLAGS = $(CFLAGS) /D "HAVE_MALLOC_H" /D "HAVE_MEMORY_H"
|
||||
+CFLAGS = $(CFLAGS) $(SOLARINC)
|
||||
|
||||
# Optimisation and debug symbols.
|
||||
!if "$(DEBUG)" == "1"
|
@@ -1,15 +0,0 @@
|
||||
--- misc/build/xmlsec1-1.2.14/win32/Makefile.msvc.old 2010-10-20 00:49:04.671875000 +0200
|
||||
+++ misc/build/xmlsec1-1.2.14/win32/Makefile.msvc 2010-10-20 00:49:23.406250000 +0200
|
||||
@@ -351,7 +351,11 @@
|
||||
!if "$(DEBUG)" == "1"
|
||||
LDFLAGS = $(LDFLAGS) /DEBUG
|
||||
!else
|
||||
-LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
|
||||
+!if "$(_NMAKE_VER)" >= "10.00.30319.01"
|
||||
+LDFLAGS = $(LDFLAGS)
|
||||
+!else
|
||||
+LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
|
||||
+!endif
|
||||
!endif
|
||||
|
||||
SOLIBS = $(LIBS) libxml2.lib
|
@@ -1,2 +1,2 @@
|
||||
tb tail_build : CPPUNIT:cppunit EXPAT:expat FONTCONFIG:fontconfig ICU:icu LIBPNG:libpng LIBXML2:libxml2 libxmlsec LIBXSLT:libxslt MOZ:moz NSS:nss OPENSSL:openssl PYTHON:python3 REDLAND:redland XPDF:xpdf ZLIB:zlib external solenv soltools NULL
|
||||
tb tail_build : CPPUNIT:cppunit EXPAT:expat FONTCONFIG:fontconfig ICU:icu LIBPNG:libpng LIBXML2:libxml2 LIBXSLT:libxslt MOZ:moz NSS:nss OPENSSL:openssl PYTHON:python3 REDLAND:redland XPDF:xpdf ZLIB:zlib external solenv soltools NULL
|
||||
tb tail_build\prj nmake - all tb_prj NULL
|
||||
|
@@ -38,6 +38,7 @@ $(eval $(call gb_Library_set_include,xsec_xmlsec,\
|
||||
$$(INCLUDE) \
|
||||
-I$(SRCDIR)/xmlsecurity/inc \
|
||||
-I$(SRCDIR)/xmlsecurity/source/xmlsec \
|
||||
-I$(call gb_UnpackedTarball_get_dir,xmlsec/include) \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_use_sdk_api,xsec_xmlsec))
|
||||
@@ -68,6 +69,9 @@ $(eval $(call gb_Library_use_libraries,xsec_xmlsec,\
|
||||
$(gb_UWINAPI) \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_use_packages,xsec_xmlsec,\
|
||||
xmlsec \
|
||||
))
|
||||
$(eval $(call gb_Library_use_externals,xsec_xmlsec,\
|
||||
libxml2 \
|
||||
nss3 \
|
||||
|
Reference in New Issue
Block a user