[Cmake-commits] CMake branch, next, updated. v3.7.0-1127-geb93652

Brad King brad.king at kitware.com
Mon Nov 14 09:46:07 EST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  eb936525a239daceef1fb6c607e540046cf09f92 (commit)
       via  f636d1e74a5a9d39d2f25b72b26c3d24813a5565 (commit)
       via  cb5dba8eb12eb75a8e66bf9326bfec22f90fda9a (commit)
       via  a9fa60997a0e6438399e2e6e4a9c02f2935b386a (commit)
       via  b4ffd26fd8750989a8aadd626242c314068ba987 (commit)
       via  60939702e1071385ada5d1082b88763cbd1bab56 (commit)
       via  92f95aede99c76af2ccff09d5b9cc895539332d0 (commit)
       via  c326209fa351ca236778c462bcb0b85f6fa392f7 (commit)
       via  979e8ba6c6c6ed538b1dd9d60d89d863e7c4273c (commit)
       via  7a79f7e3c13d3f1c87db40c3230716dcb79d0df9 (commit)
       via  87584b5e9d4bb3147de4ad2adac2d337be456a62 (commit)
       via  7fcbd47e955d7e318f1f6dd96cc26d6737525c86 (commit)
       via  c50c32a30f434613a0a46b1c7dbb7eb03d29896d (commit)
      from  08580775f0cd1443db623def952be35f9995f18a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb936525a239daceef1fb6c607e540046cf09f92
commit eb936525a239daceef1fb6c607e540046cf09f92
Merge: 0858077 f636d1e
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Nov 14 09:46:05 2016 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Nov 14 09:46:05 2016 -0500

    Merge topic 'add-SHA-3' into next
    
    f636d1e7 Help: Add notes for topic 'add-SHA-3'
    cb5dba8e Tests: Add SHA-3 algorithm coverage to CPack checksum test
    a9fa6099 ExternalProject: Add support for SHA-3 algorithms
    b4ffd26f ExternalData: Add support for SHA-3 algorithms
    60939702 file: Add support for SHA-3 algorithms
    92f95aed string: Add support for SHA-3 algorithms
    c326209f cmCryptoHash: Add support for SHA-3 algorithms
    979e8ba6 Help: De-duplicate and spell out supported hash algorithms
    7a79f7e3 librhash: Activate SHA-3 implementation
    87584b5e Merge branch 'upstream-librhash' into add-SHA-3
    7fcbd47e librhash 2016-11-06 (de79828d)
    c50c32a3 librhash: Update import script to add SHA-3 implementation


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f636d1e74a5a9d39d2f25b72b26c3d24813a5565
commit f636d1e74a5a9d39d2f25b72b26c3d24813a5565
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:50:53 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Nov 11 11:46:01 2016 -0500

    Help: Add notes for topic 'add-SHA-3'

diff --git a/Help/release/dev/add-SHA-3.rst b/Help/release/dev/add-SHA-3.rst
new file mode 100644
index 0000000..5743f10
--- /dev/null
+++ b/Help/release/dev/add-SHA-3.rst
@@ -0,0 +1,4 @@
+add-SHA-3
+---------
+
+* CMake functionality using cryptographic hashes now supports SHA-3 algorithms.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb5dba8eb12eb75a8e66bf9326bfec22f90fda9a
commit cb5dba8eb12eb75a8e66bf9326bfec22f90fda9a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:42:34 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Nov 11 11:46:01 2016 -0500

    Tests: Add SHA-3 algorithm coverage to CPack checksum test

diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index 38bd0ea..61d4332 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -22,4 +22,4 @@ run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)
 run_cpack_test(DEBUGINFO "RPM" true)
 run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true)
 run_cpack_test(LONG_FILENAMES "DEB" false)
-run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false)
+run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512;SHA3_224;SHA3_256;SHA3_384;SHA3_512" "TGZ" false)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a9fa60997a0e6438399e2e6e4a9c02f2935b386a
commit a9fa60997a0e6438399e2e6e4a9c02f2935b386a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:36:12 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Nov 11 11:46:00 2016 -0500

    ExternalProject: Add support for SHA-3 algorithms

diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 1e0be09..88ea4d8 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -423,7 +423,7 @@ if(_ep_func)
 endif()
 
 # Save regex matching supported hash algorithm names.
-set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512")
+set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512")
 set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$")
 
 set(_ExternalProject_SELF "${CMAKE_CURRENT_LIST_FILE}")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b4ffd26fd8750989a8aadd626242c314068ba987
commit b4ffd26fd8750989a8aadd626242c314068ba987
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:35:59 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Nov 11 11:46:00 2016 -0500

    ExternalData: Add support for SHA-3 algorithms

diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 07cd114..873f88d 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -279,6 +279,10 @@ The following hash algorithms are supported::
  SHA256      .sha256   US Secure Hash Algorithms, RFC 4634
  SHA384      .sha384   US Secure Hash Algorithms, RFC 4634
  SHA512      .sha512   US Secure Hash Algorithms, RFC 4634
+ SHA3_224    .sha3-224 Keccak SHA-3
+ SHA3_256    .sha3-256 Keccak SHA-3
+ SHA3_384    .sha3-384 Keccak SHA-3
+ SHA3_512    .sha3-512 Keccak SHA-3
 
 Note that the hashes are used only for unique data identification and
 download verification.
@@ -508,8 +512,8 @@ endfunction()
 #-----------------------------------------------------------------------------
 # Private helper interface
 
-set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512")
-set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512")
+set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512")
+set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512|sha3-224|sha3-256|sha3-384|sha3-512")
 set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}")
 get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH)
 
@@ -1082,6 +1086,7 @@ if("${ExternalData_ACTION}" STREQUAL "fetch")
 
     if("${ext}" MATCHES "^\\.(${_ExternalData_REGEX_EXT})$")
       string(TOUPPER "${CMAKE_MATCH_1}" algo)
+      string(REPLACE "-" "_" algo "${algo}")
     else()
       message(FATAL_ERROR "Unknown hash algorithm extension \"${ext}\"")
     endif()
