Commit 71d90635 authored by Aleksey Kravchenko's avatar Aleksey Kravchenko

New upstream version 1.3.8

parent 0bf8a181
Mon 04 Feb 2019 Aleksey
* === Version 1.3.8 ===
Wed Jan 30 2019 Aleksey
* rename Windows encoding options: --ansi to --win, --oem to --dos
Mon Jan 28 2019 Aleksey
* support GOST R 34.11-2012 hash function
* changed the short option `-G' to be alias of --gost12-256
* changed printf format token `%g' to be alias of %{gost12-256}
Sat Dec 22 2018 Aleksey
* === Version 1.3.7 ===
* new option `--message==<string>' to calculate a hash for string
......
......@@ -5,18 +5,19 @@ HEADERS = calc_sums.h hash_print.h common_func.h hash_update.h file.h file_mask.
SOURCES = calc_sums.c hash_print.c common_func.c hash_update.c file.c file_mask.c file_set.c find_file.c hash_check.c output.c parse_cmdline.c rhash_main.c win_utils.c
OBJECTS = $(SOURCES:.c=.o)
WIN_DIST_FILES = dist/MD5.bat dist/magnet.bat dist/rhashrc.sample
OTHER_FILES = configure Makefile ChangeLog INSTALL.md COPYING README \
dist/rhash.spec.in dist/rhash.1 dist/rhash.1.win.sed \
tests/test_rhash.sh tests/test1K.data win32/vc-2010/rhash.vcxproj
OTHER_FILES = configure Makefile ChangeLog INSTALL.md COPYING README.md \
build/vc-2010/rhash.vcxproj dist/rhash.spec.in dist/rhash.1 dist/rhash.1.win.sed \
docs/CONTRIBUTING.md docs/LIBRHASH.md librhash/Doxyfile po/rhash.pot \
tests/test_rhash.sh tests/test1K.data
LIBRHASH_FILES = librhash/algorithms.c librhash/algorithms.h \
librhash/byte_order.c librhash/byte_order.h librhash/plug_openssl.c librhash/plug_openssl.h \
librhash/rhash.c librhash/rhash.h librhash/rhash_torrent.c librhash/rhash_torrent.h \
librhash/rhash_timing.c librhash/rhash_timing.h \
librhash/aich.c librhash/aich.h librhash/crc32.c librhash/crc32.h \
librhash/ed2k.c librhash/ed2k.h librhash/edonr.c librhash/edonr.h \
librhash/gost.c librhash/gost.h librhash/has160.c librhash/has160.h \
librhash/hex.c librhash/hex.h librhash/md4.c librhash/md4.h \
librhash/md5.c librhash/md5.h librhash/ripemd-160.c librhash/ripemd-160.h \
librhash/gost12.c librhash/gost12.h librhash/gost94.c librhash/gost94.h \
librhash/has160.c librhash/has160.h librhash/hex.c librhash/hex.h librhash/md4.c \
librhash/md4.h librhash/md5.c librhash/md5.h librhash/ripemd-160.c librhash/ripemd-160.h \
librhash/sha1.c librhash/sha1.h librhash/sha3.c librhash/sha3.h \
librhash/sha256.c librhash/sha256.h librhash/sha512.c librhash/sha512.h \
librhash/snefru.c librhash/snefru.h librhash/tiger.c librhash/tiger.h \
......@@ -31,6 +32,7 @@ LIBRHASH_PC = dist/librhash.pc
RHASH_NAME = rhash
RHASH_BINARY = rhash$(EXEC_EXT)
CONFDIR_MACRO = -DSYSCONFDIR=\"$(SYSCONFDIR)\"
TEST_OPTIONS =
RPMTOP = rpms
RPMDIRS = SOURCES SPECS BUILD SRPMS RPMS
INSTALL_PROGRAM = $(INSTALL) -m 755
......@@ -135,14 +137,17 @@ test-lib-shared: $(LIBRHASH_SHARED)
test-libs: $(LIBRHASH_STATIC) $(LIBRHASH_SHARED)
+cd librhash && $(MAKE) test-static test-shared
test-full:
+$(MAKE) TEST_OPTIONS=--full test
test: test-$(BUILD_TYPE)
test-static: $(RHASH_STATIC)
chmod +x tests/test_rhash.sh
tests/test_rhash.sh ./$(RHASH_STATIC)
tests/test_rhash.sh $(TEST_OPTIONS) ./$(RHASH_STATIC)
test-shared: $(RHASH_SHARED)
chmod +x tests/test_rhash.sh
tests/test_rhash.sh --shared ./$(RHASH_SHARED)
tests/test_rhash.sh --shared $(TEST_OPTIONS) ./$(RHASH_SHARED)
print-info: lib-$(BUILD_TYPE)
+cd librhash && $(MAKE) print-info
......@@ -229,7 +234,7 @@ dist/rhash.1.txt: dist/rhash.1
-which groff &>/dev/null && (groff -t -e -mandoc -Tascii dist/rhash.1 | sed -e 's/.\[[0-9]*m//g' > $@)
permissions:
find . dist librhash po win32 win32/vc-2010 -maxdepth 1 -type f -exec chmod -x '{}' \;
find . build dist docs librhash po tests -maxdepth 1 -type f -exec chmod -x '{}' \;
chmod +x configure tests/test_rhash.sh
copy-dist: $(ALL_FILES) permissions
......@@ -325,7 +330,7 @@ uninstall-gmo:
done
.PHONY: all build-shared build-static lib-shared lib-static clean clean-bindings distclean clean-local \
test test-shared test-static test-lib test-libs test-lib-shared test-lib-static \
test test-shared test-static test-full test-lib test-libs test-lib-shared test-lib-static \
install build-install-binary install-binary install-lib-shared install-lib-static \
install-lib-headers install-lib-so-link install-conf install-data install-gmo install-man \
install-symlinks install-pkg-config uninstall-gmo uninstall-pkg-config \
......
# RHash
RHash is a console utility for calculation and verification of magnet links
and a wide range of hash sums like CRC32, CRC32C, MD4, MD5, SHA1, SHA256,
SHA512, SHA3, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R 34.11-94,
RIPEMD-160, HAS-160, EDON-R, Whirlpool and Snefru.
RHash (Recursive Hasher) is a console utility for calculation and
verification of magnet links and various hash sums, including CRC32, CRC32C,
MD4, MD5, SHA1, SHA256, SHA512, SHA3, AICH, ED2K, DC++ TTH, BitTorrent BTIH,
Tiger, GOST R 34.11-94, GOST R 34.11-2012, RIPEMD-160, HAS-160, EDON-R, and
Whirlpool.
Hash sums are used to ensure and verify integrity of large volumes of data
for a long-term storing or transferring.
......@@ -24,13 +25,13 @@ For more complicated cases of installation see the [INSTALL.md] file.
## Documentation
* RHash [Manual Page]
* RHash [ChangeLog]
* [The LibRHash Library] documentation
## Links
* Project Home Page: http://rhash.sourceforge.net/
* Official Releases: https://github.com/rhash/RHash/releases/
* Binary Windows Releases: https://sf.net/projects/rhash/files/rhash/
* The table of the supported by RHash [hash functions](http://sf.net/p/rhash/wiki/HashFunctions/)
* ECRYPT [The Hash Function Zoo](http://ehash.iaik.tugraz.at/wiki/The_Hash_Function_Zoo)
* ECRYPT [Benchmarking of hash functions](https://bench.cr.yp.to/results-hash.html)
......@@ -46,7 +47,6 @@ restrictions. In the case an OSI-approved license is required the
[MIT license] should be used.
[INSTALL.md]: INSTALL.md
[Manual Page]: http://rhash.anz.ru/manpage.php
[The LibRHash Library]: docs/LIBRHASH.md
[ChangeLog]: ChangeLog
[MIT license]: http://www.opensource.org/licenses/MIT
......@@ -6,10 +6,11 @@ PREFIX = /usr/local
RUBY ?= ruby
PYTHON ?= python
PERL ?= perl
CP = cp -l --parents
PERL_OPTIMIZE = -O2 -g -Wall
PERL_LIBRHASH_TYPE ?= auto
PERL_OPTIMIZE ?= -O2 -g -Wall
ARCHIVE_GZIP = rhash-bindings-$(VERSION)-src.tar.gz
COPYDIR = rhash-bindings-$(VERSION)
CP = cp -l --parents
all: configure build test
clean: distclean
......@@ -18,13 +19,14 @@ configure: $(patsubst %, configure-%, $(filter perl ruby php, $(BINDINGS)))
build: $(patsubst %, build-%, $(BINDINGS))
test: $(patsubst %, test-%, $(BINDINGS))
install: $(patsubst %, install-%, $(filter perl ruby php, $(BINDINGS)))
distclean: $(patsubst %, clean-%, $(BINDINGS))
configure-perl: perl/Makefile
configure-ruby: ruby/Makefile
configure-php: php/Makefile
perl/Makefile: perl/Makefile.PL
cd perl && USE_SYSTEM_LIBRHASH=1 $(PERL) Makefile.PL INSTALLDIRS=vendor
cd perl && LIBRHASH="$(PERL_LIBRHASH_TYPE)" $(PERL) Makefile.PL INSTALLDIRS=vendor
php/Makefile: php/config.m4
cd php && phpize && ./configure --with-rhash
......@@ -109,10 +111,15 @@ cpan:
tar -czf $(PERL_PKG).tar.gz --owner=root:0 --group=root:0 $(PERL_PKG)/
rm -rf $(PERL_PKG)/
distclean:
clean-java:
+$(MAKE) -C java distclean
clean-mono:
+$(MAKE) -C mono clean
clean-ruby:
+[ ! -f ruby/Makefile ] || $(MAKE) -C ruby distclean
clean-perl:
+[ ! -f perl/Makefile ] || $(MAKE) -C perl distclean
clean-php:
[ ! -f php/configure ] || (cd php && phpize --clean)
clean-python:
rm -f python/*.pyc
......@@ -18,9 +18,9 @@
package org.sf.rhash;
/**
* Type of hashing algorithm.
* Supported algorithms are MD4, MD5, SHA1/SHA2, Tiger,
* DC++ TTH, BitTorrent BTIH, AICH, EDonkey 2000 hash, GOST R 34.11-94,
* Type of hashing algorithm. Supported algorithms are CRC32, CRC32C,
* MD4, MD5, SHA1/SHA2, Tiger, DC++ TTH, BitTorrent BTIH,
* AICH, EDonkey 2000 hash, GOST R 34.11-94, GOST R 34.11-2012,
* RIPEMD-160, HAS-160, EDON-R 256/512, Whirlpool and Snefru-128/256.
*/
public enum HashType {
......@@ -47,14 +47,14 @@ public enum HashType {
/** RIPEMD-160 hash. */
RIPEMD160(1 << 10),
/** GOST R 34.11-94. */
GOST(1 << 11),
GOST_CRYPTOPRO(1 << 12),
GOST94(1 << 11),
GOST94_CRYPTOPRO(1 << 12),
/** HAS-160 hash. */
HAS160(1 << 13),
/** Snefru-128 hash. */
SNEFRU128(1 << 14),
/** Snefru-256 hash. */
SNEFRU256(1 << 15),
/** GOST R 34.11-2012 - 256 bit. */
GOST12_256(1 << 14),
/** GOST R 34.11-2012 - 512 bit. */
GOST12_512(1 << 15),
/** SHA-224 hash. */
SHA224(1 << 16),
/** SHA-256 hash. */
......@@ -75,24 +75,30 @@ public enum HashType {
SHA3_384(1 << 24),
/** SHA3-512 hash. */
SHA3_512(1 << 25);
/** CRC32C checksum. */
CRC32C(1 << 26),
/** Snefru-128 hash. */
SNEFRU128(1 << 27),
/** Snefru-256 hash. */
SNEFRU256(1 << 28),
/** hash_id for the native API */
private int hashId;
private int hashId;
/**
* Construct HashType for specified native hash_id
* @param hashId hash identifier for native API
*/
private HashType(int hashId) {
this.hashId = hashId;
}
/**
* Construct HashType for specified native hash_id
* @param hashId hash identifier for native API
*/
private HashType(int hashId) {
this.hashId = hashId;
}
/**
* Returns hash_id for the native API.
* @return hash identifier
*/
* @return hash identifier
*/
int hashId() {
return hashId;
return hashId;
}
/**
......
......@@ -18,6 +18,7 @@ public class RHashTest {
r.update("a").finish();
assertEquals("e8b7be43", r.getDigest(CRC32).toString());
assertEquals("c1d04330", r.getDigest(CRC32C).toString());
assertEquals("bde52cb31de33e46245e05fbdbd6fb24", r.getDigest(MD4).toString());
assertEquals("0cc175b9c0f1b6a831c399e269772661", r.getDigest(MD5).toString());
assertEquals("86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", r.getDigest(SHA1).toString());
......@@ -28,11 +29,11 @@ public class RHashTest {
assertEquals("q336in72uwt7zyk5dxolt2xk5i3xmz5y", r.getDigest(AICH).toString());
assertEquals("8aca2602792aec6f11a67206531fb7d7f0dff59413145e6973c45001d0087b42d11bc645413aeff63a42391a39145a591a92200d560195e53b478584fdae231a", r.getDigest(WHIRLPOOL).toString());
assertEquals("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", r.getDigest(RIPEMD160).toString());
assertEquals("d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd", r.getDigest(GOST).toString());
assertEquals("e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011", r.getDigest(GOST_CRYPTOPRO).toString());
assertEquals("d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd", r.getDigest(GOST94).toString());
assertEquals("e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011", r.getDigest(GOST94_CRYPTOPRO).toString());
assertEquals("4872bcbc4cd0f0a9dc7c2f7045e5b43b6c830db8", r.getDigest(HAS160).toString());
assertEquals("bf5ce540ae51bc50399f96746c5a15bd", r.getDigest(SNEFRU128).toString());
assertEquals("45161589ac317be0ceba70db2573ddda6e668a31984b39bf65e4b664b584c63d", r.getDigest(SNEFRU256).toString());
assertEquals("ba31099b9cc84ec2a671e9313572378920a705b363b031a1cb4fc03e01ce8df3", r.getDigest(GOST12_256).toString());
assertEquals("8b2a40ecab7b7496bc4cc0f773595452baf658849b495acc3ba017206810efb00420ccd73fb3297e0f7890941b84ac4a8bc27e3c95e1f97c094609e2136abb7e", r.getDigest(GOST12_512).toString());
assertEquals("abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5", r.getDigest(SHA224).toString());
assertEquals("ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", r.getDigest(SHA256).toString());
assertEquals("54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31", r.getDigest(SHA384).toString());
......@@ -43,6 +44,8 @@ public class RHashTest {
assertEquals("80084bf2fba02475726feb2cab2d8215eab14bc6bdd8bfb2c8151257032ecd8b", r.getDigest(SHA3_256).toString());
assertEquals("1815f774f320491b48569efec794d249eeb59aae46d22bf77dafe25c5edc28d7ea44f93ee1234aa88f61c91912a4ccd9", r.getDigest(SHA3_384).toString());
assertEquals("697f2d856172cb8309d6b8b97dac4de344b549d4dee61edfb4962d8698b7fa803f4f93ff24393586e28b5b957ac3d1d369420ce53332712f997bd336d09ab02a", r.getDigest(SHA3_512).toString());
assertEquals("bf5ce540ae51bc50399f96746c5a15bd", r.getDigest(SNEFRU128).toString());
assertEquals("45161589ac317be0ceba70db2573ddda6e668a31984b39bf65e4b664b584c63d", r.getDigest(SNEFRU256).toString());
r.reset();
r.finish();
......
......@@ -49,14 +49,13 @@ namespace RHash {
/* RIPEMD-160 hash. */
RIPEMD160 = 1 << 10,
/* GOST R 34.11-94. */
GOST = 1 << 11,
GOST_CRYPTOPRO = 1 << 12,
GOST94 = 1 << 11,
GOST94_CRYPTOPRO = 1 << 12,
/* HAS-160 hash. */
HAS160 = 1 << 13,
/* Snefru-128 hash. */
SNEFRU128 = 1 << 14,
/* Snefru-256 hash. */
SNEFRU256 = 1 << 15,
/* GOST R 34.11-2012. */
GOST12_256 = 1 << 14,
GOST12_512 = 1 << 15,
/* SHA-224 hash. */
SHA224 = 1 << 16,
/* SHA-256 hash. */
......@@ -76,6 +75,12 @@ namespace RHash {
/** SHA3-384 hash. */
SHA3_384 = 1 << 24,
/** SHA3-512 hash. */
SHA3_512 = 1 << 25
SHA3_512 = 1 << 25,
/* CRC32C checksum. */
CRC32C = 1 << 26,
/* Snefru-128 hash. */
SNEFRU128 = 1 << 27,
/* Snefru-256 hash. */
SNEFRU256 = 1 << 28
}
}
......@@ -106,9 +106,9 @@ Constants may be OR-combined to form <see cref="T:System.UInt32" /> mask of hash
<summary>EDON-R 512.</summary>
</Docs>
</Member>
<Member MemberName="GOST">
<MemberSignature Language="C#" Value="GOST" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype RHash.HashType GOST = unsigned int32(2048)" />
<Member MemberName="GOST94">
<MemberSignature Language="C#" Value="GOST94" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype RHash.HashType GOST94 = unsigned int32(2048)" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.1.1</AssemblyVersion>
......@@ -120,9 +120,9 @@ Constants may be OR-combined to form <see cref="T:System.UInt32" /> mask of hash
<summary>GOST R 34.11-94.</summary>
</Docs>
</Member>
<Member MemberName="GOST_CRYPTOPRO">
<MemberSignature Language="C#" Value="GOST_CRYPTOPRO" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype RHash.HashType GOST_CRYPTOPRO = unsigned int32(4096)" />
<Member MemberName="GOST94_CRYPTOPRO">
<MemberSignature Language="C#" Value="GOST94_CRYPTOPRO" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype RHash.HashType GOST94_CRYPTOPRO = unsigned int32(4096)" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.1.1</AssemblyVersion>
......
......@@ -25,6 +25,7 @@ class Test {
Dictionary<HashType,string> hashes = new Dictionary<HashType,string>();
hashes.Add(HashType.CRC32, "261dafe6");
hashes.Add(HashType.CRC32C, "3c95f7e7");
hashes.Add(HashType.MD4, "b1a45cdad19cb02482323fac9cea9b9f");
hashes.Add(HashType.MD5, "d577273ff885c3f84dadb8578bb41399");
hashes.Add(HashType.SHA1, "2672275fe0c456fb671e4f417fb2f9892c7573ba");
......@@ -38,8 +39,10 @@ class Test {
hashes.Add(HashType.AICH, "ezzcox7ayrlpwzy6j5ax7mxzrewhk452");
hashes.Add(HashType.ED2K, "b1a45cdad19cb02482323fac9cea9b9f");
hashes.Add(HashType.WHIRLPOOL, "0e8ce019c9d5185d2103a4ff015ec92587da9b22e77ad34f2eddbba9705b3602bc6ede67f5b5e4dd225e7762208ea54895b26c39fc550914d6eca9604b724d11");
hashes.Add(HashType.GOST, "0aaaf17200323d024437837d6f6f6384a4a108474cff03cd349ac12776713f5f");
hashes.Add(HashType.GOST_CRYPTOPRO, "2ed45a995ffdd7a2e5d9ab212c91cec5c65448e6a0840749a00f326ccb0c936d");
hashes.Add(HashType.GOST94, "0aaaf17200323d024437837d6f6f6384a4a108474cff03cd349ac12776713f5f");
hashes.Add(HashType.GOST94_CRYPTOPRO, "2ed45a995ffdd7a2e5d9ab212c91cec5c65448e6a0840749a00f326ccb0c936d");
hashes.Add(HashType.GOST12_256, "8ca8bf4245043db42d3c34f4d7d7391d10cfad5f897ca0001c98ffcf56b00a5d");
hashes.Add(HashType.GOST12_512, "4d46d8ea693092d367d3ba45ea0ae5bd8e58fdbda4c32dcf48489d754e9dae4e992c4db22fcdaf625a8b05af68acc08c40d011180dfec5ba58e3ebc5b21c94ac");
hashes.Add(HashType.RIPEMD160, "ead888178685c5d3a0400befba9188e4da3d5144");
hashes.Add(HashType.HAS160, "c7589afd23462e76703b1f7a031010eec70180d4");
hashes.Add(HashType.SNEFRU128, "d559a2b62f6f44111324f85208723707");
......@@ -75,27 +78,27 @@ class Test {
}
Console.WriteLine("{0} tests / {1} failed\n", hashes.Count, errcount2);
Console.WriteLine("\nTests: magnet links");
int errcount3 = 0;
Console.WriteLine("\nTests: magnet links");
int errcount3 = 0;
{
// magnet by static method
string mustbe = "magnet:?xl=6&dn=12345.txt&xt=urn:crc32:261dafe6&xt=urn:md5:d577273ff885c3f84dadb8578bb41399";
string got = Hasher.GetMagnetFor("12345.txt", (uint)HashType.CRC32 | (uint)HashType.MD5);
if (!got.Equals(mustbe)) {
Console.WriteLine("Magnet by static method test failed: expected '{0}', got '{1}'\n", mustbe, got);
errcount3++;
}
// magnet with null argument
Hasher hasher = new Hasher((uint)HashType.CRC32 | (uint)HashType.MD5);
hasher.UpdateFile("12345.txt").Finish();
mustbe = "magnet:?xl=6&xt=urn:crc32:261dafe6";
got = hasher.GetMagnet(null, (uint)HashType.CRC32 | (uint)HashType.AICH);
if (!got.Equals(mustbe)) {
Console.WriteLine("Magnet with null argument test failed: expected '{0}', got '{1}'\n", mustbe, got);
errcount3++;
}
// magnet by static method
string mustbe = "magnet:?xl=6&dn=12345.txt&xt=urn:crc32:261dafe6&xt=urn:md5:d577273ff885c3f84dadb8578bb41399";
string got = Hasher.GetMagnetFor("12345.txt", (uint)HashType.CRC32 | (uint)HashType.MD5);
if (!got.Equals(mustbe)) {
Console.WriteLine("Magnet by static method test failed: expected '{0}', got '{1}'\n", mustbe, got);
errcount3++;
}
// magnet with null argument
Hasher hasher = new Hasher((uint)HashType.CRC32 | (uint)HashType.MD5);
hasher.UpdateFile("12345.txt").Finish();
mustbe = "magnet:?xl=6&xt=urn:crc32:261dafe6";
got = hasher.GetMagnet(null, (uint)HashType.CRC32 | (uint)HashType.AICH);
if (!got.Equals(mustbe)) {
Console.WriteLine("Magnet with null argument test failed: expected '{0}', got '{1}'\n", mustbe, got);
errcount3++;
}
}
Console.WriteLine("{0} tests / {1} failed\n", 2, errcount3);
Console.WriteLine("{0} tests / {1} failed\n", 2, errcount3);
System.Environment.ExitCode = errcount1 + errcount2 + errcount3;
}
......
......@@ -37,15 +37,15 @@
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://sourceforge.net/p/rhash/bugs/"
"web" : "https://github.com/rhash/RHash/issues"
},
"homepage" : "http://rhash.sf.net/",
"license" : [
"http://rhash.anz.ru/license.php"
"https://github.com/rhash/RHash/blob/master/COPYING"
],
"repository" : {
"url" : "https://github.com/rhash/RHash"
}
},
"version" : "0.94"
"version" : "0.97"
}
......@@ -19,8 +19,8 @@ no_index:
- inc
requires: {}
resources:
bugtracker: https://sourceforge.net/p/rhash/bugs/
bugtracker: https://github.com/rhash/RHash/issues
homepage: http://rhash.sf.net/
license: http://rhash.anz.ru/license.php
license: https://github.com/rhash/RHash/blob/master/COPYING
repository: https://github.com/rhash/RHash
version: 0.94
version: 0.97
use strict;
use warnings;
use Cwd;
use ExtUtils::MakeMaker;
use File::Copy;
......@@ -7,17 +8,41 @@ my $libs = '';
my $inc = '';
my $obj = '';
my $clean = '';
my $local_librhash_dir = 'librhash';
my $has_builtin_librhash = (-f $local_librhash_dir . '/rhash.h');
my $inc_dir = undef;
my $lib_dir = undef;
my $rh_builtin_dir = 'librhash';
my $rh_local_dir = getcwd() . '/../../librhash';
my $rh_type = $ENV{'LIBRHASH'} || 'auto';
my $custom_inc = $ENV{'LIBRHASH_INC'} || '';
my $custom_ld = $ENV{'LIBRHASH_LD'} || '';
# set the location of LibRHash headers and the linking flags
$inc = $ENV{'LIBRHASH_INC'} if defined($ENV{'LIBRHASH_INC'});
if(defined($ENV{'LIBRHASH_LD'}) && $ENV{'LIBRHASH_LD'} =~ /-L/) {
$libs = $ENV{'LIBRHASH_LD'} . ' ' . $libs;
sub has_librhash {
return (-f $_[0] . '/rhash.h');
}
# use a system-wide librhash
$libs = '-lrhash' if (defined($ENV{'USE_SYSTEM_LIBRHASH'}) || ($libs eq '' && !$has_builtin_librhash));
if ($rh_type eq 'auto')
{
$rh_type = ($custom_ld =~ /-L/ ? 'custom' :
has_librhash($rh_builtin_dir) ? 'builtin' :
has_librhash($rh_local_dir) ? 'local' : 'system' );
print "Selected librhash type: $rh_type\n";
}
if ($rh_type ne 'custom')
{
$inc_dir = ($rh_type eq 'builtin' ? $rh_builtin_dir :
$rh_type eq 'local' ? $rh_local_dir :
$rh_type eq 'system' ? '' : die("Unknown type LIBRHASH='$rh_type'"));
$lib_dir = $inc_dir if $rh_type ne 'builtin';
!$inc_dir || -d $inc_dir || die "Not a directory: '$inc_dir'";
!$inc_dir || has_librhash($inc_dir) || die "No librhash headers at: '$inc_dir'";
$inc = "-I$inc_dir" if $inc_dir;
$libs = "-L$lib_dir" if $lib_dir;
$libs .= ' -lrhash' if $rh_type ne 'builtin';
} else {
# set custom compile and linking flags
$inc = $custom_inc;
$libs = $custom_ld;
}
# copy and rename *.c files by prepending underscore '_'
sub copy_c_files($) {
......@@ -39,11 +64,9 @@ sub copy_c_files($) {
return @result;
}
if($inc eq '' && $libs eq '' && $has_builtin_librhash) {
# use the local version of librhash
print "Using builtin LibRHash\n";
$inc = '-I' . $local_librhash_dir;
my @c_files = copy_c_files($local_librhash_dir);
if($rh_type eq 'builtin') {
# using sources of the builtin librhash
my @c_files = copy_c_files($rh_builtin_dir);
$clean = join(' ', @c_files);
$obj = join(' ', map { s/\.c$/\$(OBJ_EXT)/; $_ } @c_files) . ' ';
}
......@@ -71,8 +94,8 @@ WriteMakefile(
META_ADD => {
resources => {
homepage => 'http://rhash.sf.net/',
license => 'http://rhash.anz.ru/license.php',
bugtracker => 'https://sourceforge.net/p/rhash/bugs/',
bugtracker => 'https://github.com/rhash/RHash/issues',
license => 'https://github.com/rhash/RHash/blob/master/COPYING',
repository => 'https://github.com/rhash/RHash',
},
},
......
Crypt::Rhash module allows to compute various hash sums and magnet links.
The following hash sums are supported: CRC32, MD4, MD5, SHA1,
SHA256, SHA512, SHA3, Tiger, TTH, Torrent BTIH, AICH, ED2K,
GOST R 34.11-94, RIPEMD-160, HAS-160, EDON-R 256/512, WHIRLPOOL
and SNEFRU.
The following hash sums are supported: CRC32, CRC32C, MD4, MD5,
SHA1, SHA256, SHA512, SHA3, Tiger, TTH, Torrent BTIH, AICH, ED2K,
GOST R 34.11-94, GOST R 34.11-2012, RIPEMD-160, HAS-160,
EDON-R 256/512, WHIRLPOOL and SNEFRU.
BUILDING THE MODULE
-------------------
......@@ -21,17 +21,17 @@ INSTALLATION
To install Crypt::Rhash, run the following command:
make install
LICENSE
-------
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!
LICENSE
-------
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!
......@@ -10,18 +10,20 @@ our @ISA = (qw(Exporter));
# possible tags for export
our %EXPORT_TAGS = (
Functions => [qw(raw2hex raw2base32 raw2base64)],
Constants => [qw(RHASH_CRC32 RHASH_CRC32C RHASH_MD4 RHASH_MD5 RHASH_SHA1
RHASH_TIGER RHASH_TTH RHASH_BTIH RHASH_ED2K RHASH_AICH RHASH_WHIRLPOOL
RHASH_RIPEMD160 RHASH_GOST RHASH_GOST_CRYPTOPRO RHASH_HAS160
RHASH_SNEFRU128 RHASH_SNEFRU256 RHASH_SHA224 RHASH_SHA256
RHASH_SHA384 RHASH_SHA512 RHASH_EDONR256 RHASH_EDONR512
RHASH_SHA3_224 RHASH_SHA3_256 RHASH_SHA3_384 RHASH_SHA3_512 RHASH_ALL)]
Constants => [qw(RHASH_CRC32 RHASH_CRC32C RHASH_MD4 RHASH_MD5
RHASH_SHA1 RHASH_TIGER RHASH_TTH RHASH_BTIH RHASH_ED2K
RHASH_AICH RHASH_WHIRLPOOL RHASH_RIPEMD160 RHASH_GOST94
RHASH_GOST94_CRYPTOPRO RHASH_GOST12_256 RHASH_GOST12_512
RHASH_SHA224 RHASH_SHA256 RHASH_SHA384 RHASH_SHA512
RHASH_SHA3_224 RHASH_SHA3_256 RHASH_SHA3_384 RHASH_SHA3_512
RHASH_HAS160 RHASH_EDONR256 RHASH_EDONR512
RHASH_SNEFRU128 RHASH_SNEFRU256 RHASH_ALL)]
);
Exporter::export_tags( );
Exporter::export_ok_tags( qw(Functions Constants) );
our $VERSION = '0.94';
our $VERSION = '0.97';
require XSLoader;
XSLoader::load('Crypt::Rhash', $VERSION);
......@@ -39,11 +41,11 @@ use constant RHASH_ED2K => 0x80;
use constant RHASH_AICH => 0x100;
use constant RHASH_WHIRLPOOL => 0x200;
use constant RHASH_RIPEMD160 => 0x400;
use constant RHASH_GOST => 0x800;
use constant RHASH_GOST_CRYPTOPRO => 0x1000;
use constant RHASH_GOST94 => 0x800;
use constant RHASH_GOST94_CRYPTOPRO => 0x1000;
use constant RHASH_HAS160 => 0x2000;
use constant RHASH_SNEFRU128 => 0x4000;
use constant RHASH_SNEFRU256 => 0x8000;
use constant RHASH_GOST12_256 => 0x4000;
use constant RHASH_GOST12_512 => 0x8000;
use constant RHASH_SHA224 => 0x10000;
use constant RHASH_SHA256 => 0x20000;
use constant RHASH_SHA384 => 0x40000;
......@@ -55,7 +57,9 @@ use constant RHASH_SHA3_256 => 0x0800000;
use constant RHASH_SHA3_384 => 0x1000000;
use constant RHASH_SHA3_512 => 0x2000000;
use constant RHASH_CRC32C => 0x4000000;
use constant RHASH_ALL => 0x7FFFFFF;
use constant RHASH_SNEFRU128 => 0x8000000;
use constant RHASH_SNEFRU256 => 0x10000000;
use constant RHASH_ALL => 0x1FFFFFFF;
##############################################################################
# Rhash class methods
......@@ -261,8 +265,8 @@ binary format or as a magnet link.
=head1 SUPPORTED ALGORITHMS
The module supports the following hashing algorithms:
CRC32, MD4, MD5, SHA1, SHA256, SHA512, SHA3,
AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R 34.11-94, RIPEMD-160,
CRC32, CRC32C, MD4, MD5, SHA1, SHA256, SHA512, SHA3, AICH, ED2K, Tiger,
DC++ TTH, GOST R 34.11-94, GOST R 34.11-2012, BitTorrent BTIH, RIPEMD-160,
HAS-160, EDON-R 256/512, Whirlpool and Snefru-128/256.
=head1 CONSTRUCTOR
......@@ -286,11 +290,11 @@ The $hash_id parameter can be union (via bitwise OR) of any of the following bit
RHASH_AICH,
RHASH_WHIRLPOOL,
RHASH_RIPEMD160,
RHASH_GOST,
RHASH_GOST_CRYPTOPRO,
RHASH_GOST94,
RHASH_GOST94_CRYPTOPRO,
RHASH_GOST12_256,
RHASH_GOST12_512
RHASH_HAS160,
RHASH_SNEFRU128,
RHASH_SNEFRU256,
RHASH_SHA224,
RHASH_SHA256,
RHASH_SHA384,
......@@ -300,7 +304,9 @@ The $hash_id parameter can be union (via bitwise OR) of any of the following bit
RHASH_SHA3_384,
RHASH_SHA3_512,
RHASH_EDONR256,
RHASH_EDONR512
RHASH_EDONR512,
RHASH_SNEFRU128,
RHASH_SNEFRU256
Also the RHASH_ALL bit mask is the union of all listed bit-flags.
So the object created via Crypt::Rhash->new(RHASH_ALL) calculates all
......
......@@ -18,9 +18,9 @@ void verify_single_bit_hash_id(unsigned hash_id, CV* cv)
const char *func_name;
if(0 == (hash_id & RHASH_ALL_HASHES)) {
error = "%s: unknown hash hash_id = %d";
error = "%s: unsupported hash_id = 0x%x";
} else if(0 != (hash_id & (hash_id - 1))) {
error = "%s: hash_id is not a single bit: %d";
error = "%s: hash_id is not a single bit: 0x%x";
} else {
return; /* success */
}
......
use Test::More tests => 27;
use Test::More tests => 29;
use Crypt::Rhash;
#########################
......@@ -18,11 +18,11 @@ is( $r->hash(RHASH_ED2K), "bde52cb31de33e46245e05fbdbd6fb24");
is( $r->hash(RHASH_AICH), "q336in72uwt7zyk5dxolt2xk5i3xmz5y");
is( $r->hash(RHASH_WHIRLPOOL), "8aca2602792aec6f11a67206531fb7d7f0dff59413145e6973c45001d0087b42d11bc645413aeff63a42391a39145a591a92200d560195e53b478584fdae231a");
is( $r->hash(RHASH_RIPEMD160), "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe");
is( $r->hash(RHASH_GOST), "d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd");
is( $r->hash(RHASH_GOST_CRYPTOPRO), "e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011");
is( $r->hash(RHASH_GOST94), "d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd");
is( $r->hash(RHASH_GOST94_CRYPTOPRO), "e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011");
is( $r->hash(RHASH_GOST12_256), "ba31099b9cc84ec2a671e9313572378920a705b363b031a1cb4fc03e01ce8df3");
is( $r->hash(RHASH_GOST12_512), "8b2a40ecab7b7496bc4cc0f773595452baf658849b495acc3ba017206810efb00420ccd73fb3297e0f7890941b84ac4a8bc27e3c95e1f97c094609e2136abb7e");
is( $r->hash(RHASH_HAS160), "4872bcbc4cd0f0a9dc7c2f7045e5b43b6c830db8");
is( $r->hash(RHASH_SNEFRU128), "bf5ce540ae51bc50399f96746c5a15bd");
is( $r->hash(RHASH_SNEFRU256), "45161589ac317be0ceba70db2573ddda6e668a31984b39bf65e4b664b584c63d");
is( $r->hash(RHASH_SHA224), "abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5");
is( $r->hash(RHASH_SHA256), "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb");
is( $r->hash(RHASH_SHA384), "54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31");
......@@ -33,5 +33,7 @@ is( $r->hash(RHASH_SHA3_224), "9e86ff69557ca95f405f081269685b38e3a819b309ee942f4
is( $r->hash(RHASH_SHA3_256), "80084bf2fba02475726feb2cab2d8215eab14bc6bdd8bfb2c8151257032ecd8b");
is( $r->hash(RHASH_SHA3_384), "1815f774f320491b48569efec794d249eeb59aae46d22bf77dafe25c5edc28d7ea44f93ee1234aa88f61c91912a4ccd9");
is( $r->hash(RHASH_SHA3_512), "697f2d856172cb8309d6b8b97dac4de344b549d4dee61edfb4962d8698b7fa803f4f93ff24393586e28b5b957ac3d1d369420ce53332712f997bd336d09ab02a");
is( $r->hash(RHASH_SNEFRU128), "bf5ce540ae51bc50399f96746c5a15bd");
is( $r->hash(RHASH_SNEFRU256), "45161589ac317be0ceba70db2573ddda6e668a31984b39bf65e4b664b584c63d");
__END__
......@@ -252,6 +252,7 @@ PHP_MINIT_FUNCTION(rhash)
#endif
REGISTER_RHASH_CONSTANT(RHASH_CRC32);
REGISTER_RHASH_CONSTANT(RHASH_CRC32C);
REGISTER_RHASH_CONSTANT(RHASH_MD4);
REGISTER_RHASH_CONSTANT(RHASH_MD5);
REGISTER_RHASH_CONSTANT(RHASH_SHA1);
......@@ -262,11 +263,11 @@ PHP_MINIT_FUNCTION(rhash)
REGISTER_RHASH_CONSTANT(RHASH_AICH);
REGISTER_RHASH_CONSTANT(RHASH_WHIRLPOOL);
REGISTER_RHASH_CONSTANT(RHASH_RIPEMD160);
REGISTER_RHASH_CONSTANT(RHASH_GOST);
REGISTER_RHASH_CONSTANT(RHASH_GOST_CRYPTOPRO);
REGISTER_RHASH_CONSTANT(RHASH_GOST94);
REGISTER_RHASH_CONSTANT(RHASH_GOST94_CRYPTOPRO);
REGISTER_RHASH_CONSTANT(RHASH_GOST12_256);
REGISTER_RHASH_CONSTANT(RHASH_GOST12_512);
REGISTER_RHASH_CONSTANT(RHASH_HAS160);