diff --git a/configure.ac b/configure.ac index 8943a65..3612d9b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,19 +1,16 @@ # SPDX-FileCopyrightText: 2022 stenc authors # SPDX-License-Identifier: GPL-2.0-or-later -AC_INIT([stenc],[1.1.1]) +AC_INIT([stenc],[2.0.0]) AC_CONFIG_SRCDIR([src/main.cpp]) AM_INIT_AUTOMAKE([foreign subdir-objects]) -AC_CONFIG_HEADERS([config.h]) -AC_CHECK_HEADER([sys/types.h]) -AC_CHECK_HEADER([sys/machine.h]) +AC_CONFIG_HEADERS([config.h])] +AC_CHECK_HEADERS +AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) # Checks for programs AC_PROG_CXX -# Checks for header files. -AC_PROG_EGREP - AC_MSG_CHECKING(whether to output raw SCSI messages) AC_ARG_WITH([scsi-debug], [AS_HELP_STRING([--with-scsi-debug],[enable scsi communication debug])], diff --git a/src/main.cpp b/src/main.cpp index 9b1e939..2877493 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,31 +20,38 @@ GNU General Public License for more details. #include #include +#include +#include #include +#include #include #include #include +#include #include -#include #include #include #include +#include #include #include +#include #include +#include #include +#include #include +#include #include -#include #include #include -#ifdef HAVE_STDLIB_H -#include +#if HAVE_ARPA_INET_H +#include #endif -#ifdef HAVE_STRING_H -#include +#if HAVE_NETINET_IN_H +#include #endif #ifdef HAVE_UNISTD_H #include @@ -383,7 +390,7 @@ int main(int argc, char **argv) std::optional enc_mode; std::optional dec_mode; std::optional algorithm_index; - std::vector key; + std::vector key; std::string key_name; scsi::sde_rdmc rdmc {}; scsi::kadf kad_format {}; diff --git a/src/scsiencrypt.cpp b/src/scsiencrypt.cpp index 85d1866..f6752a9 100644 --- a/src/scsiencrypt.cpp +++ b/src/scsiencrypt.cpp @@ -26,6 +26,7 @@ GNU General Public License for more details. #include #include #include +#include #include #include @@ -36,7 +37,6 @@ GNU General Public License for more details. #endif #if defined(OS_LINUX) -#include #include constexpr unsigned int SCSI_TIMEOUT {5000u}; #elif defined(OS_FREEBSD) diff --git a/src/scsiencrypt.h b/src/scsiencrypt.h index 11a3bb6..83a6f07 100644 --- a/src/scsiencrypt.h +++ b/src/scsiencrypt.h @@ -20,8 +20,9 @@ GNU General Public License for more details. #ifndef _SCSIENC_H #define _SCSIENC_H +#include + #include -#include #include #include #include @@ -29,15 +30,14 @@ GNU General Public License for more details. #include #include #include +#include +#include +#if HAVE_ARPA_INET_H #include - -#ifdef HAVE_SYS_MACHINE_H -#include #endif - -#ifdef HAVE_SYS_TYPES_H -#include +#if HAVE_NETINET_IN_H +#include #endif namespace scsi { diff --git a/tests/output.cpp b/tests/output.cpp index 196aa3a..2ba3213 100644 --- a/tests/output.cpp +++ b/tests/output.cpp @@ -5,11 +5,13 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include +#include +#include +#include #include #include +#include -#include "config.h" #include "main.cpp" using namespace std::literals::string_literals; @@ -58,7 +60,7 @@ TEST_CASE("Test SCSI inquiry output", "[output]") TEST_CASE("SCSI get device encryption status output 1", "[output]") { std::map algorithms { - { 1, "AES-256-GCM-128"s }, + {1, "AES-256-GCM-128"s}, }; const std::uint8_t page[] { 0x00, 0x20, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -69,14 +71,15 @@ Reading: Not decrypting\n\ Writing: Not encrypting\n\ Key instance counter: 0\n"s}; std::ostringstream oss; - print_device_status(oss, reinterpret_cast(page), algorithms); + print_device_status(oss, reinterpret_cast(page), + algorithms); REQUIRE(oss.str() == expected_output); } TEST_CASE("SCSI get device encryption status output 2", "[output]") { std::map algorithms { - { 1, "AES-256-GCM-128"s }, + {1, "AES-256-GCM-128"s}, }; const std::uint8_t page[] { 0x00, 0x20, 0x00, 0x24, 0x42, 0x02, 0x02, 0x01, 0x00, 0x00, @@ -91,14 +94,15 @@ Writing: Encrypting (AES-256-GCM-128)\n\ Key instance counter: 1\n\ Drive key desc. (U-KAD): Hello world!\n"s}; std::ostringstream oss; - print_device_status(oss, reinterpret_cast(page), algorithms); + print_device_status(oss, reinterpret_cast(page), + algorithms); REQUIRE(oss.str() == expected_output); } TEST_CASE("Test SCSI get next block encryption status output 1", "[output]") { std::map algorithms { - { 1, "AES-256-GCM-128"s }, + {1, "AES-256-GCM-128"s}, }; const std::uint8_t page[] { 0x00, 0x21, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, @@ -107,14 +111,15 @@ TEST_CASE("Test SCSI get next block encryption status output 1", "[output]") const std::string expected_output {"\ Current block status: Not encrypted\n"s}; std::ostringstream oss; - print_block_status(oss, reinterpret_cast(page), algorithms); + print_block_status(oss, reinterpret_cast(page), + algorithms); REQUIRE(oss.str() == expected_output); } TEST_CASE("Test SCSI get next block encryption status output 2", "[output]") { std::map algorithms { - { 1, "AES-256-GCM-128"s }, + {1, "AES-256-GCM-128"s}, }; const std::uint8_t page[] { 0x00, 0x21, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -124,14 +129,15 @@ TEST_CASE("Test SCSI get next block encryption status output 2", "[output]") const std::string expected_output {"\ Current block status: Encrypted and able to decrypt (AES-256-GCM-128)\n"s}; std::ostringstream oss; - print_block_status(oss, reinterpret_cast(page), algorithms); + print_block_status(oss, reinterpret_cast(page), + algorithms); REQUIRE(oss.str() == expected_output); } TEST_CASE("Test SCSI get next block encryption status output 3", "[output]") { std::map algorithms { - { 1, "AES-256-GCM-128"s }, + {1, "AES-256-GCM-128"s}, }; const std::uint8_t page[] { 0x00, 0x21, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -142,7 +148,8 @@ TEST_CASE("Test SCSI get next block encryption status output 3", "[output]") Current block status: Encrypted, key missing or invalid (AES-256-GCM-128)\n\ Current block key desc. (U-KAD): Hello world!\n"s}; std::ostringstream oss; - print_block_status(oss, reinterpret_cast(page), algorithms); + print_block_status(oss, reinterpret_cast(page), + algorithms); REQUIRE(oss.str() == expected_output); } diff --git a/tests/scsi.cpp b/tests/scsi.cpp index db940c4..2c6e80c 100644 --- a/tests/scsi.cpp +++ b/tests/scsi.cpp @@ -5,10 +5,22 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" -#include "config.h" -#include "scsiencrypt.h" +#include +#include +#include +#include +#include +#include +#include +#if HAVE_ARPA_INET_H #include +#endif +#if HAVE_NETINET_IN_H +#include +#endif + +#include "scsiencrypt.h" using namespace std::literals::string_literals;