diff --git a/Tests/Module/ExternalData/SHA3_256/.gitattributes b/Tests/Module/ExternalData/SHA3_256/.gitattributes
new file mode 100644
index 0000000..3e51d39
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA3_256/.gitattributes
@@ -0,0 +1 @@
+*               -crlf
diff --git a/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 b/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231
new file mode 100644
index 0000000..0377f5d
--- /dev/null
+++ b/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231
@@ -0,0 +1 @@
+SeriesMixed.5
diff --git a/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 b/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256
new file mode 100644
index 0000000..1a5db39
--- /dev/null
+++ b/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256
@@ -0,0 +1 @@
+c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60939702e1071385ada5d1082b88763cbd1bab56
commit 60939702e1071385ada5d1082b88763cbd1bab56
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:31:34 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 16:41:45 2016 -0500

    file: Add support for SHA-3 algorithms

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 15257fc..c2e37c1 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -111,7 +111,9 @@ bool cmFileCommand::InitialPass(std::vector<std::string> 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 0000000..e4f4e85
--- /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 0000000..189c8a2
--- /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 0000000..08f9f5b
--- /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 0000000..4182196
--- /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 61523e6..71cb3db 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

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92f95aede99c76af2ccff09d5b9cc895539332d0
commit 92f95aede99c76af2ccff09d5b9cc895539332d0
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:31:34 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 16:40:43 2016 -0500

    string: Add support for SHA-3 algorithms

diff --git a/Help/command/string.rst b/Help/command/string.rst
index ae9442d..77538f6 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -230,6 +230,14 @@ The supported ``<HASH>`` algorithm names are:
   US Secure Hash Algorithms, RFC 4634.
 ``SHA512``
   US Secure Hash Algorithms, RFC 4634.
+``SHA3_224``
+  Keccak SHA-3.
+``SHA3_256``
+  Keccak SHA-3.
+``SHA3_384``
+  Keccak SHA-3.
+``SHA3_512``
+  Keccak SHA-3.
 
 Generation
 ^^^^^^^^^^
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index f835445..603c990 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -36,7 +36,9 @@ bool cmStringCommand::InitialPass(std::vector<std::string> 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 == "TOLOWER") {
diff --git a/Tests/CMakeTests/String-SHA3_224-Works.cmake b/Tests/CMakeTests/String-SHA3_224-Works.cmake
new file mode 100644
index 0000000..6aeb91d
--- /dev/null
+++ b/Tests/CMakeTests/String-SHA3_224-Works.cmake
@@ -0,0 +1,2 @@
+string(SHA3_224 sha3_224 "sample input string\n")
+message("${sha3_224}")
diff --git a/Tests/CMakeTests/String-SHA3_256-Works.cmake b/Tests/CMakeTests/String-SHA3_256-Works.cmake
new file mode 100644
index 0000000..cc7ea1a
--- /dev/null
+++ b/Tests/CMakeTests/String-SHA3_256-Works.cmake
@@ -0,0 +1,2 @@
+string(SHA3_256 sha3_256 "sample input string\n")
+message("${sha3_256}")
diff --git a/Tests/CMakeTests/String-SHA3_384-Works.cmake b/Tests/CMakeTests/String-SHA3_384-Works.cmake
new file mode 100644
index 0000000..9341c3f
--- /dev/null
+++ b/Tests/CMakeTests/String-SHA3_384-Works.cmake
@@ -0,0 +1,2 @@
+string(SHA3_384 sha3_384 "sample input string\n")
+message("${sha3_384}")
diff --git a/Tests/CMakeTests/String-SHA3_512-Works.cmake b/Tests/CMakeTests/String-SHA3_512-Works.cmake
new file mode 100644
index 0000000..cf4eddd
--- /dev/null
+++ b/Tests/CMakeTests/String-SHA3_512-Works.cmake
@@ -0,0 +1,2 @@
+string(SHA3_512 sha3_512 "sample input string\n")
+message("${sha3_512}")
diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in
index a45b205..83655da 100644
--- a/Tests/CMakeTests/StringTest.cmake.in
+++ b/Tests/CMakeTests/StringTest.cmake.in
@@ -16,6 +16,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-BadArg1-RESULT 1)
 set(TIMESTAMP-BadArg1-STDERR "string sub-command TIMESTAMP requires at least one argument")
 set(TIMESTAMP-BadArg2-RESULT 1)
@@ -52,6 +60,10 @@ check_cmake_test(String
   SHA256-Works
   SHA384-Works
   SHA512-Works
+  SHA3_224-Works
+  SHA3_256-Works
+  SHA3_384-Works
+  SHA3_512-Works
   TIMESTAMP-BadArg1
   TIMESTAMP-BadArg2
   TIMESTAMP-BadArg3

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c326209fa351ca236778c462bcb0b85f6fa392f7
commit c326209fa351ca236778c462bcb0b85f6fa392f7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 16:31:34 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 16:38:34 2016 -0500

    cmCryptoHash: Add support for SHA-3 algorithms

diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index f440999..d5807b1 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -9,12 +9,16 @@
 
 static unsigned int const cmCryptoHashAlgoToId[] = {
   /* clang-format needs this comment to break after the opening brace */
-  RHASH_MD5,    //
-  RHASH_SHA1,   //
-  RHASH_SHA224, //
-  RHASH_SHA256, //
-  RHASH_SHA384, //
-  RHASH_SHA512
+  RHASH_MD5,      //
+  RHASH_SHA1,     //
+  RHASH_SHA224,   //
+  RHASH_SHA256,   //
+  RHASH_SHA384,   //
+  RHASH_SHA512,   //
+  RHASH_SHA3_224, //
+  RHASH_SHA3_256, //
+  RHASH_SHA3_384, //
+  RHASH_SHA3_512
 };
 
 static int cmCryptoHash_rhash_library_initialized;
@@ -59,6 +63,18 @@ CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo)
   if (strcmp(algo, "SHA512") == 0) {
     return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA512));
   }
+  if (strcmp(algo, "SHA3_224") == 0) {
+    return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_224));
+  }
+  if (strcmp(algo, "SHA3_256") == 0) {
+    return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_256));
+  }
+  if (strcmp(algo, "SHA3_384") == 0) {
+    return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_384));
+  }
+  if (strcmp(algo, "SHA3_512") == 0) {
+    return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_512));
+  }
   return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR);
 }
 
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 95080ac..26d55b3 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -22,7 +22,11 @@ public:
     AlgoSHA224,
     AlgoSHA256,
     AlgoSHA384,
-    AlgoSHA512
+    AlgoSHA512,
+    AlgoSHA3_224,
+    AlgoSHA3_256,
+    AlgoSHA3_384,
+    AlgoSHA3_512
   };
 
   cmCryptoHash(Algo algo);
@@ -30,7 +34,8 @@ public:
 
   /// @brief Returns a new hash generator of the requested type
   /// @arg algo Hash type name. Supported hash types are
-  ///      MD5, SHA1, SHA224, SHA256, SHA384, SHA512
+  ///      MD5, SHA1, SHA224, SHA256, SHA384, SHA512,
+  ///      SHA3_224, SHA3_256, SHA3_384, SHA3_512
   /// @return A valid auto pointer if algo is supported or
   ///         an invalid/NULL pointer otherwise
   static CM_AUTO_PTR<cmCryptoHash> New(const char* algo);

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=979e8ba6c6c6ed538b1dd9d60d89d863e7c4273c
commit 979e8ba6c6c6ed538b1dd9d60d89d863e7c4273c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 15:55:29 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 16:07:46 2016 -0500

    Help: De-duplicate and spell out supported hash algorithms
    
    Spell out the supported algorithms in a definition list in the
    `string(<HASH>)` command documentation.  Revise the `file(<HASH>)`
    command and CPack module documentation to reference it instead of
    duplicating the list.

diff --git a/Help/command/file.rst b/Help/command/file.rst
index 8da46cb..3e669c2 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -83,10 +83,12 @@ from the input file.
 
 ::
 
