From 08fbcf5eaeaf09e7ab62fe0fd0bdacc5c8424a05 Mon Sep 17 00:00:00 2001 From: Marco Oliverio Date: Tue, 21 Dec 2021 13:24:27 +0100 Subject: [PATCH] autoconf: add PSA options --- configure.ac | 78 ++++++++++++++++++++++++++++++++ wolfcrypt/src/include.am | 4 ++ wolfcrypt/src/port/psa/psa.c | 31 +++++++++++++ wolfssl/wolfcrypt/include.am | 4 ++ wolfssl/wolfcrypt/port/psa/psa.h | 33 ++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 wolfcrypt/src/port/psa/psa.c create mode 100644 wolfssl/wolfcrypt/port/psa/psa.h diff --git a/configure.ac b/configure.ac index 3d493eab9..eca24b329 100644 --- a/configure.ac +++ b/configure.ac @@ -1173,6 +1173,82 @@ AC_ARG_ENABLE([smime], [ ENABLED_SMIME=no ] ) +# Platform Security Architecture (PSA) +AC_ARG_ENABLE([psa], +[AS_HELP_STRING([--enable-psa],[use Platform Security Architecture (PSA) interface (default: disabled)])], +[ ENABLED_PSA=$enableval ], +[ ENABLED_PSA=no ] +) + +AC_ARG_WITH([psa-include], + [AS_HELP_STRING([--with-psa-include=PATH], + [PATH to directory with PSA header files])], + [PSA_INCLUDE=$withval], + [PSA_INCLUDE=""]) + +AC_ARG_WITH([psa-lib], + [AS_HELP_STRING([--with-psa-lib=PATH],[PATH to directory with the PSA library])], + [PSA_LIB=$withval], + [PSA_LIB=""]) + +AC_ARG_WITH([psa-lib-name], + [AS_HELP_STRING([--with-psa-lib-name=NAME],[NAME of PSA library])], + [PSA_LIB_NAME=$withval], + [PSA_LIB_NAME=""]) + +AC_ARG_ENABLE([psa-lib-static], + [AS_HELP_STRING([--enable-psa-lib-static],[Link PSA as static library (default: disable)])], + [ ENABLED_PSA_STATIC=$enableval ], + [ ENABLED_PSA_STATIC=no ] +) + +if test "x$ENABLED_PSA" = "xyes" +then + AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_PSA" +fi + +if test "x$ENABLED_PSA" != "xyes" && \ + (test "x$PSA_LIB"! = "x" || test "x$PSA_INCLUDE" != "x" || test "x$PSA_LIB_NAME" != "x" ) +then + AC_MSG_ERROR([to use PSA you need to enable it with --enable-psa]) +fi + +if test -n "$PSA_LIB" +then + AC_MSG_CHECKING([for $PSA_LIB]) + if ! test -d "$PSA_LIB" + then + AC_MSG_ERROR([PSA lib dir $PSA_LIB not found.]) + fi + AC_MSG_RESULT([yes]) + AM_LDFLAGS="$AM_LDFLAGS -L$PSA_LIB" +fi + +if test -n "$PSA_LIB_NAME" +then + if test "x$ENABLED_PSA_STATIC" = "xyes" + then + LIB_STATIC_ADD="$LIB_STATIC_ADD $PSA_LIB/$PSA_LIB_NAME" + else + LIB_ADD="$LIB_ADD -l$PSA_LIB_NAME" + fi +fi + +if test -n "$PSA_INCLUDE" +then + AC_MSG_CHECKING([for $PSA_INCLUDE]) + if ! test -d "$PSA_INCLUDE" + then + AC_MSG_ERROR([psa include dir $PSA_INCLUDE not found.]) + fi + AC_MSG_RESULT([yes]) + AM_CFLAGS="$AM_CFLAGS -I$PSA_INCLUDE" +fi + +AC_SUBST([PSA_LIB]) +AC_SUBST([PSA_LIB_NAME]) +AC_SUBST([PSA_INCLUDE]) + # OPENSSL Compatibility ALL AC_ARG_ENABLE([opensslall], [AS_HELP_STRING([--enable-opensslall],[Enable all OpenSSL API, size++ (default: disabled)])], @@ -7512,6 +7588,7 @@ AM_CONDITIONAL([BUILD_KDF],[test "x$ENABLED_KDF" = "xyes"]) AM_CONDITIONAL([BUILD_HMAC],[test "x$ENABLED_HMAC" = "xyes"]) AM_CONDITIONAL([BUILD_ERROR_STRINGS],[test "x$ENABLED_ERROR_STRINGS" = "xyes"]) AM_CONDITIONAL([BUILD_DO178],[test "x$ENABLED_DO178" = "xyes"]) +AM_CONDITIONAL([BUILD_PSA],[test "x$ENABLED_PSA" = "xyes"]) if test "$ENABLED_REPRODUCIBLE_BUILD" != "yes" && (test "$ax_enable_debug" = "yes" || @@ -7911,6 +7988,7 @@ echo " * i.MX6 CAAM: $ENABLED_CAAM" echo " * IoT-Safe: $ENABLED_IOTSAFE" echo " * IoT-Safe HWRNG: $ENABLED_IOTSAFE_HWRNG" echo " * NXP SE050: $ENABLED_SE050" +echo " * PSA: $ENABLED_PSA" echo "" echo "---" diff --git a/wolfcrypt/src/include.am b/wolfcrypt/src/include.am index 5324cf370..5217dac46 100644 --- a/wolfcrypt/src/include.am +++ b/wolfcrypt/src/include.am @@ -184,3 +184,7 @@ endif if BUILD_SE050 src_libwolfssl_la_SOURCES += wolfcrypt/src/port/nxp/se050_port.c endif + +if BUILD_PSA +src_libwolfssl_la_SOURCES += wolfcrypt/src/port/psa/psa.c +endif diff --git a/wolfcrypt/src/port/psa/psa.c b/wolfcrypt/src/port/psa/psa.c new file mode 100644 index 000000000..99fe5e0d3 --- /dev/null +++ b/wolfcrypt/src/port/psa/psa.c @@ -0,0 +1,31 @@ +/* psa.c + * + * Copyright (C) 2006-2021 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#if defined(WOLFSSL_HAVE_PSA) + +#endif /* WOLFSSL_HAVE_PSA */ diff --git a/wolfssl/wolfcrypt/include.am b/wolfssl/wolfcrypt/include.am index d39d435cb..9bf1d9a8d 100644 --- a/wolfssl/wolfcrypt/include.am +++ b/wolfssl/wolfcrypt/include.am @@ -171,3 +171,7 @@ endif if BUILD_IOTSAFE nobase_include_HEADERS+= wolfssl/wolfcrypt/port/iotsafe/iotsafe.h endif + +if BUILD_PSA +nobase_include_HEADERS+= wolfssl/wolfcrypt/port/psa/psa.h +endif diff --git a/wolfssl/wolfcrypt/port/psa/psa.h b/wolfssl/wolfcrypt/port/psa/psa.h new file mode 100644 index 000000000..a74800a1e --- /dev/null +++ b/wolfssl/wolfcrypt/port/psa/psa.h @@ -0,0 +1,33 @@ +/* psa.h + * + * Copyright (C) 2006-2021 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#ifndef WOLFSSL_PSA_H +#define WOLFSSL_PSA_H + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#if defined(WOLFSSL_HAVE_PSA) + +#endif +#endif /* WOLFSSL_PSA_H */