From 37d66dee1bbdb529e2a773e2570fbb21f7c562bb Mon Sep 17 00:00:00 2001 From: Adrian Chiris Date: Wed, 13 Jan 2016 19:31:53 +0200 Subject: [PATCH] added --enable-cs configure flag to enable checksum calculation feature in mstflint(requires openssl package) --- Makefile.am | 2 +- configure.ac | 20 +++++++++++++++++++- flint/Makefile.am | 5 +++++ mlxfwops/lib/Makefile.am | 7 ++++++- tools_crypto/Makefile.am | 40 ++++++++++++++++++++++++++++++++++++++++ tools_crypto/tools_md5.c | 21 +++++++++++++++++++++ tools_crypto/tools_md5.h | 29 +++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 tools_crypto/Makefile.am create mode 100644 tools_crypto/tools_md5.c create mode 100644 tools_crypto/tools_md5.h diff --git a/Makefile.am b/Makefile.am index 4244974..33d48f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,7 @@ # SOFTWARE. #-- -SUBDIRS = mft_utils tools_layouts mtcr_ul reg_access cmdif dev_mgt tools_res_mgmt mflash mlxconfig mlxfwops cmdparser flint small_utils mstdump +SUBDIRS = mft_utils $(TOOLS_CRYPTO) tools_layouts mtcr_ul reg_access cmdif dev_mgt tools_res_mgmt mflash mlxconfig mlxfwops cmdparser flint small_utils mstdump man_MANS = man/mstflint.1 diff --git a/configure.ac b/configure.ac index 46114c7..94c19da 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,8 @@ AC_CONFIG_HEADERS( config.h ) dnl Checks for headers AC_CHECK_HEADER(termios.h,[CXXFLAGS="${CXXFLAGS} -DHAVE_TERMIOS_H"]) +TOOLS_CRYPTO="" + AC_MSG_CHECKING(--enable-dc argument) AC_ARG_ENABLE(dc, [ --disable-dc Disable mstflint "dc" command. Eliminates zlib dependency], @@ -47,6 +49,19 @@ fi AM_CONDITIONAL(ENABLE_INBAND, [test "x$enable_inband" = "xyes"]) +AC_MSG_CHECKING(--enable-cs argument) +AC_ARG_ENABLE(cs, + [ --enable-cs Enable mstflint "checksum" command, dependant of openssl library], + [enable_cs="yes"], + [enable_cs="no"]) +AC_MSG_RESULT($enable_cs) +if test "x$enable_cs" = "xyes"; then + AC_CHECK_HEADER(openssl/md5.h,,AC_MSG_ERROR([cannot find openssl/md5.h . remove --enable-openssl to remove this dependaency or install openssl])) + TOOLS_CRYPTO="tools_crypto" +fi +AC_SUBST(TOOLS_CRYPTO) +AM_CONDITIONAL(ENABLE_OPENSSL, [test "x$enable_cs" = "xyes"]) + AC_ARG_ENABLE([static_libstdcpp], AS_HELP_STRING([--enable-static-libstdcpp], [Enable link static to libstdc++])) @@ -66,7 +81,10 @@ CXXFLAGS="$CXXFLAGS -Werror -DMST_UL" AC_CONFIG_FILES( mstflint.spec ) +AS_IF([test "x$enable_cs" = "xyes"], [ + AC_CONFIG_FILES(tools_crypto/Makefile) + ]) + AC_OUTPUT( Makefile mft_utils/Makefile mtcr_ul/Makefile dev_mgt/Makefile tools_layouts/Makefile reg_access/Makefile cmdif/Makefile tools_res_mgmt/Makefile \ mlxconfig/Makefile mflash/Makefile mlxfwops/Makefile mlxfwops/lib/Makefile cmdparser/Makefile flint/Makefile \ small_utils/Makefile mstdump/Makefile mstdump/crd_lib/Makefile mstdump/crd_main/Makefile mstdump/mstdump_dbs/Makefile ) - diff --git a/flint/Makefile.am b/flint/Makefile.am index f001515..0041d10 100755 --- a/flint/Makefile.am +++ b/flint/Makefile.am @@ -66,6 +66,11 @@ else mstflint_CXXFLAGS += -DNO_ZLIB endif +if ENABLE_OPENSSL +mstflint_LDADD += $(top_srcdir)/tools_crypto/libtools_crypto.a -lcrypto +else +endif + #get mst device examples and tool name from makefile mstflint_CXXFLAGS+= -DFLINT_NAME=\"mstflint\" -DFLINT_DISPLAY_NAME=\"MstFlint\" mstflint_CXXFLAGS += -DMST_DEV_EXAMPLE1=\"03:00.0\" -DMST_DEV_EXAMPLE2=\"mlx4_0\" -DMST_DEV_EXAMPLE3=\"03:00.0\" -DMST_DEV_EXAMPLE4=\"04:00.0\" diff --git a/mlxfwops/lib/Makefile.am b/mlxfwops/lib/Makefile.am index 2f91b6a..8cf9e15 100755 --- a/mlxfwops/lib/Makefile.am +++ b/mlxfwops/lib/Makefile.am @@ -45,7 +45,12 @@ INCLUDES = -I$(srcdir) -I$(MTCR_INC_DIR) -I$(MFLASH_DIR) -I$(top_srcdir)/ext_lib MLXFWOPS_VERSION = 1 -AM_CXXFLAGS = -Wall -W -g -MP -MD -pipe -DNO_MFA_SUPPORT -DNO_OPEN_SSL +AM_CXXFLAGS = -Wall -W -g -MP -MD -pipe -DNO_MFA_SUPPORT + +if ENABLE_OPENSSL +else +AM_CXXFLAGS += -DNO_OPEN_SSL +endif noinst_LIBRARIES = libmlxfwops.a diff --git a/tools_crypto/Makefile.am b/tools_crypto/Makefile.am new file mode 100644 index 0000000..7dc6082 --- /dev/null +++ b/tools_crypto/Makefile.am @@ -0,0 +1,40 @@ +#-- +# Copyright (C) Jan 2013 Mellanox Technologies Ltd. All rights reserved. +# +# This software is available to you under a choice of one of two +# licenses. You may choose to be licensed under the terms of the GNU +# General Public License (GPL) Version 2, available from the file +# COPYING in the main directory of this source tree, or the +# OpenIB.org BSD license below: +# +# Redistribution and use in source and binary forms, with or +# without modification, are permitted provided that the following +# conditions are met: +# +# - Redistributions of source code must retain the above +# copyright notice, this list of conditions and the following +# disclaimer. +# +# - 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. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#-- + +# Makefile.am -- Process this file with automake to produce Makefile.in +USER_DIR = $(top_srcdir) +INCLUDES = -I$(USER_DIR) -I$(USER_DIR)/common +AM_CFLAGS = -MD -pipe -Wall -W -DMST_UL -g + +noinst_LIBRARIES = libtools_crypto.a +libtools_crypto_a_SOURCES = tools_md5.c tools_md5.h + diff --git a/tools_crypto/tools_md5.c b/tools_crypto/tools_md5.c new file mode 100644 index 0000000..aede28b --- /dev/null +++ b/tools_crypto/tools_md5.c @@ -0,0 +1,21 @@ + +/* - Mellanox Confidential and Proprietary - + * + * Copyright (C) Jan 2013, Mellanox Technologies Ltd. ALL RIGHTS RESERVED. + * + * Except as specifically permitted herein, no portion of the information, + * including but not limited to object code and source code, may be reproduced, + * modified, distributed, republished or otherwise exploited in any form or by + * any means for any purpose without the prior written permission of Mellanox + * Technologies Ltd. Use of software subject to the terms and conditions + * detailed in the file "LICENSE.txt". + * + */ + +#include +#include "tools_md5.h" + +u_int8_t *tools_md5(const u_int8_t* src, u_int32_t src_len, u_int8_t dst[16]) +{ + return MD5((const unsigned char*)src, src_len, (unsigned char*)dst); +} diff --git a/tools_crypto/tools_md5.h b/tools_crypto/tools_md5.h new file mode 100644 index 0000000..3209762 --- /dev/null +++ b/tools_crypto/tools_md5.h @@ -0,0 +1,29 @@ + +/* - Mellanox Confidential and Proprietary - + * + * Copyright (C) Jan 2013, Mellanox Technologies Ltd. ALL RIGHTS RESERVED. + * + * Except as specifically permitted herein, no portion of the information, + * including but not limited to object code and source code, may be reproduced, + * modified, distributed, republished or otherwise exploited in any form or by + * any means for any purpose without the prior written permission of Mellanox + * Technologies Ltd. Use of software subject to the terms and conditions + * detailed in the file "LICENSE.txt". + * + */ + +#ifndef TOOLS_MD5_H +#define TOOLS_MD5_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +u_int8_t *tools_md5(const u_int8_t* src, u_int32_t src_len, u_int8_t dst[16]); + +#ifdef __cplusplus +} +#endif + +#endif // TOOLS_MD5_H -- 2.46.0