-  file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> <filename> <variable>)
+  file(<HASH> <filename> <variable>)
 
 Compute a cryptographic hash of the content of ``<filename>`` and
-store it in a ``<variable>``.
+store it in a ``<variable>``.  The supported ``<HASH>`` algorithm names
+are those listed by the :ref:`string(\<HASH\>) <Supported Hash Algorithms>`
+command.
 
 ------------------------------------------------------------------------------
 
@@ -234,8 +236,8 @@ Additional options to ``DOWNLOAD`` are:
 ``EXPECTED_HASH ALGO=<value>``
 
   Verify that the downloaded content hash matches the expected value, where
-  ``ALGO`` is one of ``MD5``, ``SHA1``, ``SHA224``, ``SHA256``, ``SHA384``, or
-  ``SHA512``.  If it does not match, the operation fails with an error.
+  ``ALGO`` is one of the algorithms supported by ``file(<HASH>)``.
+  If it does not match, the operation fails with an error.
 
 ``EXPECTED_MD5 <value>``
   Historical short-hand for ``EXPECTED_HASH MD5=<value>``.
diff --git a/Help/command/string.rst b/Help/command/string.rst
index 8028333..ae9442d 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -206,15 +206,30 @@ Comparison
 
 Compare the strings and store true or false in the output variable.
 
+.. _`Supported Hash Algorithms`:
+
 Hashing
 ^^^^^^^
 
 ::
 
-  string(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512>
-         <output variable> <input>)
+  string(<HASH> <output variable> <input>)
 
 Compute a cryptographic hash of the input string.
+The supported ``<HASH>`` algorithm names are:
+
+``MD5``
+  Message-Digest Algorithm 5, RFC 1321.
+``SHA1``
+  US Secure Hash Algorithm 1, RFC 3174.
+``SHA224``
+  US Secure Hash Algorithms, RFC 4634.
+``SHA256``
+  US Secure Hash Algorithms, RFC 4634.
+``SHA384``
+  US Secure Hash Algorithms, RFC 4634.
+``SHA512``
+  US Secure Hash Algorithms, RFC 4634.
 
 Generation
 ^^^^^^^^^^
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index cee1914..4e7546b 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -126,7 +126,9 @@
 #
 #     ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM}
 #
-#  Current supported alogorithms: MD5|SHA1|SHA224|SHA256|SHA384|SHA512.
+#  Supported algorithms are those listed by the
+#  :ref:`string(\<HASH\>) <Supported Hash Algorithms>`
+#  command.
 #
 # .. variable:: CPACK_PROJECT_CONFIG_FILE
 #

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a79f7e3c13d3f1c87db40c3230716dcb79d0df9
commit 7a79f7e3c13d3f1c87db40c3230716dcb79d0df9
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 15:48:41 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 15:48:41 2016 -0500

    librhash: Activate SHA-3 implementation

