├── distro ├── debian │ ├── compat │ ├── libpkcs11-helper1.install │ ├── watch │ ├── libpkcs11-helper1-dev.install │ ├── rules │ ├── README.build │ ├── copyright.m4 │ ├── changelog │ ├── control │ └── Makefile.am ├── rpm │ ├── pkcs11-helper.spec.in │ └── Makefile.am └── Makefile.am ├── AUTHORS ├── lib ├── slotevent.exports ├── versioninfo.rc.in ├── data.exports ├── openssl.exports ├── libpkcs11-helper-1.pc.in ├── token.exports ├── core.exports ├── certificate.exports ├── _pkcs11h-sys.h ├── _pkcs11h-crypto.h ├── _pkcs11h-openssl.h ├── _pkcs11h-token.h ├── _pkcs11h-slotevent.h ├── common.h ├── _pkcs11h-mem.h ├── _pkcs11h-util.h ├── pkcs11h-sys.c ├── _pkcs11h-certificate.h ├── pkcs11h-mem.c ├── _pkcs11h-threading.h ├── _pkcs11h-session.h ├── Makefile.am ├── Makefile.w32-vc ├── pkcs11h-crypto.c └── _pkcs11h-crypto-mbedtls.c ├── codespell_ignore_words.txt ├── doc ├── api │ ├── opensc-logo.gif │ ├── Doxyfile_footer.html │ ├── main.dox │ └── Makefile.am └── Makefile.am ├── .github └── workflows │ ├── codespell.yml │ └── build-linux.yml ├── m4 ├── size_t.m4 └── vararg.m4 ├── .gitignore ├── THANKS ├── README ├── COPYING.BSD ├── tests ├── test-basic │ ├── test-basic.c │ ├── Makefile.am │ ├── test-serialize.c │ └── test-basic2.c ├── Makefile.am ├── test-fork │ ├── Makefile.am │ └── test-fork.c ├── test-openssl │ └── Makefile.am ├── test-slotevent │ ├── Makefile.am │ └── test-slotevent.c └── test-certificate │ └── Makefile.am ├── INSTALL ├── include ├── Makefile.am └── pkcs11-helper-1.0 │ ├── pkcs11h-version.h.in │ ├── pkcs11h-def.h │ ├── Makefile.am │ ├── pkcs11h-openssl.h │ ├── pkcs11h-token.h │ └── pkcs11h-data.h ├── m4dir ├── Makefile.am └── pkcs11-helper-1.m4 ├── man ├── Makefile.am └── pkcs11-helper-1.8 ├── Makefile.am ├── COPYING ├── ChangeLog └── config-w32-vc.h.in /distro/debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Alon Bar-Lev 2 | -------------------------------------------------------------------------------- /lib/slotevent.exports: -------------------------------------------------------------------------------- 1 | pkcs11h_setSlotEventHook 2 | -------------------------------------------------------------------------------- /distro/debian/libpkcs11-helper1.install: -------------------------------------------------------------------------------- 1 | usr/lib/lib*.so.* 2 | usr/share/man 3 | -------------------------------------------------------------------------------- /codespell_ignore_words.txt: -------------------------------------------------------------------------------- 1 | nmake 2 | parms 3 | ro 4 | fo 5 | gost 6 | standarts 7 | nd 8 | -------------------------------------------------------------------------------- /lib/versioninfo.rc.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenSC/pkcs11-helper/HEAD/lib/versioninfo.rc.in -------------------------------------------------------------------------------- /doc/api/opensc-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenSC/pkcs11-helper/HEAD/doc/api/opensc-logo.gif -------------------------------------------------------------------------------- /distro/debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | https://github.com/OpenSC/pkcs11-helper/releases/download/pkcs11-helper-(.*)/pkcs11-helper-(.*).tar.bz2 3 | -------------------------------------------------------------------------------- /lib/data.exports: -------------------------------------------------------------------------------- 1 | pkcs11h_data_del 2 | pkcs11h_data_enumDataObjects 3 | pkcs11h_data_freeDataIdList 4 | pkcs11h_data_get 5 | pkcs11h_data_put 6 | -------------------------------------------------------------------------------- /distro/debian/libpkcs11-helper1-dev.install: -------------------------------------------------------------------------------- 1 | usr/lib/lib*.a 2 | usr/lib/lib*.so 3 | usr/lib/pkgconfig 4 | usr/share/aclocal 5 | usr/share/doc/libpkcs11-helper1-dev/api 6 | usr/include 7 | -------------------------------------------------------------------------------- /lib/openssl.exports: -------------------------------------------------------------------------------- 1 | pkcs11h_openssl_createSession 2 | pkcs11h_openssl_freeSession 3 | pkcs11h_openssl_getCleanupHook 4 | pkcs11h_openssl_getX509 5 | pkcs11h_openssl_session_getEVP 6 | pkcs11h_openssl_session_getRSA 7 | pkcs11h_openssl_session_getX509 8 | pkcs11h_openssl_setCleanupHook 9 | -------------------------------------------------------------------------------- /doc/api/Doxyfile_footer.html: -------------------------------------------------------------------------------- 1 |
2 |
pkcs11-helper, Copyright (C) Alon Bar-Lev <alon.barlev@gmail.com>OpenSC-Project.org Logo
3 | -------------------------------------------------------------------------------- /lib/libpkcs11-helper-1.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | features=@PKCS11H_FEATURES@ 6 | 7 | Name: pkcs11-helper 8 | Description: PKCS#11 helper library 9 | Version: @PACKAGE_VERSION@ 10 | Cflags: -I${includedir} 11 | Libs: @LIBS@ -L${libdir} -lpkcs11-helper 12 | -------------------------------------------------------------------------------- /lib/token.exports: -------------------------------------------------------------------------------- 1 | pkcs11h_token_deserializeTokenId 2 | pkcs11h_token_duplicateTokenId 3 | pkcs11h_token_ensureAccess 4 | pkcs11h_token_enumTokenIds 5 | pkcs11h_token_freeTokenId 6 | pkcs11h_token_freeTokenIdList 7 | pkcs11h_token_login 8 | pkcs11h_token_logout 9 | pkcs11h_token_sameTokenId 10 | pkcs11h_token_serializeTokenId 11 | -------------------------------------------------------------------------------- /distro/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | include /usr/share/cdbs/1/class/autotools.mk 4 | include /usr/share/cdbs/1/rules/debhelper.mk 5 | 6 | DEB_CONFIGURE_EXTRA_FLAGS := --enable-doc --docdir=${prefix}/usr/share/doc/libpkcs11-helper1-dev 7 | 8 | DEB_INSTALL_DOCS_ALL := README AUTHORS THANKS 9 | 10 | DEB_DH_INSTALL_ARGS := --sourcedir=debian/tmp 11 | 12 | -------------------------------------------------------------------------------- /distro/debian/README.build: -------------------------------------------------------------------------------- 1 | pkcs11-helper1 for Debian 2 | ------------------------- 3 | 4 | To build pkcs11-helper follow these steps 5 | 6 | 1) unpack the tarball 7 | 2) cd pkcs11-helper- 8 | 3) ln -s distro/debian 9 | 4) invoke your build tool, e.g. 10 | dpkg-buildpackage -rfakeroot 11 | 12 | -- S. Wefel Mon, 29 Jan 2007 16:56:30 +0100 13 | -------------------------------------------------------------------------------- /.github/workflows/codespell.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Codespell 3 | 4 | on: 5 | pull_request: 6 | push: 7 | 8 | jobs: 9 | codespell: 10 | name: Check for spelling errors 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: codespell-project/actions-codespell@master 16 | with: 17 | ignore_words_file: codespell_ignore_words.txt 18 | -------------------------------------------------------------------------------- /distro/debian/copyright.m4: -------------------------------------------------------------------------------- 1 | This package was debianized by S. Wefel on 2 | Mon, 29 Jan 2007 16:56:30 +0100. 3 | 4 | It was downloaded from https://github.com/OpenSC/pkcs11-helper/ 5 | 6 | Upstream Author: Alon Bar-Lev 7 | 8 | Copyright: Copyright (c) 2005-2006 Alon Bar-Lev 9 | 10 | include(top_srcdir/COPYING) 11 | 12 | On Debian GNU/Linux systems, the complete text of the GNU General 13 | Public License can be found in `/usr/share/common-licenses/GPL'. 14 | -------------------------------------------------------------------------------- /m4/size_t.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AX_SIZE_T_PRINTF 2 | dnl 3 | dnl Test if %zx is supported by printf. 4 | dnl 5 | dnl @version 6 | dnl @author 7 | AC_DEFUN([AX_SIZE_T_PRINTF], [dnl 8 | AC_TYPE_SIZE_T dnl 9 | AC_CHECK_SIZEOF([size_t])dnl 10 | AC_MSG_CHECKING([size_t printf format]) 11 | if test ${ac_cv_sizeof_size_t} = 4; then 12 | ax_cv_printf_z_format="%08x" 13 | else 14 | ax_cv_printf_z_format="%016lx" 15 | fi 16 | AC_MSG_RESULT([${ax_cv_printf_z_format}])dnl 17 | AC_DEFINE_UNQUOTED( 18 | [PRINTF_Z_FORMAT],dnl 19 | ["${ax_cv_printf_z_format}"],dnl 20 | [Define printf format for size_t]dnl 21 | )dnl 22 | ]) 23 | -------------------------------------------------------------------------------- /.github/workflows/build-linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: build-linux 3 | 4 | on: 5 | pull_request: 6 | push: 7 | 8 | jobs: 9 | build-linux: 10 | name: build-linux 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: dependencies 16 | run: | 17 | sudo apt update 18 | sudo apt install autotools-dev autoconf automake libtool libssl-dev libnss3-dev libmbedtls-dev libgnutls28-dev 19 | - name: gen 20 | run: | 21 | autoreconf -ivf 22 | - name: build 23 | run: | 24 | ./configure --enable-strict --enable-pedantic 25 | make distcheck 26 | -------------------------------------------------------------------------------- /lib/core.exports: -------------------------------------------------------------------------------- 1 | pkcs11h_addProvider 2 | pkcs11h_engine_setCrypto 3 | pkcs11h_engine_setSystem 4 | pkcs11h_forkFixup 5 | pkcs11h_getFeatures 6 | pkcs11h_getLogLevel 7 | pkcs11h_getMessage 8 | pkcs11h_getProperty 9 | pkcs11h_getVersion 10 | pkcs11h_initialize 11 | pkcs11h_initializeProvider 12 | pkcs11h_logout 13 | pkcs11h_plugAndPlay 14 | pkcs11h_registerProvider 15 | pkcs11h_removeProvider 16 | pkcs11h_setForkMode 17 | pkcs11h_setLogHook 18 | pkcs11h_setLogLevel 19 | pkcs11h_setMaxLoginRetries 20 | pkcs11h_setPINCachePeriod 21 | pkcs11h_setPINPromptHook 22 | pkcs11h_setProperty 23 | pkcs11h_setProtectedAuthentication 24 | pkcs11h_setProviderProperty 25 | pkcs11h_setProviderPropertyByName 26 | pkcs11h_setTokenPromptHook 27 | pkcs11h_terminate 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | 4 | *.bz2 5 | *.gz 6 | *.o 7 | *.obj 8 | *.exe 9 | *.dll 10 | *.lib 11 | *.a 12 | *.def 13 | *.exp 14 | *.idb 15 | *.manifest 16 | *.out 17 | *.in 18 | *.lo 19 | *.la 20 | *~ 21 | 22 | ltsugar.m4 23 | libtool.m4 24 | ltversion.m4 25 | lt~obsolete.m4 26 | ltoptions.m4 27 | 28 | test-* 29 | *.[0-9].html 30 | 31 | Makefile 32 | aclocal.m4 33 | autom4te.cache 34 | compile 35 | config.guess 36 | config.h 37 | config.log 38 | config.status 39 | config.sub 40 | configure 41 | depcomp 42 | install-sh 43 | libtool 44 | ltmain.sh 45 | missing 46 | stamp-h1 47 | 48 | pkcs11h-version.h 49 | config-w32-vc.h 50 | pkcs11-helper.exports 51 | libpkcs11-helper-1.pc 52 | versioninfo.rc 53 | 54 | copyright 55 | pkcs11-helper.spec 56 | 57 | doc/api/Doxyfile 58 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | 2 | James Yonan 3 | - Supported the initial development of pkcs11-helper as 4 | part of OpenVPN. 5 | - Provided the user base to work with. 6 | 7 | Brad Hards 8 | - For his help in getting pkcs11-helper into QCA. 9 | 10 | Justin Karneges 11 | - For integrating qca-pkcs11 into QCA. 12 | - For a lot of patience for my crazy requirements from QCA. 13 | 14 | Zeljko Vrba 15 | - pkcs11-helper was improved as a result of our work on 16 | gnupg-pkcs11-scd project. 17 | - Some bug fixes. 18 | 19 | Andreas Jellinghaus 20 | - For setting up the infrastructure required in OpenSC project. 21 | - For helping in the complex task of licenses. 22 | 23 | Eddy Nigg 24 | - For maintaining RPM support. 25 | 26 | Sandro Wefel 27 | - For maintaining Debian packaging. 28 | 29 | PolarSSL crypto engine by Adriaan de Jong 30 | - For PolarSSL support. 31 | 32 | Apologies to anyone I have missed. 33 | 34 | Alon Bar-Lev 35 | 36 | -------------------------------------------------------------------------------- /lib/certificate.exports: -------------------------------------------------------------------------------- 1 | pkcs11h_certificate_create 2 | pkcs11h_certificate_decrypt 3 | pkcs11h_certificate_decrypt 4 | pkcs11h_certificate_decryptAny 5 | pkcs11h_certificate_decryptAny_ex 6 | pkcs11h_certificate_decrypt_ex 7 | pkcs11h_certificate_deserializeCertificateId 8 | pkcs11h_certificate_duplicateCertificateId 9 | pkcs11h_certificate_ensureCertificateAccess 10 | pkcs11h_certificate_ensureKeyAccess 11 | pkcs11h_certificate_enumCertificateIds 12 | pkcs11h_certificate_enumTokenCertificateIds 13 | pkcs11h_certificate_freeCertificate 14 | pkcs11h_certificate_freeCertificateId 15 | pkcs11h_certificate_freeCertificateIdList 16 | pkcs11h_certificate_getCertificateBlob 17 | pkcs11h_certificate_getCertificateId 18 | pkcs11h_certificate_getPromptMask 19 | pkcs11h_certificate_getUserData 20 | pkcs11h_certificate_lockSession 21 | pkcs11h_certificate_releaseSession 22 | pkcs11h_certificate_serializeCertificateId 23 | pkcs11h_certificate_setCertificateIdCertificateBlob 24 | pkcs11h_certificate_setPromptMask 25 | pkcs11h_certificate_setUserData 26 | pkcs11h_certificate_sign 27 | pkcs11h_certificate_signAny 28 | pkcs11h_certificate_signAny_ex 29 | pkcs11h_certificate_signRecover 30 | pkcs11h_certificate_signRecover_ex 31 | pkcs11h_certificate_sign_ex 32 | pkcs11h_certificate_unwrap 33 | pkcs11h_certificate_unwrap_ex 34 | -------------------------------------------------------------------------------- /distro/debian/changelog: -------------------------------------------------------------------------------- 1 | libpkcs11-helper1 (1.03-0) unstable; urgency=low 2 | 3 | * New maintainer 4 | * New upstream release 5 | * renamed to libpkcs11-helper1 (lintian check) 6 | * removed *.la 7 | * size_t printf 64bit fixups (debug). 8 | * Certificate session period fixup, thank to Leo Pohl for reporting. 9 | 10 | -- Sandro Wefel (testlaeufer) Mon, 23 Apr 2007 08:59:16 +0200 11 | 12 | pkcs11-helper (1.02-99.0saw0) unstable; urgency=low 13 | 14 | * Non-maintainer upload. 15 | * upgrade to version 1.03 beta 1 16 | - use --with-apidocdir for the path to the api docs 17 | 18 | -- Sandro Wefel (testlaeufer) Fri, 16 Feb 2007 15:54:41 +0100 19 | 20 | pkcs11-helper (1.02-1.0saw1) unstable; urgency=low 21 | 22 | * Non-maintainer upload. 23 | * api docs added to pkcs11-helper-dev 24 | * license information updated 25 | * fix dependencies 26 | 27 | -- Sandro Wefel (testlaeufer) Sun, 11 Feb 2007 17:44:13 +0100 28 | 29 | pkcs11-helper (1.02-1.0saw0) unstable; urgency=low 30 | 31 | * Initial release 32 | - based on version 1.02 from 2007-10-05 33 | 34 | -- Sandro Wefel (testlaeufer) Mon, 29 Jan 2007 16:56:30 +0100 35 | 36 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | pkcs11-helper -- PKCS#11 simplification. 2 | 3 | Copyright (c) 2005-2018 Alon Bar-Lev 4 | 5 | ABOUT 6 | PKCS#11 is published standard. PKCS#11 is the de-facto standard to 7 | access cryptographic devices. 8 | 9 | pkcs11-helper is a library that simplifies the interaction with 10 | PKCS#11 providers for end-user applications. 11 | 12 | FEATURES 13 | pkcs11-helper allows using multiple PKCS#11 providers at the same 14 | time, enumerating available token certificates, or selecting a 15 | certificate directly by serialized id, handling card removal and 16 | card insert events, handling card re-insert to a different 17 | slot, supporting session expiration and much more all using a 18 | simple API. 19 | 20 | pkcs11-helper is not designed to manage card content, since object 21 | attributes are usually vendor specific, and 99% of application need 22 | to access existing objects in order to perform signature and 23 | decryption. 24 | 25 | COMPATIBILITY 26 | - The pkcs11-helper library is available in POSIX and WIN32 compliant 27 | systems. 28 | 29 | - The pkcs11-helper library should work with almost any PKCS#11 provider, 30 | since it uses the minimum required features of the PKCS#11 standard. 31 | 32 | SUPPORT 33 | https://github.com/OpenSC/pkcs11-helper 34 | 35 | AUTHORS 36 | Alon Bar-Lev 37 | 38 | -------------------------------------------------------------------------------- /COPYING.BSD: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2018, Alon Bar-Lev 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | o Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | o Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | o Neither the name of the Alon Bar-Lev nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /tests/test-basic/test-basic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../../config.h" 4 | #include 5 | 6 | static 7 | void 8 | fatal (const char * const m, CK_RV rv) { 9 | fprintf (stderr, "%s - %08lu - %s\n", m, rv, pkcs11h_getMessage (rv)); 10 | exit (1); 11 | } 12 | 13 | static 14 | void 15 | _pkcs11h_hooks_log ( 16 | IN void * const global_data, 17 | IN unsigned flags, 18 | IN const char * const format, 19 | IN va_list args 20 | ) { 21 | vfprintf (stdout, format, args); 22 | fprintf (stdout, "\n"); 23 | fflush (stdout); 24 | } 25 | 26 | int main () { 27 | CK_RV rv; 28 | 29 | printf ("Version: %08x\n", pkcs11h_getVersion ()); 30 | printf ("Features: %08x\n", pkcs11h_getFeatures ()); 31 | 32 | printf ("Initializing pkcs11-helper\n"); 33 | 34 | if ((rv = pkcs11h_initialize ()) != CKR_OK) { 35 | fatal ("pkcs11h_initialize failed", rv); 36 | } 37 | 38 | printf ("Registering pkcs11-helper hooks\n"); 39 | 40 | if ((rv = pkcs11h_setLogHook (_pkcs11h_hooks_log, NULL)) != CKR_OK) { 41 | fatal ("pkcs11h_setLogHook failed", rv); 42 | } 43 | 44 | pkcs11h_setLogLevel (TEST_LOG_LEVEL); 45 | 46 | printf ("Adding provider '%s'\n", TEST_PROVIDER); 47 | 48 | if ( 49 | (rv = pkcs11h_addProvider ( 50 | "reference1", 51 | TEST_PROVIDER, 52 | TRUE, 53 | PKCS11H_PRIVATEMODE_MASK_DECRYPT, 54 | PKCS11H_SLOTEVENT_METHOD_POLL, 55 | 0x55, 56 | TRUE 57 | )) != CKR_OK 58 | ) { 59 | fatal ("pkcs11h_addProvider failed", rv); 60 | } 61 | 62 | printf ("Terminating pkcs11-helper\n"); 63 | 64 | if ((rv = pkcs11h_terminate ()) != CKR_OK) { 65 | fatal ("pkcs11h_terminate failed", rv); 66 | } 67 | 68 | exit (0); 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /m4/vararg.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AX_CPP_VARARG_MACRO_GCC 2 | dnl 3 | dnl Test if the preprocessor understands GNU GCC-style vararg macros. 4 | dnl If it does, defines HAVE_CPP_VARARG_MACRO_GCC to 1. 5 | dnl 6 | dnl @version 7 | dnl @author James Yonan , Matthias Andree 8 | AC_DEFUN([AX_CPP_VARARG_MACRO_GCC], [dnl 9 | AS_VAR_PUSHDEF([VAR],[ax_cv_cpp_vararg_macro_gcc])dnl 10 | AC_CACHE_CHECK([for GNU GCC vararg macro support], VAR, [dnl 11 | AC_COMPILE_IFELSE([AC_LANG_SOURCE( 12 | , 13 | [[#define macro(a, b...) func(a, b) 14 | int func(int a, int b, int c); 15 | int test() { return macro(1, 2, 3); } 16 | ]])], [ VAR=yes ], [VAR=no])]) 17 | if test $VAR = yes ; then 18 | AC_DEFINE([HAVE_CPP_VARARG_MACRO_GCC], 1, 19 | [Define to 1 if your compiler supports GNU GCC-style variadic macros]) 20 | fi 21 | AS_VAR_POPDEF([VAR])dnl 22 | ]) 23 | 24 | dnl @synopsis AX_CPP_VARARG_MACRO_ISO 25 | dnl 26 | dnl Test if the preprocessor understands ISO C 1999 vararg macros. 27 | dnl If it does, defines HAVE_CPP_VARARG_MACRO_ISO to 1. 28 | dnl 29 | dnl @version 30 | dnl @author James Yonan , Matthias Andree 31 | AC_DEFUN([AX_CPP_VARARG_MACRO_ISO], [dnl 32 | AS_VAR_PUSHDEF([VAR],[ax_cv_cpp_vararg_macro_iso])dnl 33 | AC_CACHE_CHECK([for ISO C 1999 vararg macro support], VAR, [dnl 34 | AC_COMPILE_IFELSE([AC_LANG_SOURCE( 35 | , 36 | [[ 37 | #define macro(a, ...) func(a, __VA_ARGS__) 38 | int func(int a, int b, int c); 39 | int test() { return macro(1, 2, 3); } 40 | ]])], [ VAR=yes ], [VAR=no])]) 41 | if test $VAR = yes ; then 42 | AC_DEFINE([HAVE_CPP_VARARG_MACRO_ISO], 1, 43 | [Define to 1 if your compiler supports ISO C99 variadic macros]) 44 | fi 45 | AS_VAR_POPDEF([VAR])dnl 46 | ]) 47 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | pkcs11-helper -- PKCS#11 simplification. 2 | 3 | Copyright (c) 2005-2018 Alon Bar-Lev 4 | 5 | POSIX 6 | Dependencies: 7 | dl 8 | threading: (Optional) 9 | pthread (nptl) 10 | engine-crypt: (Optional, usually must choose) 11 | OpenSSL>=0.9.7 || GNUTLS>=1.4.4 12 | openssl: (Optional) 13 | OpenSSL>=0.9.7 14 | doc: (Optional) 15 | doxygen>=1.4 16 | 17 | Build: 18 | $ ./configure 19 | $ make 20 | $ make install 21 | 22 | Cross-MinGW32 23 | Dependencies: 24 | man2html 25 | openssl: (Optional) 26 | OpenSSL>=0.9.7 27 | doc: (Optional) 28 | doxygen>=1.4 29 | 30 | Build: 31 | w32root=/tmp/w32root 32 | 33 | Without openssl engine: 34 | ./configure \ 35 | --prefix=/ --host=mingw32 \ 36 | --disable-openssl \ 37 | --disable-crypto-engine-openssl \ 38 | --disable-crypto-engine-gnutls 39 | With openssl engine: 40 | ./configure --prefix=/ --host=mingw32 \ 41 | --disable-crypto-engine-gnutls \ 42 | --disable-crypto-engine-nss \ 43 | PKG_CONFIG=true \ 44 | OPENSSL_CFLAGS="-I${w32root}/include" \ 45 | OPENSSL_LIBS="-L${w32root}/lib -lcrypto" 46 | 47 | make 48 | make install DESTDIR="${w32root}" 49 | 50 | Create Microsoft LIB file (Optional): 51 | [[Must use Microsoft lib utility]] 52 | lib /def:libpkcs11-helper-1.dll.def \ 53 | /name:libpkcs11-helper-1.dll \ 54 | /out:pkcs11-helper.dll.lib 55 | 56 | Native-Cygwin 57 | Dependencies: 58 | Same as Cross-MinGW32 59 | 60 | Build: 61 | Same as Cross-MinGW32, replace --host=mingw32 with --with-cygwin-native. 62 | 63 | Visual Studio 64 | Dependencies: 65 | None. 66 | 67 | Build: 68 | Without openssl engine: 69 | cd lib 70 | nmake -f Makefile.w32-vc 71 | With openssl engine: 72 | cd lib 73 | nmake -f Makefile.w32-vc OPENSSL=1 OPENSSL_HOME= 74 | 75 | -------------------------------------------------------------------------------- /doc/api/main.dox: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @mainpage pkcs11-helper-1.0 4 | @section about About 5 | @par 6 | PKCS#11 7 | is 8 | RSA Security 9 | published standard. PKCS#11 is the de-facto standard to access cryptographic 10 | devices. 11 | @par 12 | pkcs11-helper is a library that simplifies the interaction with PKCS#11 13 | providers for end-user applications. 14 | @section features Features 15 | @par 16 | pkcs11-helper allows using multiple PKCS#11 providers at the same time, enumerating 17 | available token certificates, or selecting a certificate directly by serialized id, 18 | handling card removal and card insert events, handling card re-insert to a different 19 | slot, supporting session expiration and much more all using a simple API. 20 | @par 21 | pkcs11-helper is not designed to manage card content, since object attributes 22 | are usually vendor specific, and 99% of application need to access 23 | existing objects in order to perform signature and decryption. 24 | @section compatibility Compatibility 25 | - The pkcs11-helper library is available in POSIX and WIN32 compliant systems. 26 | - The pkcs11-helper library should work with almost any PKCS#11 provider, since it 27 | uses the minimum required features of the PKCS#11 standard. 28 | @section support Support 29 | @par 30 | pkcs11-helper support is available via the 31 | project page. 32 | @section license License 33 | @par 34 | @ref License is dual BSD or GPL. 35 | @section modules Modules 36 | - @ref pkcs11h_core - Initialize library, adding providers, hooks. 37 | - @ref pkcs11h_token - Handle tokens. 38 | - @ref pkcs11h_certificate - Handle certificate objects. 39 | - @ref pkcs11h_data - Handle data objects. 40 | - @ref pkcs11h_openssl - OpenSSL engine support. 41 | @page License pkcs11-helper license 42 | @verbinclude COPYING 43 | 44 | */ 45 | 46 | /** 47 | @example test-basic.c 48 | 49 | The following example shows some basic usage of the library. 50 | */ 51 | 52 | /** 53 | @example test-slotevent.c 54 | 55 | The following example shows how to use the slot event interface. 56 | */ 57 | 58 | -------------------------------------------------------------------------------- /distro/debian/control: -------------------------------------------------------------------------------- 1 | Source: libpkcs11-helper1 2 | Priority: extra 3 | Maintainer: Sandro Wefel 4 | Build-Depends: cdbs (>= 0.4.27-1), debhelper (>= 5), autotools-dev, libssl-dev, pkg-config, doxygen 5 | Standards-Version: 3.7.2 6 | Section: libs 7 | 8 | Package: libpkcs11-helper1-dev 9 | Section: libdevel 10 | Architecture: any 11 | Provides: libpkcs11-helper-dev 12 | Conflicts: libpkcs11-helper-dev 13 | Depends: libpkcs11-helper1 (= ${Source-Version}), libssl-dev 14 | Description: library that simplifies the interaction with PKCS#11 15 | libpkcs11-helper is a library that simplifies the interaction with PKCS#11 16 | providers for end-user applications. 17 | . 18 | libpkcs11-helper allows using multiple PKCS#11 providers at the same time, 19 | enumerating available token certificates, or selecting a certificate 20 | directly by serialized id, handling card removal and card insert 21 | events, handling card re-insert to a different slot, supporting session 22 | expiration and much more all using a simple API. 23 | . 24 | libpkcs11-helper is not designed to manage card content, since object 25 | attributes are usually vendor specific, and 99% of application need to 26 | access existing objects in order to perform signature and decryption. 27 | 28 | 29 | 30 | Package: libpkcs11-helper1 31 | Section: libs 32 | Architecture: any 33 | Depends: ${shlibs:Depends}, ${misc:Depends} 34 | Description: library that simplifies the interaction with PKCS#11 35 | libpkcs11-helper is a library that simplifies the interaction with PKCS#11 36 | providers for end-user applications. 37 | . 38 | libpkcs11-helper allows using multiple PKCS#11 providers at the same time, 39 | enumerating available token certificates, or selecting a certificate 40 | directly by serialized id, handling card removal and card insert 41 | events, handling card re-insert to a different slot, supporting session 42 | expiration and much more all using a simple API. 43 | . 44 | libpkcs11-helper is not designed to manage card content, since object 45 | attributes are usually vendor specific, and 99% of application need to 46 | access existing objects in order to perform signature and decryption. 47 | -------------------------------------------------------------------------------- /distro/rpm/pkcs11-helper.spec.in: -------------------------------------------------------------------------------- 1 | # doc support 2 | %bcond_with doc 3 | 4 | %define name @PACKAGE@ 5 | %define version @VERSION@ 6 | %define release 2 7 | %define prefix /usr 8 | 9 | Summary: A helper library for the use with smart cards and the PKCS#11 API 10 | Name: %{name} 11 | Version: %{version} 12 | Release: %{release} 13 | License: GPLv2 or BSD 14 | Vendor: The OpenSC Project, https://github.com/OpenSC 15 | Packager: Alon Bar-Lev 16 | Group: System/Crypto 17 | Url: https://github.com/OpenSC/pkcs11-helper 18 | Source: https://github.com/OpenSC/pkcs11-helper/releases/download/%{name}-%{version}/%{name}-%{version}.tar.bz2 19 | %if %{with doc} 20 | BuildRequires: doxygen 21 | %endif 22 | BuildRequires: openssl-devel >= 0.9.7a 23 | Requires: openssl >= 0.9.7a 24 | %description 25 | The pkcs11-helper library allows using multiple PKCS#11 providers at 26 | the same time, selecting keys by id, label or certificate subject, 27 | handling card removal and card insert events, handling card re-insert 28 | to a different slot, supporting session expiration serialization and 29 | much more, all using a simple API. 30 | 31 | %package devel 32 | Summary: pkcs11-helper development files 33 | Group: Development/Libraries 34 | Requires: %{name} >= %{version} 35 | Requires: pkgconfig 36 | %description devel 37 | pkcs11-helper development files. 38 | 39 | %prep 40 | %setup -q 41 | 42 | %build 43 | %configure -q \ 44 | %{?with_doc:--enable-doc} \ 45 | %{nil} 46 | %{__make} %{?_smp_mflags} 47 | 48 | %install 49 | %{__make} %{?_smp_mflags} install DESTDIR="%{?buildroot}" 50 | 51 | %post -p /sbin/ldconfig 52 | %postun -p /sbin/ldconfig 53 | 54 | %files 55 | %{_docdir}/%{name}/COPYING* 56 | %{_docdir}/%{name}/README 57 | %{_libdir}/libpkcs11-helper.so.* 58 | %{_mandir}/*/* 59 | 60 | %files devel 61 | %{_datadir}/aclocal/* 62 | %{_includedir}/* 63 | %{_libdir}/libpkcs11-helper.a 64 | %{_libdir}/libpkcs11-helper.la 65 | %{_libdir}/libpkcs11-helper.so 66 | %{_libdir}/pkgconfig/* 67 | %if %{with doc} 68 | %{_docdir}/%{name}/api/* 69 | %endif 70 | 71 | %changelog 72 | * Sat Jan 14 2017 Alon Bar-Lev 73 | - Cleanups. 74 | 75 | * Fri Nov 11 2011 Alon Bar-Lev 76 | - Cleanups. 77 | 78 | * Thu Feb 15 2007 Alon Bar-Lev 79 | - Modify docs location. 80 | 81 | * Mon Jan 15 2007 Eddy Nigg 82 | - Make doxygen dependency only for doc builds 83 | 84 | * Tue Jan 9 2007 Eddy Nigg 85 | - Build new version 1.03 86 | 87 | * Sun Jan 7 2007 Eddy Nigg 88 | - Fix for pkgconfig. 89 | 90 | * Mon Nov 27 2006 Eddy Nigg 91 | - Fix documentation. 92 | 93 | * Sun Nov 26 2006 Eddy Nigg 94 | - Initial build for StartCom Linux 5.0.x 95 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | SUBDIRS=api 54 | -------------------------------------------------------------------------------- /distro/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | SUBDIRS=rpm debian 54 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | SUBDIRS=pkcs11-helper-1.0 54 | -------------------------------------------------------------------------------- /m4dir/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | dist_m4_DATA=pkcs11-helper-1.m4 54 | -------------------------------------------------------------------------------- /distro/rpm/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | dist_noinst_DATA=pkcs11-helper.spec 54 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | COMMON= \ 54 | test-basic \ 55 | test-fork \ 56 | test-certificate \ 57 | test-openssl \ 58 | test-slotevent 59 | 60 | if ENABLE_TESTS 61 | SUBDIRS = $(COMMON) 62 | endif 63 | DIST_SUBDIRS = $(COMMON) 64 | -------------------------------------------------------------------------------- /lib/_pkcs11h-sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_SYS_H 52 | #define ___PKCS11H_SYS_H 53 | 54 | #include "common.h" 55 | 56 | #include 57 | 58 | extern pkcs11h_engine_system_t _g_pkcs11h_sys_engine; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /lib/_pkcs11h-crypto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_CRYPTO_H 52 | #define ___PKCS11H_CRYPTO_H 53 | 54 | #include "common.h" 55 | 56 | #include 57 | 58 | extern pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | CLEANFILES=pkcs11-helper-1.8.html 53 | 54 | if WIN32 55 | nodist_html_DATA=pkcs11-helper-1.8.html 56 | dist_noinst_DATA=pkcs11-helper-1.8 57 | pkcs11-helper-1.8.html: pkcs11-helper-1.8 58 | $(MAN2HTML) < "$^" > "$@" 59 | else 60 | dist_man_MANS=pkcs11-helper-1.8 61 | endif 62 | -------------------------------------------------------------------------------- /tests/test-fork/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | MY_TESTS = \ 54 | test-fork \ 55 | $(NULL) 56 | 57 | TESTS=$(MY_TESTS) 58 | noinst_PROGRAMS=$(MY_TESTS) 59 | 60 | AM_CPPFLAGS= \ 61 | -I$(top_srcdir)/include \ 62 | -I$(top_builddir)/include 63 | LDADD= \ 64 | $(top_builddir)/lib/libpkcs11-helper.la 65 | 66 | test_fork_SOURCES=test-fork.c 67 | -------------------------------------------------------------------------------- /tests/test-openssl/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | MY_TESTS = \ 54 | test-openssl \ 55 | $(NULL) 56 | 57 | TESTS=$(MY_TESTS) 58 | noinst_PROGRAMS=$(MY_TESTS) 59 | 60 | AM_CPPFLAGS= \ 61 | -I$(top_srcdir)/include \ 62 | -I$(top_builddir)/include 63 | LDADD= \ 64 | $(top_builddir)/lib/libpkcs11-helper.la 65 | 66 | test_openssl_SOURCES=test-openssl.c 67 | -------------------------------------------------------------------------------- /tests/test-slotevent/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | MY_TESTS = \ 54 | test-slotevent \ 55 | $(NULL) 56 | 57 | TESTS=$(MY_TESTS) 58 | noinst_PROGRAMS=$(MY_TESTS) 59 | 60 | AM_CPPFLAGS= \ 61 | -I$(top_srcdir)/include \ 62 | -I$(top_builddir)/include 63 | LDADD= \ 64 | $(top_builddir)/lib/libpkcs11-helper.la 65 | 66 | test_slotevent_SOURCES=test-slotevent.c 67 | -------------------------------------------------------------------------------- /tests/test-certificate/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | MY_TESTS = \ 54 | test-certificate \ 55 | $(NULL) 56 | 57 | TESTS=$(MY_TESTS) 58 | noinst_PROGRAMS=$(MY_TESTS) 59 | 60 | AM_CPPFLAGS= \ 61 | -I$(top_srcdir)/include \ 62 | -I$(top_builddir)/include 63 | LDADD= \ 64 | $(top_builddir)/lib/libpkcs11-helper.la 65 | 66 | test_certificate_SOURCES=test-certificate.c 67 | -------------------------------------------------------------------------------- /lib/_pkcs11h-openssl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_OPENSSL_H 52 | #define ___PKCS11H_OPENSSL_H 53 | 54 | #include "common.h" 55 | 56 | #if defined(ENABLE_PKCS11H_OPENSSL) 57 | 58 | #include 59 | 60 | PKCS11H_BOOL 61 | _pkcs11h_openssl_initialize (void); 62 | 63 | PKCS11H_BOOL 64 | _pkcs11h_openssl_terminate (void); 65 | 66 | #endif 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /distro/debian/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | SUFFIXES=.m4 52 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 53 | CLEANFILES=copyright 54 | BUILT_SOURCES=copyright 55 | 56 | dist_noinst_DATA= \ 57 | changelog \ 58 | README.build \ 59 | compat \ 60 | control \ 61 | copyright.m4 \ 62 | copyright \ 63 | rules \ 64 | watch \ 65 | libpkcs11-helper1-dev.install \ 66 | libpkcs11-helper1.install 67 | 68 | .m4: 69 | $(M4) -Dtop_srcdir="$(top_srcdir)" "$^" > "$@" 70 | -------------------------------------------------------------------------------- /tests/test-basic/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | MY_TESTS = \ 54 | test-basic \ 55 | test-basic2 \ 56 | test-serialize \ 57 | $(NULL) 58 | 59 | TESTS=$(MY_TESTS) 60 | noinst_PROGRAMS=$(MY_TESTS) 61 | 62 | AM_CPPFLAGS= \ 63 | -I$(top_srcdir)/include \ 64 | -I$(top_builddir)/include 65 | LDADD= \ 66 | $(top_builddir)/lib/libpkcs11-helper.la 67 | 68 | test_basic_SOURCES=test-basic.c 69 | test_basic2_SOURCES=test-basic2.c 70 | -------------------------------------------------------------------------------- /doc/api/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | dist_noinst_DATA=Doxyfile $(srcdir)/Doxyfile_footer.html $(srcdir)/*.dox $(srcdir)/*.gif 54 | 55 | if ENABLE_DOC 56 | 57 | apidoc_DATA=api.out/html/* 58 | 59 | api.out/html/*: \ 60 | $(EXTRA_DIST) \ 61 | $(top_srcdir)/include/pkcs11-helper-1.0/*.h \ 62 | $(srcdir)/*.gif 63 | -rm -fr api.out 64 | $(DOXYGEN) 65 | cp "$(srcdir)"/*.gif api.out/html 66 | 67 | endif 68 | 69 | clean-local: 70 | -rm -fr api.out 71 | -------------------------------------------------------------------------------- /lib/_pkcs11h-token.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_TOKEN_H 52 | #define ___PKCS11H_TOKEN_H 53 | 54 | #include "common.h" 55 | #include "_pkcs11h-core.h" 56 | #include 57 | 58 | CK_RV 59 | _pkcs11h_token_getTokenId ( 60 | IN const CK_TOKEN_INFO_PTR info, 61 | OUT pkcs11h_token_id_t * const p_token_id 62 | ); 63 | 64 | CK_RV 65 | _pkcs11h_token_newTokenId ( 66 | OUT pkcs11h_token_id_t * const token_id 67 | ); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /lib/_pkcs11h-slotevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_SLOTEVENT_H 52 | #define ___PKCS11H_SLOTEVENT_H 53 | 54 | #include "common.h" 55 | 56 | #if defined(ENABLE_PKCS11H_SLOTEVENT) 57 | 58 | #include 59 | 60 | CK_RV 61 | _pkcs11h_slotevent_init (void); 62 | 63 | CK_RV 64 | _pkcs11h_slotevent_notify (void); 65 | 66 | CK_RV 67 | _pkcs11h_slotevent_terminate_force (void); 68 | 69 | CK_RV 70 | _pkcs11h_slotevent_terminate (void); 71 | 72 | #endif /* ENABLE_PKCS11H_SLOTEVENT */ 73 | 74 | #endif /* ___PKCS11H_SLOTEVENT_H */ 75 | 76 | -------------------------------------------------------------------------------- /lib/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef __COMMON_H 52 | #define __COMMON_H 53 | 54 | #if defined(_MSC_VER) 55 | #include "../config-w32-vc.h" 56 | #else 57 | #include "../config.h" 58 | #endif 59 | 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | 67 | #if defined(_WIN32) 68 | #include 69 | #endif 70 | 71 | #define P_Z PRINTF_Z_FORMAT 72 | 73 | #define _PKCS11H_ASSERT assert 74 | 75 | #ifndef FALSE 76 | #define FALSE 0 77 | #endif 78 | #ifndef TRUE 79 | #define TRUE 1 80 | #endif 81 | 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /tests/test-fork/test-fork.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../../config.h" 4 | #include 5 | 6 | #if !defined(ENABLE_PKCS11H_CERTIFICATE) || defined(WIN32) 7 | int main () { 8 | printf ("!win32, certificate, enum and crypto engine interfaces should be enabled for this test"); 9 | exit (77); 10 | return 0; 11 | } 12 | #else 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | static 19 | void 20 | fatal (const char * const m, CK_RV rv) { 21 | fprintf (stderr, "%s - %08lu - %s\n", m, rv, pkcs11h_getMessage (rv)); 22 | exit (1); 23 | } 24 | 25 | static 26 | void 27 | _pkcs11h_hooks_log ( 28 | IN void * const global_data, 29 | IN unsigned flags, 30 | IN const char * const format, 31 | IN va_list args 32 | ) { 33 | vfprintf (stdout, format, args); 34 | fprintf (stdout, "\n"); 35 | fflush (stdout); 36 | } 37 | 38 | int main () { 39 | pkcs11h_certificate_id_list_t issuers, certs; 40 | pid_t pid; 41 | CK_RV rv; 42 | 43 | printf ("Version: %08x\n", pkcs11h_getVersion ()); 44 | printf ("Features: %08x\n", pkcs11h_getFeatures ()); 45 | 46 | printf ("Initializing pkcs11-helper\n"); 47 | 48 | if ((rv = pkcs11h_initialize ()) != CKR_OK) { 49 | fatal ("pkcs11h_initialize failed", rv); 50 | } 51 | 52 | pkcs11h_setForkMode(TRUE); 53 | 54 | printf ("Registering pkcs11-helper hooks\n"); 55 | 56 | if ((rv = pkcs11h_setLogHook (_pkcs11h_hooks_log, NULL)) != CKR_OK) { 57 | fatal ("pkcs11h_setLogHook failed", rv); 58 | } 59 | 60 | pkcs11h_setLogLevel (TEST_LOG_LEVEL); 61 | 62 | printf ("Adding provider '%s'\n", TEST_PROVIDER); 63 | 64 | if ( 65 | (rv = pkcs11h_addProvider ( 66 | TEST_PROVIDER, 67 | TEST_PROVIDER, 68 | FALSE, 69 | PKCS11H_PRIVATEMODE_MASK_AUTO, 70 | PKCS11H_SLOTEVENT_METHOD_AUTO, 71 | 0, 72 | FALSE 73 | )) != CKR_OK 74 | ) { 75 | fatal ("pkcs11h_addProvider failed", rv); 76 | } 77 | 78 | printf ("Forking pkcs11-helper\n"); 79 | fflush(stdout); 80 | 81 | if ((pid = fork()) == -1) { 82 | fatal ("fork failed", CKR_GENERAL_ERROR); 83 | } 84 | else if (pid == 0) { 85 | printf ("Child fork fixup\n"); 86 | pkcs11h_forkFixup(); 87 | printf ("Child Enum certs\n"); 88 | if ( 89 | (rv = pkcs11h_certificate_enumCertificateIds ( 90 | PKCS11H_ENUM_METHOD_CACHE, 91 | NULL, 92 | PKCS11H_PROMPT_MASK_ALLOW_ALL, 93 | &issuers, 94 | &certs 95 | )) != CKR_OK 96 | ) { 97 | fatal ("pkcs11h_certificate_enumCertificateIds failed", rv); 98 | } 99 | printf ("Child termination\n"); 100 | if ((rv = pkcs11h_terminate ()) != CKR_OK) { 101 | fatal ("pkcs11h_terminate failed", rv); 102 | } 103 | exit (0); 104 | } 105 | else { 106 | printf ("Parent Enum certs\n"); 107 | if ( 108 | (rv = pkcs11h_certificate_enumCertificateIds ( 109 | PKCS11H_ENUM_METHOD_CACHE, 110 | NULL, 111 | PKCS11H_PROMPT_MASK_ALLOW_ALL, 112 | &issuers, 113 | &certs 114 | )) != CKR_OK 115 | ) { 116 | fatal ("pkcs11h_certificate_enumCertificateIds failed", rv); 117 | } 118 | waitpid(pid, NULL, 0); 119 | } 120 | 121 | printf ("Terminating pkcs11-helper\n"); 122 | 123 | if ((rv = pkcs11h_terminate ()) != CKR_OK) { 124 | fatal ("pkcs11h_terminate failed", rv); 125 | } 126 | 127 | exit (0); 128 | return 0; 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /tests/test-basic/test-serialize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../config.h" 5 | #include 6 | #include 7 | 8 | static 9 | void 10 | fatal (const char * const m, CK_RV rv) { 11 | fprintf (stderr, "%s - %08lu - %s\n", m, rv, pkcs11h_getMessage (rv)); 12 | exit (1); 13 | } 14 | 15 | static 16 | void 17 | _pkcs11h_hooks_log ( 18 | IN void * const global_data, 19 | IN unsigned flags, 20 | IN const char * const format, 21 | IN va_list args 22 | ) { 23 | vfprintf (stdout, format, args); 24 | fprintf (stdout, "\n"); 25 | fflush (stdout); 26 | } 27 | 28 | static 29 | CK_RV 30 | _deserialize ( 31 | const char * const str, 32 | const PKCS11H_BOOL should_success 33 | ) { 34 | pkcs11h_certificate_id_t id = NULL; 35 | char *p = NULL; 36 | size_t max; 37 | CK_RV ret; 38 | CK_RV rv; 39 | 40 | ret = pkcs11h_certificate_deserializeCertificateId ( 41 | &id, 42 | str 43 | ); 44 | 45 | if (should_success && ret != CKR_OK) { 46 | fprintf(stderr, "String: %s\n", str); 47 | fatal("Should succeed", rv); 48 | } 49 | if (!should_success && ret == CKR_OK) { 50 | fprintf(stderr, "String: %s\n", str); 51 | fatal("Should fail", rv); 52 | } 53 | 54 | if (id != NULL) { 55 | if ((rv = pkcs11h_certificate_serializeCertificateId ( 56 | NULL, 57 | &max, 58 | id 59 | )) != CKR_OK) { 60 | fatal("pkcs11h_certificate_serializeCertificateId", rv); 61 | } 62 | 63 | if ((p = malloc(max)) == NULL) { 64 | fatal("malloc", CKR_HOST_MEMORY); 65 | } 66 | 67 | if ((rv = pkcs11h_certificate_serializeCertificateId ( 68 | p, 69 | &max, 70 | id 71 | )) != CKR_OK) { 72 | fatal("pkcs11h_certificate_serializeCertificateId(2)", rv); 73 | } 74 | 75 | if (strcmp(p, str)) { 76 | fprintf(stderr, "in: '%s' construct: '%s'\n", str, p); 77 | fatal("Fail serialize compare", CKR_FUNCTION_FAILED); 78 | } 79 | } 80 | 81 | if (p != NULL) { 82 | free(p); 83 | } 84 | 85 | if (id != NULL) { 86 | pkcs11h_certificate_freeCertificateId(id); 87 | } 88 | 89 | return ret; 90 | } 91 | 92 | int main () { 93 | CK_RV rv; 94 | int i; 95 | 96 | printf ("Initializing pkcs11-helper\n"); 97 | 98 | if ((rv = pkcs11h_initialize ()) != CKR_OK) { 99 | fatal ("pkcs11h_initialize failed", rv); 100 | } 101 | 102 | printf ("Registering pkcs11-helper hooks\n"); 103 | 104 | if ((rv = pkcs11h_setLogHook (_pkcs11h_hooks_log, NULL)) != CKR_OK) { 105 | fatal ("pkcs11h_setLogHook failed", rv); 106 | } 107 | 108 | pkcs11h_setLogLevel (TEST_LOG_LEVEL); 109 | 110 | printf ("Sanity\n"); 111 | 112 | _deserialize("manufacturer/model/serial/label/02", TRUE); 113 | 114 | _deserialize("manufacturer/model/serial/label/0z", FALSE); 115 | 116 | _deserialize("manufa\\xggcturer/model/serial/label/02", FALSE); 117 | 118 | printf ("Components\n"); 119 | 120 | const char *failure_string = "manu\\xff/model/serial/label\xee/0"; 121 | char buffer[1024]; 122 | 123 | for (i = 0; i < strlen(failure_string); i++) { 124 | strcpy(buffer, failure_string); 125 | buffer[i] = '\0'; 126 | _deserialize(buffer, FALSE); 127 | } 128 | 129 | printf ("Terminating pkcs11-helper\n"); 130 | 131 | if ((rv = pkcs11h_terminate ()) != CKR_OK) { 132 | fatal ("pkcs11h_terminate failed", rv); 133 | } 134 | 135 | exit (0); 136 | return 0; 137 | } 138 | -------------------------------------------------------------------------------- /include/pkcs11-helper-1.0/pkcs11h-version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | #ifndef __PKCS11H_VERSION_H 51 | #define __PKCS11H_VERSION_H 52 | 53 | /** 54 | * @file pkcs11h-version.h 55 | * @brief pkcs11-helper core. 56 | * @author Alon Bar-Lev 57 | * @see pkcs11h_core. 58 | */ 59 | 60 | /** 61 | * @addtogroup pkcs11h_core pkcs11-helper core interface 62 | * 63 | * Core functionality. 64 | * 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @brief Library version. 70 | */ 71 | #define PKCS11H_VERSION ( \ 72 | (@PKCS11H_VERSION_MAJOR@<<16) | \ 73 | (@PKCS11H_VERSION_MINOR@<<8) | \ 74 | (@PKCS11H_VERSION_FIX@<<0) \ 75 | ) 76 | 77 | /** @} */ 78 | 79 | #endif /* __PKCS11H_VERSION_H */ 80 | -------------------------------------------------------------------------------- /lib/_pkcs11h-mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_MEM_H 52 | #define ___PKCS11H_MEM_H 53 | 54 | #include "common.h" 55 | 56 | #include 57 | 58 | CK_RV 59 | _pkcs11h_mem_malloc ( 60 | OUT const void * * const p, 61 | IN const size_t s 62 | ); 63 | 64 | CK_RV 65 | _pkcs11h_mem_free ( 66 | IN const void * * const p 67 | ); 68 | 69 | CK_RV 70 | _pkcs11h_mem_strdup ( 71 | OUT const char * * const dest, 72 | IN const char * const src 73 | ); 74 | 75 | CK_RV 76 | _pkcs11h_mem_duplicate ( 77 | OUT const void * * const dest, 78 | OUT size_t * const dest_size, 79 | IN const void * const src, 80 | IN const size_t mem_size 81 | ); 82 | 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | AUTOMAKE_OPTIONS=foreign dist-bzip2 1.10 52 | ACLOCAL_AMFLAGS = -I m4 53 | 54 | MAINTAINERCLEANFILES= \ 55 | config.log config.status \ 56 | $(srcdir)/Makefile.in \ 57 | $(srcdir)/config.h.in $(srcdir)/config.h.in~ $(srcdir)/configure \ 58 | $(srcdir)/install-sh $(srcdir)/ltmain.sh $(srcdir)/missing \ 59 | $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ 60 | $(srcdir)/config.guess $(srcdir)/config.sub \ 61 | $(srcdir)/m4/ltsugar.m4 $(srcdir)/m4/libtool.m4 \ 62 | $(srcdir)/m4/ltversion.m4 $(srcdir)/m4/lt~obsolete.m4 \ 63 | $(srcdir)/m4/ltoptions.m4 \ 64 | $(srcdir)/pkcs11-helper.spec $(srcdir)/config-w32-vc.h 65 | 66 | SUBDIRS=man include lib m4dir doc distro tests 67 | 68 | dist_doc_DATA=README COPYING.GPL COPYING.BSD COPYING 69 | noinst_HEADERS=config-w32-vc.h 70 | -------------------------------------------------------------------------------- /tests/test-basic/test-basic2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../config.h" 5 | #include 6 | 7 | static 8 | void 9 | fatal (const char * const m, CK_RV rv) { 10 | fprintf (stderr, "%s - %08lu - %s\n", m, rv, pkcs11h_getMessage (rv)); 11 | exit (1); 12 | } 13 | 14 | static 15 | void 16 | _pkcs11h_hooks_log ( 17 | IN void * const global_data, 18 | IN unsigned flags, 19 | IN const char * const format, 20 | IN va_list args 21 | ) { 22 | vfprintf (stdout, format, args); 23 | fprintf (stdout, "\n"); 24 | fflush (stdout); 25 | } 26 | 27 | static 28 | void 29 | _pkcs11h_hooks_provider_destroy ( 30 | IN void * const * global_data, 31 | IN const char * const reference 32 | ) { 33 | fprintf (stdout, "Provider '%s' destroyed\n", reference); 34 | fflush (stdout); 35 | } 36 | 37 | int main () { 38 | struct { 39 | char *p; 40 | char *v; 41 | } props[] = { 42 | {"location", TEST_PROVIDER}, 43 | {"allow_protected_auth", "1"}, 44 | {"mask_private_mode", "2"}, 45 | {"slot_event_method", "3"}, 46 | {"slot_poll_interval", "0x55"}, 47 | {"cert_is_private", "1"}, 48 | {NULL, NULL} 49 | }, *p; 50 | 51 | const char * reference = "reference1"; 52 | CK_C_INITIALIZE_ARGS init_args; 53 | CK_C_INITIALIZE_ARGS_PTR init_args_ptr = &init_args; 54 | CK_RV rv; 55 | 56 | printf ("Version: %08x\n", pkcs11h_getVersion ()); 57 | printf ("Features: %08x\n", pkcs11h_getFeatures ()); 58 | 59 | printf ("Initializing pkcs11-helper\n"); 60 | 61 | if ((rv = pkcs11h_initialize ()) != CKR_OK) { 62 | fatal ("pkcs11h_initialize failed", rv); 63 | } 64 | 65 | printf ("Registering pkcs11-helper hooks\n"); 66 | 67 | if ((rv = pkcs11h_setLogHook (_pkcs11h_hooks_log, NULL)) != CKR_OK) { 68 | fatal ("pkcs11h_setLogHook failed", rv); 69 | } 70 | 71 | pkcs11h_setLogLevel (TEST_LOG_LEVEL); 72 | 73 | printf ("Registering provider '%s'\n", TEST_PROVIDER); 74 | if ((rv = pkcs11h_registerProvider (reference)) != CKR_OK) { 75 | fatal ("pkcs11h_registerProvider failed", rv); 76 | } 77 | 78 | for (p = props; p->p != NULL; p++) { 79 | printf("Setting property '%s'='%s'\n", p->p, p->v); 80 | if ( 81 | (rv = pkcs11h_setProviderPropertyByName ( 82 | reference, 83 | p->p, 84 | p->v 85 | )) != CKR_OK 86 | ) { 87 | fatal ("pkcs11h_setProviderPropertyByName failed", rv); 88 | } 89 | } 90 | 91 | { 92 | void *p; 93 | p = &_pkcs11h_hooks_provider_destroy; 94 | pkcs11h_setProviderProperty(reference, PKCS11H_PROVIDER_PROPERTY_PROVIDER_DESTRUCT_HOOK, &p, sizeof(p)); 95 | } 96 | 97 | memset(&init_args, 0, sizeof(init_args)); 98 | init_args.flags = CKF_OS_LOCKING_OK; 99 | if ( 100 | (rv = pkcs11h_setProviderProperty ( 101 | reference, 102 | PKCS11H_PROVIDER_PROPERTY_INIT_ARGS, 103 | &init_args_ptr, 104 | sizeof(init_args_ptr) 105 | )) != CKR_OK 106 | ) { 107 | fatal ("pkcs11h_setProviderProperty failed for PKCS11H_PROVIDER_PROPERTY_INIT_ARGS", rv); 108 | } 109 | 110 | if ((rv = pkcs11h_initializeProvider (reference)) != CKR_OK) { 111 | fatal ("pkcs11h_initializeProvider failed", rv); 112 | } 113 | 114 | if ((rv = pkcs11h_removeProvider (reference)) != CKR_OK) { 115 | fatal ("pkcs11h_initializeProvider failed", rv); 116 | } 117 | 118 | printf ("Terminating pkcs11-helper\n"); 119 | 120 | if ((rv = pkcs11h_terminate ()) != CKR_OK) { 121 | fatal ("pkcs11h_terminate failed", rv); 122 | } 123 | 124 | exit (0); 125 | return 0; 126 | } 127 | -------------------------------------------------------------------------------- /include/pkcs11-helper-1.0/pkcs11h-def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | /** 52 | * @file pkcs11h-def.h 53 | * @brief pkcs11-helper core definitions. 54 | * @author Alon Bar-Lev 55 | */ 56 | 57 | #ifndef __PKCS11H_DEF_H 58 | #define __PKCS11H_DEF_H 59 | 60 | #include 61 | #if !defined(_WIN32) 62 | #include 63 | #endif 64 | 65 | #if defined(__cplusplus) 66 | extern "C" { 67 | #endif 68 | 69 | #if !defined(IN) 70 | #define IN 71 | #endif 72 | #if !defined(OUT) 73 | #define OUT 74 | #endif 75 | 76 | #if defined(PKCS11H_USE_CYGWIN) 77 | #define CRYPTOKI_FORCE_WIN32 78 | #endif 79 | #include 80 | 81 | typedef int PKCS11H_BOOL; 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* __PKCS11H_DEF_H */ 88 | -------------------------------------------------------------------------------- /include/pkcs11-helper-1.0/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=$(srcdir)/Makefile.in 52 | 53 | pkcs11hinclude_HEADERS= \ 54 | pkcs11.h \ 55 | pkcs11h-def.h \ 56 | pkcs11h-engines.h \ 57 | pkcs11h-core.h 58 | noinst_HEADERS= 59 | 60 | # 61 | # For win32 vc, add this into 62 | # dist as well 63 | # 64 | pkcs11hinclude_HEADERS+=pkcs11h-version.h 65 | 66 | if ENABLE_PKCS11H_CERTIFICATE 67 | pkcs11hinclude_HEADERS+=pkcs11h-certificate.h 68 | else 69 | noinst_HEADERS+=pkcs11h-certificate.h 70 | endif 71 | if ENABLE_PKCS11H_DATA 72 | pkcs11hinclude_HEADERS+=pkcs11h-data.h 73 | else 74 | noinst_HEADERS+=pkcs11h-data.h 75 | endif 76 | if ENABLE_PKCS11H_OPENSSL 77 | pkcs11hinclude_HEADERS+=pkcs11h-openssl.h 78 | else 79 | noinst_HEADERS+=pkcs11h-openssl.h 80 | endif 81 | if ENABLE_PKCS11H_TOKEN 82 | pkcs11hinclude_HEADERS+=pkcs11h-token.h 83 | else 84 | noinst_HEADERS+=pkcs11h-token.h 85 | endif 86 | -------------------------------------------------------------------------------- /m4dir/pkcs11-helper-1.m4: -------------------------------------------------------------------------------- 1 | # pkcs11-helper-1.m4 - Macros to locate and utilise pkcs11-helper. -*- Autoconf -*- 2 | # 3 | # Copyright (c) 2005-2018 Alon Bar-Lev 4 | # 5 | # This software is available to you under a choice of one of two 6 | # licenses. You may choose to be licensed under the terms of the GNU 7 | # General Public License (GPL) Version 2, or the BSD license. 8 | # 9 | # GNU General Public License (GPL) Version 2 10 | # =========================================== 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License version 2 13 | # as published by the Free Software Foundation. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program (see the file COPYING.GPL included with this 22 | # distribution); if not, write to the Free Software Foundation, Inc., 23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | # 25 | # BSD License 26 | # ============ 27 | # Redistribution and use in source and binary forms, with or without 28 | # modification, are permitted provided that the following conditions are met: 29 | # 30 | # o Redistributions of source code must retain the above copyright notice, 31 | # this list of conditions and the following disclaimer. 32 | # o Redistributions in binary form must reproduce the above copyright 33 | # notice, this list of conditions and the following disclaimer in the 34 | # documentation and/or other materials provided with the distribution. 35 | # o Neither the name of the Alon Bar-Lev nor the names of its 36 | # contributors may be used to endorse or promote products derived from 37 | # this software without specific prior written permission. 38 | # 39 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 40 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 42 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 43 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 44 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 45 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 46 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 47 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 49 | # POSSIBILITY OF SUCH DAMAGE. 50 | # 51 | 52 | # PKCS11_HELPER_CHECK_FEATURES([features]) 53 | # 54 | # Check whether features exists in pkcs11-helper. 55 | # 56 | # debug threading token data certificate locate slotevent openssl standalone engine_crypto 57 | # 58 | AC_DEFUN([PKCS11_HELPER_1_CHECK_FEATURES], [ 59 | AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 60 | AC_ARG_VAR([PKCS11_HELPER_FEATURES], [pkcs11-helperer feartures overriding pkg-config]) 61 | AC_MSG_CHECKING([pkcs11-helper features]) 62 | _PKG_CONFIG([PKCS11_HELPER_FEATURES], [variable features], [libpkcs11-helper-1]) 63 | for pkcs11h_feature in $1; do 64 | echo " ${pkg_cv_PKCS11_HELPER_FEATURES} " | grep " ${pkcs11h_feature} " > /dev/null 2>&1 || \ 65 | AC_MSG_ERROR([pkcs11-helper ${pkcs11h_feature} feature must be enabled.]) 66 | done 67 | AC_MSG_RESULT([ok]) 68 | ]) 69 | -------------------------------------------------------------------------------- /man/pkcs11-helper-1.8: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright (c) 2005-2018 Alon Bar-Lev 3 | .\" 4 | .\" This software is available to you under a choice of one of two 5 | .\" licenses. You may choose to be licensed under the terms of the GNU 6 | .\" General Public License (GPL) Version 2, or the BSD license. 7 | .\" 8 | .\" GNU General Public License (GPL) Version 2 9 | .\" =========================================== 10 | .\" This program is free software; you can redistribute it and/or modify 11 | .\" it under the terms of the GNU General Public License version 2 12 | .\" as published by the Free Software Foundation. 13 | .\" 14 | .\" This program is distributed in the hope that it will be useful, 15 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | .\" GNU General Public License for more details. 18 | .\" 19 | .\" You should have received a copy of the GNU General Public License 20 | .\" along with this program (see the file COPYING.GPL included with this 21 | .\" distribution); if not, write to the Free Software Foundation, Inc., 22 | .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | .\" 24 | .\" BSD License 25 | .\" ============ 26 | .\" Redistribution and use in source and binary forms, with or without 27 | .\" modification, are permitted provided that the following conditions are met: 28 | .\" 29 | .\" o Redistributions of source code must retain the above copyright notice, 30 | .\" this list of conditions and the following disclaimer. 31 | .\" o Redistributions in binary form must reproduce the above copyright 32 | .\" notice, this list of conditions and the following disclaimer in the 33 | .\" documentation and/or other materials provided with the distribution. 34 | .\" o Neither the name of the Alon Bar-Lev nor the names of its 35 | .\" contributors may be used to endorse or promote products derived from 36 | .\" this software without specific prior written permission. 37 | .\" 38 | .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | .\" POSSIBILITY OF SUCH DAMAGE. 49 | .\" 50 | .Dd November 18, 2006 51 | .Os POSIX-compatible 52 | .Dt pkcs11-helper 8 53 | .Sh NAME 54 | .Nm pkcs11-helper 55 | .Nd Simplified PKCS#11 library. 56 | .Sh DESCRIPTION 57 | .Nm pkcs11-helper 58 | is a simplified API for accessing PKCS#11 tokens for user applications. 59 | .Sh SEE ALSO 60 | .Rs 61 | .%T "pkcs11-helper Home Page" 62 | .%O https://github.com/OpenSC/pkcs11-helper/ 63 | .Re 64 | .Sh AUTHORS AND COPYRIGHT 65 | Copyright (c) 2006-2018 Alon Bar-Lev 66 | .Pp 67 | .Pp 68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 70 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 71 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 72 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 73 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 74 | SOFTWARE. 75 | -------------------------------------------------------------------------------- /lib/_pkcs11h-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_UTIL_H 52 | #define ___PKCS11H_UTIL_H 53 | 54 | #include "common.h" 55 | 56 | #include 57 | 58 | void 59 | _pkcs11h_util_fixupFixedString ( 60 | OUT char * const target, /* MUST BE >= length+1 */ 61 | IN const char * const source, 62 | IN const size_t length /* FIXED STRING LENGTH */ 63 | ); 64 | 65 | CK_RV 66 | _pkcs11h_util_hexToBinary ( 67 | OUT unsigned char * const target, 68 | IN const char * const source, 69 | IN OUT size_t * const p_target_size 70 | ); 71 | 72 | CK_RV 73 | _pkcs11h_util_binaryToHex ( 74 | OUT char * const target, 75 | IN const size_t target_size, 76 | IN const unsigned char * const source, 77 | IN const size_t source_size 78 | ); 79 | 80 | CK_RV 81 | _pkcs11h_util_escapeString ( 82 | IN OUT char * const target, 83 | IN const char * const source, 84 | IN size_t * const max, 85 | IN const char * const invalid_chars 86 | ); 87 | 88 | CK_RV 89 | _pkcs11h_util_unescapeString ( 90 | IN OUT char * const target, 91 | IN const char * const source, 92 | IN size_t * const max 93 | ); 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /lib/pkcs11h-sys.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #include "common.h" 52 | #include 53 | 54 | #if !defined(_WIN32) 55 | #include 56 | #endif 57 | 58 | #include 59 | #include "_pkcs11h-sys.h" 60 | 61 | static 62 | time_t 63 | __mytime (void) { 64 | return time (NULL); 65 | } 66 | 67 | static 68 | void 69 | __mysleep (unsigned long usec) { 70 | #if defined(_WIN32) 71 | Sleep (usec/1000); 72 | #else 73 | usleep (usec); 74 | #endif 75 | } 76 | 77 | #if !defined(_WIN32) 78 | static 79 | int 80 | __mygettimeofday (struct timeval *tv) { 81 | return gettimeofday (tv, NULL); 82 | } 83 | #endif 84 | 85 | pkcs11h_engine_system_t _g_pkcs11h_sys_engine = { 86 | malloc, 87 | free, 88 | __mytime, 89 | __mysleep, 90 | #if defined(_WIN32) 91 | NULL 92 | #else 93 | __mygettimeofday 94 | #endif 95 | }; 96 | 97 | CK_RV 98 | pkcs11h_engine_setSystem ( 99 | IN const pkcs11h_engine_system_t * const engine 100 | ) { 101 | _PKCS11H_ASSERT (engine!=NULL); 102 | 103 | memmove (&_g_pkcs11h_sys_engine, engine, sizeof (pkcs11h_engine_system_t)); 104 | 105 | return CKR_OK; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /lib/_pkcs11h-certificate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_CERTIFICATE_H 52 | #define ___PKCS11H_CERTIFICATE_H 53 | 54 | #include "common.h" 55 | 56 | #if defined(ENABLE_PKCS11H_CERTIFICATE) 57 | 58 | #include "_pkcs11h-core.h" 59 | #include 60 | 61 | struct pkcs11h_certificate_s { 62 | 63 | pkcs11h_certificate_id_t id; 64 | int pin_cache_period; 65 | 66 | unsigned mask_private_mode; 67 | PKCS11H_BOOL always_authenticate; 68 | 69 | _pkcs11h_session_t session; 70 | CK_OBJECT_HANDLE key_handle; 71 | 72 | PKCS11H_BOOL operation_active; 73 | 74 | #if defined(ENABLE_PKCS11H_THREADING) 75 | _pkcs11h_mutex_t mutex; 76 | #endif 77 | 78 | unsigned mask_prompt; 79 | void * user_data; 80 | }; 81 | 82 | PKCS11H_BOOL 83 | _pkcs11h_certificate_isBetterCertificate ( 84 | IN const unsigned char * const current, 85 | IN const size_t current_size, 86 | IN const unsigned char * const newone, 87 | IN const size_t newone_size 88 | ); 89 | 90 | CK_RV 91 | _pkcs11h_certificate_newCertificateId ( 92 | OUT pkcs11h_certificate_id_t * const certificate_id 93 | ); 94 | 95 | CK_RV 96 | _pkcs11h_certificate_validateSession ( 97 | IN const pkcs11h_certificate_t certificate 98 | ); 99 | 100 | CK_RV 101 | _pkcs11h_certificate_resetSession ( 102 | IN const pkcs11h_certificate_t certificate, 103 | IN const PKCS11H_BOOL public_only, 104 | IN const PKCS11H_BOOL session_mutex_locked 105 | ); 106 | 107 | CK_RV 108 | _pkcs11h_certificate_enumSessionCertificates ( 109 | IN const _pkcs11h_session_t session, 110 | IN void * const user_data, 111 | IN const unsigned mask_prompt 112 | ); 113 | 114 | #endif /* ENABLE_PKCS11H_CERTIFICATE */ 115 | 116 | #endif /* ___PKCS11H_CERTIFICATE_H */ 117 | 118 | -------------------------------------------------------------------------------- /lib/pkcs11h-mem.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #include "common.h" 52 | 53 | #include "_pkcs11h-sys.h" 54 | #include "_pkcs11h-mem.h" 55 | 56 | CK_RV 57 | _pkcs11h_mem_malloc ( 58 | OUT const void * * const p, 59 | IN const size_t s 60 | ) { 61 | CK_RV rv = CKR_OK; 62 | 63 | _PKCS11H_ASSERT (p!=NULL); 64 | _PKCS11H_ASSERT (s!=0); 65 | 66 | *p = NULL; 67 | 68 | if (s > 0) { 69 | if ( 70 | (*p = (void *)_g_pkcs11h_sys_engine.malloc (s)) == NULL 71 | ) { 72 | rv = CKR_HOST_MEMORY; 73 | } 74 | else { 75 | memset ((void *)*p, 0, s); 76 | } 77 | } 78 | 79 | return rv; 80 | } 81 | 82 | CK_RV 83 | _pkcs11h_mem_free ( 84 | IN const void * * const p 85 | ) { 86 | _PKCS11H_ASSERT (p!=NULL); 87 | 88 | _g_pkcs11h_sys_engine.free ((void *)*p); 89 | *p = NULL; 90 | 91 | return CKR_OK; 92 | } 93 | 94 | CK_RV 95 | _pkcs11h_mem_strdup ( 96 | OUT const char * * const dest, 97 | IN const char * const src 98 | ) { 99 | return _pkcs11h_mem_duplicate ( 100 | (void *)dest, 101 | NULL, 102 | src, 103 | strlen (src)+1 104 | ); 105 | } 106 | 107 | CK_RV 108 | _pkcs11h_mem_duplicate ( 109 | OUT const void * * const dest, 110 | OUT size_t * const p_dest_size, 111 | IN const void * const src, 112 | IN const size_t mem_size 113 | ) { 114 | CK_RV rv = CKR_FUNCTION_FAILED; 115 | 116 | _PKCS11H_ASSERT (dest!=NULL); 117 | /*_PKCS11H_ASSERT (dest_size!=NULL); NOT NEEDED*/ 118 | _PKCS11H_ASSERT (!(mem_size!=0&&src==NULL)); 119 | 120 | *dest = NULL; 121 | if (p_dest_size != NULL) { 122 | *p_dest_size = 0; 123 | } 124 | 125 | if (src != NULL) { 126 | if ((rv = _pkcs11h_mem_malloc (dest, mem_size)) != CKR_OK) { 127 | goto cleanup; 128 | } 129 | 130 | if (p_dest_size != NULL) { 131 | *p_dest_size = mem_size; 132 | } 133 | memmove ((void*)*dest, src, mem_size); 134 | } 135 | 136 | rv = CKR_OK; 137 | 138 | cleanup: 139 | 140 | return rv; 141 | } 142 | 143 | -------------------------------------------------------------------------------- /tests/test-slotevent/test-slotevent.c: -------------------------------------------------------------------------------- 1 | #include "../../config.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #if !defined(ENABLE_PKCS11H_SLOTEVENT) 7 | int main () { 8 | printf ("!win32, certificate, enum and crypto engine interfaces should be enabled for this test"); 9 | exit (0); 10 | return 0; 11 | } 12 | #else 13 | 14 | #if defined(_WIN32) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | #include 21 | 22 | static 23 | void 24 | fatal (const char * const m, CK_RV rv) { 25 | fprintf (stderr, "%s - %08lu - %s\n", m, rv, pkcs11h_getMessage (rv)); 26 | exit (1); 27 | } 28 | 29 | static 30 | void 31 | mypause (const char * const m) { 32 | char temp[10]; 33 | 34 | fprintf (stdout, "%s", m); 35 | fflush (stdout); 36 | fgets (temp, sizeof (temp), stdin); 37 | } 38 | 39 | static 40 | void 41 | _pkcs11h_hooks_log ( 42 | IN void * const global_data, 43 | IN unsigned flags, 44 | IN const char * const format, 45 | IN va_list args 46 | ) { 47 | vfprintf (stdout, format, args); 48 | fprintf (stdout, "\n"); 49 | fflush (stdout); 50 | } 51 | 52 | static 53 | void 54 | _pkcs11h_hooks_slotevent ( 55 | IN void * const global_data 56 | ) { 57 | printf ("slotevent\n"); 58 | } 59 | 60 | int main () { 61 | CK_RV rv; 62 | 63 | printf ("Initializing pkcs11-helper\n"); 64 | 65 | if ((rv = pkcs11h_initialize ()) != CKR_OK) { 66 | fatal ("pkcs11h_initialize failed", rv); 67 | } 68 | 69 | printf ("Registering pkcs11-helper hooks\n"); 70 | 71 | if ((rv = pkcs11h_setLogHook (_pkcs11h_hooks_log, NULL)) != CKR_OK) { 72 | fatal ("pkcs11h_setLogHook failed", rv); 73 | } 74 | 75 | pkcs11h_setLogLevel (TEST_LOG_LEVEL); 76 | 77 | if ((rv = pkcs11h_setSlotEventHook (_pkcs11h_hooks_slotevent, NULL)) != CKR_OK) { 78 | fatal ("pkcs11h_setSlotEventHook failed", rv); 79 | } 80 | 81 | printf ("Adding provider '%s' as auto\n", TEST_PROVIDER); 82 | 83 | if ( 84 | (rv = pkcs11h_addProvider ( 85 | TEST_PROVIDER, 86 | TEST_PROVIDER, 87 | FALSE, 88 | PKCS11H_PRIVATEMODE_MASK_AUTO, 89 | PKCS11H_SLOTEVENT_METHOD_AUTO, 90 | 0, 91 | FALSE 92 | )) != CKR_OK 93 | ) { 94 | fatal ("pkcs11h_addProvider failed", rv); 95 | } 96 | 97 | printf ("Please remove and insert tokens (pause for 30 seconds)\n"); 98 | 99 | #if defined(_WIN32) 100 | Sleep (30*1024); 101 | #else 102 | sleep (30); 103 | #endif 104 | 105 | if ((rv = pkcs11h_removeProvider (TEST_PROVIDER)) != CKR_OK) { 106 | fatal ("pkcs11h_removeProvider failed", rv); 107 | } 108 | 109 | printf ("Adding provider '%s' as trigger\n", TEST_PROVIDER); 110 | 111 | if ( 112 | (rv = pkcs11h_addProvider ( 113 | TEST_PROVIDER, 114 | TEST_PROVIDER, 115 | FALSE, 116 | PKCS11H_PRIVATEMODE_MASK_AUTO, 117 | PKCS11H_SLOTEVENT_METHOD_TRIGGER, 118 | 0, 119 | FALSE 120 | )) != CKR_OK 121 | ) { 122 | fatal ("pkcs11h_addProvider failed", rv); 123 | } 124 | 125 | printf ("Please remove and insert tokens (pause for 30 seconds)\n"); 126 | 127 | #if defined(_WIN32) 128 | Sleep (30*1024); 129 | #else 130 | sleep (30); 131 | #endif 132 | 133 | if ((rv = pkcs11h_removeProvider (TEST_PROVIDER)) != CKR_OK) { 134 | fatal ("pkcs11h_removeProvider failed", rv); 135 | } 136 | 137 | printf ("Adding provider '%s' as poll\n", TEST_PROVIDER); 138 | 139 | if ( 140 | (rv = pkcs11h_addProvider ( 141 | TEST_PROVIDER, 142 | TEST_PROVIDER, 143 | FALSE, 144 | PKCS11H_PRIVATEMODE_MASK_AUTO, 145 | PKCS11H_SLOTEVENT_METHOD_POLL, 146 | 0, 147 | FALSE 148 | )) != CKR_OK 149 | ) { 150 | fatal ("pkcs11h_addProvider failed", rv); 151 | } 152 | 153 | printf ("Please remove and insert tokens (pause for 30 seconds)\n"); 154 | 155 | #if defined(_WIN32) 156 | Sleep (30*1024); 157 | #else 158 | sleep (30); 159 | #endif 160 | 161 | if ((rv = pkcs11h_removeProvider (TEST_PROVIDER)) != CKR_OK) { 162 | fatal ("pkcs11h_removeProvider failed", rv); 163 | } 164 | 165 | printf ("Adding provider '%s' as fetch\n", TEST_PROVIDER); 166 | 167 | if ( 168 | (rv = pkcs11h_addProvider ( 169 | TEST_PROVIDER, 170 | TEST_PROVIDER, 171 | FALSE, 172 | PKCS11H_PRIVATEMODE_MASK_AUTO, 173 | PKCS11H_SLOTEVENT_METHOD_FETCH, 174 | 0, 175 | FALSE 176 | )) != CKR_OK 177 | ) { 178 | fatal ("pkcs11h_addProvider failed", rv); 179 | } 180 | 181 | printf ("Please remove and insert tokens (pause for 30 seconds)\n"); 182 | 183 | #if defined(_WIN32) 184 | Sleep (30*1024); 185 | #else 186 | sleep (30); 187 | #endif 188 | 189 | printf ("Terminating pkcs11-helper\n"); 190 | 191 | if ((rv = pkcs11h_terminate ()) != CKR_OK) { 192 | fatal ("pkcs11h_terminate failed", rv); 193 | } 194 | 195 | exit (0); 196 | return 0; 197 | } 198 | 199 | #endif 200 | -------------------------------------------------------------------------------- /lib/_pkcs11h-threading.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_THREADING_H 52 | #define ___PKCS11H_THREADING_H 53 | 54 | #include "common.h" 55 | 56 | #if defined(ENABLE_PKCS11H_THREADING) 57 | 58 | #include 59 | 60 | #if !defined(_WIN32) 61 | #include 62 | #endif 63 | 64 | #define PKCS11H_COND_INFINITE 0xffffffff 65 | 66 | #if defined(_WIN32) 67 | #define PKCS11H_THREAD_NULL NULL 68 | typedef HANDLE _pkcs11h_cond_t; 69 | typedef HANDLE _pkcs11h_mutex_t; 70 | typedef HANDLE _pkcs11h_thread_t; 71 | #else 72 | #define PKCS11H_THREAD_NULL 0l 73 | typedef pthread_mutex_t _pkcs11h_mutex_t; 74 | typedef pthread_t _pkcs11h_thread_t; 75 | 76 | typedef struct { 77 | pthread_cond_t cond; 78 | pthread_mutex_t mut; 79 | } _pkcs11h_cond_t; 80 | #endif 81 | 82 | typedef void * (*_pkcs11h_thread_start_t)(void *); 83 | 84 | void 85 | _pkcs11h_threading_sleep ( 86 | IN const unsigned milli 87 | ); 88 | 89 | CK_RV 90 | _pkcs11h_threading_mutexInit ( 91 | OUT _pkcs11h_mutex_t * const mutex 92 | ); 93 | 94 | CK_RV 95 | _pkcs11h_threading_mutexLock ( 96 | IN OUT _pkcs11h_mutex_t *const mutex 97 | ); 98 | 99 | CK_RV 100 | _pkcs11h_threading_mutexRelease ( 101 | IN OUT _pkcs11h_mutex_t *const mutex 102 | ); 103 | 104 | CK_RV 105 | _pkcs11h_threading_mutexFree ( 106 | IN OUT _pkcs11h_mutex_t *const mutex 107 | ); 108 | 109 | CK_RV 110 | _pkcs11h_threading_condSignal ( 111 | IN OUT _pkcs11h_cond_t *const cond 112 | ); 113 | 114 | CK_RV 115 | _pkcs11h_threading_condInit ( 116 | OUT _pkcs11h_cond_t * const cond 117 | ); 118 | 119 | CK_RV 120 | _pkcs11h_threading_condWait ( 121 | IN OUT _pkcs11h_cond_t *const cond, 122 | IN const unsigned milli 123 | ); 124 | 125 | CK_RV 126 | _pkcs11h_threading_condFree ( 127 | IN OUT _pkcs11h_cond_t *const cond 128 | ); 129 | 130 | CK_RV 131 | _pkcs11h_threading_threadStart ( 132 | OUT _pkcs11h_thread_t * const thread, 133 | IN _pkcs11h_thread_start_t const start, 134 | IN void * data 135 | ); 136 | 137 | CK_RV 138 | _pkcs11h_threading_threadJoin ( 139 | IN _pkcs11h_thread_t * const thread 140 | ); 141 | 142 | #if !defined(_WIN32) 143 | void 144 | _pkcs1h_threading_mutexLockAll (void); 145 | 146 | void 147 | _pkcs1h_threading_mutexReleaseAll (void); 148 | #endif 149 | 150 | #endif 151 | 152 | #endif 153 | 154 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | pkcs11-helper License 3 | 4 | Copyright (c) 2005-2018 Alon Bar-Lev 5 | 6 | This software is available to you under a choice of one of two 7 | licenses. You may choose to be licensed under the terms of the GNU 8 | General Public License (GPL) Version 2, or the BSD license. 9 | 10 | GNU General Public License (GPL) Version 2 11 | =========================================== 12 | This program is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License version 2 14 | as published by the Free Software Foundation. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program (see the file COPYING.GPL included with this 23 | distribution); if not, write to the Free Software Foundation, Inc., 24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 25 | 26 | BSD License 27 | ============ 28 | Redistribution and use in source and binary forms, with or without 29 | modification, are permitted provided that the following conditions are met: 30 | 31 | o Redistributions of source code must retain the above copyright notice, 32 | this list of conditions and the following disclaimer. 33 | o Redistributions in binary form must reproduce the above copyright 34 | notice, this list of conditions and the following disclaimer in the 35 | documentation and/or other materials provided with the distribution. 36 | o Neither the name of the Alon Bar-Lev nor the names of its 37 | contributors may be used to endorse or promote products derived from 38 | this software without specific prior written permission. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 44 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 45 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 46 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 47 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 48 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 50 | POSSIBILITY OF SUCH DAMAGE. 51 | 52 | Packaging License 53 | 54 | RPM 55 | Copyright (c) 2006-2007 Eddy Nigg 56 | 57 | Debian 58 | Copyright (c) 2007 Sandro Wefel 59 | 60 | m4 Macros License 61 | 62 | autoconf/automake 63 | Copyright (C) 2002, 2003 Free Software Foundation, Inc. 64 | 65 | pkg.m4 66 | Copyright © 2004 Scott James Remnant . 67 | 68 | AX_CPP_VARARG* 69 | Copyright (c) James Yonan 70 | Copyright (c) Matthias Andree 71 | 72 | pkcs11.h License 73 | Copyright 2006, 2007 g10 Code GmbH 74 | Copyright 2006 Andreas Jellinghaus 75 | 76 | OpenSSL License (Optional component, parsing certificates, engine) 77 | 78 | This product includes software developed by the OpenSSL Project 79 | for use in the OpenSSL Toolkit (http://www.OpenSSL.org/) 80 | 81 | This product includes cryptographic software written by Eric Young 82 | (eay@cryptsoft.com). This product includes software written by Tim 83 | Hudson (tjh@cryptsoft.com). 84 | 85 | GnuTLS License (Optional component, for a complete GPLed license, replaces OpenSSL) 86 | 87 | Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Nikos Mavroyanopoulos 88 | See the end for copying conditions. 89 | 90 | The copyright holder for Gnutls is Free Software Foundation, 91 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 92 | USA. 93 | 94 | NSS License (Optional component, parsing certificates, engine) 95 | 96 | The Original Code is Mozilla Communicator client code, released 97 | March 31, 1998. 98 | 99 | The Initial Developer of the Original Code is Netscape 100 | Communications Corporation. Portions created by Netscape are 101 | Copyright (C) 1998-1999 Netscape Communications Corporation. All 102 | Rights Reserved. 103 | 104 | Doxygen License (Optional component, documentation) 105 | 106 | Copyright © 1997-2006 by Dimitri van Heesch. 107 | 108 | Permission to use, copy, modify, and distribute this software and 109 | its documentation under the terms of the GNU General Public License 110 | is hereby granted. No representations are made about the suitability 111 | of this software for any purpose. It is provided "as is" without express 112 | or implied warranty. See the GNU General Public License for more details. 113 | 114 | Documents produced by doxygen are derivative works derived 115 | from the input used in their production; they are not affected by this 116 | license. 117 | -------------------------------------------------------------------------------- /lib/_pkcs11h-session.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #ifndef ___PKCS11H_SESSION_H 52 | #define ___PKCS11H_SESSION_H 53 | 54 | #include "common.h" 55 | #include "_pkcs11h-core.h" 56 | 57 | CK_RV 58 | _pkcs11h_session_getSlotList ( 59 | IN const _pkcs11h_provider_t provider, 60 | IN const CK_BBOOL token_present, 61 | OUT CK_SLOT_ID_PTR * const pSlotList, 62 | OUT CK_ULONG_PTR pulCount 63 | ); 64 | 65 | CK_RV 66 | _pkcs11h_session_getObjectAttributes ( 67 | IN const _pkcs11h_session_t session, 68 | IN const CK_OBJECT_HANDLE object, 69 | IN OUT const CK_ATTRIBUTE_PTR attrs, 70 | IN const unsigned count 71 | ); 72 | 73 | CK_RV 74 | _pkcs11h_session_freeObjectAttributes ( 75 | IN OUT const CK_ATTRIBUTE_PTR attrs, 76 | IN const unsigned count 77 | ); 78 | 79 | CK_RV 80 | _pkcs11h_session_findObjects ( 81 | IN const _pkcs11h_session_t session, 82 | IN const CK_ATTRIBUTE * const filter, 83 | IN const CK_ULONG filter_attrs, 84 | OUT CK_OBJECT_HANDLE **const p_objects, 85 | OUT CK_ULONG *p_objects_found 86 | ); 87 | 88 | CK_RV 89 | _pkcs11h_session_getSessionByTokenId ( 90 | IN const pkcs11h_token_id_t token_id, 91 | OUT _pkcs11h_session_t * const p_session 92 | ); 93 | 94 | CK_RV 95 | _pkcs11h_session_release ( 96 | IN const _pkcs11h_session_t session 97 | ); 98 | 99 | CK_RV 100 | _pkcs11h_session_reset ( 101 | IN const _pkcs11h_session_t session, 102 | IN void * const user_data, 103 | IN const unsigned mask_prompt, 104 | OUT CK_SLOT_ID * const p_slot 105 | ); 106 | 107 | CK_RV 108 | _pkcs11h_session_getObjectById ( 109 | IN const _pkcs11h_session_t session, 110 | IN const CK_OBJECT_CLASS class, 111 | IN const CK_BYTE_PTR id, 112 | IN const size_t id_size, 113 | OUT CK_OBJECT_HANDLE * const p_handle 114 | ); 115 | 116 | CK_RV 117 | _pkcs11h_session_validate ( 118 | IN const _pkcs11h_session_t session 119 | ); 120 | 121 | CK_RV 122 | __pkcs11h_session_touch ( 123 | IN const _pkcs11h_session_t session 124 | ); 125 | 126 | CK_RV 127 | _pkcs11h_session_login_context ( 128 | IN const _pkcs11h_session_t session, 129 | IN const CK_USER_TYPE user, 130 | IN const char * const label, 131 | IN void * const user_data, 132 | IN const unsigned mask_prompt 133 | ); 134 | 135 | CK_RV 136 | _pkcs11h_session_login ( 137 | IN const _pkcs11h_session_t session, 138 | IN const PKCS11H_BOOL public_only, 139 | IN const PKCS11H_BOOL readonly, 140 | IN void * const user_data, 141 | IN const unsigned mask_prompt 142 | ); 143 | 144 | CK_RV 145 | _pkcs11h_session_logout ( 146 | IN const _pkcs11h_session_t session 147 | ); 148 | 149 | #endif 150 | 151 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | MAINTAINERCLEANFILES=\ 52 | $(srcdir)/Makefile.in 53 | $(srcdir)/versioninfo.rc 54 | CLEANFILES=pkcs11-helper.exports 55 | 56 | dist_noinst_DATA= \ 57 | Makefile.w32-vc \ 58 | certificate.exports \ 59 | core.exports \ 60 | data.exports \ 61 | openssl.exports \ 62 | slotevent.exports \ 63 | token.exports 64 | 65 | BUILT_SOURCES=pkcs11-helper.exports 66 | pkgconfig_DATA=libpkcs11-helper-1.pc 67 | lib_LTLIBRARIES=libpkcs11-helper.la 68 | 69 | AM_CPPFLAGS= \ 70 | -I$(top_srcdir)/include \ 71 | -I$(top_builddir)/include 72 | 73 | nodist_libpkcs11_helper_la_SOURCES= \ 74 | pkcs11-helper.exports 75 | libpkcs11_helper_la_SOURCES= \ 76 | common.h \ 77 | _pkcs11h-mem.h pkcs11h-mem.c \ 78 | _pkcs11h-sys.h pkcs11h-sys.c \ 79 | _pkcs11h-crypto.h pkcs11h-crypto.c \ 80 | _pkcs11h-crypto-openssl.c _pkcs11h-crypto-nss.c \ 81 | _pkcs11h-crypto-gnutls.c _pkcs11h-crypto-mbedtls.c \ 82 | _pkcs11h-crypto-cryptoapi.c \ 83 | _pkcs11h-threading.h pkcs11h-threading.c \ 84 | _pkcs11h-util.h pkcs11h-util.c \ 85 | _pkcs11h-session.h pkcs11h-session.c \ 86 | _pkcs11h-token.h pkcs11h-token.c \ 87 | _pkcs11h-certificate.h pkcs11h-certificate.c \ 88 | _pkcs11h-slotevent.h pkcs11h-slotevent.c \ 89 | _pkcs11h-core.h pkcs11h-core.c \ 90 | pkcs11h-data.c \ 91 | pkcs11h-serialization.c \ 92 | _pkcs11h-openssl.h pkcs11h-openssl.c \ 93 | $(NULL) 94 | libpkcs11_helper_la_LDFLAGS= \ 95 | $(AM_LDFLAGS) \ 96 | -version-info @LIBPKCS11_HELPER_LT_CURRENT@:@LIBPKCS11_HELPER_LT_REVISION@:@LIBPKCS11_HELPER_LT_AGE@ \ 97 | -export-symbols "pkcs11-helper.exports" \ 98 | -no-undefined 99 | if WIN32 100 | libpkcs11_helper_la_SOURCES+=versioninfo.rc 101 | else 102 | dist_noinst_DATA+=versioninfo.rc 103 | endif 104 | 105 | pkcs11-helper.exports: \ 106 | $(top_builddir)/config.h \ 107 | $(srcdir)/certificate.exports \ 108 | $(srcdir)/core.exports \ 109 | $(srcdir)/data.exports \ 110 | $(srcdir)/openssl.exports \ 111 | $(srcdir)/slotevent.exports \ 112 | $(srcdir)/token.exports 113 | cat "$(srcdir)/core.exports" > pkcs11-helper.exports 114 | if ENABLE_PKCS11H_CERTIFICATE 115 | cat "$(srcdir)/certificate.exports" >> pkcs11-helper.exports 116 | endif 117 | if ENABLE_PKCS11H_DATA 118 | cat "$(srcdir)/data.exports" >> pkcs11-helper.exports 119 | endif 120 | if ENABLE_PKCS11H_OPENSSL 121 | cat "$(srcdir)/openssl.exports" >> pkcs11-helper.exports 122 | endif 123 | if ENABLE_PKCS11H_SLOTEVENT 124 | cat "$(srcdir)/slotevent.exports" >> pkcs11-helper.exports 125 | endif 126 | if ENABLE_PKCS11H_TOKEN 127 | cat "$(srcdir)/token.exports" >> pkcs11-helper.exports 128 | endif 129 | 130 | if WIN32 131 | if ENABLE_SHARED 132 | mylibdir=$(libdir) 133 | mylib_DATA=.libs/@WIN_LIBPREFIX@pkcs11-helper-@LIBPKCS11_HELPER_LT_OLDEST@.dll.def 134 | .libs/@WIN_LIBPREFIX@pkcs11-helper-@LIBPKCS11_HELPER_LT_OLDEST@.dll.def: libpkcs11-helper.la 135 | endif 136 | endif 137 | 138 | RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 139 | $(AM_CPPFLAGS) $(CPPFLAGS) 140 | LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) 141 | 142 | .rc.lo: 143 | $(LTRCCOMPILE) -i "$<" -o "$@" 144 | 145 | .rc.o: 146 | $(RCCOMPILE) -i "$<" -o "$@" 147 | -------------------------------------------------------------------------------- /lib/Makefile.w32-vc: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2005-2018 Alon Bar-Lev 3 | # 4 | # This software is available to you under a choice of one of two 5 | # licenses. You may choose to be licensed under the terms of the GNU 6 | # General Public License (GPL) Version 2, or the BSD license. 7 | # 8 | # GNU General Public License (GPL) Version 2 9 | # =========================================== 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License version 2 12 | # as published by the Free Software Foundation. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program (see the file COPYING.GPL included with this 21 | # distribution); if not, write to the Free Software Foundation, Inc., 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | # BSD License 25 | # ============ 26 | # Redistribution and use in source and binary forms, with or without 27 | # modification, are permitted provided that the following conditions are met: 28 | # 29 | # o Redistributions of source code must retain the above copyright notice, 30 | # this list of conditions and the following disclaimer. 31 | # o Redistributions in binary form must reproduce the above copyright 32 | # notice, this list of conditions and the following disclaimer in the 33 | # documentation and/or other materials provided with the distribution. 34 | # o Neither the name of the Alon Bar-Lev nor the names of its 35 | # contributors may be used to endorse or promote products derived from 36 | # this software without specific prior written permission. 37 | # 38 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | # POSSIBILITY OF SUCH DAMAGE. 49 | # 50 | 51 | # 52 | # If you wish openssl interface 53 | # Provide OPENSSL=1 OPENSSL_HOME= as nmake argument. 54 | # 55 | #OPENSSL=1 56 | !ifdef OPENSSL 57 | !ifndef OPENSSL_HOME 58 | OPENSSL_HOME = ..\..\openssl 59 | !endif 60 | !endif 61 | 62 | !ifdef OPENSSL 63 | OPENSSL_STATIC = libcrypto.lib 64 | #OPENSSL_STATIC = libcryptosd.lib 65 | OPENSSL_DYNAMIC = libcrypto.lib 66 | #OPENSSL_DYNAMIC = libcryptod.lib 67 | 68 | OPENSSL_INC=$(OPENSSL_HOME)\include 69 | OPENSSL_LIB=$(OPENSSL_HOME)\lib 70 | 71 | OPENSSL_CFLAGS=-I$(OPENSSL_INC) -DENABLE_PKCS11H_OPENSSL 72 | OPENSSL_LIBS=-LIBPATH:$(OPENSSL_LIB) user32.lib advapi32.lib ws2_32.lib crypt32.lib $(OPENSSL_STATIC) 73 | !endif 74 | 75 | CFLAGS = -I../include $(OPENSSL_CFLAGS) -DWIN32 -DWIN32_LEAN_AND_MEAN -D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_WIN32_WINNT=0x0400 76 | CC=cl.exe 77 | RC=rc.exe 78 | CCPARAMS=/nologo /W3 /O2 /FD /c 79 | 80 | CCPARAMS=$(CCPARAMS) /MD 81 | CFLAGS=$(CFLAGS) -DNDEBUG 82 | 83 | LINK32=link.exe 84 | LIB32=lib.exe 85 | LINK32_FLAGS=/nologo /subsystem:windows /dll /incremental:no /release 86 | LIB32_FLAGS=/nologo 87 | 88 | HEADERS = \ 89 | config.h \ 90 | common.h \ 91 | _pkcs11h-core.h \ 92 | _pkcs11h-certificate.h \ 93 | _pkcs11h-crypto.h \ 94 | _pkcs11h-mem.h \ 95 | _pkcs11h-session.h \ 96 | _pkcs11h-slotevent.h \ 97 | _pkcs11h-sys.h \ 98 | _pkcs11h-threading.h \ 99 | _pkcs11h-token.h \ 100 | _pkcs11h-util.h \ 101 | ../include/pkcs11-helper-1.0/cryptoki.h \ 102 | ../include/pkcs11-helper-1.0/cryptoki-win32.h \ 103 | ../include/pkcs11-helper-1.0/pkcs11h-core.h \ 104 | ../include/pkcs11-helper-1.0/pkcs11h-certificate.h \ 105 | ../include/pkcs11-helper-1.0/pkcs11h-data.h \ 106 | ../include/pkcs11-helper-1.0/pkcs11h-def.h \ 107 | ../include/pkcs11-helper-1.0/pkcs11h-engines.h \ 108 | ../include/pkcs11-helper-1.0/pkcs11h-openssl.h \ 109 | ../include/pkcs11-helper-1.0/pkcs11h-token.h 110 | 111 | OBJS = \ 112 | pkcs11h-core.obj \ 113 | pkcs11h-certificate.obj \ 114 | pkcs11h-crypto.obj \ 115 | _pkcs11h-crypto-cryptoapi.obj \ 116 | pkcs11h-data.obj \ 117 | pkcs11h-mem.obj \ 118 | pkcs11h-openssl.obj \ 119 | pkcs11h-serialization.obj \ 120 | pkcs11h-session.obj \ 121 | pkcs11h-slotevent.obj \ 122 | pkcs11h-sys.obj \ 123 | pkcs11h-threading.obj \ 124 | pkcs11h-token.obj \ 125 | pkcs11h-util.obj 126 | 127 | RES = \ 128 | versioninfo.res 129 | 130 | all: libpkcs11-helper-1.dll pkcs11-helper.lib 131 | 132 | pkcs11-helper-1.dll.def: 133 | echo LIBRARY libpkcs11-helper-1 > pkcs11-helper-1.dll.def 134 | echo EXPORTS >> pkcs11-helper-1.dll.def 135 | type core.exports >> pkcs11-helper-1.dll.def 136 | type certificate.exports >> pkcs11-helper-1.dll.def 137 | type data.exports >> pkcs11-helper-1.dll.def 138 | type slotevent.exports >> pkcs11-helper-1.dll.def 139 | type token.exports >> pkcs11-helper-1.dll.def 140 | !ifdef OPENSSL 141 | type openssl.exports >> pkcs11-helper-1.dll.def 142 | !endif 143 | 144 | libpkcs11-helper-1.dll: pkcs11-helper-1.dll.def $(OBJS) $(RES) 145 | $(LINK32) @<< 146 | $(LINK32_FLAGS) 147 | /out:"libpkcs11-helper-1.dll" /def:pkcs11-helper-1.dll.def 148 | kernel32.lib gdi32.lib $(OPENSSL_LIBS) 149 | $(OBJS) 150 | $(RES) 151 | << 152 | move libpkcs11-helper-1.lib pkcs11-helper.dll.lib 153 | 154 | pkcs11-helper.lib: $(OBJS) 155 | $(LIB32) @<< 156 | $(LIB32_FLAGS) 157 | /out:"pkcs11-helper.lib" 158 | $(OBJS) 159 | << 160 | 161 | clean: 162 | -del /Q $(OBJS) $(RES) libpkcs11-helper-1.dll *.lib *.exp *.manifest *.idb *.pdb pkcs11-helper-1.dll.def 163 | 164 | .rc.res:: 165 | $(RC) $(CFLAGS) $< 166 | 167 | .c.obj:: 168 | $(CC) @<< 169 | $(CCPARAMS) $(CFLAGS) 170 | $< 171 | << 172 | -------------------------------------------------------------------------------- /lib/pkcs11h-crypto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #include "common.h" 52 | 53 | #include "_pkcs11h-crypto.h" 54 | 55 | #if defined(ENABLE_PKCS11H_ENGINE_CRYPTOAPI) 56 | extern const pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine_cryptoapi; 57 | #endif 58 | #if defined(ENABLE_PKCS11H_ENGINE_OPENSSL) 59 | extern const pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine_openssl; 60 | #endif 61 | #if defined(ENABLE_PKCS11H_ENGINE_NSS) 62 | extern const pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine_nss; 63 | #endif 64 | #if defined(ENABLE_PKCS11H_ENGINE_MBEDTLS) 65 | extern const pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine_mbedtls; 66 | #endif 67 | #if defined(ENABLE_PKCS11H_ENGINE_GNUTLS) 68 | extern const pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine_gnutls; 69 | #endif 70 | 71 | pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine = { 72 | NULL, 73 | NULL, 74 | NULL, 75 | NULL, 76 | NULL, 77 | NULL 78 | }; 79 | 80 | CK_RV 81 | pkcs11h_engine_setCrypto ( 82 | IN const pkcs11h_engine_crypto_t * const engine 83 | ) { 84 | const pkcs11h_engine_crypto_t *_engine = NULL; 85 | CK_RV rv = CKR_FUNCTION_FAILED; 86 | 87 | /*_PKCS11H_ASSERT (engine!=NULL); Not required */ 88 | 89 | if (engine == PKCS11H_ENGINE_CRYPTO_AUTO) { 90 | #if defined(ENABLE_PKCS11H_ENGINE_CRYPTOAPI) 91 | _engine = &_g_pkcs11h_crypto_engine_cryptoapi; 92 | #elif defined(ENABLE_PKCS11H_ENGINE_OPENSSL) 93 | _engine = &_g_pkcs11h_crypto_engine_openssl; 94 | #elif defined(ENABLE_PKCS11H_ENGINE_NSS) 95 | _engine = &_g_pkcs11h_crypto_engine_nss; 96 | #elif defined(ENABLE_PKCS11H_ENGINE_MBEDTLS) 97 | _engine = &_g_pkcs11h_crypto_engine_mbedtls; 98 | #elif defined(ENABLE_PKCS11H_ENGINE_GNUTLS) 99 | _engine = &_g_pkcs11h_crypto_engine_gnutls; 100 | #else 101 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 102 | goto cleanup; 103 | #endif 104 | } 105 | else if (engine == PKCS11H_ENGINE_CRYPTO_GPL) { 106 | #if defined(ENABLE_PKCS11H_ENGINE_CRYPTOAPI) 107 | _engine = &_g_pkcs11h_crypto_engine_cryptoapi; 108 | #elif defined(ENABLE_PKCS11H_ENGINE_MBEDTLS) 109 | _engine = &_g_pkcs11h_crypto_engine_mbedtls; 110 | #elif defined(ENABLE_PKCS11H_ENGINE_GNUTLS) 111 | _engine = &_g_pkcs11h_crypto_engine_gnutls; 112 | #else 113 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 114 | goto cleanup; 115 | #endif 116 | } 117 | else if (engine == PKCS11H_ENGINE_CRYPTO_CRYPTOAPI) { 118 | #if defined(ENABLE_PKCS11H_ENGINE_CRYPTOAPI) 119 | _engine = &_g_pkcs11h_crypto_engine_cryptoapi; 120 | #else 121 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 122 | goto cleanup; 123 | #endif 124 | } 125 | else if (engine == PKCS11H_ENGINE_CRYPTO_OPENSSL) { 126 | #if defined(ENABLE_PKCS11H_ENGINE_OPENSSL) 127 | _engine = &_g_pkcs11h_crypto_engine_openssl; 128 | #else 129 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 130 | goto cleanup; 131 | #endif 132 | } 133 | else if (engine == PKCS11H_ENGINE_CRYPTO_GNUTLS) { 134 | #if defined(ENABLE_PKCS11H_ENGINE_GNUTLS) 135 | _engine = &_g_pkcs11h_crypto_engine_gnutls; 136 | #else 137 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 138 | goto cleanup; 139 | #endif 140 | } 141 | else if (engine == PKCS11H_ENGINE_CRYPTO_NSS) { 142 | #if defined(ENABLE_PKCS11H_ENGINE_NSS) 143 | _engine = &_g_pkcs11h_crypto_engine_nss; 144 | #else 145 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 146 | goto cleanup; 147 | #endif 148 | } 149 | else if (engine == PKCS11H_ENGINE_CRYPTO_MBEDTLS) { 150 | #if defined(ENABLE_PKCS11H_ENGINE_MBEDTLS) 151 | _engine = &_g_pkcs11h_crypto_engine_mbedtls; 152 | #else 153 | rv = CKR_ATTRIBUTE_VALUE_INVALID; 154 | goto cleanup; 155 | #endif 156 | } 157 | else { 158 | _engine = engine; 159 | } 160 | 161 | memmove (&_g_pkcs11h_crypto_engine, _engine, sizeof (pkcs11h_engine_crypto_t)); 162 | 163 | rv = CKR_OK; 164 | 165 | cleanup: 166 | 167 | return rv; 168 | } 169 | 170 | -------------------------------------------------------------------------------- /include/pkcs11-helper-1.0/pkcs11h-openssl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | /** 52 | * @addtogroup pkcs11h_openssl OpenSSL interface 53 | * 54 | * OpenSSL engine to be used by OpenSSL enabled applications. 55 | * 56 | * @{ 57 | */ 58 | 59 | /** 60 | * @file pkcs11h-openssl.h 61 | * @brief pkcs11-helper OpenSSL interface. 62 | * @author Alon Bar-Lev 63 | * @see pkcs11h_openssl. 64 | */ 65 | 66 | #ifndef __PKCS11H_HELPER_H 67 | #define __PKCS11H_HELPER_H 68 | 69 | #include 70 | #ifndef OPENSSL_NO_RSA 71 | #include 72 | #endif 73 | #include 74 | #include 75 | 76 | #if defined(__cplusplus) 77 | extern "C" { 78 | #endif 79 | 80 | /** 81 | * @brief OpenSSL RSA cleanup hook. 82 | * @param certificate Certificate attached to the RSA object. 83 | */ 84 | typedef void (*pkcs11h_hook_openssl_cleanup_t) ( 85 | IN const pkcs11h_certificate_t certificate 86 | ); 87 | 88 | struct pkcs11h_openssl_session_s; 89 | 90 | /** 91 | * @brief OpenSSL session reference. 92 | */ 93 | typedef struct pkcs11h_openssl_session_s *pkcs11h_openssl_session_t; 94 | 95 | /** 96 | * @brief Returns an X509 object out of the openssl_session object. 97 | * @param certificate Certificate object. 98 | * @return X509. 99 | */ 100 | X509 * 101 | pkcs11h_openssl_getX509 ( 102 | IN const pkcs11h_certificate_t certificate 103 | ); 104 | 105 | /** 106 | * @brief Create OpenSSL session based on a certificate object. 107 | * @param certificate Certificate object. 108 | * @return OpenSSL session reference. 109 | * @note The certificate object will be freed by the OpenSSL interface on session end. 110 | * @see pkcs11h_openssl_freeSession(). 111 | */ 112 | pkcs11h_openssl_session_t 113 | pkcs11h_openssl_createSession ( 114 | IN const pkcs11h_certificate_t certificate 115 | ); 116 | 117 | /** 118 | * @brief Sets cleanup hook 119 | * @param openssl_session OpenSSL session reference. 120 | * @return Current hook. 121 | */ 122 | pkcs11h_hook_openssl_cleanup_t 123 | pkcs11h_openssl_getCleanupHook ( 124 | IN const pkcs11h_openssl_session_t openssl_session 125 | ); 126 | 127 | /** 128 | * @brief Sets cleanup hook 129 | * @param openssl_session OpenSSL session reference. 130 | * @param cleanup hook. 131 | */ 132 | void 133 | pkcs11h_openssl_setCleanupHook ( 134 | IN const pkcs11h_openssl_session_t openssl_session, 135 | IN const pkcs11h_hook_openssl_cleanup_t cleanup 136 | ); 137 | 138 | /** 139 | * @brief Free OpenSSL session. 140 | * @param openssl_session OpenSSL session reference. 141 | * @note The openssl_session object has a reference count just like other OpenSSL objects. 142 | */ 143 | void 144 | pkcs11h_openssl_freeSession ( 145 | IN const pkcs11h_openssl_session_t openssl_session 146 | ); 147 | 148 | /** 149 | * @brief Returns an RSA object out of the openssl_session object. 150 | * @param openssl_session OpenSSL session reference. 151 | * @return RSA. 152 | */ 153 | #ifndef OPENSSL_NO_RSA 154 | RSA * 155 | pkcs11h_openssl_session_getRSA ( 156 | IN const pkcs11h_openssl_session_t openssl_session 157 | ); 158 | #endif 159 | 160 | /** 161 | * @brief Returns an EVP_PKEY out of the openssl_session object. 162 | * @param openssl_session OpenSSL session reference. 163 | * @return EVP_PKEY. 164 | */ 165 | EVP_PKEY * 166 | pkcs11h_openssl_session_getEVP ( 167 | IN const pkcs11h_openssl_session_t openssl_session 168 | ); 169 | 170 | /** 171 | * @brief Returns an X509 object out of the openssl_session object. 172 | * @param openssl_session OpenSSL session reference. 173 | * @return X509. 174 | */ 175 | X509 * 176 | pkcs11h_openssl_session_getX509 ( 177 | IN const pkcs11h_openssl_session_t openssl_session 178 | ); 179 | 180 | #ifdef __cplusplus 181 | } 182 | #endif 183 | 184 | /** @} */ 185 | 186 | #endif /* __PKCS11H_OPENSSL_H */ 187 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | pkcs11-helper 2 | Copyright (c) 2005-2022 Alon Bar-Lev 3 | 4 | ????-??-?? - Version 1.32.0 5 | 6 | 2025-11-10 - Version 1.31.0 7 | * threading: fix mutex handling for cond_wait, thanks to Gleb Popov. 8 | * mbed: initialize certificate early using mbedtls_x509_crt_init. 9 | * util: fix deserialize buffer overflow. thanks to Aarnav Bos. 10 | 11 | 2023-12-01 - Version 1.30.0 12 | * core: add dynamic loader provider attribute, thanks to Marc Becker. 13 | * openssl: support DSA in libressl-3.5.0, thanks to Fabrice Fontaine. 14 | * openssl: fix openssl_ex_data_dup prototype, thanks to Sam James for 15 | reporting. 16 | 17 | 2022-04-21 - Version 1.29.0 18 | 19 | * build: do not fail if slot evnets are disabled, thanks to Fabrice Fontaine. 20 | * core: do not assume standard objects supported by provider. 21 | * openssl: set back key into EVP for openssl-3 to work, thanks to apollo13. 22 | 23 | 2021-12-31 - Version 1.28 24 | 25 | * build: openssl: remove RSA_SSLV23_PADDING constant usage due to openssl-3 26 | compatibility, thanks to t0b3. 27 | * build: nss: use nss pkcs11.h, thanks to Fabrice Fontaine. 28 | * build: windows: checksum in PE, thanks to Simon Rozman. 29 | * build: windows: support openssl-1.1.1, thanks to Lev Stipakov. 30 | * mbed: require >=mbedtls-2, mbed dropped polarssl compatibility, 31 | thanks to Uipko Berghuis 32 | * certificate: add methods accept full mechanism, thanks to Selva Nair. 33 | * core: load provider library as private. 34 | * core: add pkcs11h_getProperty, pkcs11h_setProperty to support adding 35 | properties without breaking API. 36 | * core: add pkcs11h_initializeProvider, pkcs11h_registerProvider, 37 | pkcs11h_setProviderProperty, pkcs11h_setProviderPropertyByName to 38 | support adding properties without breaking API thanks to Михалицын Петр. 39 | * core: add initialization arguments property, thanks for Михалицын Петр. 40 | * core: add PKCS11H_PROVIDER_PROPERTY_PROVIDER_DESTRUCT_HOOK. 41 | * session: respect login required token flag. 42 | * certificate: respect always authenticate flag. 43 | 44 | 2020-11-17 - Version 1.27 45 | 46 | * core: handle PIN expiration after C_Login as C_Login may take a while 47 | * core: return explicit success when plugin&play and no threading and no 48 | safefork, thanks to Tunnelblick 49 | 50 | 2020-01-21 - Version 1.26 51 | 52 | * openssl: build with openssl ec disabled 53 | * openssl: support RSA_NO_PADDING padding, thanks to Selva Nair 54 | * core: reduce mutex lock scope of add/remove provider, thanks to Frank Morgner 55 | * core: improve the fork fixup sequence 56 | 57 | 2018-08-16 - Version 1.25.1 58 | 59 | * core: build with threading disabled 60 | 61 | 2018-08-04 - Version 1.25 62 | 63 | * core: do not attempt to initialize provider with fork mode is not safe. Too 64 | many providers do not follow the PKCS#11 spec. 65 | 66 | 2018-06-15 - Version 1.24 67 | 68 | * build: support libressl-2.7 69 | 70 | 2018-06-02 - Version 1.23 71 | 72 | * build: cleanups. 73 | * openssl: rework support 1.1. 74 | 75 | 2017-02-12 - Version 1.22 76 | 77 | * spec: minor cleanups. 78 | 79 | 2017-01-06 - Version 1.21 80 | 81 | * mbedtls: fix missing logic if issur certificate, thanks to Steffan Karger 82 | 83 | 2016-12-08 - Version 1.20 84 | 85 | * polarssl: support polarssl-1.3, thanks to Steffan Karger. 86 | * certificate: ignore certificate object without CKA_ID. 87 | * openssl: fix memory leak, thanks to ASPj. 88 | * openssl: support 1.1 and libressl, thanks to Daiki Ueno. 89 | 90 | 2013-10-11 - Version 1.11 91 | 92 | * openssl: support generic pkey. 93 | * openssl: add dsa support. 94 | * openssl: add ecdsa support, thanks for Sanaullah for testing. 95 | 96 | 2012-02-29 - Version 1.10 97 | 98 | * PolarSSL crypto engine by Adriaan de Jong 99 | * build: --disable-crypto-engine-win32 renamed to --disable-crypto-engine-cryptoapi 100 | * api: PKCS11H_FEATURE_MASK_ENGINE_CRYPTO_WIN32 renamed to 101 | PKCS11H_FEATURE_MASK_ENGINE_CRYPTO_CRYPTOAPI. 102 | * api: PKCS11H_ENGINE_CRYPTO_WIN32 renamed to 103 | PKCS11H_ENGINE_CRYPTO_CRYPTOAPI 104 | 105 | 2011-08-16 - Version 1.09 106 | 107 | * Do not retry if CKR_BUFFER_TOO_SMALL and none NULL target. 108 | * Fixup OpenSSL engine's rsa_priv_enc to use RSA size output buffer. 109 | 110 | 2011-02-23 - Version 1.08 111 | 112 | * Do not attempt to logout if uninitialized, thanks to Jan Just Keijser. 113 | * Use OpenSSL engine's rsa_priv_enc instead of rsa_sign, thanks to Markus 114 | Friedl. 115 | 116 | 2009-02-27 - Version 1.07 117 | 118 | * Minor Win64 fixup. 119 | 120 | 2008-07-31 - Version 1.06 121 | 122 | * Some MinGW build fixups. 123 | 124 | * Some BSD build fixups. 125 | 126 | * Fix some VC6 issues thanks to Justin Karneges. 127 | 128 | * Add version resource for Windows. 129 | 130 | 2007-10-12 - Version 1.05 131 | 132 | * Export pkcs11h_logout(). 133 | 134 | 2007-10-05 - Version 1.04 135 | 136 | * Added NSS crypto enigne. 137 | 138 | * Added new slotevent mode (poll vs fetch). 139 | 140 | * Add more invalid characters to serialization string. 141 | 142 | * Fix openssl decrypt return code. 143 | 144 | 2007-06-13 - Version 1.03 145 | 146 | * Autoconf fixups. 147 | 148 | * RPM packaging is available, thank to Eddy Nigg. 149 | 150 | * Debian packaging is available, thank to Sandro Wefel. 151 | 152 | * size_t printf 64bit fixups (debug). 153 | 154 | * Certificate session period fixup, thank to Leo Pohl for reporting. 155 | 156 | * Block signals for own threads using pthread calls. 157 | 158 | * Fixup compilation error when using GnuTLS only environment, thank to 159 | Simon Josefsson. 160 | 161 | * Allow several engines to co-exist, so application may select its 162 | favorite. 163 | 164 | * Add logout verb. 165 | 166 | 2007-10-05 - Version 1.02 167 | 168 | * Switch to free implementation of PKCS#11 headers. 169 | 170 | * First standalone version. 171 | 172 | * Fix invalid certificate max size handling (Zeljko Vrba). 173 | 174 | * Added object serialization. 175 | 176 | * Added user data to hooks. 177 | 178 | * Added a force login method. 179 | 180 | * Added support for gnutls in addition to openssl. 181 | 182 | * Fixup threading lock issues. 183 | 184 | * Added support for duplicate serial tokens, based on label. 185 | 186 | * Added workaround for OpenSC cards, OpenSC bug#108, thanks to Kaupo Arulo. 187 | 188 | * Added a methods to lock session between two sign/decrypt operations. 189 | 190 | * Modified openssl interface. 191 | 192 | * Added engines for system and crypto to minimize dependencies. 193 | 194 | * Added win32 crypto engine. 195 | 196 | * Added decrypt option using C_UnwrapKey, thanks for Christoph Neerfeld. 197 | 198 | 2006-06-26 - Version 1.01 199 | 200 | * Fix handling multiple providers. 201 | 202 | 2006-05-14 - Version 1.00 203 | 204 | * First stable release. 205 | -------------------------------------------------------------------------------- /lib/_pkcs11h-crypto-mbedtls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | #include "common.h" 52 | 53 | #include "_pkcs11h-crypto.h" 54 | 55 | #if defined(ENABLE_PKCS11H_ENGINE_MBEDTLS) 56 | #include 57 | 58 | static 59 | int 60 | __pkcs11h_crypto_mbedtls_initialize ( 61 | IN void * const global_data 62 | ) { 63 | (void)global_data; 64 | 65 | return TRUE; 66 | } 67 | 68 | static 69 | int 70 | __pkcs11h_crypto_mbedtls_uninitialize ( 71 | IN void * const global_data 72 | ) { 73 | (void)global_data; 74 | 75 | return TRUE; 76 | } 77 | 78 | static 79 | int 80 | __pkcs11h_crypto_mbedtls_certificate_get_expiration ( 81 | IN void * const global_data, 82 | IN const unsigned char * const blob, 83 | IN const size_t blob_size, 84 | OUT time_t * const expiration 85 | ) { 86 | mbedtls_x509_crt x509; 87 | 88 | (void)global_data; 89 | 90 | mbedtls_x509_crt_init(&x509); 91 | 92 | /*_PKCS11H_ASSERT (global_data!=NULL); NOT NEEDED*/ 93 | _PKCS11H_ASSERT (blob!=NULL); 94 | _PKCS11H_ASSERT (expiration!=NULL); 95 | 96 | *expiration = (time_t)0; 97 | 98 | if (0 != mbedtls_x509_crt_parse (&x509, blob, blob_size)) { 99 | goto cleanup; 100 | } 101 | 102 | if (0 == mbedtls_x509_time_is_past(&x509.valid_to)) { 103 | struct tm tm1; 104 | 105 | memset (&tm1, 0, sizeof (tm1)); 106 | tm1.tm_year = x509.valid_to.year - 1900; 107 | tm1.tm_mon = x509.valid_to.mon - 1; 108 | tm1.tm_mday = x509.valid_to.day; 109 | tm1.tm_hour = x509.valid_to.hour - 1; 110 | tm1.tm_min = x509.valid_to.min - 1; 111 | tm1.tm_sec = x509.valid_to.sec - 1; 112 | 113 | *expiration = mktime (&tm1); 114 | *expiration += (int)(mktime (localtime (expiration)) - mktime (gmtime (expiration))); 115 | } 116 | 117 | cleanup: 118 | 119 | mbedtls_x509_crt_free(&x509); 120 | 121 | return *expiration != (time_t)0; 122 | } 123 | 124 | static 125 | int 126 | __pkcs11h_crypto_mbedtls_certificate_get_dn ( 127 | IN void * const global_data, 128 | IN const unsigned char * const blob, 129 | IN const size_t blob_size, 130 | OUT char * const dn, 131 | IN const size_t dn_max 132 | ) { 133 | mbedtls_x509_crt x509; 134 | int ret = FALSE; 135 | 136 | (void)global_data; 137 | 138 | mbedtls_x509_crt_init(&x509); 139 | 140 | /*_PKCS11H_ASSERT (global_data!=NULL); NOT NEEDED*/ 141 | _PKCS11H_ASSERT (blob!=NULL); 142 | _PKCS11H_ASSERT (dn!=NULL); 143 | _PKCS11H_ASSERT (dn_max>0); 144 | 145 | dn[0] = '\x0'; 146 | 147 | if (0 != mbedtls_x509_crt_parse (&x509, blob, blob_size)) { 148 | goto cleanup; 149 | } 150 | 151 | if (-1 == mbedtls_x509_dn_gets(dn, dn_max, &x509.subject)) { 152 | goto cleanup; 153 | } 154 | 155 | ret = TRUE; 156 | 157 | cleanup: 158 | 159 | mbedtls_x509_crt_free(&x509); 160 | 161 | return ret; 162 | } 163 | 164 | static 165 | int 166 | __pkcs11h_crypto_mbedtls_certificate_is_issuer ( 167 | IN void * const global_data, 168 | IN const unsigned char * const issuer_blob, 169 | IN const size_t issuer_blob_size, 170 | IN const unsigned char * const cert_blob, 171 | IN const size_t cert_blob_size 172 | ) { 173 | mbedtls_x509_crt x509_issuer; 174 | mbedtls_x509_crt x509_cert; 175 | uint32_t verify_flags = 0; 176 | 177 | PKCS11H_BOOL is_issuer = FALSE; 178 | 179 | (void)global_data; 180 | 181 | mbedtls_x509_crt_init(&x509_issuer); 182 | mbedtls_x509_crt_init(&x509_cert); 183 | 184 | /*_PKCS11H_ASSERT (global_data!=NULL); NOT NEEDED*/ 185 | _PKCS11H_ASSERT (issuer_blob!=NULL); 186 | _PKCS11H_ASSERT (cert_blob!=NULL); 187 | 188 | if (0 != mbedtls_x509_crt_parse (&x509_issuer, issuer_blob, issuer_blob_size)) { 189 | goto cleanup; 190 | } 191 | 192 | if (0 != mbedtls_x509_crt_parse (&x509_cert, cert_blob, cert_blob_size)) { 193 | goto cleanup; 194 | } 195 | 196 | if ( 0 == mbedtls_x509_crt_verify(&x509_cert, &x509_issuer, NULL, NULL, 197 | &verify_flags, NULL, NULL )) { 198 | is_issuer = TRUE; 199 | } 200 | 201 | cleanup: 202 | mbedtls_x509_crt_free(&x509_cert); 203 | mbedtls_x509_crt_free(&x509_issuer); 204 | 205 | return is_issuer; 206 | } 207 | 208 | const pkcs11h_engine_crypto_t _g_pkcs11h_crypto_engine_mbedtls = { 209 | NULL, 210 | __pkcs11h_crypto_mbedtls_initialize, 211 | __pkcs11h_crypto_mbedtls_uninitialize, 212 | __pkcs11h_crypto_mbedtls_certificate_get_expiration, 213 | __pkcs11h_crypto_mbedtls_certificate_get_dn, 214 | __pkcs11h_crypto_mbedtls_certificate_is_issuer 215 | }; 216 | 217 | #endif /* ENABLE_PKCS11H_ENGINE_MBEDTLS */ 218 | -------------------------------------------------------------------------------- /include/pkcs11-helper-1.0/pkcs11h-token.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | /** 52 | * @addtogroup pkcs11h_token Token interface 53 | * 54 | * Token related functions. 55 | * 56 | * @{ 57 | */ 58 | 59 | /** 60 | * @file pkcs11h-token.h 61 | * @brief pkcs11-helper token interface. 62 | * @author Alon Bar-Lev 63 | * @see pkcs11h_token. 64 | */ 65 | 66 | #ifndef __PKCS11H_TOKEN_H 67 | #define __PKCS11H_TOKEN_H 68 | 69 | #include 70 | 71 | #if defined(__cplusplus) 72 | extern "C" { 73 | #endif 74 | 75 | struct pkcs11h_token_id_list_s; 76 | 77 | /** 78 | * @brief Token identifier list. 79 | */ 80 | typedef struct pkcs11h_token_id_list_s *pkcs11h_token_id_list_t; 81 | 82 | /** 83 | * @brief Token identifier list. 84 | */ 85 | struct pkcs11h_token_id_list_s { 86 | /** Next element. */ 87 | pkcs11h_token_id_list_t next; 88 | /** Token id element. */ 89 | pkcs11h_token_id_t token_id; 90 | }; 91 | 92 | /** 93 | * @brief Free token_id object. 94 | * @param token_id Token reference. 95 | * @return CK_RV. 96 | */ 97 | CK_RV 98 | pkcs11h_token_freeTokenId ( 99 | IN pkcs11h_token_id_t token_id 100 | ); 101 | 102 | /** 103 | * @brief Duplicate token_id object. 104 | * @param to Target. 105 | * @param from Source. 106 | * @return CK_RV. 107 | * @see pkcs11h_token_freeTokenId(). 108 | */ 109 | CK_RV 110 | pkcs11h_token_duplicateTokenId ( 111 | OUT pkcs11h_token_id_t * const to, 112 | IN const pkcs11h_token_id_t from 113 | ); 114 | 115 | /** 116 | * @brief Returns TRUE if same token id 117 | * @param a a. 118 | * @param b b. 119 | * @return TRUE if same token identifier. 120 | */ 121 | PKCS11H_BOOL 122 | pkcs11h_token_sameTokenId ( 123 | IN const pkcs11h_token_id_t a, 124 | IN const pkcs11h_token_id_t b 125 | ); 126 | 127 | /** 128 | * @brief Force logout. 129 | * @param token_id Token to login into. 130 | * @return CK_RV. 131 | */ 132 | CK_RV 133 | pkcs11h_token_logout ( 134 | IN const pkcs11h_token_id_t token_id 135 | ); 136 | 137 | /** 138 | * @brief Force login, avoid hooks. 139 | * @param token_id Token to login into. 140 | * @param readonly Should session be readonly. 141 | * @param pin PIN to login, NULL for protected authentication. 142 | * @return CK_RV. 143 | */ 144 | CK_RV 145 | pkcs11h_token_login ( 146 | IN const pkcs11h_token_id_t token_id, 147 | IN const PKCS11H_BOOL readonly, 148 | IN const char * const pin 149 | ); 150 | 151 | /** 152 | * @brief Ensure token is accessible. 153 | * @param token_id Token id object. 154 | * @param user_data Optional user data, to be passed to hooks. 155 | * @param mask_prompt Allow prompt @ref PKCS11H_PROMPT_MASK. 156 | * @return CK_RV. 157 | */ 158 | CK_RV 159 | pkcs11h_token_ensureAccess ( 160 | IN const pkcs11h_token_id_t token_id, 161 | IN void * const user_data, 162 | IN const unsigned mask_prompt 163 | ); 164 | 165 | /** 166 | * @brief Free certificate_id list. 167 | * @param token_id_list List. 168 | * @return CK_RV. 169 | */ 170 | CK_RV 171 | pkcs11h_token_freeTokenIdList ( 172 | IN const pkcs11h_token_id_list_t token_id_list 173 | ); 174 | 175 | /** 176 | * @brief Enumerate available tokens. 177 | * @param method Enum method @ref PKCS11H_ENUM_METHOD. 178 | * @param p_token_id_list List. 179 | * @return CK_RV. 180 | * @note Caller must free result. 181 | * @see pkcs11h_token_freeTokenIdList(). 182 | */ 183 | CK_RV 184 | pkcs11h_token_enumTokenIds ( 185 | IN const unsigned method, 186 | OUT pkcs11h_token_id_list_t * const p_token_id_list 187 | ); 188 | 189 | /** 190 | * @brief Serialize token_id into string. 191 | * @param sz Output string. 192 | * @param max Maximum string size. 193 | * @param token_id id to serialize 194 | * @return CK_RV. 195 | * @note sz may be NULL to get size. 196 | */ 197 | CK_RV 198 | pkcs11h_token_serializeTokenId ( 199 | OUT char * const sz, 200 | IN OUT size_t *max, 201 | IN const pkcs11h_token_id_t token_id 202 | ); 203 | 204 | /** 205 | * @brief Deserialize token_id from string. 206 | * @param p_token_id id. 207 | * @param sz Input string. 208 | * @return CK_RV. 209 | * @note Caller must free result. 210 | * @see pkcs11h_token_freeTokenId(). 211 | */ 212 | CK_RV 213 | pkcs11h_token_deserializeTokenId ( 214 | OUT pkcs11h_token_id_t *p_token_id, 215 | IN const char * const sz 216 | ); 217 | 218 | #ifdef __cplusplus 219 | } 220 | #endif 221 | 222 | /** @} */ 223 | 224 | #endif /* __PKCS11H_TOKEN_H */ 225 | -------------------------------------------------------------------------------- /include/pkcs11-helper-1.0/pkcs11h-data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2018 Alon Bar-Lev 3 | * 4 | * This software is available to you under a choice of one of two 5 | * licenses. You may choose to be licensed under the terms of the GNU 6 | * General Public License (GPL) Version 2, or the BSD license. 7 | * 8 | * GNU General Public License (GPL) Version 2 9 | * =========================================== 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 12 | * as published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program (see the file COPYING.GPL included with this 21 | * distribution); if not, write to the Free Software Foundation, Inc., 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | * 24 | * BSD License 25 | * ============ 26 | * Redistribution and use in source and binary forms, with or without 27 | * modification, are permitted provided that the following conditions are met: 28 | * 29 | * o Redistributions of source code must retain the above copyright notice, 30 | * this list of conditions and the following disclaimer. 31 | * o Redistributions in binary form must reproduce the above copyright 32 | * notice, this list of conditions and the following disclaimer in the 33 | * documentation and/or other materials provided with the distribution. 34 | * o Neither the name of the Alon Bar-Lev nor the names of its 35 | * contributors may be used to endorse or promote products derived from 36 | * this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 41 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 42 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 45 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 46 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 47 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 48 | * POSSIBILITY OF SUCH DAMAGE. 49 | */ 50 | 51 | /** 52 | * @addtogroup pkcs11h_data Data object interface 53 | * 54 | * Data object manipulation. 55 | * 56 | * @{ 57 | */ 58 | 59 | /** 60 | * @file pkcs11h-data.h 61 | * @brief pkcs11-helper data object support. 62 | * @author Alon Bar-Lev 63 | * @see pkcs11h_data. 64 | */ 65 | 66 | #ifndef __PKCS11H_DATA_H 67 | #define __PKCS11H_DATA_H 68 | 69 | #include 70 | 71 | #if defined(__cplusplus) 72 | extern "C" { 73 | #endif 74 | 75 | struct pkcs11h_data_id_list_s; 76 | 77 | /** 78 | * @brief Data identifier list. 79 | */ 80 | typedef struct pkcs11h_data_id_list_s *pkcs11h_data_id_list_t; 81 | 82 | /** 83 | * @brief Data identifier list. 84 | */ 85 | struct pkcs11h_data_id_list_s { 86 | /** Next element */ 87 | pkcs11h_data_id_list_t next; 88 | 89 | /** Application string */ 90 | char *application; 91 | /** Label string */ 92 | char *label; 93 | }; 94 | 95 | /** 96 | * @brief Get data object. 97 | * @param token_id Token id object. 98 | * @param is_public Object is public. 99 | * @param application Object application attribute. 100 | * @param label Object label attribute. 101 | * @param user_data Optional user data, to be passed to hooks. 102 | * @param mask_prompt Allow prompt @ref PKCS11H_PROMPT_MASK. 103 | * @param blob Blob, set to NULL to get size. 104 | * @param p_blob_size Blob size. 105 | * @return CK_RV. 106 | * @note blob may be NULL to get size. 107 | */ 108 | CK_RV 109 | pkcs11h_data_get ( 110 | IN const pkcs11h_token_id_t token_id, 111 | IN const PKCS11H_BOOL is_public, 112 | IN const char * const application, 113 | IN const char * const label, 114 | IN void * const user_data, 115 | IN const unsigned mask_prompt, 116 | OUT unsigned char * const blob, 117 | IN OUT size_t * const p_blob_size 118 | ); 119 | 120 | /** 121 | * @brief Put data object. 122 | * @param token_id Token id object. 123 | * @param is_public Object is public. 124 | * @param application Object application attribute. 125 | * @param label Object label attribute. 126 | * @param user_data Optional user data, to be passed to hooks. 127 | * @param mask_prompt Allow prompt @ref PKCS11H_PROMPT_MASK. 128 | * @param blob Blob, set to NULL to get size. 129 | * @param blob_size Blob size. 130 | * @return CK_RV. 131 | */ 132 | CK_RV 133 | pkcs11h_data_put ( 134 | IN const pkcs11h_token_id_t token_id, 135 | IN const PKCS11H_BOOL is_public, 136 | IN const char * const application, 137 | IN const char * const label, 138 | IN void * const user_data, 139 | IN const unsigned mask_prompt, 140 | OUT unsigned char * const blob, 141 | IN const size_t blob_size 142 | ); 143 | 144 | /** 145 | * @brief Delete data object. 146 | * @param token_id Token id object. 147 | * @param is_public Object is public. 148 | * @param application Object application attribute. 149 | * @param label Object label attribute. 150 | * @param user_data Optional user data, to be passed to hooks. 151 | * @param mask_prompt Allow prompt @ref PKCS11H_PROMPT_MASK. 152 | * @return CK_RV. 153 | */ 154 | CK_RV 155 | pkcs11h_data_del ( 156 | IN const pkcs11h_token_id_t token_id, 157 | IN const PKCS11H_BOOL is_public, 158 | IN const char * const application, 159 | IN const char * const label, 160 | IN void * const user_data, 161 | IN const unsigned mask_prompt 162 | ); 163 | 164 | /** 165 | * @brief Free data object list. 166 | * @param data_id_list List to free. 167 | * @return CK_RV. 168 | */ 169 | CK_RV 170 | pkcs11h_data_freeDataIdList ( 171 | IN const pkcs11h_data_id_list_t data_id_list 172 | ); 173 | 174 | /** 175 | * @brief Get list of data objects. 176 | * @param token_id Token id object. 177 | * @param is_public Get a list of public objects. 178 | * @param user_data Optional user data, to be passed to hooks. 179 | * @param mask_prompt Allow prompt @ref PKCS11H_PROMPT_MASK. 180 | * @param p_data_id_list List location. 181 | * @see pkcs11h_data_freeDataIdList(). 182 | * @return CK_RV. 183 | */ 184 | CK_RV 185 | pkcs11h_data_enumDataObjects ( 186 | IN const pkcs11h_token_id_t token_id, 187 | IN const PKCS11H_BOOL is_public, 188 | IN void * const user_data, 189 | IN const unsigned mask_prompt, 190 | OUT pkcs11h_data_id_list_t * const p_data_id_list 191 | ); 192 | 193 | #ifdef __cplusplus 194 | } 195 | #endif 196 | 197 | /** @} */ 198 | 199 | #endif /* __PKCS11H_DATA_H */ 200 | -------------------------------------------------------------------------------- /config-w32-vc.h.in: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Enable certificate interface */ 5 | #define ENABLE_PKCS11H_CERTIFICATE 1 6 | 7 | /* Enable data interface */ 8 | #define ENABLE_PKCS11H_DATA 1 9 | 10 | /* Enable debug support */ 11 | #define ENABLE_PKCS11H_DEBUG 1 12 | 13 | /* Use GNUTLS crypto engine */ 14 | /* #undef ENABLE_PKCS11H_ENGINE_GNUTLS */ 15 | 16 | /* Use OpenSSL crypto engine */ 17 | /* #undef ENABLE_PKCS11H_ENGINE_OPENSSL */ 18 | 19 | /* Use win32 crypto engine */ 20 | #define ENABLE_PKCS11H_ENGINE_CRYPTOAPI 1 21 | 22 | /* Enable openssl interface */ 23 | /* #undef ENABLE_PKCS11H_OPENSSL */ 24 | 25 | /* Enable slotevent interface */ 26 | #define ENABLE_PKCS11H_SLOTEVENT 1 27 | 28 | /* Enable threading */ 29 | #define ENABLE_PKCS11H_THREADING 1 30 | 31 | /* Enable token interface */ 32 | #define ENABLE_PKCS11H_TOKEN 1 33 | 34 | /* Define to 1 if you have the `alarm' function. */ 35 | /* #undef HAVE_ALARM */ 36 | 37 | /* Define to 1 if you have the header file. */ 38 | /* #undef HAVE_DLFCN_H */ 39 | 40 | /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ 41 | /* #undef HAVE_DOPRNT */ 42 | 43 | /* Define to 1 if you have the `gettimeofday' function. */ 44 | /* #undef HAVE_GETTIMEOFDAY */ 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_INTTYPES_H 1 48 | 49 | /* Define to 1 if you have the `dl' library (-ldl). */ 50 | /* #undef HAVE_LIBDL */ 51 | 52 | /* Define to 1 if you have the `pthread' library (-lpthread). */ 53 | /* #undef HAVE_LIBPTHREAD */ 54 | 55 | /* Define to 1 if you have the `memmove' function. */ 56 | #define HAVE_MEMMOVE 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_MEMORY_H 1 60 | 61 | /* Define to 1 if you have the `memset' function. */ 62 | #define HAVE_MEMSET 1 63 | 64 | /* Define to 1 if you have the header file. */ 65 | /* #undef HAVE_PTHREAD_H */ 66 | 67 | /* Define to 1 if you have the header file. */ 68 | /* #undef HAVE_SIGNAL_H */ 69 | 70 | /* Define to 1 if you have the `snprintf' function. */ 71 | #define HAVE_SNPRINTF 1 72 | 73 | /* Define to 1 if you have the `socket' function. */ 74 | /* #undef HAVE_SOCKET */ 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #define HAVE_STDINT_H 1 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #define HAVE_STDLIB_H 1 81 | 82 | /* Define to 1 if you have the `strchr' function. */ 83 | #define HAVE_STRCHR 1 84 | 85 | /* Define to 1 if you have the `strdup' function. */ 86 | #define HAVE_STRDUP 1 87 | 88 | /* Define to 1 if you have the `strerror' function. */ 89 | #define HAVE_STRERROR 1 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #define HAVE_STRINGS_H 1 93 | 94 | /* Define to 1 if you have the header file. */ 95 | #define HAVE_STRING_H 1 96 | 97 | /* Define to 1 if you have the `strrchr' function. */ 98 | #define HAVE_STRRCHR 1 99 | 100 | /* Define to 1 if you have the header file. */ 101 | #define HAVE_SYS_STAT_H 1 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #define HAVE_SYS_TIME_H 1 105 | 106 | /* Define to 1 if you have the header file. */ 107 | #define HAVE_SYS_TYPES_H 1 108 | 109 | /* Define to 1 if you have the header file. */ 110 | #define HAVE_UNISTD_H 1 111 | 112 | /* Define to 1 if you have the `vprintf' function. */ 113 | #define HAVE_VPRINTF 1 114 | 115 | /* Define to 1 if you have the <[], [stdio.h], [stdlib.h], [stdargs.h], 116 | [malloc.h], [ctype.h], [string.h], [errno.h], [assert.h], [time.h], []> 117 | header file. */ 118 | /* #undef HAVE______STDIO_H____STDLIB_H____STDARGS_H____MALLOC_H____CTYPE_H____STRING_H____ERRNO_H____ASSERT_H____TIME_H_____ */ 119 | 120 | /* Name of package */ 121 | #define PACKAGE "@PACKAGE@" 122 | 123 | /* Define to the address where bug reports for this package should be sent. */ 124 | #define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" 125 | 126 | /* Define to the full name of this package. */ 127 | #define PACKAGE_NAME "@PACKAGE_NAME@" 128 | 129 | /* Define to the full name and version of this package. */ 130 | #define PACKAGE_STRING "@PACKAGE_STRING@" 131 | 132 | /* Define to the one symbol short name of this package. */ 133 | #define PACKAGE_TARNAME "@PACKAGE_TARNAME@" 134 | 135 | /* Define to the version of this package. */ 136 | #define PACKAGE_VERSION "@PACKAGE_VERSION@" 137 | 138 | /* Define if you are on Cygwin */ 139 | /* #undef PKCS11H_USE_CYGWIN */ 140 | 141 | /* Define printf format for size_t */ 142 | #define PRINTF_Z_FORMAT "%x" 143 | 144 | /* Define as the return type of signal handlers (`int' or `void'). */ 145 | #define RETSIGTYPE void 146 | 147 | /* Define to 1 if you have the ANSI C header files. */ 148 | #define STDC_HEADERS 1 149 | 150 | /* Test log level */ 151 | #define TEST_LOG_LEVEL 3 152 | 153 | /* Test provider */ 154 | #define TEST_PROVIDER "@TEST_PROVIDER@" 155 | 156 | /* Define to 1 if you can safely include both and . */ 157 | #define TIME_WITH_SYS_TIME 1 158 | 159 | /* Define to 1 if your declares `struct tm'. */ 160 | /* #undef TM_IN_SYS_TIME */ 161 | 162 | /* Use valgrind memory debugging library */ 163 | /* #undef USE_VALGRIND */ 164 | 165 | /* Version number of package */ 166 | #define VERSION "@VERSION@" 167 | 168 | /* Define to empty if `const' does not conform to ANSI C. */ 169 | /* #undef const */ 170 | 171 | /* Define to `long int' if does not define. */ 172 | /* #undef off_t */ 173 | 174 | /* Define to `int' if does not define. */ 175 | /* #undef pid_t */ 176 | 177 | /* Define to `unsigned int' if does not define. */ 178 | /* #undef size_t */ 179 | 180 | /* Define to empty if the keyword `volatile' does not work. Warning: valid 181 | code using `volatile' can become incorrect without. Disable with care. */ 182 | /* #undef volatile */ 183 | 184 | /* Visual Studio 2005 supports vararg macros */ 185 | #if _MSC_VER >= 1400 186 | #define HAVE_CPP_VARARG_MACRO_ISO 1 187 | #endif 188 | 189 | /* Define to 1 if you have the `RSA_meth_dup' function. */ 190 | #define HAVE_RSA_METH_DUP 1 191 | 192 | /* Define to 1 if you have the `RSA_meth_free' function. */ 193 | #define HAVE_RSA_METH_FREE 1 194 | 195 | /* Define to 1 if you have the `RSA_meth_set1_name' function. */ 196 | #define HAVE_RSA_METH_SET1_NAME 1 197 | 198 | /* Define to 1 if you have the `RSA_meth_set_flags' function. */ 199 | #define HAVE_RSA_METH_SET_FLAGS 1 200 | 201 | /* Define to 1 if you have the `RSA_meth_set_priv_dec' function. */ 202 | #define HAVE_RSA_METH_SET_PRIV_DEC 1 203 | 204 | /* Define to 1 if you have the `RSA_meth_set_priv_enc' function. */ 205 | #define HAVE_RSA_METH_SET_PRIV_ENC 1 206 | 207 | /* Define to 1 if you have the `DSA_meth_dup' function. */ 208 | #define HAVE_DSA_METH_DUP 1 209 | 210 | /* Define to 1 if you have the `DSA_meth_free' function. */ 211 | #define HAVE_DSA_METH_FREE 1 212 | 213 | /* Define to 1 if you have the `DSA_meth_set1_name' function. */ 214 | #define HAVE_DSA_METH_SET1_NAME 1 215 | 216 | /* Define to 1 if you have the `DSA_meth_set_sign' function. */ 217 | #define HAVE_DSA_METH_SET_SIGN 1 218 | 219 | /* Define to 1 if you have the `DSA_SIG_set0' function. */ 220 | #define HAVE_DSA_SIG_SET0 1 221 | --------------------------------------------------------------------------------