Commit 648a9ff8 authored by Aleksey Kravchenko's avatar Aleksey Kravchenko

Imported Upstream version 1.2.8

parent 2b002a52
RHash License
Copyright (c) 2005-2011 Alexey Kravchenko <rhash.admin@gmail.com>
Copyright (c) 2005-2011 Aleksey Kravchenko <rhash.admin@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
......
Wed Sep 14 2011 Aleksey
* === Version 1.2.8 ===
Tue Sep 6 2011 Aleksey
* librhash: implemented auto-final feature, turned on by default
Tue Sep 6 2011 Aleksey, SBasalaev
* Russian translation
Sat Sep 3 2011 Aleksey
* Bugfix: not enough trailing '=' in a base64-encoded hash
Sat Aug 20 2011 Aleksey
* Bugfix: fix broken --openssl option parsing
* Bugfix: buffer overflow when using --embed-crc-delimiter
* Bugfix: segmentation fault on SUSE Linux
Sun Aug 14 2011 Aleksey
* === Version 1.2.7 ===
......
# Samples of usage:
# compile with debug info: make OPTFLAGS=-g OPTLDFLAGS= TARGET=rhash.debug
# compile for pentiumpro: make OPTFLAGS="-O2 -DNDEBUG -march=i586 -mcpu=pentiumpro -fomit-frame-pointer"
# create rpm with statically linked program: make rpm LDFLAGS="-Llibrhash -lrhash -static -s -Wl,--gc-sections"
# Sample usage:
# compile with debug info: make CFLAGS=-g
# compile for pentiumpro: make CFLAGS="-O2 -DNDEBUG -march=i586 -mcpu=pentiumpro -fomit-frame-pointer"
# create rpm with statically linked program: make rpm ADDLDFLAGS="-static -s -Wl,--gc-sections"
CC = gcc
VERSION = 1.2.7
VERSION = 1.2.8
PREFIX = /usr/local
# we use OPTFLAGS/OPTLDFLAGS for compatibilty with older makefiles
# using OPTFLAGS/OPTLDFLAGS for compatibilty with old scripts using this makefile
OPTFLAGS = -O2 -DNDEBUG -fomit-frame-pointer -ffunction-sections -fdata-sections
OPTLDFLAGS = -s
OPTLDFLAGS =
CFLAGS = $(OPTFLAGS)
LDFLAGS = $(OPTLDFLAGS)
ADDCFLAGS =
......@@ -17,9 +17,9 @@ ALLCFLAGS = -pipe $(CFLAGS) $(ADDCFLAGS) \
-Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations
LDLIBRHASH = -Llibrhash -lrhash
ALLLDFLAGS = $(LDLIBRHASH) $(LDFLAGS) $(ADDLDFLAGS)
HEADERS = calc_sums.h crc_print.h common_func.h crc_update.h file_mask.h file_set.h find_file.h hash_check.h output.h parse_cmdline.h rhash_main.h win_utils.h version.h
SOURCES = calc_sums.c crc_print.c common_func.c crc_update.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 = calc_sums.o crc_print.o common_func.o crc_update.o file_mask.o file_set.o find_file.o hash_check.o output.o parse_cmdline.o rhash_main.o win_utils.o
HEADERS = calc_sums.h hash_print.h common_func.h hash_update.h file_mask.h file_set.h find_file.h hash_check.h output.h parse_cmdline.h rhash_main.h win_utils.h version.h
SOURCES = calc_sums.c hash_print.c common_func.c hash_update.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 = calc_sums.o hash_print.o common_func.o hash_update.o file_mask.o file_set.o find_file.o hash_check.o output.o parse_cmdline.o rhash_main.o win_utils.o
OUTDIR =
PROGNAME = rhash
TARGET = $(OUTDIR)$(PROGNAME)
......@@ -45,7 +45,8 @@ LIBRHASH_FILES = librhash/algorithms.c librhash/algorithms.h \
librhash/whirlpool.h librhash/whirlpool_sbox.c librhash/test_hashes.c \
librhash/test_hashes.h librhash/torrent.h librhash/torrent.c \
librhash/util.c librhash/util.h librhash/config.h librhash/Makefile
DIST_FILES = $(LIN_DIST_FILES) $(LIBRHASH_FILES) $(WIN_DIST_FILES) $(WIN_SRC_FILES)
I18N_FILES = po/rhash.pot po/ru.po
DIST_FILES = $(LIN_DIST_FILES) $(LIBRHASH_FILES) $(WIN_DIST_FILES) $(WIN_SRC_FILES) $(I18N_FILES)
WIN_SUFFIX = win32
ARCHIVE_BZIP = rhash-$(VERSION)-src.tar.bz2
ARCHIVE_GZIP = rhash-$(VERSION)-src.tar.gz
......@@ -53,9 +54,10 @@ ARCHIVE_DEB_GZ = ../rhash_$(VERSION).orig.tar.gz
ARCHIVE_7Z = rhash-$(VERSION)-src.tar.7z
ARCHIVE_ZIP = rhash-$(VERSION)-$(WIN_SUFFIX).zip
WIN_ZIP_DIR = RHash-$(VERSION)-$(WIN_SUFFIX)
DESTDIR =
DESTDIR =
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
LOCALEDIR = $(PREFIX)/share/locale
RPMTOP = rpms
RPMDIRS = SOURCES SPECS BUILD SRPMS RPMS
LIBRHASH = librhash/librhash.a
......@@ -132,7 +134,7 @@ $(TARGET): $(OBJECTS) $(LIBRHASH)
# we are using plain old makefile style to support BSD make
calc_sums.o: calc_sums.c common_func.h librhash/util.h librhash/hex.h \
librhash/rhash.h librhash/timing.h parse_cmdline.h rhash_main.h \
file_set.h calc_sums.h hash_check.h crc_print.h output.h win_utils.h \
file_set.h calc_sums.h hash_check.h hash_print.h output.h win_utils.h \
version.h
$(CC) -c $(ALLCFLAGS) $< -o $@
......@@ -140,22 +142,22 @@ common_func.o: common_func.c common_func.h librhash/util.h librhash/hex.h \
win_utils.h parse_cmdline.h
$(CC) -c $(ALLCFLAGS) $< -o $@
crc_print.o: crc_print.c common_func.h librhash/util.h librhash/hex.h \
hash_print.o: hash_print.c common_func.h librhash/util.h librhash/hex.h \
librhash/byte_order.h calc_sums.h librhash/rhash.h hash_check.h \
parse_cmdline.h crc_print.h
parse_cmdline.h hash_print.h
$(CC) -c $(ALLCFLAGS) $< -o $@
crc_update.o: crc_update.c common_func.h librhash/util.h \
hash_update.o: hash_update.c common_func.h librhash/util.h \
librhash/timing.h win_utils.h parse_cmdline.h output.h rhash_main.h \
file_set.h calc_sums.h librhash/rhash.h hash_check.h file_mask.h \
crc_update.h
hash_update.h
$(CC) -c $(ALLCFLAGS) $< -o $@
file_mask.o: file_mask.c common_func.h librhash/util.h file_mask.h
$(CC) -c $(ALLCFLAGS) $< -o $@
file_set.o: file_set.c librhash/hex.h librhash/crc32.h common_func.h \
librhash/util.h crc_print.h parse_cmdline.h rhash_main.h output.h \
librhash/util.h hash_print.h parse_cmdline.h rhash_main.h output.h \
file_set.h calc_sums.h librhash/rhash.h hash_check.h
$(CC) -c $(ALLCFLAGS) $< -o $@
......@@ -164,7 +166,7 @@ find_file.o: find_file.c common_func.h librhash/util.h win_utils.h \
$(CC) -c $(ALLCFLAGS) $< -o $@
hash_check.o: hash_check.c librhash/hex.h librhash/byte_order.h \
librhash/rhash.h output.h parse_cmdline.h crc_print.h hash_check.h
librhash/rhash.h output.h parse_cmdline.h hash_print.h hash_check.h
$(CC) -c $(ALLCFLAGS) $< -o $@
output.o: output.c common_func.h librhash/util.h librhash/rhash.h \
......@@ -173,12 +175,12 @@ output.o: output.c common_func.h librhash/util.h librhash/rhash.h \
parse_cmdline.o: parse_cmdline.c common_func.h librhash/util.h \
librhash/rhash.h librhash/plug_openssl.h win_utils.h file_mask.h \
crc_print.h output.h rhash_main.h version.h parse_cmdline.h
hash_print.h output.h rhash_main.h version.h parse_cmdline.h
$(CC) -c $(ALLCFLAGS) $< -o $@
rhash_main.o: rhash_main.c common_func.h librhash/util.h \
librhash/timing.h win_utils.h find_file.h file_set.h calc_sums.h \
librhash/rhash.h hash_check.h crc_update.h file_mask.h crc_print.h \
librhash/rhash.h hash_check.h hash_update.h file_mask.h hash_print.h \
parse_cmdline.h output.h version.h rhash_main.h
$(CC) -c $(ALLCFLAGS) $< -o $@
......@@ -211,6 +213,8 @@ $(ARCHIVE_GZIP): $(DIST_FILES)
rm -rf $(PROGNAME)-$(VERSION)
mkdir $(PROGNAME)-$(VERSION)
cp -rl --parents $(DIST_FILES) $(PROGNAME)-$(VERSION)/
make -C bindings distclean
find bindings/ -type f -regex '.*\(\.\([hct]\|java\|PL\|pm\|py\|rb\|txt\|xs\)\|Makefile\|MANIFEST\|typemap\)' -exec cp -l --parents '{}' $(PROGNAME)-$(VERSION)/ \;
tar czf $(ARCHIVE_GZIP) $(PROGNAME)-$(VERSION)/
rm -rf $(PROGNAME)-$(VERSION)
......@@ -260,3 +264,26 @@ distclean: clean
clean:
cd librhash && make clean
rm -f *.o $(TARGET)
rm -f po/*.gmo
rm -f po/*.po~
update-po:
xgettext *.c -k_ -cTRANSLATORS -o po/rhash.pot \
--msgid-bugs-address='rhash.admin@gmail.com' --package-name='RHash'
for f in po/*.po; do \
msgmerge -U $$f po/rhash.pot; \
done
compile-gmo:
for f in po/*.po; do \
g=`basename $$f .po`; \
msgfmt $$f -o po/$$g.gmo; \
done
install-gmo: compile-gmo
for f in po/*.gmo; do \
l=`basename $$f .gmo`; \
$(INSTALL) -d $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES; \
$(INSTALL_DATA) -T $$f $(DESTDIR)$(LOCALEDIR)/$$l/LC_MESSAGES/rhash.mo; \
done
MAKE = make
RUBY = ruby
PERL = /usr/bin/perl
DESTDIR =
PREFIX = /usr/local
PERL_OPTIMIZE = -O2 -g -Wall
all: configure build test
configure: configure-ruby configure-perl
build: build-java build-perl build-ruby
test: test-java test-perl test-ruby
install: install-ruby install-perl
clean: distclean
configure-perl:
cd perl && perl Makefile.PL INSTALLDIRS=vendor
configure-ruby:
$(RUBY) -C ruby extconf.rb
build-java:
$(MAKE) -C java/ jar jar-symlink jni javadoc
build-perl:
$(MAKE) -C perl OPTIMIZE="$(PERL_OPTIMIZE)"
build-ruby:
$(MAKE) -C ruby
test-java:
$(MAKE) -C java test
test-perl:
$(MAKE) -C perl test
test-ruby:
$(RUBY) -C ruby test_rhash.rb
install-ruby:
$(MAKE) -C ruby install DESTDIR=$(DESTDIR) sitedir=$(DESTDIR)/usr/lib/ruby
install-perl:
$(MAKE) -C perl install DESTDIR=$(DESTDIR)
# $(MAKE) -C perl install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) SITEPREFIX=$(PREFIX)
distclean:
$(MAKE) -C java distclean
[ ! -f ruby/Makefile ] || $(MAKE) -C ruby distclean
[ ! -f perl/Makefile ] || $(MAKE) -C perl distclean
#!/usr/bin/make -f
# This file is a part of Java Bindings for Librhash
# Copyright (c) 2011, Sergey Basalaev <sbasalaev@gmail.com>
# Librhash is (c) 2011, Alexey S Kravchenko <rhash.admin@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 library 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 it at your own risk!
MAKE = make
JAVA = java
JAVAC = javac
JAVADOC = javadoc
JAVAH = javah
JAR = jar
VERSION = $(shell sed -e 's/.*"\(.*\)".*/\1/' ../../version.h)
JAVASRC_DIR = src
CSRC_DIR = native
DEST_DIR = dist
CLASSES_DIR = classes
JAVADOC_DIR = javadoc
TEST_DIR = test
JAVADOC_API_URL = http://download.oracle.com/javase/6/docs/api/
JARFILE = $(DEST_DIR)/rhash-$(VERSION).jar
all: jar jni test
jar: compile-classes
mkdir -p $(DEST_DIR)
$(JAR) cf $(JARFILE) -C $(CLASSES_DIR) org/
jar-symlink:
ln -s rhash-$(VERSION).jar $(DEST_DIR)/rhash.jar
compile-classes:
mkdir -p $(CLASSES_DIR)
$(JAVAC) -d $(CLASSES_DIR) -sourcepath $(JAVASRC_DIR) `find ${JAVASRC_DIR} -name '*.java'`
update-header: compile-classes
$(JAVAH) -o $(CSRC_DIR)/bindings.h -classpath $(CLASSES_DIR) org.sf.rhash.Bindings
jni:
$(MAKE) -C $(CSRC_DIR)
mkdir -p $(DEST_DIR)
cp $(CSRC_DIR)/*rhash-jni* $(DEST_DIR)
javadoc: clean-javadoc
$(JAVADOC) -windowtitle 'RHash' \
-sourcepath src \
-subpackages org \
-d $(JAVADOC_DIR) \
-link $(JAVADOC_API_URL)
test: jar jni
$(JAVAC) -classpath $(JARFILE) $(TEST_DIR)/Test.java
$(JAVA) -classpath $(TEST_DIR):$(JARFILE) -Djava.library.path=$(DEST_DIR) Test
clean: clean-javadoc clean-jni clean-classes clean-test
clean-javadoc:
rm -rf $(JAVADOC_DIR)
clean-classes:
rm -rf $(CLASSES_DIR)
clean-jni:
$(MAKE) -C $(CSRC_DIR) clean
clean-test:
rm -f $(TEST_DIR)/*.class
distclean: clean
rm -rf $(DEST_DIR)
.PHONY: jar jni javadoc clean clean-javadoc distclean
#!/usr/bin/make -f
# This file is a part of Java Bindings for Librhash
# Copyright (c) 2011, Sergey Basalaev <sbasalaev@gmail.com>
# Librhash is (c) 2011, Alexey S Kravchenko <rhash.admin@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 library 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 it at your own risk!
CC = gcc
CFLAGS = -g -O2
LIBRHASH_INC =
LIBRHASH_LD =
LDFLAGS = -lrhash $(LIBRHASH_LD)
ALLCFLAGS = $(CFLAGS) $(LIBRHASH_INC) -fPIC
#Platform dependent
JNI_INCLUDES = /usr/lib/jvm/default-java/include
LIB_PREFIX = lib
LIB_SUFFIX = .so
OBJECTS = bindings.o digest.o
LIBRARY = $(LIB_PREFIX)rhash-jni$(LIB_SUFFIX)
all: $(LIBRARY)
bindings.o: bindings.c bindings.h
$(CC) $(ALLCFLAGS) -I$(JNI_INCLUDES) -c $< -o $@
digest.o: digest.c digest.h
$(CC) $(ALLCFLAGS) -c $< -o $@
$(LIBRARY): $(OBJECTS)
$(CC) $(LDFLAGS) -shared -o $@ $(OBJECTS)
clean:
rm -f *.o $(LIBRARY)
/*
* This file is a part of Java Bindings for Librhash
* Copyright (c) 2011, Sergey Basalaev <sbasalaev@gmail.com>
* Librhash is (c) 2011, Alexey S Kravchenko <rhash.admin@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 library 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 it at your own risk!
*/
#include <rhash/rhash.h>
#include <stdlib.h>
#include "bindings.h"
#include "digest.h"
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_library_init
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1library_1init
(JNIEnv *env, jclass clz) {
rhash_library_init();
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_count
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_sf_rhash_Bindings_rhash_1count
(JNIEnv *env, jclass clz) {
return rhash_count();
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_msg
* Signature: (I[BII)J
*/
JNIEXPORT jlong JNICALL Java_org_sf_rhash_Bindings_rhash_1msg
(JNIEnv *env, jclass clz, jint hash_id, jbyteArray buf, jint ofs, jint len) {
// reading data
void* msg = malloc(len);
(*env)->GetByteArrayRegion(env, buf, ofs, len, msg);
// creating and populating Digest
Digest obj = malloc(sizeof(DigestStruct));
obj->hash_len = rhash_get_digest_size(hash_id);
obj->hash_data = calloc(obj->hash_len, sizeof(unsigned char));
rhash_msg(hash_id, msg, len, obj->hash_data);
//cleaning
free(msg);
//returning
return (jlong)obj;
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_print_bytes
* Signature: (JI)[B
*/
JNIEXPORT jbyteArray JNICALL Java_org_sf_rhash_Bindings_rhash_1print_1bytes
(JNIEnv *env, jclass clz, jlong ptr, jint flags) {
Digest obj = (Digest)ptr;
unsigned char output[130];
int len = rhash_print_bytes(output, obj->hash_data, obj->hash_len, flags);
jbyteArray arr = (*env)->NewByteArray(env, len);
(*env)->SetByteArrayRegion(env, arr, 0, len, output);
return arr;
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_is_base32
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_org_sf_rhash_Bindings_rhash_1is_1base32
(JNIEnv *env, jclass clz, jint hash_id) {
return rhash_is_base32(hash_id);
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_get_digest_size
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_org_sf_rhash_Bindings_rhash_1get_1digest_1size
(JNIEnv *env, jclass clz, jint hash_id) {
return rhash_get_digest_size(hash_id);
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_init
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_org_sf_rhash_Bindings_rhash_1init
(JNIEnv *env, jclass clz, jint hash_flags) {
return (jlong)rhash_init(hash_flags);
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_update
* Signature: (J[BII)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1update
(JNIEnv *env, jclass clz, jlong context, jbyteArray data, jint ofs, jint len) {
void* msg = malloc(len);
(*env)->GetByteArrayRegion(env, data, ofs, len, msg);
rhash_update((rhash)context, msg, len);
free(msg);
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_final
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1final
(JNIEnv *env, jclass clz, jlong context) {
rhash_final((rhash)context, NULL);
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_reset
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1reset
(JNIEnv *env, jclass clz, jlong context) {
rhash_reset((rhash)context);
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_print
* Signature: (JI)J
*/
JNIEXPORT jlong JNICALL Java_org_sf_rhash_Bindings_rhash_1print
(JNIEnv *env, jclass clz, jlong context, jint hash_id) {
Digest obj = malloc(sizeof(DigestStruct));
obj->hash_len = rhash_get_digest_size(hash_id);
obj->hash_data = calloc(obj->hash_len, sizeof(unsigned char));
rhash_print(obj->hash_data, (rhash)context, hash_id, RHPR_RAW);
return (jlong)obj;
}
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_free
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1free
(JNIEnv *env, jclass clz, jlong context) {
rhash_free((rhash)context);
}
/*
* Class: org_sf_rhash_Bindings
* Method: compareDigests
* Signature: (JJ)Z
*/
JNIEXPORT jboolean JNICALL Java_org_sf_rhash_Bindings_compareDigests
(JNIEnv *env, jclass clz, jlong ptr1, jlong ptr2) {
return compareDigests((Digest)ptr1, (Digest)ptr2);
}
/*
* Class: org_sf_rhash_Bindings
* Method: hashcodeForDigest
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_sf_rhash_Bindings_hashcodeForDigest
(JNIEnv *env, jclass clz, jlong ptr) {
return hashcodeForDigest((Digest)ptr);
}
/*
* Class: org_sf_rhash_Bindings
* Method: freeDigest
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_freeDigest
(JNIEnv *env, jclass clz, jlong ptr) {
freeDigest((Digest)ptr);
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_sf_rhash_Bindings */
#ifndef _Included_org_sf_rhash_Bindings
#define _Included_org_sf_rhash_Bindings
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_library_init
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1library_1init
(JNIEnv *, jclass);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_count
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_sf_rhash_Bindings_rhash_1count
(JNIEnv *, jclass);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_msg
* Signature: (I[BII)J
*/
JNIEXPORT jlong JNICALL Java_org_sf_rhash_Bindings_rhash_1msg
(JNIEnv *, jclass, jint, jbyteArray, jint, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_print_bytes
* Signature: (JI)[B
*/
JNIEXPORT jbyteArray JNICALL Java_org_sf_rhash_Bindings_rhash_1print_1bytes
(JNIEnv *, jclass, jlong, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_is_base32
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL Java_org_sf_rhash_Bindings_rhash_1is_1base32
(JNIEnv *, jclass, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_get_digest_size
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_org_sf_rhash_Bindings_rhash_1get_1digest_1size
(JNIEnv *, jclass, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_init
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_org_sf_rhash_Bindings_rhash_1init
(JNIEnv *, jclass, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_update
* Signature: (J[BII)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1update
(JNIEnv *, jclass, jlong, jbyteArray, jint, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_final
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1final
(JNIEnv *, jclass, jlong);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_reset
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1reset
(JNIEnv *, jclass, jlong);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_print
* Signature: (JI)J
*/
JNIEXPORT jlong JNICALL Java_org_sf_rhash_Bindings_rhash_1print
(JNIEnv *, jclass, jlong, jint);
/*
* Class: org_sf_rhash_Bindings
* Method: rhash_free
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_rhash_1free
(JNIEnv *, jclass, jlong);
/*
* Class: org_sf_rhash_Bindings
* Method: compareDigests
* Signature: (JJ)Z
*/
JNIEXPORT jboolean JNICALL Java_org_sf_rhash_Bindings_compareDigests
(JNIEnv *, jclass, jlong, jlong);
/*
* Class: org_sf_rhash_Bindings
* Method: hashcodeForDigest
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_sf_rhash_Bindings_hashcodeForDigest
(JNIEnv *, jclass, jlong);
/*
* Class: org_sf_rhash_Bindings
* Method: freeDigest
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_sf_rhash_Bindings_freeDigest
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
}
#endif
#endif
/*
* This file is a part of Java Bindings for Librhash
* Copyright (c) 2011, Sergey Basalaev <sbasalaev@gmail.com>
* Librhash is (c) 2011, Alexey S Kravchenko <rhash.admin@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 library 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 it at your own risk!
*/
#include <stdlib.h>
#include <string.h>
#include "digest.h"
void freeDigest(Digest obj) {
free(obj->hash_data);
free(obj);
}
int compareDigests(Digest o1, Digest o2) {
if (o1->hash_len != o2->hash_len) return 0;
return memcmp(o1->hash_data, o2->hash_data, o1->hash_len) == 0;
}
int hashcodeForDigest(Digest obj) {
int hash = 123321, i;
for (i = 0; i < obj->hash_len; i++) {