diff --git a/Utilities/cmlibrhash/CMakeLists.txt b/Utilities/cmlibrhash/CMakeLists.txt
index 340d946..aa28055 100644
--- a/Utilities/cmlibrhash/CMakeLists.txt
+++ b/Utilities/cmlibrhash/CMakeLists.txt
@@ -23,6 +23,8 @@ set(librhash_sources
   librhash/sha1.h
   librhash/sha256.c
   librhash/sha256.h
+  librhash/sha3.c
+  librhash/sha3.h
   librhash/sha512.c
   librhash/sha512.h
   librhash/ustd.h
diff --git a/Utilities/cmlibrhash/librhash/algorithms.c b/Utilities/cmlibrhash/librhash/algorithms.c
index 56d20b8..fc01690 100644
--- a/Utilities/cmlibrhash/librhash/algorithms.c
+++ b/Utilities/cmlibrhash/librhash/algorithms.c
@@ -39,8 +39,8 @@
 #include "sha1.h"
 #include "sha256.h"
 #include "sha512.h"
-#if 0
 #include "sha3.h"
+#if 0
 #include "tiger.h"
 #include "tth.h"
 #include "whirlpool.h"
@@ -104,11 +104,11 @@ rhash_info info_sha512 = { RHASH_SHA512,     F_BE64, 64, "SHA-512", "sha512" };
 #if 0
 rhash_info info_edr256 = { RHASH_EDONR256,   F_LE32, 32, "EDON-R256", "edon-r256" };
 rhash_info info_edr512 = { RHASH_EDONR512,   F_LE64, 64, "EDON-R512", "edon-r512" };
+#endif
 rhash_info info_sha3_224 = { RHASH_SHA3_224, F_LE64, 28, "SHA3-224", "sha3-224" };
 rhash_info info_sha3_256 = { RHASH_SHA3_256, F_LE64, 32, "SHA3-256", "sha3-256" };
 rhash_info info_sha3_384 = { RHASH_SHA3_384, F_LE64, 48, "SHA3-384", "sha3-384" };
 rhash_info info_sha3_512 = { RHASH_SHA3_512, F_LE64, 64, "SHA3-512", "sha3-512" };
-#endif
 
 /* some helper macros */
 #define dgshft(name) (((char*)&((name##_ctx*)0)->hash) - (char*)0)
@@ -148,11 +148,11 @@ rhash_hash_info rhash_hash_info_default[RHASH_HASH_COUNT] =
 #if 0
 	{ &info_edr256, sizeof(edonr_ctx), dgshft2(edonr, u.data256.hash) + 32, iuf(rhash_edonr256), 0 },  /* 256 bit */
 	{ &info_edr512, sizeof(edonr_ctx), dgshft2(edonr, u.data512.hash) + 64, iuf(rhash_edonr512), 0 },  /* 512 bit */
+#endif
 	{ &info_sha3_224, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_224), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 224 bit */
 	{ &info_sha3_256, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_256), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 256 bit */
 	{ &info_sha3_384, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_384), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 384 bit */
 	{ &info_sha3_512, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_512), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 512 bit */
-#endif
 };
 
 /**
diff --git a/Utilities/cmlibrhash/librhash/rhash.h b/Utilities/cmlibrhash/librhash/rhash.h
index 1ac6265..cee0e25 100644
--- a/Utilities/cmlibrhash/librhash/rhash.h
+++ b/Utilities/cmlibrhash/librhash/rhash.h
@@ -66,14 +66,22 @@ enum rhash_ids
 	RHASH_SHA256     = 0x08,
 	RHASH_SHA384     = 0x10,
 	RHASH_SHA512     = 0x20,
+	RHASH_SHA3_224   = 0x40,
+	RHASH_SHA3_256   = 0x80,
+	RHASH_SHA3_384   = 0x100,
+	RHASH_SHA3_512   = 0x200,
 	RHASH_ALL_HASHES =
 		RHASH_MD5 |
 		RHASH_SHA1 |
 		RHASH_SHA224 |
 		RHASH_SHA256 |
 		RHASH_SHA384 |
-		RHASH_SHA512,
-	RHASH_HASH_COUNT = 6
+		RHASH_SHA512 |
+		RHASH_SHA3_224 |
+		RHASH_SHA3_256 |
+		RHASH_SHA3_384 |
+		RHASH_SHA3_512,
+	RHASH_HASH_COUNT = 10
 #endif
 };
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87584b5e9d4bb3147de4ad2adac2d337be456a62
commit 87584b5e9d4bb3147de4ad2adac2d337be456a62
Merge: c50c32a 7fcbd47
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 15:42:32 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 15:42:32 2016 -0500

    Merge branch 'upstream-librhash' into add-SHA-3
    
    * upstream-librhash:
      librhash 2016-11-06 (de79828d)

diff --cc Utilities/cmlibrhash/librhash/rhash.h
index 6d18c18,0000000..1ac6265
mode 100644,000000..100644
--- a/Utilities/cmlibrhash/librhash/rhash.h
+++ b/Utilities/cmlibrhash/librhash/rhash.h
@@@ -1,280 -1,0 +1,280 @@@
 +/** @file rhash.h LibRHash interface */
 +#ifndef RHASH_H
 +#define RHASH_H
 +
 +#include <stdio.h>
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
 +#ifndef RHASH_API
 +/* modifier for LibRHash functions */
 +# define RHASH_API
 +#endif
 +
 +/**
 + * Identifiers of supported hash functions.
 + * The rhash_init() function allows mixing several ids using
 + * binary OR, to calculate several hash functions for one message.
 + */
 +enum rhash_ids
 +{
 +#if 0
 +	RHASH_CRC32 = 0x01,
 +	RHASH_MD4   = 0x02,
 +	RHASH_MD5   = 0x04,
 +	RHASH_SHA1  = 0x08,
 +	RHASH_TIGER = 0x10,
 +	RHASH_TTH   = 0x20,
 +	RHASH_BTIH  = 0x40,
 +	RHASH_ED2K  = 0x80,
 +	RHASH_AICH  = 0x100,
 +	RHASH_WHIRLPOOL = 0x200,
 +	RHASH_RIPEMD160 = 0x400,
 +	RHASH_GOST      = 0x800,
 +	RHASH_GOST_CRYPTOPRO = 0x1000,
 +	RHASH_HAS160    = 0x2000,
 +	RHASH_SNEFRU128 = 0x4000,
 +	RHASH_SNEFRU256 = 0x8000,
 +	RHASH_SHA224    = 0x10000,
 +	RHASH_SHA256    = 0x20000,
 +	RHASH_SHA384    = 0x40000,
 +	RHASH_SHA512    = 0x80000,
 +	RHASH_EDONR256  = 0x0100000,
 +	RHASH_EDONR512  = 0x0200000,
 +	RHASH_SHA3_224  = 0x0400000,
 +	RHASH_SHA3_256  = 0x0800000,
 +	RHASH_SHA3_384  = 0x1000000,
 +	RHASH_SHA3_512  = 0x2000000,
 +
 +	/** The bit-mask containing all supported hashe functions */
 +	RHASH_ALL_HASHES = RHASH_CRC32 | RHASH_MD4 | RHASH_MD5 | RHASH_ED2K | RHASH_SHA1 |
 +		RHASH_TIGER | RHASH_TTH | RHASH_GOST | RHASH_GOST_CRYPTOPRO |
 +		RHASH_BTIH | RHASH_AICH | RHASH_WHIRLPOOL | RHASH_RIPEMD160 |
 +		RHASH_HAS160 | RHASH_SNEFRU128 | RHASH_SNEFRU256 |
 +		RHASH_SHA224 | RHASH_SHA256 | RHASH_SHA384 | RHASH_SHA512 |
 +		RHASH_SHA3_224 | RHASH_SHA3_256 | RHASH_SHA3_384 | RHASH_SHA3_512 |
 +		RHASH_EDONR256 | RHASH_EDONR512,
 +
 +	/** The number of supported hash functions */
 +	RHASH_HASH_COUNT = 26
 +#else
 +	RHASH_MD5        = 0x01,
 +	RHASH_SHA1       = 0x02,
 +	RHASH_SHA224     = 0x04,
 +	RHASH_SHA256     = 0x08,
 +	RHASH_SHA384     = 0x10,
 +	RHASH_SHA512     = 0x20,
 +	RHASH_ALL_HASHES =
 +		RHASH_MD5 |
 +		RHASH_SHA1 |
 +		RHASH_SHA224 |
 +		RHASH_SHA256 |
 +		RHASH_SHA384 |
 +		RHASH_SHA512,
 +	RHASH_HASH_COUNT = 6
 +#endif
 +};
 +
 +/**
 + * The rhash context structure contains contexts for several hash functions
 + */
 +typedef struct rhash_context
 +{
 +	/** The size of the hashed message */
 +	unsigned long long msg_size;
 +
 +	/**
 +	 * The bit-mask containing identifiers of the hashes being calculated
 +	 */
 +	unsigned hash_id;
 +} rhash_context;
 +
 +#ifndef LIBRHASH_RHASH_CTX_DEFINED
 +#define LIBRHASH_RHASH_CTX_DEFINED
 +/**
 + * Hashing context.
 + */
 +typedef struct rhash_context* rhash;
 +#endif /* LIBRHASH_RHASH_CTX_DEFINED */
 +
 +/** type of a callback to be called periodically while hashing a file */
 +typedef void (*rhash_callback_t)(void* data, unsigned long long offset);
 +
 +RHASH_API void rhash_library_init(void); /* initialize static data */
 +
 +/* hi-level hashing functions */
 +RHASH_API int rhash_msg(unsigned hash_id, const void* message, size_t length, unsigned char* result);
 +RHASH_API int rhash_file(unsigned hash_id, const char* filepath, unsigned char* result);
 +RHASH_API int rhash_file_update(rhash ctx, FILE* fd);
 +
 +#ifdef _WIN32 /* windows only function */
 +RHASH_API int rhash_wfile(unsigned hash_id, const wchar_t* filepath, unsigned char* result);
 +#endif
 +
 +/* lo-level interface */
 +RHASH_API rhash rhash_init(unsigned hash_id);
 +/*RHASH_API rhash rhash_init_by_ids(unsigned hash_ids[], unsigned count);*/
 +RHASH_API int  rhash_update(rhash ctx, const void* message, size_t length);
 +RHASH_API int  rhash_final(rhash ctx, unsigned char* first_result);
 +RHASH_API void rhash_reset(rhash ctx); /* reinitialize the context */
 +RHASH_API void rhash_free(rhash ctx);
 +
 +/* additional lo-level functions */
 +RHASH_API void  rhash_set_callback(rhash ctx, rhash_callback_t callback, void* callback_data);
 +
 +/** bit-flag: default hash output format is base32 */
 +#define RHASH_INFO_BASE32 1
 +
 +/**
 + * Information about a hash function.
 + */
 +typedef struct rhash_info
 +{
 +	/** hash function indentifier */
 +	unsigned hash_id;
 +	/** flags bit-mask, including RHASH_INFO_BASE32 bit */
 +	unsigned flags;
 +	/** size of binary message digest in bytes */
 +	size_t digest_size;
 +	const char* name;
 +	const char* magnet_name;
 +} rhash_info;
 +
 +/* information functions */
 +RHASH_API int  rhash_count(void); /* number of supported hashes */
 +RHASH_API int  rhash_get_digest_size(unsigned hash_id); /* size of binary message digest */
