diff --git a/.appveyor.yml b/.appveyor.yml index 4a46ea58e..1a049cdaf 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -43,22 +43,20 @@ init: $env:CONFIGURE_OPTIONS = "$env:CONFIGURE_OPTIONS with-crypto-backend=$env:CRYPTO_BACKEND with-$env:CRYPTO_BACKEND=$env:CRYPTO_PACKAGE_PATH\ with-cppunit=$env:CPPUNIT_PATH\" environment: matrix: - - CRYPTO_BACKEND: openssl - PACKAGE_VERSION_NAME: OpenSSL-1.0.2j - CRYPTO_PACKAGE_NAME: openssl-1.0.2j - ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa - CRYPTO_BACKEND: botan - PACKAGE_VERSION_NAME: Botan-1.10.13 - CRYPTO_PACKAGE_NAME: botan-1.10.13 - ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa + ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=botan - CRYPTO_BACKEND: openssl - PACKAGE_VERSION_NAME: OpenSSL-1.1.0b - CRYPTO_PACKAGE_NAME: openssl-1.1.0b - ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost + ADDITIONAL_CONFIGURE_OPTIONS: disable-eddsa disable-gost with-crypto-backend=openssl install: -- cmd: powershell -File testing/appveyor/appveyor_download_requirements.ps1 +- cmd: vcpkg install sqlite3:x86-windows +- cmd: vcpkg install openssl-windows:x64-windows +- cmd: vcpkg install botan:x86-windows +- cmd: vcpkg install cppunit:x86-windows +- cmd: vcpkg install getopt-win32:x86-windows build_script: -- cmd: testing/appveyor/appveyor_build.bat +- cmd: vcpkg integrate install +- cmd: cmake -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DWITH_CRYPTO_BACKEND=%CRYPTO_BACKEND% -DBUILD_TESTS=OFF -DDISABLE_NON_PAGED_MEMORY=ON -DENABLE_GOST=OFF . +- cmd: msbuild softhsm2.sln /p:Configuration="Release" /p:Platform="Win32" /p:PlatformToolset=v140 /target:Build & exit 0 test: off artifacts: - path: build/SoftHSMv2-$(Platform) diff --git a/.gitignore b/.gitignore index 3a6eaf2c0..df37da22a 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,8 @@ test-results.xml build Botan-* ROOT +*.cmake +CMakeFiles # Specifics softhsm2.module diff --git a/config.h.in.cmake b/config.h.in.cmake index d19380115..03cd0a74b 100644 --- a/config.h.in.cmake +++ b/config.h.in.cmake @@ -159,3 +159,104 @@ /* Compile with raw RSA PKCS PSS */ #cmakedefine WITH_RAW_PSS @WITH_RAW_PSS@ + +/* + * Remainder is specific for Windows build to + * set some default that aren't configured from + * cmake yet, and provide compatibility functions. + */ +#ifdef _WIN32 + +/* The default log level */ +#undef DEFAULT_LOG_LEVEL +#define DEFAULT_LOG_LEVEL "INFO" + +/* Default storage backend for token objects */ +#undef DEFAULT_OBJECTSTORE_BACKEND +#define DEFAULT_OBJECTSTORE_BACKEND "file" + +/* The default PKCS#11 library */ +#undef DEFAULT_PKCS11_LIB +#define DEFAULT_PKCS11_LIB "softhsm2.dll" + +/* The default location of softhsm2.conf */ +#undef DEFAULT_SOFTHSM2_CONF +#define DEFAULT_SOFTHSM2_CONF "softhsm2.conf" + +/* The default location of the token directory */ +#undef DEFAULT_TOKENDIR +#define DEFAULT_TOKENDIR "tokens" + +/* Whether LoadLibrary is available */ +#undef HAVE_LOADLIBRARY +#define HAVE_LOADLIBRARY 1 + + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H +#define HAVE_SYS_TYPES_H 1 + +/* Maximum PIN length */ +#undef MAX_PIN_LEN +#define MAX_PIN_LEN 255 + +/* Minimum PIN length */ +#undef MIN_PIN_LEN +#define MIN_PIN_LEN 4 + +/* Define to 1 if you have getpassphrase(). */ +#define HAVE_GETPASSPHRASE + +/* Addition things */ + +char *getpassphrase(const char *prompt); +int setenv(const char *name, const char *value, int overwrite); + +/* At least Vista */ + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif + +#if _MSC_VER < 1900 +#define snprintf _snprintf +#endif +#define strcasecmp _stricmp +#define strncasecmp _strnicmp + +/* Prevent inclusion of winsock.h in windows.h */ + +#define WIN32_LEAN_AND_MEAN 1 + +#include + +/* avoid collision from min and max macros */ + +#undef min +#undef max + +/* Temporary for debug */ + +#undef DEBUG_LOG_STDERR +// #define DEBUG_LOG_STDERR 1 + +/* To avoid unsafe warnings (off) */ + +// #pragma warning(disable: 4996) + +#endif diff --git a/m4/pkg.m4 b/m4/pkg.m4 new file mode 100644 index 000000000..13a889017 --- /dev/null +++ b/m4/pkg.m4 @@ -0,0 +1,275 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) + +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.2]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])dnl _PKG_CONFIG + +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $2]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_INSTALLDIR + + +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_NOARCH_INSTALLDIR + + +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR diff --git a/modules/FindBotan.cmake b/modules/FindBotan.cmake index 233c53346..3f223e2d3 100644 --- a/modules/FindBotan.cmake +++ b/modules/FindBotan.cmake @@ -1,46 +1,44 @@ -# - Try to find the Botan library +# - Find botan +# Find the botan cryptographic library # -# Once done this will define +# This module defines the following variables: +# BOTAN_FOUND - True if library and include directory are found +# If set to TRUE, the following are also defined: +# BOTAN_INCLUDE_DIRS - The directory where to find the header file +# BOTAN_LIBRARIES - Where to find the library file # -# BOTAN_FOUND - System has Botan -# BOTAN_INCLUDE_DIR - The Botan include directory -# BOTAN_LIBRARIES - The libraries needed to use Botan -# BOTAN_DEFINITIONS - Compiler switches required for using Botan +# For conveniance, these variables are also set. They have the same values +# than the variables above. The user can thus choose his/her prefered way +# to write them. +# BOTAN_LIBRARY +# BOTAN_INCLUDE_DIR +# +# This file is in the public domain -IF (BOTAN_INCLUDE_DIR AND BOTAN_LIBRARY) - # in cache already - SET(Botan_FIND_QUIETLY TRUE) -ENDIF (BOTAN_INCLUDE_DIR AND BOTAN_LIBRARY) +include(FindPkgConfig) -IF (NOT WIN32) - # try using pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - # also fills in BOTAN_DEFINITIONS, although that isn't normally useful - FIND_PACKAGE(PkgConfig) - PKG_SEARCH_MODULE(PC_BOTAN botan-2) - SET(BOTAN_DEFINITIONS ${PC_BOTAN_CFLAGS}) -ENDIF (NOT WIN32) +if(NOT BOTAN_FOUND) + pkg_check_modules(BOTAN botan-2) +endif() -FIND_PATH(BOTAN_INCLUDE_DIR botan/version.h - HINTS - ${PC_BOTAN_INCLUDEDIR} - ${PC_BOTAN_INCLUDE_DIRS} - ) +if(NOT BOTAN_FOUND) + find_path(BOTAN_INCLUDE_DIRS NAMES botan/botan.h + PATH_SUFFIXES botan-2 + DOC "The botan include directory") -FIND_LIBRARY(BOTAN_LIBRARY NAMES ${PC_BOTAN_LIBRARIES} - HINTS - ${PC_BOTAN_LIBDIR} - ${PC_BOTAN_LIBRARY_DIRS} - ) + find_library(BOTAN_LIBRARIES NAMES botan botan-2 + DOC "The botan library") -MARK_AS_ADVANCED(BOTAN_INCLUDE_DIR BOTAN_LIBRARY) + # Use some standard module to handle the QUIETLY and REQUIRED arguments, and + # set BOTAN_FOUND to TRUE if these two variables are set. + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(BOTAN REQUIRED_VARS BOTAN_LIBRARIES BOTAN_INCLUDE_DIRS) -# handle the QUIETLY and REQUIRED arguments and set BOTAN_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Botan DEFAULT_MSG BOTAN_LIBRARY BOTAN_INCLUDE_DIR) + if(BOTAN_FOUND) + set(BOTAN_LIBRARY ${BOTAN_LIBRARIES} CACHE INTERNAL "") + set(BOTAN_INCLUDE_DIR ${BOTAN_INCLUDE_DIRS} CACHE INTERNAL "") + set(BOTAN_FOUND ${BOTAN_FOUND} CACHE INTERNAL "") + endif() +endif() -IF(BOTAN_FOUND) - SET(BOTAN_LIBRARIES ${BOTAN_LIBRARY}) - SET(BOTAN_INCLUDE_DIRS ${BOTAN_INCLUDE_DIR}) -ENDIF(BOTAN_FOUND) +mark_as_advanced(BOTAN_INCLUDE_DIRS BOTAN_LIBRARIES) diff --git a/src/bin/win32/getopt.cpp b/src/bin/win32/getopt.cpp deleted file mode 100644 index dfeabe20a..000000000 --- a/src/bin/win32/getopt.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#ifdef _WIN32 - -/* Windows needs warnx(). We change the definition though: - * 1. (another) global is defined, opterrmsg, which holds the error message - * 2. errors are always printed out on stderr w/o the program name - * Note that opterrmsg always gets set no matter what opterr is set to. The - * error message will not be printed if opterr is 0 as usual. - */ - -#include -#include - -extern char opterrmsg[128]; -char opterrmsg[128]; /* last error message is stored here */ - -static void warnx(int print_error, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (fmt != NULL) - _vsnprintf(opterrmsg, 128, fmt, ap); - else - opterrmsg[0]='\0'; - va_end(ap); - if (print_error) { - fprintf(stderr, opterrmsg); - fprintf(stderr, "\n"); - } -} - -#endif /*_WIN32*/ - -/* not part of the original file */ -#ifndef _DIAGASSERT -#define _DIAGASSERT(X) -#endif - -#if HAVE_CONFIG_H && !HAVE_GETOPT_LONG && !HAVE_DECL_OPTIND -#define REPLACE_GETOPT -#endif - -int opterr = 1; /* if error message should be printed */ -int optind = 1; /* index into parent argv vector */ -int optopt = '?'; /* character checked for validity */ -int optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ - -#if !HAVE_GETOPT_LONG -#define IGNORE_FIRST (*options == '-' || *options == '+') -#define PRINT_ERROR ((opterr) && ((*options != ':') \ - || (IGNORE_FIRST && options[1] != ':'))) -#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL) -#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST) -/* XXX: GNU ignores PC if *options == '-' */ -#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-') - -/* return values */ -#define BADCH (int)'?' -#define BADARG ((IGNORE_FIRST && options[1] == ':') \ - || (*options == ':') ? (int)':' : (int)'?') -#define INORDER (int)1 - -#define EMSG "" - -static int getopt_internal(int, char * const *, const char *); -static int gcd(int, int); -static void permute_args(int, int, int, char * const *); - -static char *place = EMSG; /* option letter processing */ - -/* XXX: set optreset to 1 rather than these two */ -static int nonopt_start = -1; /* first non option argument (for permute) */ -static int nonopt_end = -1; /* first option after non options (for permute) */ - -/* Error messages */ -static const char recargchar[] = "option requires an argument -- %c"; -static const char recargstring[] = "option requires an argument -- %s"; -static const char ambig[] = "ambiguous option -- %.*s"; -static const char noarg[] = "option doesn't take an argument -- %.*s"; -static const char illoptchar[] = "unknown option -- %c"; -static const char illoptstring[] = "unknown option -- %s"; - - -/* - * Compute the greatest common divisor of a and b. - */ -static int -gcd(int a, int b) -{ - int c; - - c = a % b; - while (c != 0) { - a = b; - b = c; - c = a % b; - } - - return b; -} - -/* - * Exchange the block from nonopt_start to nonopt_end with the block - * from nonopt_end to opt_end (keeping the same order of arguments - * in each block). - */ -static void -permute_args(int panonopt_start, int panonopt_end, - int opt_end, char * const *nargv) -{ - int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; - char *swap; - - _DIAGASSERT(nargv != NULL); - - /* - * compute lengths of blocks and number and size of cycles - */ - nnonopts = panonopt_end - panonopt_start; - nopts = opt_end - panonopt_end; - ncycle = gcd(nnonopts, nopts); - cyclelen = (opt_end - panonopt_start) / ncycle; - - for (i = 0; i < ncycle; i++) { - cstart = panonopt_end+i; - pos = cstart; - for (j = 0; j < cyclelen; j++) { - if (pos >= panonopt_end) - pos -= nnonopts; - else - pos += nopts; - swap = nargv[pos]; - /* LINTED const cast */ - ((char **) nargv)[pos] = nargv[cstart]; - /* LINTED const cast */ - ((char **)nargv)[cstart] = swap; - } - } -} - -/* - * getopt_internal -- - * Parse argc/argv argument vector. Called by user level routines. - * Returns -2 if -- is found (can be long option or end of options marker). - */ -static int -getopt_internal(int nargc, char * const *nargv, const char *options) -{ - char *oli; /* option letter list index */ - int optchar; - - _DIAGASSERT(nargv != NULL); - _DIAGASSERT(options != NULL); - - optarg = NULL; - - /* - * XXX Some programs (like rsyncd) expect to be able to - * XXX re-initialize optind to 0 and have getopt_long(3) - * XXX properly function again. Work around this braindamage. - */ - if (optind == 0) - optind = 1; - - if (optreset) - nonopt_start = nonopt_end = -1; -start: - if (optreset || !*place) { /* update scanning pointer */ - optreset = 0; - if (optind >= nargc) { /* end of argument vector */ - place = EMSG; - if (nonopt_end != -1) { - /* do permutation, if we have to */ - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - else if (nonopt_start != -1) { - /* - * If we skipped non-options, set optind - * to the first of them. - */ - optind = nonopt_start; - } - nonopt_start = nonopt_end = -1; - return -1; - } - if ((*(place = nargv[optind]) != '-') - || (place[1] == '\0')) { /* found non-option */ - place = EMSG; - if (IN_ORDER) { - /* - * GNU extension: - * return non-option as argument to option 1 - */ - optarg = nargv[optind++]; - return INORDER; - } - if (!PERMUTE) { - /* - * if no permutation wanted, stop parsing - * at first non-option - */ - return -1; - } - /* do permutation */ - if (nonopt_start == -1) - nonopt_start = optind; - else if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - nonopt_start = optind - - (nonopt_end - nonopt_start); - nonopt_end = -1; - } - optind++; - /* process next argument */ - goto start; - } - if (nonopt_start != -1 && nonopt_end == -1) - nonopt_end = optind; - if (place[1] && *++place == '-') { /* found "--" */ - place++; - return -2; - } - } - if ((optchar = (int)*place++) == (int)':' || - (oli = (char *) strchr(options + (IGNORE_FIRST ? 1 : 0), - optchar)) == NULL) { - /* option letter unknown or ':' */ - if (!*place) - ++optind; -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(illoptchar, optchar); -#else - warnx(PRINT_ERROR, illoptchar, optchar); -#endif - optopt = optchar; - return BADCH; - } - if (optchar == 'W' && oli[1] == ';') { /* -W long-option */ - /* XXX: what if no long options provided (called by getopt)? */ - if (*place) - return -2; - - if (++optind >= nargc) { /* no arg */ - place = EMSG; -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(recargchar, optchar); -#else - warnx(PRINT_ERROR, recargchar, optchar); -#endif - optopt = optchar; - return BADARG; - } else /* white space */ - place = nargv[optind]; - /* - * Handle -W arg the same as --arg (which causes getopt to - * stop parsing). - */ - return -2; - } - if (*++oli != ':') { /* doesn't take argument */ - if (!*place) - ++optind; - } else { /* takes (optional) argument */ - optarg = NULL; - if (*place) /* no white space */ - optarg = place; - /* XXX: disable test for :: if PC? (GNU doesn't) */ - else if (oli[1] != ':') { /* arg not optional */ - if (++optind >= nargc) { /* no arg */ - place = EMSG; -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(recargchar, optchar); -#else - warnx(PRINT_ERROR, recargchar, optchar); -#endif - optopt = optchar; - return BADARG; - } else - optarg = nargv[optind]; - } - place = EMSG; - ++optind; - } - /* dump back option letter */ - return optchar; -} - -/* - * getopt -- - * Parse argc/argv argument vector. - * - * [eventually this will replace the real getopt] - */ -int -getopt(int nargc, char * const *nargv, const char *options) -{ - int retval; - - _DIAGASSERT(nargv != NULL); - _DIAGASSERT(options != NULL); - - if ((retval = getopt_internal(nargc, nargv, options)) == -2) { - ++optind; - /* - * We found an option (--), so if we skipped non-options, - * we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, optind, - nargv); - optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - retval = -1; - } - return retval; -} - -/* - * getopt_long -- - * Parse argc/argv argument vector. - */ -int -getopt_long(int nargc, - char * const *nargv, - const char *options, - const struct option *long_options, - int *idx) -{ - int retval; - - _DIAGASSERT(nargv != NULL); - _DIAGASSERT(options != NULL); - _DIAGASSERT(long_options != NULL); - /* idx may be NULL */ - - if ((retval = getopt_internal(nargc, nargv, options)) == -2) { - char *current_argv, *has_equal; - size_t current_argv_len; - int i, match; - - current_argv = place; - match = -1; - - optind++; - place = EMSG; - - if (*current_argv == '\0') { /* found "--" */ - /* - * We found an option (--), so if we skipped - * non-options, we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - return -1; - } - if ((has_equal = strchr(current_argv, '=')) != NULL) { - /* argument found (--option=arg) */ - current_argv_len = has_equal - current_argv; - has_equal++; - } else - current_argv_len = strlen(current_argv); - - for (i = 0; long_options[i].name; i++) { - /* find matching long option */ - if (strncmp(current_argv, long_options[i].name, - current_argv_len)) - continue; - - if (strlen(long_options[i].name) == - (unsigned)current_argv_len) { - /* exact match */ - match = i; - break; - } - if (match == -1) /* partial match */ - match = i; - else { - /* ambiguous abbreviation */ -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(ambig, (int)current_argv_len, - current_argv); -#else - warnx(PRINT_ERROR, ambig, (int)current_argv_len, - current_argv); -#endif - optopt = 0; - return BADCH; - } - } - if (match != -1) { /* option found */ - if (long_options[match].has_arg == no_argument - && has_equal) { -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(noarg, (int)current_argv_len, - current_argv); -#else - warnx(PRINT_ERROR, noarg, (int)current_argv_len, - current_argv); -#endif - /* - * XXX: GNU sets optopt to val regardless of - * flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - return BADARG; - } - if (long_options[match].has_arg == required_argument || - long_options[match].has_arg == optional_argument) { - if (has_equal) - optarg = has_equal; - else if (long_options[match].has_arg == - required_argument) { - /* - * optional argument doesn't use - * next nargv - */ - optarg = nargv[optind++]; - } - } - if ((long_options[match].has_arg == required_argument) - && (optarg == NULL)) { - /* - * Missing argument; leading ':' - * indicates no error should be generated - */ -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(recargstring, current_argv); -#else - warnx(PRINT_ERROR, recargstring, current_argv); -#endif - /* - * XXX: GNU sets optopt to val regardless - * of flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - --optind; - return BADARG; - } - } else { /* unknown option */ -#ifndef _WIN32 - if (PRINT_ERROR) - warnx(illoptstring, current_argv); -#else - warnx(PRINT_ERROR, illoptstring, current_argv); -#endif - optopt = 0; - return BADCH; - } - if (long_options[match].flag) { - *long_options[match].flag = long_options[match].val; - retval = 0; - } else - retval = long_options[match].val; - if (idx) - *idx = match; - } - return retval; -} -#endif /* !GETOPT_LONG */ diff --git a/src/bin/win32/getopt.h b/src/bin/win32/getopt.h deleted file mode 100644 index f6b65a504..000000000 --- a/src/bin/win32/getopt.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _GETOPT_H_ -#define _GETOPT_H_ - -#ifdef _WIN32 -/* from */ -# ifdef __cplusplus -# define __BEGIN_DECLS extern "C" { -# define __END_DECLS } -# else -# define __BEGIN_DECLS -# define __END_DECLS -# endif -# define __P(args) args -#endif - -/*#ifndef _WIN32 -#include -#include -#endif*/ - -/* - * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions - */ -#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -struct option { - /* name of long option */ - const char *name; - /* - * one of no_argument, required_argument, and optional_argument: - * whether option takes an argument - */ - int has_arg; - /* if not NULL, set *flag to val when option found */ - int *flag; - /* if flag not NULL, value to set *flag to; else return value */ - int val; -}; - -__BEGIN_DECLS -int getopt_long __P((int, char * const *, const char *, - const struct option *, int *)); -__END_DECLS -#endif - -#ifdef _WIN32 -/* These are global getopt variables */ -__BEGIN_DECLS - -extern int opterr, /* if error message should be printed */ - optind, /* index into parent argv vector */ - optopt, /* character checked for validity */ - optreset; /* reset getopt */ -extern char* optarg; /* argument associated with option */ - -/* Original getopt */ -int getopt __P((int, char * const *, const char *)); - -__END_DECLS -#endif - -#endif /* !_GETOPT_H_ */ diff --git a/src/lib/object_store/SessionObjectStore.cpp b/src/lib/object_store/SessionObjectStore.cpp index 193536838..13adb18fb 100644 --- a/src/lib/object_store/SessionObjectStore.cpp +++ b/src/lib/object_store/SessionObjectStore.cpp @@ -70,14 +70,21 @@ SessionObjectStore::~SessionObjectStore() MutexFactory::i()->recycleMutex(storeMutex); } -// Retrieve objects -std::set SessionObjectStore::getObjects() +int SessionObjectStore::getObjectCount() { - // Make sure that no other thread is in the process of changing - // the object list when we return it - MutexLocker lock(storeMutex); + return objects.size(); +} - return objects; +void SessionObjectStore::getObjects(std::set &inObjects) +{ + // Make sure that no other thread is in the process of changing + // the object list when we return it + MutexLocker lock(storeMutex); + + std::set::iterator it; + for (it=objects.begin(); it!=objects.end(); ++it) { + inObjects.insert(*it); + } } void SessionObjectStore::getObjects(CK_SLOT_ID slotID, std::set &inObjects) diff --git a/src/lib/object_store/SessionObjectStore.h b/src/lib/object_store/SessionObjectStore.h index 2ec4bc58f..196b447cf 100644 --- a/src/lib/object_store/SessionObjectStore.h +++ b/src/lib/object_store/SessionObjectStore.h @@ -52,8 +52,11 @@ class SessionObjectStore // Constructor SessionObjectStore(); - // Retrieve objects - std::set getObjects(); + // Return the total number of objects in the store + int getObjectCount(); + + // Insert the session objects into the given OSObject set + void getObjects(std::set &inObjects); // Insert the session objects for the given slotID into the given OSObject set void getObjects(CK_SLOT_ID slotID, std::set &inObjects); diff --git a/src/lib/object_store/test/SessionObjectStoreTests.cpp b/src/lib/object_store/test/SessionObjectStoreTests.cpp index 2c41eb0de..62439aeb4 100644 --- a/src/lib/object_store/test/SessionObjectStoreTests.cpp +++ b/src/lib/object_store/test/SessionObjectStoreTests.cpp @@ -76,13 +76,14 @@ void SessionObjectStoreTests::testCreateDeleteObjects() obj3->setAttribute(CKA_ID, idAtt[2]); // Check that the store contains 3 objects - CPPUNIT_ASSERT(testStore->getObjects().size() == 3); + CPPUNIT_ASSERT(testStore->getObjectCount() == 3); // Check that all three objects are distinct and present - std::set objects = testStore->getObjects(); + std::set objects; + testStore->getObjects(objects); bool present1[3] = { false, false, false }; - for (std::set::iterator i = objects.begin(); i != objects.end(); i++) + for (std::set::iterator i = objects.begin(); i != objects.end(); i++) { ByteString retrievedId; @@ -106,10 +107,8 @@ void SessionObjectStoreTests::testCreateDeleteObjects() } // Now delete the second object - for (std::set::iterator i = objects.begin(); i != objects.end(); i++) + for (std::set::iterator i = objects.begin(); i != objects.end(); i++) { - ByteString retrievedId; - CPPUNIT_ASSERT((*i)->isValid()); CPPUNIT_ASSERT((*i)->attributeExists(CKA_ID)); @@ -117,21 +116,20 @@ void SessionObjectStoreTests::testCreateDeleteObjects() if ((*i)->getAttribute(CKA_ID).getByteStringValue() == id[1]) { - CPPUNIT_ASSERT(testStore->deleteObject(*i)); + CPPUNIT_ASSERT(testStore->deleteObject(static_cast(*i))); break; } } // Verify that it was indeed removed - CPPUNIT_ASSERT(testStore->getObjects().size() == 2); + CPPUNIT_ASSERT(testStore->getObjectCount() == 2); - objects = testStore->getObjects(); + objects.clear(); + testStore->getObjects(objects); bool present3[2] = { false, false }; - for (std::set::iterator i = objects.begin(); i != objects.end(); i++) + for (std::set::iterator i = objects.begin(); i != objects.end(); i++) { - ByteString retrievedId; - CPPUNIT_ASSERT((*i)->isValid()); CPPUNIT_ASSERT((*i)->attributeExists(CKA_ID)); @@ -161,7 +159,7 @@ void SessionObjectStoreTests::testMultiSession() SessionObjectStore* store = new SessionObjectStore(); // Check that the store is empty - CPPUNIT_ASSERT(store->getObjects().size() == 0); + CPPUNIT_ASSERT(store->getObjectCount() == 0); // Test IDs ByteString id[5] = { "112233445566", "AABBCCDDEEFF", "ABABABABABAB", "557788991122", "005500550055" }; @@ -181,13 +179,14 @@ void SessionObjectStoreTests::testMultiSession() obj3->setAttribute(CKA_ID, idAtt[2]); // Check that the store contains 3 objects - CPPUNIT_ASSERT(store->getObjects().size() == 3); + CPPUNIT_ASSERT(store->getObjectCount() == 3); // Check that all three objects are distinct and present - std::set objects = store->getObjects(); + std::set objects; + store->getObjects(objects); bool present1[3] = { false, false, false }; - for (std::set::iterator i = objects.begin(); i != objects.end(); i++) + for (std::set::iterator i = objects.begin(); i != objects.end(); i++) { ByteString retrievedId; @@ -214,12 +213,13 @@ void SessionObjectStoreTests::testMultiSession() store->sessionClosed(2); // Verify that it was indeed removed - CPPUNIT_ASSERT(store->getObjects().size() == 2); + CPPUNIT_ASSERT(store->getObjectCount() == 2); - objects = store->getObjects(); + objects.clear(); + store->getObjects(objects); bool present3[2] = { false, false }; - for (std::set::iterator i = objects.begin(); i != objects.end(); i++) + for (std::set::iterator i = objects.begin(); i != objects.end(); i++) { ByteString retrievedId; @@ -249,14 +249,15 @@ void SessionObjectStoreTests::testMultiSession() SessionObject* obj5 = store->createObject(1, 7); CPPUNIT_ASSERT(obj5 != NULL); - CPPUNIT_ASSERT(store->getObjects().size() == 4); + CPPUNIT_ASSERT(store->getObjectCount() == 4); // Close session 1 store->sessionClosed(1); - CPPUNIT_ASSERT(store->getObjects().size() == 3); + CPPUNIT_ASSERT(store->getObjectCount() == 3); - objects = store->getObjects(); + objects.clear(); + store->getObjects(objects); CPPUNIT_ASSERT(objects.find(obj1) == objects.end()); CPPUNIT_ASSERT(objects.find(obj2) == objects.end()); @@ -273,9 +274,10 @@ void SessionObjectStoreTests::testMultiSession() // Close session 7 store->sessionClosed(7); - CPPUNIT_ASSERT(store->getObjects().size() == 1); + CPPUNIT_ASSERT(store->getObjectCount() == 1); - objects = store->getObjects(); + objects.clear(); + store->getObjects(objects); CPPUNIT_ASSERT(objects.find(obj1) == objects.end()); CPPUNIT_ASSERT(objects.find(obj2) == objects.end()); @@ -298,7 +300,7 @@ void SessionObjectStoreTests::testWipeStore() SessionObjectStore* store = new SessionObjectStore(); // Check that the store is empty - CPPUNIT_ASSERT(store->getObjects().size() == 0); + CPPUNIT_ASSERT(store->getObjectCount() == 0); // Create 3 objects in the store for three different sessions SessionObject* obj1 = store->createObject(1, 1); @@ -312,7 +314,7 @@ void SessionObjectStoreTests::testWipeStore() store->clearStore(); // Check that the store is empty - CPPUNIT_ASSERT(store->getObjects().size() == 0); + CPPUNIT_ASSERT(store->getObjectCount() == 0); delete store; } diff --git a/testing/appveyor/APPVEYOR-NOTES.MD b/testing/appveyor/APPVEYOR-NOTES.MD deleted file mode 100644 index b2347b073..000000000 --- a/testing/appveyor/APPVEYOR-NOTES.MD +++ /dev/null @@ -1,27 +0,0 @@ -# AppVeyor integration with SoftHSMv2 on GitHub - -This document describes the process of integrating AppVeyor with SoftHSMv2 on GitHub. - -## Integration - -### Add project - -To add the project, click on the following: - -1. New Project -2. GitHub -3. opendnssec -> SoftHSMv2 -> Add - -### Settings - -The following settings where changed. - -#### General - -* Custom configuration .yml file name: .appveyor.yml -* Skip branches without appveyor.yml: check - -## Dependencies - -Prebuilt dependencies (OpenSSL and CppUnit) are currently hosted in a dedicated -repository by [disig/SoftHSM2-AppVeyor](https://github.com/disig/SoftHSM2-AppVeyor/) diff --git a/testing/appveyor/appveyor_build.bat b/testing/appveyor/appveyor_build.bat deleted file mode 100644 index 4e7f41f7b..000000000 --- a/testing/appveyor/appveyor_build.bat +++ /dev/null @@ -1,51 +0,0 @@ -setlocal - -echo "Setting visual studio variables" - -call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %VCVARS_PLATFORM% -@echo on - -echo "Setting PATH and other variables" -set cur_dir=%CD% -set PATH=%PATH%;%PYTHON_PATH% - -echo %cur_dir% -cd win32 - -python Configure.py %CONFIGURE_OPTIONS% || goto :error - -msbuild softhsm2.sln /p:Configuration="Release" /p:Platform="%MSBUILD_PLATFORM%" /p:PlatformToolset=v140 /target:Build || goto :error - -cd %cur_dir% - -IF "%ENV_PLATFORM%"=="x86" (set from_dir=%CD%\win32\Release) ELSE (set from_dir=%CD%\win32\x64\Release) - -echo "Testing build" - -cd %from_dir% -cryptotest.exe || goto :error -datamgrtest.exe || goto :error -handlemgrtest.exe || goto :error -objstoretest.exe || goto :error -p11test.exe || goto :error -sessionmgrtest.exe || goto :error -slotmgrtest.exe || goto :error - -echo "Preparing output package" -copy %from_dir%\softhsm2.dll %RELEASE_DIR% || goto :error -copy %from_dir%\softhsm2-dump-file.exe %RELEASE_DIR% || goto :error -copy %from_dir%\softhsm2-keyconv.exe %RELEASE_DIR% || goto :error -copy %from_dir%\softhsm2-util.exe %RELEASE_DIR% || goto :error -copy %cur_dir%\src\lib\common\softhsm2.conf.in %RELEASE_DIR%\softhsm2.conf || goto :error - -dir %RELEASE_DIR% - -@echo *** BUILD SUCCESSFUL *** -endlocal -@exit /b 0 - - -:error -@echo *** BUILD FAILED *** -endlocal -@exit /b 1 diff --git a/testing/appveyor/appveyor_download_requirements.ps1 b/testing/appveyor/appveyor_download_requirements.ps1 deleted file mode 100644 index 7e0e192c5..000000000 --- a/testing/appveyor/appveyor_download_requirements.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -Add-Type -AssemblyName System.IO.Compression.FileSystem -function Unzip -{ - param([string]$zipfile, [string]$outpath) - - [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) -} - -$CURRENT_DIR_PATH = (Get-Item -Path ".\" -Verbose).FullName -$BUILD_DIR = Join-Path $CURRENT_DIR_PATH build - -#prepare directories -Write-Host "Preparing directories" - -$exists = Test-Path build -if ($exists -eq $false) { - mkdir build -} -cd build - -$exists = Test-Path $env:RELEASE_DIR -if ($exists -eq $false) { - mkdir $env:RELEASE_DIR -} - -$exists = Test-Path python -if ($exists -eq $true) { - Remove-Item python -recurse -} - -$exists = Test-Path "$env:CPPUNIT_PATH" -if ($exists -eq $true) { - Remove-Item "$env:CPPUNIT_PATH" -recurse -} - -$exists = Test-Path "$env:CRYPTO_PACKAGE_PATH" -if ($exists -eq $true) { - Remove-Item "$env:CRYPTO_PACKAGE_PATH" -recurse -} - -mkdir python - -Write-Host "Preparing directories - OK" - -Write-Host "Downloading needed tools and dependencies" - -[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" - -$exists = Test-Path "$env:CRYPTO_PACKAGE_NAME" -if ($exists -eq $false) { - $source = "https://github.com/disig/SoftHSM2-AppVeyor/raw/master/$env:PACKAGE_VERSION_NAME/$env:CRYPTO_PACKAGE" - Invoke-WebRequest $source -OutFile $env:CRYPTO_PACKAGE -} - -$exists = Test-Path "$env:CPPUNIT_PACKAGE" -if ($exists -eq $false) { - $source = "https://github.com/disig/SoftHSM2-AppVeyor/raw/master/$env:CPPUNIT_VERSION_NAME/$env:CPPUNIT_PACKAGE" - Invoke-WebRequest $source -OutFile $env:CPPUNIT_PACKAGE -} - -$exists = Test-Path python-3.5.2-embed-win32.zip -if ($exists -eq $false) { - $source = "https://www.python.org/ftp/python/3.5.2/python-3.5.2-embed-win32.zip" - Invoke-WebRequest $source -OutFile python-3.5.2-embed-win32.zip -} - -Write-Host "Downloading needed tools and dependencies - OK" - -Write-Host "Extracting ..." -Unzip "$BUILD_DIR/python-3.5.2-embed-win32.zip" "$env:PYTHON_PATH" - -Unzip "$BUILD_DIR/$env:CRYPTO_PACKAGE" "$BUILD_DIR" - -Unzip "$BUILD_DIR/$env:CPPUNIT_PACKAGE" "$BUILD_DIR" - -dir - -dir "$env:PYTHON_PATH" -dir "$env:CRYPTO_PACKAGE_PATH" -dir "$env:CPPUNIT_PATH" - -cd $CURRENT_DIR_PATH diff --git a/win32/Configure.py b/win32/Configure.py deleted file mode 100644 index cd0786429..000000000 --- a/win32/Configure.py +++ /dev/null @@ -1,1243 +0,0 @@ -#!python - -# Configure -- python version -# -# this script builds Visual Studio files - -from __future__ import print_function - -import sys -import os -import os.path -import re -import subprocess - -# files to configure - -filelist = ["config.h", - "softhsm2.sln", - "convarch\\convarch.vcxproj.filters", - "convarch\\convarch.vcxproj", - "cryptotest\\cryptotest.vcxproj", - "datamgrtest\\datamgrtest.vcxproj", - "dump\\dump.vcxproj", - "handlemgrtest\\handlemgrtest.vcxproj", - "keyconv\\keyconv.vcxproj.filters", - "keyconv\\keyconv.vcxproj", - "objstoretest\\objstoretest.vcxproj", - "p11test\\p11test.vcxproj", - "sessionmgrtest\\sessionmgrtest.vcxproj", - "slotmgrtest\\slotmgrtest.vcxproj", - "softhsm2\\softhsm2.vcxproj", - "util\\util.vcxproj.filters", - "util\\util.vcxproj"] - -# test files -testlist = ["botan", - "ecc", - "eddsa", - "gnump", - "gost", - "ossl", - "osslv", - "rawpss", - "rfc3394", - "rfc5649"] - -# variables to expand - -varvals = {} - -varnames = ["CUINCPATH", - "CULIBPATH", - "DEBUGDLLPATH", - "DEBUGINCPATH", - "DEBUGLIBPATH", - "DLLPATH", - "EXTRALIBS", - "INCLUDEPATH", - "LIBNAME", - "LIBPATH", - "PLATFORM", - "PLATFORMDIR", - "PLATFORMTOOLSET", - "RUNTIMELIBRARY"] - -# conditions to stack - -condvals = {} - -condnames = ["AESGCM", - "BOTAN", - "ECC", - "EDDSA", - "GOST", - "NONPAGE", - "OPENSSL", - "RAWPSS", - "RFC3394", - "RFC5649", - "TESTS"] - -# enable-xxx/disable-xxx arguments - -enablelist = ["64bit", - "debug", - "ecc", - "eddsa", - "gost", - "keep", - "non-paged-memory", - "static-runtime", - "verbose"] - -# with-xxx/without-xxx arguments - -withlist = ["botan", - "cppunit", - "crypto-backend", - "debug-botan", - "debug-openssl", - "openssl", - "toolset"] - -# general commands - -commandlist = ["help", "clean"] # verbose, keep - -# usage - -usage = ["Usage: python Configure.py help", - " python Configure.py options*", - " python Configure.py clean"] - -# help - -myhelp = ["'python Configure.py' configures SoftHSMv2 build files.\n"] +\ -usage + [\ -"\nGeneral Commands:", -" help print this help", -" clean clean up generated files", -" print a summary of the configuration", -"\nOptional Features:", -" enable-verbose print messages [default=no]", -" enable-keep keep test files after config [default=no]", -" enable-64bit enable 64-bit compiling [default=no]", -" enable-debug enable build of Debug config [default=yes]", -" enable-ecc enable support for ECC [default=yes]", -" enable-eddsa enable support for EDDSA [default=yes]", -" enable-gost enable support for GOST [default=yes]", -" enable-static-runtime enable build with static CRT (/MT) [default=no]", -" enable-non-paged-memory enable non-paged memory [default=yes]", -"\nOptional Packages:", -" with-crypto-backend select the crypto backend [openssl|botan]", -" with-botan=PATH speficy prefix of path of Botan (Release)", -" with-debug-botan=PATH speficy prefix of path of Botan (Debug)", -" with-openssl=PATH speficy prefix of path of OpenSSL (Release)", -" with-debug-openssl=PATH speficy prefix of path of OpenSSL (Debug)", -" with-cppunit=PATH specify prefix of path of CppUnit", -" with-toolset=VALUE set Visual Studio platform toolset version (eg v110 for vs2012)", -] - -# variables for parsing - -verbose = False -configargs = None -want_help = False -want_clean = False -want_unknown = False -unknown_value = None -enable_keep = False -enable_debug = True -enable_ecc = True -enable_eddsa = True -enable_gost = True -enable_static_runtime = False -enable_non_paged = True -platform = 32 -crypto_backend = "openssl" -botan_path = "..\\..\\btn" -debug_botan_path = None -openssl_path = "..\\..\\ssl" -debug_openssl_path = None -want_tests = True -cppunit_path = "..\\..\\cu" -toolset = "" - -def dodetectplatform(visualstudio): - # detect platform tool set >= VS2010 - global toolset - - if "Microsoft Visual Studio 10.0" in visualstudio: - toolset="v100" - elif "Microsoft Visual Studio 11.0" in visualstudio: - toolset="v110" - elif "Microsoft Visual Studio 12.0" in visualstudio: - toolset="v120" - elif "Microsoft Visual Studio 14.0" in visualstudio: - toolset="v140" - elif "Microsoft Visual Studio\\2017" in visualstudio: - toolset="v141" - else: - print("PlatformToolset for \""+visualstudio+"\" not supported") - toolset="" - -def dodetectvisualstudio(): - """detect visual studio version""" - if os.environ.get('VSINSTALLDIR'): - dodetectplatform(os.environ.get('VSINSTALLDIR')) - -def parseargs(args): - """parse arguments""" - global verbose - global enable_keep - global want_help - global want_clean - global want_unknown - global unknown_value - global debug_botan_path - global debug_openssl_path - for arg in args: - if arg.lower() == "verbose": - verbose = True - continue - if arg.lower() == "keep": - enable_keep = True - continue - if arg.lower() == "help": - want_help = True - continue - di = re.match(r'disable-(.*)', arg, re.I) - if di: - appargs(arg) - myenable(di.group(1), False) - continue - en = re.match(r'enable-(.*)', arg, re.I) - if en: - appargs(arg) - myenable(en.group(1), True) - continue - wo = re.match(r'without-(.*)', arg, re.I) - if wo: - appargs(arg) - mywith(wo.group(1), False) - continue - wv = re.match(r'with-(.*)=(.*)', arg, re.I) - if wv: - appargs(arg) - if wv.group(2).lower() == "no": - mywith(wv.group(1), False) - continue - mywith(wv.group(1), True, wv.group(2)) - continue - wi = re.match(r'with-(.*)', arg, re.I) - if wi: - appargs(arg) - mywith(wi.group(1), True) - continue - if arg.lower() == "clean": - want_clean = True - continue - want_unknown = True - unknown_value = arg - break - - # debug - if enable_debug: - if debug_botan_path is None: - debug_botan_path = botan_path + "_d" - if debug_openssl_path is None: - debug_openssl_path = openssl_path + "_d" - -def appargs(arg): - """append seen arguments to configargs""" - global configargs - # escape backslashes, spaces and double quotes - escaped = "" - - for x in arg: - if (x == "\\") or (x == " ") or (x == "\""): - escaped += "\\" - escaped += x - if configargs: - configargs += " " + escaped - else: - configargs = escaped - -def myenable(key, val): - """parse enable/disable""" - global platform - global enable_debug - global enable_ecc - global enable_eddsa - global enable_gost - global enable_static_runtime - global enable_non_paged - global enable_keep - global verbose - global want_unknown - global unknown_value - if key.lower() == "64bit": - if val: - platform = 64 - return - if key.lower() == "debug": - if not val: - enable_debug = False - return - if key.lower() == "ecc": - if not val: - enable_ecc = False - return - if key.lower() == "eddsa": - if not val: - enable_eddsa = False - return - if key.lower() == "gost": - if not val: - enable_gost = False - return - if key.lower() == "static-runtime": - if val: - enable_static_runtime = True - return - if key.lower() == "non-paged-memory": - if not val: - enable_non_paged = False - return - if key.lower() == "keep": - if val: - enable_keep = True - return - if key.lower() == "verbose": - if val: - verbose = True - return - want_unknown = True - if not val: - unknown_value = "disable-" + key - else: - unknown_value = "enable-" + key - -def mywith(key, val, detail=None): - """parse with/without""" - global crypto_backend - global botan_path - global debug_botan_path - global openssl_path - global debug_openssl_path - global want_tests - global cppunit_path - global want_unknown - global unknown_value - global toolset - - if key.lower() == "crypto-backend": - if val and (detail.lower() == "openssl"): - crypto_backend = "openssl" - return - if val and (detail.lower() == "botan"): - crypto_backend = "botan" - return - want_unknown = True - unknown_value = "with-crypto-backend=" + detail - return - if key.lower() == "botan": - if not val: - want_unknown = True - unknown_value = "without-botan doesn't make sense" - return - if detail.lower() != "yes": - botan_path = detail - return - if key.lower() == "debug-botan": - if not val: - want_unknown = True - unknown_value = "without-debug-botan doesn't make sense" - return - if detail.lower() != "yes": - debug_botan_path = detail - return - if key.lower() == "openssl": - if not val: - want_unknown = True - unknown_value = "without-openssl doesn't make sense" - return - if detail.lower() != "yes": - openssl_path = detail - return - if key.lower() == "debug-openssl": - if not val: - want_unknown = True - unknown_value = "without-debug-openssl doesn't make sense" - return - if detail.lower() != "yes": - debug_openssl_path = detail - return - if key.lower() == "cppunit": - if not val: - want_tests = False - return - if detail.lower() != "yes": - cppunit_path = detail - return - if key.lower() == "toolset": - if not val: - want_tests = False - return - if detail: - toolset=detail.lower() - return - want_unknown = True - if not val: - unknown_value = "without-" + key - else: - unknown_value = "with-" + key - -def dohelp(): - """help""" - for line in myhelp: - print(line) - sys.exit(1) - -def docleantest(): - """clean test files""" - for basename in testlist: - filename = "test" + basename + ".c" - if os.path.isfile(filename): - os.unlink(filename) - filename = "test" + basename + ".cpp" - if os.path.isfile(filename): - os.unlink(filename) - filename = "test" + basename + ".obj" - if os.path.isfile(filename): - os.unlink(filename) - filename = "test" + basename + ".exe" - if os.path.isfile(filename): - os.unlink(filename) - if os.path.isfile("botan.dll"): - os.unlink("botan.dll") - if os.path.isfile("libeay32.dll"): - os.unlink("libeay32.dll") - if os.path.isfile("libeaycompat32.dll"): - os.unlink("libeaycompat32.dll") - if os.path.isfile("libcrypto-1_1.dll"): - os.unlink("libcrypto-1_1.dll") - if os.path.isfile("libcrypto-1_1-x64.dll"): - os.unlink("libcrypto-1_1-x64.dll") - -def doclean(): - """clean""" - docleantest() - for filename in filelist: - if os.path.isfile(filename): - os.unlink(filename) - sys.exit(0) - -def dounknown(): - """parsing error""" - print("can't parse " + unknown_value + "", file=sys.stderr) - sys.exit(1) - -def doconfig(): - """config itself""" - global botan_path - global debug_botan_path - global openssl_path - global debug_openssl_path - global cppunit_path - - # configure the platform - if platform == 32: - varvals["PLATFORM"] = "Win32" - else: - varvals["PLATFORM"] = "x64" - varvals["PLATFORMDIR"] = "x64\\" - - # configure the runtime library - if enable_static_runtime: - varvals["RUNTIMELIBRARY"] = "MultiThreaded" - else: - varvals["RUNTIMELIBRARY"] = "MultiThreadedDLL" - - # configure ECC, EDDSA, and GOST - if enable_ecc: - condvals["ECC"] = True - if enable_eddsa: - condvals["EDDSA"] = True - if enable_gost: - condvals["GOST"] = True - - # configure the crypto - if crypto_backend == "botan": - condvals["BOTAN"] = True - varvals["LIBNAME"] = "botan.lib" - botan_path = os.path.abspath(botan_path) - botan_inc = os.path.join(botan_path, "include") - botan_dll = "" - if os.path.exists(os.path.join(botan_inc, "botan-2\\botan\\init.h")): - varvals["INCLUDEPATH"] = os.path.join(botan_inc, "botan-2") - elif os.path.exists(os.path.join(botan_inc, "botan-1.11\\botan\\init.h")): - varvals["INCLUDEPATH"] = os.path.join(botan_inc, "botan-1.11") - elif os.path.exists(os.path.join(botan_inc, "botan\\init.h")): - varvals["INCLUDEPATH"] = botan_inc - else: - print("can't find Botan includes", file=sys.stderr) - sys.exit(1) - if os.path.exists(os.path.join(botan_path, "lib\\botan.lib")): - varvals["LIBPATH"] = os.path.join(botan_path, "lib") - botan_dll = os.path.join(botan_path, "lib\\botan.dll") - elif os.path.exists(os.path.join(botan_path, "botan.lib")): - varvals["LIBPATH"] = botan_path - botan_dll = os.path.join(botan_path, "botan.dll") - else: - print("can't find Botan library", file=sys.stderr) - sys.exit(1) - varvals["DLLPATH"] = botan_dll - if enable_debug: - debug_botan_path = os.path.abspath(debug_botan_path) - debug_botan_inc = os.path.join(debug_botan_path, "include") - debug_botan_dll = "" - if os.path.exists(os.path.join(debug_botan_inc, "botan-2\\botan\\init.h")): - varvals["DEBUGINCPATH"] = os.path.join(debug_botan_inc, "botan-2") - elif os.path.exists(os.path.join(debug_botan_inc, "botan-1.11\\botan\\init.h")): - varvals["DEBUGINCPATH"] = os.path.join(debug_botan_inc, "botan-1.11") - elif os.path.exists(os.path.join(debug_botan_inc, "botan\\init.h")): - varvals["DEBUGINCPATH"] = debug_botan_inc - else: - print("can't find debug Botan includes", file=sys.stderr) - sys.exit(1) - if os.path.exists(os.path.join(debug_botan_path, "lib\\botan.lib")): - varvals["DEBUGLIBPATH"] = os.path.join(debug_botan_path, "lib") - debug_botan_dll = os.path.join(debug_botan_path, "lib\\botan.dll") - if os.path.exists(os.path.join(debug_botan_path, "botan.lib")): - varvals["DEBUGLIBPATH"] = debug_botan_path - debug_botan_dll = os.path.join(debug_botan_path, "botan.dll") - else: - print("can't find debug Botan library", file=sys.stderr) - sys.exit(1) - varvals["DEBUGDLLPATH"] = debug_botan_dll - else: - varvals["DEBUGDLLPATH"] = varvals["DLLPATH"] - varvals["DEBUGINCPATH"] = varvals["INCLUDEPATH"] - varvals["DEBUGLIBPATH"] = varvals["LIBPATH"] - - # Botan version - if verbose: - print("checking Botan version") - botan_version_major = 0 - botan_version_minor = 0 - system_libs = [] - if os.path.exists(botan_dll): - subprocess.call(["copy", botan_dll, "."], shell=True) - else: - system_libs = ["user32.lib", "advapi32.lib"] - inc = varvals["INCLUDEPATH"] - lib = os.path.join(varvals["LIBPATH"], "botan.lib") - testfile = open("testbotan.cpp", "w") - print('\ -#include \n\ -int main() {\n\ -#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(2,0,0)\n\ - return 3;\n\ -#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\ - return 2;\n\ -#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)\n\ - return 1;\n\ -#else\n\ - return 0;\n\ -#endif\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testbotan.cpp", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testbotan.exe"): - print("can't create .\\testbotan.exe", file=sys.stderr) - sys.exit(1) - ret = subprocess.call(".\\testbotan.exe") - if ret == 0: - print("Botan version too old", file=sys.stderr) - sys.exit(1) - elif ret == 1: - botan_version_major = 1 - botan_version_minor = 10 - elif ret == 2: - botan_version_major = 1 - botan_version_minor = 11 - print("Botan version 1.11 not yet supported", file=sys.stderr) - sys.exit(1) - elif ret == 3: - botan_version_major = 2 - botan_version_minor = 0 - print("Botan version 2.0 not yet supported", file=sys.stderr) - sys.exit(1) - else: - print("Botan test failed", file=sys.stderr) - sys.exit(1) - - # Botan ECC support - if enable_ecc: - if verbose: - print("checking Botan ECC support") - testfile = open("testecc.cpp", "w") - print('\ -#include \n\ -#include \n\ -#include \n\ -#include \n\ -int main() {\n\ - Botan::LibraryInitializer::initialize();\n\ - const std::string name("secp256r1");\n\ - const Botan::OID oid(Botan::OIDS::lookup(name));\n\ - const Botan::EC_Group ecg(oid);\n\ - try {\n\ -#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\ - const std::vector der =\n\ - ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\ -#else\n\ - const Botan::SecureVector der =\n\ - ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\ -#endif\n\ - } catch(...) {\n\ - return 1;\n\ - }\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testecc.cpp", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testecc.exe"): - print("can't create .\\testecc.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testecc.exe") != 0: - print("can't find P256: upgrade to Botan >= 1.10.6", file=sys.stderr) - sys.exit(1) - - # Botan EDDSA support - if enable_eddsa: - if verbose: - print("checking Botan EDDSA support") - testfile = open("testeddsa.cpp", "w") - print('\ -#include \n\ -#include \n\ -#include \n\ -int main() {\n\ - Botan::secure_vector k(32);\n\ - try {\n\ - Botan::Ed25519_PrivateKey* key =\n\ - new Botan::Ed25519_PrivateKey(k);\n\ - } catch(...) {\n\ - return 1;\n\ - }\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testeddsa.cpp", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testeddsa.exe"): - print("can't create .\\testeddsa.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testeddsa.exe") != 0: - print("can't find EDDSA: upgrade to Botan >= 2.2.0", file=sys.stderr) - sys.exit(1) - - # Botan GOST support - if enable_gost: - if verbose: - print("checking Botan GOST support") - testfile = open("testgost.cpp", "w") - print('\ -#include \n\ -#include \n\ -#include \n\ -#include \n\ -int main() {\n\ - Botan::LibraryInitializer::initialize();\n\ - const std::string name("gost_256A");\n\ - const Botan::OID oid(Botan::OIDS::lookup(name));\n\ - const Botan::EC_Group ecg(oid);\n\ - try {\n\ -#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\ - const std::vector der =\n\ - ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\ -#else\n\ - const Botan::SecureVector der =\n\ - ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\ -#endif\n\ - } catch(...) {\n\ - return 1;\n\ - }\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testgost.cpp", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testgost.exe"): - print("can't create .\\testgost.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testgost.exe") != 0: - print("can't find GOST: upgrade to Botan >= 1.10.6", file=sys.stderr) - sys.exit(1) - - # no check for Botan RFC3394 support - condvals["RFC3394"] = True - - # Botan RFC5649 support - if verbose: - print("checking Botan RFC5649 support") - testfile = open("testrfc5649.cpp", "w") - print('\ -#include \n\ -#include \n\ -#include \n\ -using namespace Botan;\n\ -int main() {\n\ -#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\ - secure_vector key(10);\n\ - SymmetricKey kek("AABB");\n\ - secure_vector x = rfc5649_keywrap(key, kek);\n\ -#else\n\ - SecureVector key(10);\n\ - SymmetricKey kek("AABB");\n\ - Algorithm_Factory& af = global_state().algorithm_factory();\n\ - SecureVector x = rfc5649_keywrap(key, kek, af);\n\ -#endif\n\ - return 1;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/EHsc","/I", inc, "testrfc5649.cpp", lib] - command.extend(system_libs) - subprocess.call(command) - if os.path.exists(".\\testrfc5649.exe"): - if verbose: - print("Found AES key wrap with pad") - condvals["RFC5649"] = True - else: - if verbose: - print("can't compile Botan AES key wrap with pad") - - # Botan GNU MP support - if botan_version_major == 1 and botan_version_minor == 10: - if verbose: - print("checking Botan GNU MP support") - testfile = open("testgnump.cpp", "w") - print('\ -#include \n\ -int main() {\n\ -#ifndef BOTAN_HAS_ENGINE_GNU_MP\n\ -#error "No GNU MP support";\n\ -#endif\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testgnump.cpp", lib] - command.extend(system_libs) - subprocess.call(command) - if os.path.exists(".\\testgnump.exe"): - if verbose: - print("Botan GNU MP is supported") - else: - if verbose: - print("Botan GNU MP is not supported") - - # Botan raw PSS support - if verbose: - print("checking Botan raw PSS support") - testfile = open("testrawpss.cpp", "w") - print('\ -#include \n\ -#include \n\ -int main() {\n\ -#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(2,3,0)\n\ - return 0;\n\ -#endif\n\ - return 1;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testrawpss.cpp", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testrawpss.exe"): - if verbose: - print("can't create .\\testrawpss.exe", file=sys.stderr) - else: - if subprocess.call(".\\testrawpss.exe") != 0: - if verbose: - print("can't find raw PSS: upgrade to Botan >= 2.3.0", file=sys.stderr) - else: - condvals["RAWPSS"] = True - - else: - - condvals["OPENSSL"] = True - varvals["EXTRALIBS"] = "crypt32.lib;ws2_32.lib;" - openssl_path = os.path.abspath(openssl_path) - openssl_inc = os.path.join(openssl_path, "include") - if not os.path.exists(os.path.join(openssl_inc, "openssl\\ssl.h")): - print("can't find OpenSSL headers", file=sys.stderr) - sys.exit(1) - varvals["INCLUDEPATH"] = openssl_inc - openssl_lib = os.path.join(openssl_path, "lib") - openssl_lib_name = "" - openssl_lib_dll = "" - if os.path.exists(os.path.join(openssl_lib, "libeay32.lib")): - openssl_lib_name = "libeay32.lib" - openssl_lib_dll = "bin\\libeay32.dll" - elif os.path.exists(os.path.join(openssl_lib, "libeaycompat32.lib")): - openssl_lib_name = "libeaycompat32.lib" - openssl_lib_dll = "bin\\libeaycompat32.dll" - elif os.path.exists(os.path.join(openssl_lib, "libcrypto.lib")): - openssl_lib_name = "libcrypto.lib" - if platform == 32: - openssl_lib_dll = "bin\\libcrypto-1_1.dll" - else: - openssl_lib_dll = "bin\\libcrypto-1_1-x64.dll" - - else: - print("can't find OpenSSL library", file=sys.stderr) - sys.exit(1) - openssl_dll = os.path.join(openssl_path,openssl_lib_dll) - varvals["LIBPATH"] = openssl_lib - varvals["LIBNAME"] = openssl_lib_name - varvals["DLLPATH"] = openssl_dll - if enable_debug: - debug_openssl_path = os.path.abspath(debug_openssl_path) - varvals["DEBUGDLLPATH"] = \ - os.path.join(debug_openssl_path, openssl_lib_dll) - debug_openssl_inc = os.path.join(debug_openssl_path, "include") - if not os.path.exists(os.path.join(debug_openssl_inc, - "openssl\\ssl.h")): - print("can't find debug OpenSSL headers", file=sys.stderr) - sys.exit(1) - varvals["DEBUGINCPATH"] = debug_openssl_inc - debug_openssl_lib = os.path.join(debug_openssl_path, "lib") - if not os.path.exists(os.path.join(debug_openssl_lib, - openssl_lib_name)): - print("can't find debug OpenSSL library", file=sys.stderr) - sys.exit(1) - varvals["DEBUGLIBPATH"] = debug_openssl_lib - else: - varvals["DEBUGDLLPATH"] = varvals["DLLPATH"] - varvals["DEBUGINCPATH"] = varvals["INCLUDEPATH"] - varvals["DEBUGLIBPATH"] = varvals["LIBPATH"] - - # OpenSSL support - if verbose: - print("checking OpenSSL") - system_libs = [] - if os.path.exists(openssl_dll): - subprocess.call(["copy", openssl_dll, "."], shell=True) - else: - system_libs = ["user32.lib", "advapi32.lib", "gdi32.lib", "crypt32.lib", "ws2_32.lib"] - inc = openssl_inc - lib = os.path.join(openssl_lib, openssl_lib_name) - testfile = open("testossl.c", "w") - print('\ -#include \n\ -int main() {\n\ - ERR_clear_error();\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testossl.c", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testossl.exe"): - print("can't create .\\testossl.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testossl.exe") != 0: - print("OpenSSL test failed", file=sys.stderr) - sys.exit(1) - - # OpenSSL version - if verbose: - print("checking OpenSSL version") - testfile = open("testosslv.c", "w") - print('\ -#include \n\ -#include \n\ -int main() {\n\ -#ifndef OPENSSL_VERSION_NUMBER\n\ - return -1;\n\ -#endif\n\ -#if OPENSSL_VERSION_NUMBER >= 0x010000000L\n\ - return 0;\n\ -#else\n\ - return 1;\n\ -#endif\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testosslv.c", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testosslv.exe"): - print("can't create .\\testosslv.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testosslv.exe") != 0: - print("OpenSLL version too old (1.0.0 or later required)", file=sys.stderr) - sys.exit(1) - - # OpenSSL ECC support - if enable_ecc: - if verbose: - print("checking OpenSSL ECC support") - testfile = open("testecc.c", "w") - print('\ -#include \n\ -#include \n\ -int main() {\n\ - EC_KEY *ec256, *ec384, *ec521;\n\ - ec256 = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);\n\ - ec384 = EC_KEY_new_by_curve_name(NID_secp384r1);\n\ - ec521 = EC_KEY_new_by_curve_name(NID_secp521r1);\n\ - if (ec256 == NULL || ec384 == NULL || ec521 == NULL)\n\ - return 1;\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testecc.c", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testecc.exe"): - print("can't create .\\testecc.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testecc.exe") != 0: - print("can't find P256, P384, or P521: no ECC support", file=sys.stderr) - sys.exit(1) - - # OpenSSL EDDSA support - if enable_eddsa: - if verbose: - print("checking OpenSSL EDDSA support") - testfile = open("testeddsa.c", "w") - print('\ -#include \n\ -#include \n\ -int main()\n\ -{\n\ - EVP_PKEY_CTX *ctx;\n\ - ctx = EVP_PKEY_CTX_new_id(NID_ED25519, NULL);\n\ - if (ctx == NULL)\n\ - return 1;\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testeddsa.c", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testeddsa.exe"): - print("can't create .\\testeddsa.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testeddsa.exe") != 0: - print("can't find EDDSA", file=sys.stderr) - sys.exit(1) - - # OpenSSL GOST support - if enable_gost: - if verbose: - print("checking OpenSSL GOST support") - testfile = open("testgost.c", "w") - print('\ -#include \n\ -#include \n\ -#include \n\ -#include \n\ -int main() {\n\ - ENGINE *eg;\n\ - const EVP_MD* EVP_GOST_34_11;\n\ - OpenSSL_add_all_algorithms();\n\ -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)\n\ - ENGINE_load_builtin_engines();\n\ -#else\n\ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN | OPENSSL_INIT_LOAD_CONFIG, NULL);\n\ -#endif\n\ - eg = ENGINE_by_id("gost");\n\ - if (eg == NULL)\n\ - return 1;\n\ - if (ENGINE_init(eg) <= 0)\n\ - return 1;\n\ - EVP_GOST_34_11 = ENGINE_get_digest(eg, NID_id_GostR3411_94);\n\ - if (EVP_GOST_34_11 == NULL)\n\ - return 1;\n\ - if (ENGINE_register_pkey_asn1_meths(eg) <= 0)\n\ - return 1;\n\ - if (ENGINE_ctrl_cmd_string(eg, "CRYPT_PARAMS",\n\ - "id-Gost28147-89-CryptoPro-A-ParamSet", 0) <= 0)\n\ - return 1;\n\ - return 0;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testgost.c", lib] - command.extend(system_libs) - subprocess.check_output(command, stderr=subprocess.STDOUT) - if not os.path.exists(".\\testgost.exe"): - print("can't create .\\testgost.exe", file=sys.stderr) - sys.exit(1) - if subprocess.call(".\\testgost.exe") != 0: - print("can't find GOST: no GOST support", file=sys.stderr) - sys.exit(1) - - # OpenSSL EVP interface for AES key wrapping (aka RFC 3394) - if verbose: - print("checking OpenSSL EVP interface for AES key wrapping") - testfile = open("testrfc3394.c", "w") - print('\ -#include \n\ -int main() {\n\ - EVP_aes_128_wrap();\n\ - return 1;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testrfc3394.c", lib] - command.extend(system_libs) - subprocess.call(command) - if os.path.exists(".\\testrfc3394.exe"): - if verbose: - print("RFC 3394 is supported") - condvals["RFC3394"] = True - else: - if verbose: - print("can't compile OpenSSL RFC 3394") - - # OpenSSL EVP interface for AES key wrap with pad (aka RFC 5649) - if verbose: - print("checking OpenSSL EVP interface for AES key wrapping with pad") - testfile = open("testrfc5649.c", "w") - print('\ -#include \n\ -int main() {\n\ - EVP_aes_128_wrap_pad();\n\ - return 1;\n\ -}', file=testfile) - testfile.close() - command = ["cl", "/nologo", "/MD", "/I", inc, "testrfc5649.c", lib] - command.extend(system_libs) - subprocess.call(command) - if os.path.exists(".\\testrfc5649.exe"): - if verbose: - print("RFC 5649 is supported") - condvals["RFC5649"] = True - else: - if verbose: - print("can't compile OpenSSL RFC 5649") - - # no check for OpenSSL raw PSS support - condvals["RAWPSS"] = True - # no check for OpenSSL AES GCM - condvals["AESGCM"] = True - - # configure CppUnit - if want_tests: - condvals["TESTS"] = True - cppunit_path = os.path.abspath(cppunit_path) - cppunit_inc = os.path.join(cppunit_path, "include") - if not os.path.exists(os.path.join(cppunit_inc, "cppunit\\Test.h")): - print("can't find CppUnit headers", file=sys.stderr) - sys.exit(1) - varvals["CUINCPATH"] = cppunit_inc - cppunit_lib = os.path.join(cppunit_path, "lib") - if not os.path.exists(os.path.join(cppunit_lib, "cppunit.lib")): - cppunit_lib = cppunit_path - if not os.path.exists(os.path.join(cppunit_lib, "cppunit.lib")): - print("can't find CppUnit library", file=sys.stderr) - sys.exit(1) - if enable_debug: - if not os.path.exists(os.path.join(cppunit_lib, "cppunitd.lib")): - print("can't find debug CppUnit library", file=sys.stderr) - sys.exit(1) - varvals["CULIBPATH"] = cppunit_lib - - # misc - if enable_non_paged: - condvals["NONPAGE"] = True - -def kw(path): - """escape spaces""" - if re.search(r' ', path): - return '"' + path + '"' - else: - return path - -def setupfile(filename): - """setup files with condition stacks and variable expansions""" - cond = "@@@" - conds = [] - passing = True - passes = [] - filein = open(filename + ".in", "r") - fileout = open(filename, "w") - - for line in filein: - line = line.rstrip("\r\n") - cif = re.match(r'@IF (.*)', line) - if cif: - conds.append(cond) - passes.append(passing) - cond = cif.group(1) - if condvals.get(cond): - # do nothing - pass - else: - passing = False - continue - celse = re.match(r'@ELSE (.*)', line) - if celse: - if cond != celse.group(1): - raise SyntaxError("@ELSE " + celse.group(1) + - " mismatch in " + filename) - if condvals.get(cond): - passing = False - else: - if len(passes) > 0: - passing = passes[-1] - else: - passing = True - continue - cend = re.match(r'@END (.*)', line) - if cend: - if cond != cend.group(1): - raise SyntaxError("@END " + cend.group(1) + - " mismatch in " + filename) - cond = conds.pop() - if len(passes) > 0: - passing = passes.pop() - else: - passing = True - continue - if not passing: - continue - while True: - vm = re.match(r'([^@]*)@([^@ ]*)@(.*)', line) - if vm: - if vm.group(2) in varnames: - if varvals.get(vm.group(2)): - val = kw(varvals[vm.group(2)]) - else: - val = "" - line = vm.group(1) + val + vm.group(3) - continue - else: - raise SyntaxError("unknown control @" + vm.group(2) + - "@ in " + filename) - break - print(line, file=fileout) - if verbose: - print("Setting up " + filename) - filein.close() - fileout.close() - -def main(args): - """run it""" - - # no arguments -> usage - if len(args) <= 1: - for line in usage: - print(line) - sys.exit(1) - - parseargs(args[1:]) - - if want_help: - dohelp() - if want_clean: - doclean() - if want_unknown: - dounknown() - if not toolset: - dodetectvisualstudio() - if not toolset: - print("Build skipped. To build, this file needs to run from VS command prompt.") - sys.exit(1) - - varvals["PLATFORMTOOLSET"] = toolset - - # status before config - if verbose: - if enable_keep: - print("keep: enabled") - else: - print("keep: disabled") - if platform == 64: - print("64bit: enabled") - else: - print("64bit: disabled") - if enable_debug: - print("debug: enabled") - else: - print("debug: disabled") - if enable_ecc: - print("ecc: enabled") - else: - print("ecc: disabled") - if enable_eddsa: - print("eddsa: enabled") - else: - print("eddsa: disabled") - if enable_gost: - print("gost: enabled") - else: - print("gost: disabled") - if enable_non_paged: - print("non-paged-memory: enabled") - else: - print("non-paged-memory: disabled") - print("crypto-backend: " + crypto_backend) - if crypto_backend == "botan": - print("botan-path: " + botan_path) - if enable_debug: - print("debug-botan-path: " + debug_botan_path) - else: - print("openssl-path: " + openssl_path) - if enable_debug: - print("debug-openssl-path: " + debug_openssl_path) - if want_tests: - print("cppunit-path: " + cppunit_path) - print("toolset: "+toolset) - - - doconfig() - - # status after config - if verbose: - print("Configuration Status") - print("\tconditions:") - for name in condnames: - if condvals.get(name): - print("\t\t" + name + " is true") - else: - print("\t\t" + name + " is false") - print("\tsubstitutions:") - for name in varnames: - if varvals.get(name): - print("\t\t" + name + '-> "' + varvals[name] + '"') - print() - - for filename in filelist: - setupfile(filename) - - # clean test file - if not enable_keep: - docleantest() - - print("Configured.") - sys.exit(0) - -main(sys.argv) - -# Notes: Unix configure.ac options -# --enable-64bit supported -# --enable-ecc supported -# --enable-eddsa supported -# --enable-gost supported -# --enable-non-paged-memory supported -# --enable-visibility (enforced by DLLs) -# --with-crypto-backend supported -# --with-botan supported (Release and Debug) -# --with-openssl supported (Release and Debug) -# --with-migrate (useless as SoftHSMv1 is not supported) -# --with-objectstore-backend-db (TODO) -# --with-sqlite3 (useless until objectstore backend can be chosen) diff --git a/win32/config.h.in b/win32/config.h.in deleted file mode 100644 index 0a400b7ef..000000000 --- a/win32/config.h.in +++ /dev/null @@ -1,192 +0,0 @@ -/* config.h for WIN32 */ - -/* The default log level */ -#define DEFAULT_LOG_LEVEL "INFO" - -/* Default storage backend for token objects */ -#define DEFAULT_OBJECTSTORE_BACKEND "file" - -/* The default PKCS#11 library */ -#define DEFAULT_PKCS11_LIB "softhsm2.dll" - -/* The default location of softhsm2.conf */ -#define DEFAULT_SOFTHSM2_CONF "softhsm2.conf" - -/* The default location of the token directory */ -#define DEFAULT_TOKENDIR "tokens" - -/* Define if advanced AES key wrap without pad is supported */ -@IF RFC3394 -#define HAVE_AES_KEY_WRAP 1 -@ELSE RFC3394 -#undef HAVE_AES_KEY_WRAP -@END RFC3394 - -/* Define if advanced AES key wrap with pad is supported */ -@IF RFC5649 -#define HAVE_AES_KEY_WRAP_PAD 1 -@ELSE RFC5649 -#undef HAVE_AES_KEY_WRAP_PAD -@END RFC5649 - -/* Whether LoadLibrary is available */ -#define HAVE_LOADLIBRARY 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_SQLITE3_H - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Maximum PIN length */ -#define MAX_PIN_LEN 255 - -/* Minimum PIN length */ -#define MIN_PIN_LEN 4 - -/* Name of package */ -#define PACKAGE "softhsm" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "SoftHSM" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "SoftHSM 2.5.0" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "softhsm" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "2.5.0" - -/* Non-paged memory for secure storage */ -@IF NONPAGE -#define SENSITIVE_NON_PAGE 1 -@ELSE NONPAGE -#undef SENSITIVE_NON_PAGE -@END NONPAGE - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#define VERSION "2.5.0" - -/* SoftHSM major version number via PKCS#11 */ -#define VERSION_MAJOR 2 - -/* SoftHSM minor version number via PKCS#11 */ -#define VERSION_MINOR 5 - -/* Compile with Botan support */ -@IF BOTAN -#define WITH_BOTAN 1 -@ELSE BOTAN -#undef WITH_BOTAN -@END BOTAN - -/* Compile with ECC support */ -@IF ECC -#define WITH_ECC 1 -@ELSE ECC -#undef WITH_ECC -@END ECC - -/* Compile with EDDSA support */ -@IF EDDSA -#define WITH_EDDSA 1 -@ELSE EDDSA -#undef WITH_EDDSA -@END EDDSA - -/* Compile with GOST support */ -@IF GOST -#define WITH_GOST 1 -@ELSE GOST -#undef WITH_GOST -@END GOST - -/* Compile with OpenSSL support */ -@IF OPENSSL -#define WITH_OPENSSL 1 -@ELSE OPENSSL -#undef WITH_OPENSSL -@END OPENSSL - -/* Compile with raw PSS support */ -@IF RAWPSS -#define WITH_RAW_PSS 1 -@ELSE RAWPSS -#undef WITH_RAW_PSS -@END RAWPSS - -/* Compile with AES GCM support */ -@IF AESGCM -#define WITH_AES_GCM 1 -@ELSE AESGCM -#undef WITH_AES_GCM -@END AESGCM - -/* Define to 1 if you have getpassphrase(). */ -#define HAVE_GETPASSPHRASE - -/* Addition things */ - -char *getpassphrase(const char *prompt); -int setenv(const char *name, const char *value, int overwrite); - -/* At least Vista */ - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - -#if _MSC_VER < 1900 -#define snprintf _snprintf -#endif -#define strcasecmp _stricmp -#define strncasecmp _strnicmp - -/* Prevent inclusion of winsock.h in windows.h */ - -#define WIN32_LEAN_AND_MEAN 1 - -#include - -/* avoid collision from min and max macros */ - -#undef min -#undef max - -@IF BOTAN -/* For Botan */ - -#pragma warning(disable: 4275 4267) -@END BOTAN - -/* Temporary for debug */ - -#undef DEBUG_LOG_STDERR -// #define DEBUG_LOG_STDERR 1 - -/* To avoid unsafe warnings (off) */ - -// #pragma warning(disable: 4996) diff --git a/win32/cryptotest/cryptotest.vcxproj.in b/win32/cryptotest/cryptotest.vcxproj.in index 010b89058..c8917aa3f 100644 --- a/win32/cryptotest/cryptotest.vcxproj.in +++ b/win32/cryptotest/cryptotest.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/datamgrtest/datamgrtest.vcxproj.in b/win32/datamgrtest/datamgrtest.vcxproj.in index 0251af337..779d6567c 100644 --- a/win32/datamgrtest/datamgrtest.vcxproj.in +++ b/win32/datamgrtest/datamgrtest.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/handlemgrtest/handlemgrtest.vcxproj.in b/win32/handlemgrtest/handlemgrtest.vcxproj.in index ddc9addcb..208c6f229 100644 --- a/win32/handlemgrtest/handlemgrtest.vcxproj.in +++ b/win32/handlemgrtest/handlemgrtest.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;%(AdditionalDependencies) diff --git a/win32/keyconv/keyconv.vcxproj.filters.in b/win32/keyconv/keyconv.vcxproj.filters.in index bd6ce41d4..52574219d 100644 --- a/win32/keyconv/keyconv.vcxproj.filters.in +++ b/win32/keyconv/keyconv.vcxproj.filters.in @@ -48,9 +48,6 @@ Header Files - - Win32 Header Files - @@ -78,9 +75,6 @@ Source Files - - Win32 Source Files - Win32 Source Files diff --git a/win32/keyconv/keyconv.vcxproj.in b/win32/keyconv/keyconv.vcxproj.in index 87c1b5e8e..6c6bec8a2 100644 --- a/win32/keyconv/keyconv.vcxproj.in +++ b/win32/keyconv/keyconv.vcxproj.in @@ -61,7 +61,7 @@ Console true @DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - @LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + @BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -82,7 +82,7 @@ true true @LIBPATH@;%(AdditionalLibraryDirectories) - @LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + @BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -92,7 +92,6 @@ @IF OPENSSL @END OPENSSL - @@ -107,7 +106,6 @@ @END OPENSSL - diff --git a/win32/objstoretest/objstoretest.vcxproj.in b/win32/objstoretest/objstoretest.vcxproj.in index d26e7cb4f..3437d56d2 100644 --- a/win32/objstoretest/objstoretest.vcxproj.in +++ b/win32/objstoretest/objstoretest.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/p11test/p11test.vcxproj.in b/win32/p11test/p11test.vcxproj.in index 350636eb7..55dfb0871 100644 --- a/win32/p11test/p11test.vcxproj.in +++ b/win32/p11test/p11test.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -91,7 +91,7 @@ copy ..\..\src\lib\test\tokens\dummy.in "$(TargetDir)\tokens\dummy" true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/sessionmgrtest/sessionmgrtest.vcxproj.in b/win32/sessionmgrtest/sessionmgrtest.vcxproj.in index 572c9c3f5..9f161e18f 100644 --- a/win32/sessionmgrtest/sessionmgrtest.vcxproj.in +++ b/win32/sessionmgrtest/sessionmgrtest.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/slotmgrtest/slotmgrtest.vcxproj.in b/win32/slotmgrtest/slotmgrtest.vcxproj.in index ea52e3b62..571d9a33d 100644 --- a/win32/slotmgrtest/slotmgrtest.vcxproj.in +++ b/win32/slotmgrtest/slotmgrtest.vcxproj.in @@ -59,7 +59,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunitd.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunitd.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@CULIBPATH@;@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;cppunit.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;cppunit.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/softhsm2/softhsm2.vcxproj.in b/win32/softhsm2/softhsm2.vcxproj.in index efa808e5f..467b1d25a 100644 --- a/win32/softhsm2/softhsm2.vcxproj.in +++ b/win32/softhsm2/softhsm2.vcxproj.in @@ -59,7 +59,7 @@ Windows true ..\@PLATFORMDIR@$(Configuration);@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) @@ -80,7 +80,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) diff --git a/win32/util/util.vcxproj.filters.in b/win32/util/util.vcxproj.filters.in index 2c4171b87..dc45e16a5 100644 --- a/win32/util/util.vcxproj.filters.in +++ b/win32/util/util.vcxproj.filters.in @@ -68,9 +68,6 @@ Header Files - - Win32 Header Files - @@ -98,9 +95,6 @@ Source Files @END OPENSSL - - Win32 Source Files - Win32 Source Files diff --git a/win32/util/util.vcxproj.in b/win32/util/util.vcxproj.in index 28bdcd0f2..765850885 100644 --- a/win32/util/util.vcxproj.in +++ b/win32/util/util.vcxproj.in @@ -61,7 +61,7 @@ Console true ..\@PLATFORMDIR@$(Configuration);@DEBUGLIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) if exist @DEBUGDLLPATH@ copy @DEBUGDLLPATH@ ..\@PLATFORMDIR@$(Configuration) @@ -85,7 +85,7 @@ true true ..\@PLATFORMDIR@$(Configuration);@LIBPATH@;%(AdditionalLibraryDirectories) - convarch.lib;@LIBNAME@;@EXTRALIBS@%(AdditionalDependencies) + convarch.lib;@BOTAN_LIBRARY@;@EXTRALIBS@%(AdditionalDependencies) if exist @DLLPATH@ copy @DLLPATH@ ..\@PLATFORMDIR@$(Configuration) @@ -103,7 +103,6 @@ @END OPENSSL - @@ -121,7 +120,6 @@ @END OPENSSL -