From 60939702e1071385ada5d1082b88763cbd1bab56 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Nov 2016 16:31:34 -0500 Subject: [PATCH] file: Add support for SHA-3 algorithms --- Source/cmFileCommand.cxx | 4 +++- Tests/CMakeTests/File-SHA3_224-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA3_256-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA3_384-Works.cmake | 2 ++ Tests/CMakeTests/File-SHA3_512-Works.cmake | 2 ++ Tests/CMakeTests/FileTest.cmake.in | 12 ++++++++++++ 6 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Tests/CMakeTests/File-SHA3_224-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA3_256-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA3_384-Works.cmake create mode 100644 Tests/CMakeTests/File-SHA3_512-Works.cmake diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 15257fc384..c2e37c1e3d 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -111,7 +111,9 @@ bool cmFileCommand::InitialPass(std::vector const& args, } if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || subCommand == "SHA256" || subCommand == "SHA384" || - subCommand == "SHA512") { + subCommand == "SHA512" || subCommand == "SHA3_224" || + subCommand == "SHA3_256" || subCommand == "SHA3_384" || + subCommand == "SHA3_512") { return this->HandleHashCommand(args); } if (subCommand == "STRINGS") { diff --git a/Tests/CMakeTests/File-SHA3_224-Works.cmake b/Tests/CMakeTests/File-SHA3_224-Works.cmake new file mode 100644 index 0000000000..e4f4e855eb --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_224-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_224 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_224) +message("${sha3_224}") diff --git a/Tests/CMakeTests/File-SHA3_256-Works.cmake b/Tests/CMakeTests/File-SHA3_256-Works.cmake new file mode 100644 index 0000000000..189c8a2961 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_256-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_256 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_256) +message("${sha3_256}") diff --git a/Tests/CMakeTests/File-SHA3_384-Works.cmake b/Tests/CMakeTests/File-SHA3_384-Works.cmake new file mode 100644 index 0000000000..08f9f5b3d5 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_384-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_384 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_384) +message("${sha3_384}") diff --git a/Tests/CMakeTests/File-SHA3_512-Works.cmake b/Tests/CMakeTests/File-SHA3_512-Works.cmake new file mode 100644 index 0000000000..4182196391 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_512-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_512 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_512) +message("${sha3_512}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 61523e6f64..71cb3db864 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -36,6 +36,14 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(SHA3_224-Works-RESULT 0) +set(SHA3_224-Works-STDERR "4272868085f4f25080681a7712509fd12e16dcda79bd356836dd2100") +set(SHA3_256-Works-RESULT 0) +set(SHA3_256-Works-STDERR "be0df472b6bd474417a166d12f2774f2ef5095e86f0a88ef4c78c703800cfc8a") +set(SHA3_384-Works-RESULT 0) +set(SHA3_384-Works-STDERR "935a17cc708443c1369549483656a4521af03a52e4f3b314566272017ccae03a2c5db838f6d4c156b1dc5c366182481b") +set(SHA3_512-Works-RESULT 0) +set(SHA3_512-Works-STDERR "471a85ed537e8f77f31412a089f22d836054ffa179599f87a5d7568927d8fa236b6793ded8a387d1de92398c967177bcc6361672a722bf736cb0f63a0956d5cf") set(TIMESTAMP-NoFile-RESULT 0) set(TIMESTAMP-NoFile-STDERR "~~") set(TIMESTAMP-BadArg1-RESULT 1) @@ -66,6 +74,10 @@ check_cmake_test(File SHA256-Works SHA384-Works SHA512-Works + SHA3_224-Works + SHA3_256-Works + SHA3_384-Works + SHA3_512-Works TIMESTAMP-NoFile TIMESTAMP-BadArg1 TIMESTAMP-NotBogus