- RHASH_API int  rhash_get_hash_length(unsigned hash_id); /* length of formated hash string */
++RHASH_API int  rhash_get_hash_length(unsigned hash_id); /* length of formatted hash string */
 +RHASH_API int  rhash_is_base32(unsigned hash_id); /* default digest output format */
 +RHASH_API const char* rhash_get_name(unsigned hash_id); /* get hash function name */
 +RHASH_API const char* rhash_get_magnet_name(unsigned hash_id); /* get name part of magnet urn */
 +
 +/* note, that rhash_info_by_id() is not exported to a shared library or DLL */
 +const rhash_info* rhash_info_by_id(unsigned hash_id); /* get hash sum info by hash id */
 +
 +#if 0
 +/**
 + * Flags for printing a hash sum
 + */
 +enum rhash_print_sum_flags
 +{
 +	/** print in a default format */
 +	RHPR_DEFAULT   = 0x0,
 +	/** output as binary message digest */
 +	RHPR_RAW       = 0x1,
 +	/** print as a hexadecimal string */
 +	RHPR_HEX       = 0x2,
 +	/** print as a base32-encoded string */
 +	RHPR_BASE32    = 0x3,
 +	/** print as a base64-encoded string */
 +	RHPR_BASE64    = 0x4,
 +
 +	/**
 +	 * Print as an uppercase string. Can be used
 +	 * for base32 or hexadecimal format only.
 +	 */
 +	RHPR_UPPERCASE = 0x8,
 +
 +	/**
 +	 * Reverse hash bytes. Can be used for GOST hash.
 +	 */
 +	RHPR_REVERSE   = 0x10,
 +
 +	/** don't print 'magnet:?' prefix in rhash_print_magnet */
 +	RHPR_NO_MAGNET  = 0x20,
 +	/** print file size in rhash_print_magnet */
 +	RHPR_FILESIZE  = 0x40,
 +};
 +#endif
 +
 +/* output hash into the given buffer */
 +RHASH_API size_t rhash_print_bytes(char* output,
 +	const unsigned char* bytes, size_t size, int flags);
 +
 +RHASH_API size_t rhash_print(char* output, rhash ctx, unsigned hash_id,
 +	int flags);
 +
 +/* output magnet URL into the given buffer */
 +RHASH_API size_t rhash_print_magnet(char* output, const char* filepath,
 +	rhash context, unsigned hash_mask, int flags);
 +
 +/* macros for message API */
 +
 +/** The type of an unsigned integer large enough to hold a pointer */
 +#if defined(UINTPTR_MAX)
 +typedef uintptr_t rhash_uptr_t;
 +#elif defined(_LP64) || defined(__LP64__) || defined(__x86_64) || \
 +	defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
 +typedef unsigned long long rhash_uptr_t;
 +#else
 +typedef unsigned long rhash_uptr_t;
 +#endif
 +
 +/** The value returned by rhash_transmit on error */
 +#define RHASH_ERROR ((rhash_uptr_t)-1)
 +/** Convert a pointer to rhash_uptr_t */
 +#define RHASH_STR2UPTR(str) ((rhash_uptr_t)(char*)(str))
 +/** Convert a rhash_uptr_t to a void* pointer */
 +#define RHASH_UPTR2PVOID(u) ((void*)((char*)0 + (u)))
 +
 +/* rhash API to set/get data via messages */
 +RHASH_API rhash_uptr_t rhash_transmit(
 +	unsigned msg_id, void* dst, rhash_uptr_t ldata, rhash_uptr_t rdata);
 +
 +/* rhash message constants */
 +
 +#define RMSG_GET_CONTEXT 1
 +#define RMSG_CANCEL      2
 +#define RMSG_IS_CANCELED 3
 +#define RMSG_GET_FINALIZED 4
 +#define RMSG_SET_AUTOFINAL 5
 +#define RMSG_SET_OPENSSL_MASK 10
 +#define RMSG_GET_OPENSSL_MASK 11
 +
 +/* helper macros */
 +
 +/** Get a pointer to context of the specified hash function */
 +#define rhash_get_context_ptr(ctx, hash_id) RHASH_UPTR2PVOID(rhash_transmit(RMSG_GET_CONTEXT, ctx, hash_id, 0))
 +/** Cancel hash calculation of a file */
 +#define rhash_cancel(ctx) rhash_transmit(RMSG_CANCEL, ctx, 0, 0)
 +/** Return non-zero if hash calculation was canceled, zero otherwise */
 +#define rhash_is_canceled(ctx) rhash_transmit(RMSG_IS_CANCELED, ctx, 0, 0)
 +/** Return non-zero if rhash_final was called for rhash_context */
 +#define rhash_get_finalized(ctx) rhash_transmit(RMSG_GET_FINALIZED, ctx, 0, 0)
 +
 +/**
 + * Turn on/off the auto-final flag for the given rhash_context. By default
 + * auto-final is on, which means rhash_final is called automatically, if
 + * needed when a hash value is retrived by rhash_print call.
 + */
 +#define rhash_set_autofinal(ctx, on) rhash_transmit(RMSG_SET_AUTOFINAL, ctx, on, 0)
 +
 +/**
 + * Set the bit-mask of hash algorithms to be calculated by OpenSSL library.
 + * The call rhash_set_openssl_mask(0) made before rhash_library_init(),
 + * turns off loading of the OpenSSL dynamic library.
 + * This call works if the LibRHash was compiled with OpenSSL support.
 + */
 +#define rhash_set_openssl_mask(mask) rhash_transmit(RMSG_SET_OPENSSL_MASK, NULL, mask, 0)
 +
 +/**
 + * Return current bit-mask of hash algorithms selected to be calculated
 + * by OpenSSL library.
 + */
 +#define rhash_get_openssl_mask() rhash_transmit(RMSG_GET_OPENSSL_MASK, NULL, 0, 0)
 +
 +/** The bit mask of hash algorithms implemented by OpenSSL */
 +#if defined(USE_OPENSSL) || defined(OPENSSL_RUNTIME)
 +# define RHASH_OPENSSL_SUPPORTED_HASHES (RHASH_MD4 | RHASH_MD5 | \
 +	RHASH_SHA1 | RHASH_SHA224 | RHASH_SHA256 | RHASH_SHA384 | \
 +	RHASH_SHA512 | RHASH_RIPEMD160 | RHASH_WHIRLPOOL)
 +#else
 +# define RHASH_OPENSSL_SUPPORTED_HASHES 0
 +#endif
 +
 +#ifdef __cplusplus
 +} /* extern "C" */
 +#endif /* __cplusplus */
 +
 +#endif /* RHASH_H */
diff --cc Utilities/cmlibrhash/librhash/sha3.c
index 0000000,e4a845f..e4a845f
mode 000000,100644..100644
--- a/Utilities/cmlibrhash/librhash/sha3.c
+++ b/Utilities/cmlibrhash/librhash/sha3.c
diff --cc Utilities/cmlibrhash/librhash/sha3.h
index 0000000,2831997..2831997
mode 000000,100644..100644
--- a/Utilities/cmlibrhash/librhash/sha3.h
+++ b/Utilities/cmlibrhash/librhash/sha3.h

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fcbd47e955d7e318f1f6dd96cc26d6737525c86
commit 7fcbd47e955d7e318f1f6dd96cc26d6737525c86
Author:     librhash upstream <kwrobot at kitware.com>
AuthorDate: Sun Nov 6 23:12:16 2016 +0300
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 15:42:31 2016 -0500

    librhash 2016-11-06 (de79828d)
    
    Code extracted from:
    
        https://github.com/rhash/rhash.git
    
    at commit de79828d01d5a7d86cb77edb0569d75bfed6d2dc (master).

diff --git a/librhash/rhash.h b/librhash/rhash.h
index 73ee537..4276938 100644
--- a/librhash/rhash.h
+++ b/librhash/rhash.h
@@ -128,7 +128,7 @@ typedef struct rhash_info
 /* information functions */
 RHASH_API int  rhash_count(void); /* number of supported hashes */
 RHASH_API int  rhash_get_digest_size(unsigned hash_id); /* size of binary message digest */
-RHASH_API int  rhash_get_hash_length(unsigned hash_id); /* length of formated hash string */
+RHASH_API int  rhash_get_hash_length(unsigned hash_id); /* length of formatted hash string */
 RHASH_API int  rhash_is_base32(unsigned hash_id); /* default digest output format */
 RHASH_API const char* rhash_get_name(unsigned hash_id); /* get hash function name */
 RHASH_API const char* rhash_get_magnet_name(unsigned hash_id); /* get name part of magnet urn */
diff --git a/librhash/sha3.c b/librhash/sha3.c
new file mode 100644
index 0000000..e4a845f
--- /dev/null
+++ b/librhash/sha3.c
@@ -0,0 +1,356 @@
+/* sha3.c - an implementation of Secure Hash Algorithm 3 (Keccak).
+ * based on the
+ * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011
+ * by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche
+ *
+ * Copyright: 2013 Aleksey Kravchenko <rhash.admin at gmail.com>
+ *
+ * Permission is hereby granted,  free of charge,  to any person  obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction,  including without limitation
+ * the rights to  use, copy, modify,  merge, publish, distribute, sublicense,
+ * and/or sell copies  of  the Software,  and to permit  persons  to whom the
+ * Software is furnished to do so.
+ *
+ * This program  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.  Use this program  at  your own risk!
+ */
+
+#include <assert.h>
+#include <string.h>
+#include "byte_order.h"
+#include "sha3.h"
+
+/* constants */
+#define NumberOfRounds 24
+
+/* SHA3 (Keccak) constants for 24 rounds */
+static uint64_t keccak_round_constants[NumberOfRounds] = {
+	I64(0x0000000000000001), I64(0x0000000000008082), I64(0x800000000000808A), I64(0x8000000080008000),
+	I64(0x000000000000808B), I64(0x0000000080000001), I64(0x8000000080008081), I64(0x8000000000008009),
+	I64(0x000000000000008A), I64(0x0000000000000088), I64(0x0000000080008009), I64(0x000000008000000A),
+	I64(0x000000008000808B), I64(0x800000000000008B), I64(0x8000000000008089), I64(0x8000000000008003),
+	I64(0x8000000000008002), I64(0x8000000000000080), I64(0x000000000000800A), I64(0x800000008000000A),
+	I64(0x8000000080008081), I64(0x8000000000008080), I64(0x0000000080000001), I64(0x8000000080008008)
+};
+
+/* Initializing a sha3 context for given number of output bits */
+static void rhash_keccak_init(sha3_ctx *ctx, unsigned bits)
+{
+	/* NB: The Keccak capacity parameter = bits * 2 */
+	unsigned rate = 1600 - bits * 2;
+
+	memset(ctx, 0, sizeof(sha3_ctx));
+	ctx->block_size = rate / 8;
+	assert(rate <= 1600 && (rate % 64) == 0);
+}
+
+/**
+ * Initialize context before calculating hash.
+ *
+ * @param ctx context to initialize
+ */
+void rhash_sha3_224_init(sha3_ctx *ctx)
+{
+	rhash_keccak_init(ctx, 224);
+}
+
+/**
+ * Initialize context before calculating hash.
+ *
+ * @param ctx context to initialize
+ */
+void rhash_sha3_256_init(sha3_ctx *ctx)
+{
+	rhash_keccak_init(ctx, 256);
+}
+
+/**
+ * Initialize context before calculating hash.
+ *
+ * @param ctx context to initialize
+ */
+void rhash_sha3_384_init(sha3_ctx *ctx)
+{
+	rhash_keccak_init(ctx, 384);
+}
+
+/**
+ * Initialize context before calculating hash.
+ *
+ * @param ctx context to initialize
+ */
+void rhash_sha3_512_init(sha3_ctx *ctx)
+{
+	rhash_keccak_init(ctx, 512);
+}
+
+/* Keccak theta() transformation */
+static void keccak_theta(uint64_t *A)
+{
+	unsigned int x;
+	uint64_t C[5], D[5];
+
+	for (x = 0; x < 5; x++) {
+		C[x] = A[x] ^ A[x + 5] ^ A[x + 10] ^ A[x + 15] ^ A[x + 20];
+	}
+	D[0] = ROTL64(C[1], 1) ^ C[4];
+	D[1] = ROTL64(C[2], 1) ^ C[0];
+	D[2] = ROTL64(C[3], 1) ^ C[1];
+	D[3] = ROTL64(C[4], 1) ^ C[2];
+	D[4] = ROTL64(C[0], 1) ^ C[3];
+
+	for (x = 0; x < 5; x++) {
+		A[x]      ^= D[x];
+		A[x + 5]  ^= D[x];
+		A[x + 10] ^= D[x];
+		A[x + 15] ^= D[x];
+		A[x + 20] ^= D[x];
+	}
+}
+
+/* Keccak pi() transformation */
+static void keccak_pi(uint64_t *A)
+{
+	uint64_t A1;
+	A1 = A[1];
+	A[ 1] = A[ 6];
+	A[ 6] = A[ 9];
+	A[ 9] = A[22];
+	A[22] = A[14];
+	A[14] = A[20];
+	A[20] = A[ 2];
+	A[ 2] = A[12];
+	A[12] = A[13];
+	A[13] = A[19];
+	A[19] = A[23];
+	A[23] = A[15];
+	A[15] = A[ 4];
+	A[ 4] = A[24];
+	A[24] = A[21];
+	A[21] = A[ 8];
+	A[ 8] = A[16];
+	A[16] = A[ 5];
+	A[ 5] = A[ 3];
+	A[ 3] = A[18];
+	A[18] = A[17];
+	A[17] = A[11];
+	A[11] = A[ 7];
+	A[ 7] = A[10];
+	A[10] = A1;
+	/* note: A[ 0] is left as is */
+}
+
+/* Keccak chi() transformation */
+static void keccak_chi(uint64_t *A)
+{
+	int i;
+	for (i = 0; i < 25; i += 5) {
+		uint64_t A0 = A[0 + i], A1 = A[1 + i];
+		A[0 + i] ^= ~A1 & A[2 + i];
+		A[1 + i] ^= ~A[2 + i] & A[3 + i];
+		A[2 + i] ^= ~A[3 + i] & A[4 + i];
+		A[3 + i] ^= ~A[4 + i] & A0;
+		A[4 + i] ^= ~A0 & A1;
+	}
+}
+
+static void rhash_sha3_permutation(uint64_t *state)
+{
+	int round;
+	for (round = 0; round < NumberOfRounds; round++)
+	{
+		keccak_theta(state);
+
+		/* apply Keccak rho() transformation */
+		state[ 1] = ROTL64(state[ 1],  1);
+		state[ 2] = ROTL64(state[ 2], 62);
+		state[ 3] = ROTL64(state[ 3], 28);
+		state[ 4] = ROTL64(state[ 4], 27);
+		state[ 5] = ROTL64(state[ 5], 36);
+		state[ 6] = ROTL64(state[ 6], 44);
+		state[ 7] = ROTL64(state[ 7],  6);
+		state[ 8] = ROTL64(state[ 8], 55);
+		state[ 9] = ROTL64(state[ 9], 20);
+		state[10] = ROTL64(state[10],  3);
+		state[11] = ROTL64(state[11], 10);
+		state[12] = ROTL64(state[12], 43);
+		state[13] = ROTL64(state[13], 25);
+		state[14] = ROTL64(state[14], 39);
+		state[15] = ROTL64(state[15], 41);
+		state[16] = ROTL64(state[16], 45);
+		state[17] = ROTL64(state[17], 15);
+		state[18] = ROTL64(state[18], 21);
+		state[19] = ROTL64(state[19],  8);
+		state[20] = ROTL64(state[20], 18);
+		state[21] = ROTL64(state[21],  2);
+		state[22] = ROTL64(state[22], 61);
+		state[23] = ROTL64(state[23], 56);
+		state[24] = ROTL64(state[24], 14);
+
+		keccak_pi(state);
+		keccak_chi(state);
+
+		/* apply iota(state, round) */
+		*state ^= keccak_round_constants[round];
+	}
+}
+
+/**
+ * The core transformation. Process the specified block of data.
+ *
+ * @param hash the algorithm state
+ * @param block the message block to process
+ * @param block_size the size of the processed block in bytes
+ */
+static void rhash_sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t block_size)
+{
+	/* expanded loop */
+	hash[ 0] ^= le2me_64(block[ 0]);
+	hash[ 1] ^= le2me_64(block[ 1]);
+	hash[ 2] ^= le2me_64(block[ 2]);
+	hash[ 3] ^= le2me_64(block[ 3]);
+	hash[ 4] ^= le2me_64(block[ 4]);
+	hash[ 5] ^= le2me_64(block[ 5]);
+	hash[ 6] ^= le2me_64(block[ 6]);
+	hash[ 7] ^= le2me_64(block[ 7]);
+	hash[ 8] ^= le2me_64(block[ 8]);
+	/* if not sha3-512 */
+	if (block_size > 72) {
+		hash[ 9] ^= le2me_64(block[ 9]);
+		hash[10] ^= le2me_64(block[10]);
+		hash[11] ^= le2me_64(block[11]);
+		hash[12] ^= le2me_64(block[12]);
+		/* if not sha3-384 */
+		if (block_size > 104) {
+			hash[13] ^= le2me_64(block[13]);
+			hash[14] ^= le2me_64(block[14]);
+			hash[15] ^= le2me_64(block[15]);
+			hash[16] ^= le2me_64(block[16]);
+			/* if not sha3-256 */
+			if (block_size > 136) {
+				hash[17] ^= le2me_64(block[17]);
+#ifdef FULL_SHA3_FAMILY_SUPPORT
+				/* if not sha3-224 */
+				if (block_size > 144) {
+					hash[18] ^= le2me_64(block[18]);
+					hash[19] ^= le2me_64(block[19]);
+					hash[20] ^= le2me_64(block[20]);
+					hash[21] ^= le2me_64(block[21]);
+					hash[22] ^= le2me_64(block[22]);
+					hash[23] ^= le2me_64(block[23]);
+					hash[24] ^= le2me_64(block[24]);
+				}
+#endif
+			}
+		}
+	}
+	/* make a permutation of the hash */
+	rhash_sha3_permutation(hash);
+}
+
+#define SHA3_FINALIZED 0x80000000
+
+/**
+ * Calculate message hash.
+ * Can be called repeatedly with chunks of the message to be hashed.
+ *
+ * @param ctx the algorithm context containing current hashing state
+ * @param msg message chunk
+ * @param size length of the message chunk
+ */
+void rhash_sha3_update(sha3_ctx *ctx, const unsigned char *msg, size_t size)
+{
+	size_t index = (size_t)ctx->rest;
+	size_t block_size = (size_t)ctx->block_size;
+
+	if (ctx->rest & SHA3_FINALIZED) return; /* too late for additional input */
+	ctx->rest = (unsigned)((ctx->rest + size) % block_size);
+
+	/* fill partial block */
+	if (index) {
+		size_t left = block_size - index;
+		memcpy((char*)ctx->message + index, msg, (size < left ? size : left));
+		if (size < left) return;
+
+		/* process partial block */
+		rhash_sha3_process_block(ctx->hash, ctx->message, block_size);
+		msg  += left;
+		size -= left;
+	}
+	while (size >= block_size) {
+		uint64_t* aligned_message_block;
+		if (IS_ALIGNED_64(msg)) {
+			/* the most common case is processing of an already aligned message
+			without copying it */
+			aligned_message_block = (uint64_t*)msg;
+		} else {
+			memcpy(ctx->message, msg, block_size);
+			aligned_message_block = ctx->message;
+		}
+
+		rhash_sha3_process_block(ctx->hash, aligned_message_block, block_size);
+		msg  += block_size;
+		size -= block_size;
+	}
+	if (size) {
+		memcpy(ctx->message, msg, size); /* save leftovers */
+	}
+}
+
+/**
+ * Store calculated hash into the given array.
+ *
+ * @param ctx the algorithm context containing current hashing state
+ * @param result calculated hash in binary form
+ */
+void rhash_sha3_final(sha3_ctx *ctx, unsigned char* result)
+{
+	size_t digest_length = 100 - ctx->block_size / 2;
+	const size_t block_size = ctx->block_size;
+
+	if (!(ctx->rest & SHA3_FINALIZED))
+	{
+		/* clear the rest of the data queue */
+		memset((char*)ctx->message + ctx->rest, 0, block_size - ctx->rest);
+		((char*)ctx->message)[ctx->rest] |= 0x06;
+		((char*)ctx->message)[block_size - 1] |= 0x80;
+
+		/* process final block */
+		rhash_sha3_process_block(ctx->hash, ctx->message, block_size);
+		ctx->rest = SHA3_FINALIZED; /* mark context as finalized */
+	}
+
+	assert(block_size > digest_length);
+	if (result) me64_to_le_str(result, ctx->hash, digest_length);
+}
+
+#ifdef USE_KECCAK
+/**
+* Store calculated hash into the given array.
+*
+* @param ctx the algorithm context containing current hashing state
+* @param result calculated hash in binary form
+*/
+void rhash_keccak_final(sha3_ctx *ctx, unsigned char* result)
+{
+	size_t digest_length = 100 - ctx->block_size / 2;
+	const size_t block_size = ctx->block_size;
+
+	if (!(ctx->rest & SHA3_FINALIZED))
+	{
+		/* clear the rest of the data queue */
+		memset((char*)ctx->message + ctx->rest, 0, block_size - ctx->rest);
+		((char*)ctx->message)[ctx->rest] |= 0x01;
+		((char*)ctx->message)[block_size - 1] |= 0x80;
+
+		/* process final block */
+		rhash_sha3_process_block(ctx->hash, ctx->message, block_size);
+		ctx->rest = SHA3_FINALIZED; /* mark context as finalized */
+	}
+
+	assert(block_size > digest_length);
+	if (result) me64_to_le_str(result, ctx->hash, digest_length);
+}
+#endif /* USE_KECCAK */
diff --git a/librhash/sha3.h b/librhash/sha3.h
new file mode 100644
index 0000000..2831997
--- /dev/null
+++ b/librhash/sha3.h
@@ -0,0 +1,54 @@
+/* sha3.h */
+#ifndef RHASH_SHA3_H
+#define RHASH_SHA3_H
+#include "ustd.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define sha3_224_hash_size  28
+#define sha3_256_hash_size  32
+#define sha3_384_hash_size  48
+#define sha3_512_hash_size  64
+#define sha3_max_permutation_size 25
+#define sha3_max_rate_in_qwords 24
+
+/**
+ * SHA3 Algorithm context.
+ */
+typedef struct sha3_ctx
+{
+	/* 1600 bits algorithm hashing state */
+	uint64_t hash[sha3_max_permutation_size];
+	/* 1536-bit buffer for leftovers */
+	uint64_t message[sha3_max_rate_in_qwords];
+	/* count of bytes in the message[] buffer */
+	unsigned rest;
+	/* size of a message block processed at once */
+	unsigned block_size;
+} sha3_ctx;
+
+/* methods for calculating the hash function */
+
+void rhash_sha3_224_init(sha3_ctx *ctx);
+void rhash_sha3_256_init(sha3_ctx *ctx);
+void rhash_sha3_384_init(sha3_ctx *ctx);
+void rhash_sha3_512_init(sha3_ctx *ctx);
+void rhash_sha3_update(sha3_ctx *ctx, const unsigned char* msg, size_t size);
+void rhash_sha3_final(sha3_ctx *ctx, unsigned char* result);
+
+#ifdef USE_KECCAK
+#define rhash_keccak_224_init rhash_sha3_224_init
+#define rhash_keccak_256_init rhash_sha3_256_init
+#define rhash_keccak_384_init rhash_sha3_384_init
+#define rhash_keccak_512_init rhash_sha3_512_init
+#define rhash_keccak_update rhash_sha3_update
+void rhash_keccak_final(sha3_ctx *ctx, unsigned char* result);
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* RHASH_SHA3_H */

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c50c32a30f434613a0a46b1c7dbb7eb03d29896d
commit c50c32a30f434613a0a46b1c7dbb7eb03d29896d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Nov 10 15:42:13 2016 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Nov 10 15:42:13 2016 -0500

    librhash: Update import script to add SHA-3 implementation

diff --git a/Utilities/Scripts/update-librhash.bash b/Utilities/Scripts/update-librhash.bash
index 2f67ea2..009ce32 100755
--- a/Utilities/Scripts/update-librhash.bash
+++ b/Utilities/Scripts/update-librhash.bash
@@ -27,6 +27,8 @@ readonly paths="
   librhash/sha1.h
   librhash/sha256.c
   librhash/sha256.h
+  librhash/sha3.c
+  librhash/sha3.h
   librhash/sha512.c
   librhash/sha512.h
   librhash/ustd.h

-----------------------------------------------------------------------

Summary of changes:
 Help/command/file.rst                              |   10 +-
 Help/command/string.rst                            |   27 +-
 Help/release/dev/add-SHA-3.rst                     |    4 +
 Modules/CPack.cmake                                |    4 +-
 Modules/ExternalData.cmake                         |    9 +-
 Modules/ExternalProject.cmake                      |    2 +-
 Source/cmCryptoHash.cxx                            |   28 +-
 Source/cmCryptoHash.h                              |    9 +-
 Source/cmFileCommand.cxx                           |    4 +-
 Source/cmStringCommand.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 +
 Tests/CMakeTests/String-SHA3_224-Works.cmake       |    2 +
 Tests/CMakeTests/String-SHA3_256-Works.cmake       |    2 +
 Tests/CMakeTests/String-SHA3_384-Works.cmake       |    2 +
 Tests/CMakeTests/String-SHA3_512-Works.cmake       |    2 +
 Tests/CMakeTests/StringTest.cmake.in               |   12 +
 .../ExternalData/{MD5 => SHA3_256}/.gitattributes  |    0
 ...c7b45493750a3612ecc483095eb1366f9f46b179550e231 |    1 +
 .../Module/ExternalData/SeriesMixed.5.dat.sha3-256 |    1 +
 Tests/RunCMake/CPack/RunCMakeTest.cmake            |    2 +-
 Utilities/Scripts/update-librhash.bash             |    2 +
 Utilities/cmlibrhash/CMakeLists.txt                |    2 +
 Utilities/cmlibrhash/librhash/algorithms.c         |    6 +-
 Utilities/cmlibrhash/librhash/rhash.h              |   14 +-
 Utilities/cmlibrhash/librhash/sha3.c               |  356 ++++++++++++++++++++
 Utilities/cmlibrhash/librhash/sha3.h               |   54 +++
 30 files changed, 552 insertions(+), 27 deletions(-)
 create mode 100644 Help/release/dev/add-SHA-3.rst
 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
 create mode 100644 Tests/CMakeTests/String-SHA3_224-Works.cmake
 create mode 100644 Tests/CMakeTests/String-SHA3_256-Works.cmake
 create mode 100644 Tests/CMakeTests/String-SHA3_384-Works.cmake
 create mode 100644 Tests/CMakeTests/String-SHA3_512-Works.cmake
 copy Tests/Module/ExternalData/{MD5 => SHA3_256}/.gitattributes (100%)
 create mode 100644 Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231
 create mode 100644 Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256
 create mode 100644 Utilities/cmlibrhash/librhash/sha3.c
 create mode 100644 Utilities/cmlibrhash/librhash/sha3.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list