0000: 2f 2a 0a 20 2a 20 54 68 69 73 20 66 69 6c 65 20 /*. * This file
0010: 69 73 20 61 20 70 61 72 74 20 6f 66 20 4a 61 76 is a part of Jav
0020: 61 20 42 69 6e 64 69 6e 67 73 20 66 6f 72 20 4c a Bindings for L
0030: 69 62 72 68 61 73 68 0a 20 2a 20 43 6f 70 79 72 ibrhash. * Copyr
0040: 69 67 68 74 20 28 63 29 20 32 30 31 31 2d 32 30 ight (c) 2011-20
0050: 31 32 2c 20 53 65 72 67 65 79 20 42 61 73 61 6c 12, Sergey Basal
0060: 61 65 76 20 3c 73 62 61 73 61 6c 61 65 76 40 67 aev <sbasalaev@g
0070: 6d 61 69 6c 2e 63 6f 6d 3e 0a 20 2a 20 4c 69 62 mail.com>. * Lib
0080: 72 68 61 73 68 20 69 73 20 28 63 29 20 32 30 31 rhash is (c) 201
0090: 31 2d 32 30 31 32 2c 20 41 6c 65 6b 73 65 79 20 1-2012, Aleksey
00a0: 4b 72 61 76 63 68 65 6e 6b 6f 20 3c 72 68 61 73 Kravchenko <rhas
00b0: 68 2e 61 64 6d 69 6e 40 67 6d 61 69 6c 2e 63 6f h.admin@gmail.co
00c0: 6d 3e 0a 20 2a 20 0a 20 2a 20 50 65 72 6d 69 73 m>. * . * Permis
00d0: 73 69 6f 6e 20 69 73 20 68 65 72 65 62 79 20 67 sion is hereby g
00e0: 72 61 6e 74 65 64 2c 20 66 72 65 65 20 6f 66 20 ranted, free of
00f0: 63 68 61 72 67 65 2c 20 20 74 6f 20 61 6e 79 20 charge, to any
0100: 70 65 72 73 6f 6e 20 6f 62 74 61 69 6e 69 6e 67 person obtaining
0110: 20 61 20 63 6f 70 79 0a 20 2a 20 6f 66 20 74 68 a copy. * of th
0120: 69 73 20 73 6f 66 74 77 61 72 65 20 61 6e 64 20 is software and
0130: 61 73 73 6f 63 69 61 74 65 64 20 64 6f 63 75 6d associated docum
0140: 65 6e 74 61 74 69 6f 6e 20 66 69 6c 65 73 20 28 entation files (
0150: 74 68 65 20 22 53 6f 66 74 77 61 72 65 22 29 2c the "Software"),
0160: 20 74 6f 20 64 65 61 6c 0a 20 2a 20 69 6e 20 74 to deal. * in t
0170: 68 65 20 53 6f 66 74 77 61 72 65 20 77 69 74 68 he Software with
0180: 6f 75 74 20 72 65 73 74 72 69 63 74 69 6f 6e 2c out restriction,
0190: 20 20 69 6e 63 6c 75 64 69 6e 67 20 77 69 74 68 including with
01a0: 6f 75 74 20 6c 69 6d 69 74 61 74 69 6f 6e 20 74 out limitation t
01b0: 68 65 20 72 69 67 68 74 73 0a 20 2a 20 74 6f 20 he rights. * to
01c0: 20 75 73 65 2c 20 20 63 6f 70 79 2c 20 20 6d 6f use, copy, mo
01d0: 64 69 66 79 2c 20 20 6d 65 72 67 65 2c 20 70 75 dify, merge, pu
01e0: 62 6c 69 73 68 2c 20 64 69 73 74 72 69 62 75 74 blish, distribut
01f0: 65 2c 20 73 75 62 6c 69 63 65 6e 73 65 2c 20 61 e, sublicense, a
0200: 6e 64 2f 6f 72 20 73 65 6c 6c 0a 20 2a 20 63 6f nd/or sell. * co
0210: 70 69 65 73 20 20 6f 66 20 20 74 68 65 20 53 6f pies of the So
0220: 66 74 77 61 72 65 2c 20 20 61 6e 64 20 20 74 6f ftware, and to
0230: 20 70 65 72 6d 69 74 20 20 70 65 72 73 6f 6e 73 permit persons
0240: 20 20 74 6f 20 77 68 6f 6d 20 20 74 68 65 20 53 to whom the S
0250: 6f 66 74 77 61 72 65 20 20 69 73 0a 20 2a 20 66 oftware is. * f
0260: 75 72 6e 69 73 68 65 64 20 74 6f 20 64 6f 20 73 urnished to do s
0270: 6f 2e 0a 20 2a 20 0a 20 2a 20 54 68 69 73 20 6c o.. * . * This l
0280: 69 62 72 61 72 79 20 20 69 73 20 64 69 73 74 72 ibrary is distr
0290: 69 62 75 74 65 64 20 20 69 6e 20 74 68 65 20 68 ibuted in the h
02a0: 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c ope that it will
02b0: 20 62 65 20 75 73 65 66 75 6c 2c 20 62 75 74 20 be useful, but
02c0: 57 49 54 48 4f 55 54 0a 20 2a 20 41 4e 59 20 57 WITHOUT. * ANY W
02d0: 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 ARRANTY; without
02e0: 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 65 even the implie
02f0: 64 20 77 61 72 72 61 6e 74 79 20 6f 66 20 4d 45 d warranty of ME
0300: 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 6f 72 RCHANTABILITY or
0310: 20 46 49 54 4e 45 53 53 0a 20 2a 20 46 4f 52 20 FITNESS. * FOR
0320: 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 A PARTICULAR PUR
0330: 50 4f 53 45 2e 20 55 73 65 20 69 74 20 61 74 20 POSE. Use it at
0340: 79 6f 75 72 20 6f 77 6e 20 72 69 73 6b 21 0a 20 your own risk!.
0350: 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 72 68 */..#include <rh
0360: 61 73 68 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 ash.h>.#include
0370: 3c 73 74 64 6c 69 62 2e 68 3e 0a 0a 23 69 66 64 <stdlib.h>..#ifd
0380: 65 66 20 5f 5f 47 4e 55 43 5f 5f 0a 23 69 6e 63 ef __GNUC__.#inc
0390: 6c 75 64 65 20 3c 73 74 64 69 6e 74 2e 68 3e 0a lude <stdint.h>.
03a0: 23 64 65 66 69 6e 65 20 54 4f 5f 52 48 41 53 48 #define TO_RHASH
03b0: 28 61 29 20 20 20 28 28 72 68 61 73 68 29 28 69 (a) ((rhash)(i
03c0: 6e 74 70 74 72 5f 74 29 28 61 29 29 0a 23 64 65 ntptr_t)(a)).#de
03d0: 66 69 6e 65 20 54 4f 5f 44 49 47 45 53 54 28 61 fine TO_DIGEST(a
03e0: 29 20 20 28 28 44 69 67 65 73 74 29 28 69 6e 74 ) ((Digest)(int
03f0: 70 74 72 5f 74 29 28 61 29 29 0a 23 64 65 66 69 ptr_t)(a)).#defi
0400: 6e 65 20 54 4f 5f 4a 4c 4f 4e 47 28 61 29 20 20 ne TO_JLONG(a)
0410: 20 28 28 6a 6c 6f 6e 67 29 28 69 6e 74 70 74 72 ((jlong)(intptr
0420: 5f 74 29 28 61 29 29 0a 23 65 6c 73 65 0a 23 64 _t)(a)).#else.#d
0430: 65 66 69 6e 65 20 54 4f 5f 52 48 41 53 48 28 61 efine TO_RHASH(a
0440: 29 20 20 20 28 28 72 68 61 73 68 29 28 61 29 29 ) ((rhash)(a))
0450: 0a 23 64 65 66 69 6e 65 20 54 4f 5f 44 49 47 45 .#define TO_DIGE
0460: 53 54 28 61 29 20 20 28 28 44 69 67 65 73 74 29 ST(a) ((Digest)
0470: 28 61 29 29 0a 23 64 65 66 69 6e 65 20 54 4f 5f (a)).#define TO_
0480: 4a 4c 4f 4e 47 28 61 29 20 20 20 28 28 6a 6c 6f JLONG(a) ((jlo
0490: 6e 67 29 28 61 29 29 0a 23 65 6e 64 69 66 20 2f ng)(a)).#endif /
04a0: 2a 20 5f 5f 47 4e 55 43 5f 5f 20 2a 2f 0a 0a 0a * __GNUC__ */...
04b0: 23 69 6e 63 6c 75 64 65 20 22 62 69 6e 64 69 6e #include "bindin
04c0: 67 73 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 22 gs.h".#include "
04d0: 64 69 67 65 73 74 2e 68 22 0a 0a 2f 2a 0a 20 2a digest.h"../*. *
04e0: 20 43 6c 61 73 73 3a 20 20 20 20 20 6f 72 67 5f Class: org_
04f0: 73 66 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 sf_rhash_Binding
0500: 73 0a 20 2a 20 4d 65 74 68 6f 64 3a 20 20 20 20 s. * Method:
0510: 72 68 61 73 68 5f 6c 69 62 72 61 72 79 5f 69 6e rhash_library_in
0520: 69 74 0a 20 2a 20 53 69 67 6e 61 74 75 72 65 3a it. * Signature:
0530: 20 28 29 56 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f ()V. */.JNIEXPO
0540: 52 54 20 76 6f 69 64 20 4a 4e 49 43 41 4c 4c 20 RT void JNICALL
0550: 4a 61 76 61 5f 6f 72 67 5f 73 66 5f 72 68 61 73 Java_org_sf_rhas
0560: 68 5f 42 69 6e 64 69 6e 67 73 5f 72 68 61 73 68 h_Bindings_rhash
0570: 5f 31 6c 69 62 72 61 72 79 5f 31 69 6e 69 74 0a _1library_1init.
0580: 28 4a 4e 49 45 6e 76 20 2a 65 6e 76 2c 20 6a 63 (JNIEnv *env, jc
0590: 6c 61 73 73 20 63 6c 7a 29 20 7b 0a 09 72 68 61 lass clz) {..rha
05a0: 73 68 5f 6c 69 62 72 61 72 79 5f 69 6e 69 74 28 sh_library_init(
05b0: 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 );.}../*. * Clas
05c0: 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 5f 72 68 s: org_sf_rh
05d0: 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a 20 2a 20 ash_Bindings. *
05e0: 4d 65 74 68 6f 64 3a 20 20 20 20 72 68 61 73 68 Method: rhash
05f0: 5f 63 6f 75 6e 74 0a 20 2a 20 53 69 67 6e 61 74 _count. * Signat
0600: 75 72 65 3a 20 28 29 49 0a 20 2a 2f 0a 4a 4e 49 ure: ()I. */.JNI
0610: 45 58 50 4f 52 54 20 6a 69 6e 74 20 4a 4e 49 43 EXPORT jint JNIC
0620: 41 4c 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 5f ALL Java_org_sf_
0630: 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f 72 rhash_Bindings_r
0640: 68 61 73 68 5f 31 63 6f 75 6e 74 0a 28 4a 4e 49 hash_1count.(JNI
0650: 45 6e 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 73 Env *env, jclass
0660: 20 63 6c 7a 29 20 7b 0a 09 72 65 74 75 72 6e 20 clz) {..return
0670: 72 68 61 73 68 5f 63 6f 75 6e 74 28 29 3b 0a 7d rhash_count();.}
0680: 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 73 3a 20 20 ../*. * Class:
0690: 20 20 20 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f org_sf_rhash_
06a0: 42 69 6e 64 69 6e 67 73 0a 20 2a 20 4d 65 74 68 Bindings. * Meth
06b0: 6f 64 3a 20 20 20 20 72 68 61 73 68 5f 6d 73 67 od: rhash_msg
06c0: 0a 20 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 28 . * Signature: (
06d0: 49 5b 42 49 49 29 4a 0a 20 2a 2f 0a 4a 4e 49 45 I[BII)J. */.JNIE
06e0: 58 50 4f 52 54 20 6a 6c 6f 6e 67 20 4a 4e 49 43 XPORT jlong JNIC
06f0: 41 4c 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 5f ALL Java_org_sf_
0700: 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f 72 rhash_Bindings_r
0710: 68 61 73 68 5f 31 6d 73 67 0a 28 4a 4e 49 45 6e hash_1msg.(JNIEn
0720: 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 73 20 63 v *env, jclass c
0730: 6c 7a 2c 20 6a 69 6e 74 20 68 61 73 68 5f 69 64 lz, jint hash_id
0740: 2c 20 6a 62 79 74 65 41 72 72 61 79 20 62 75 66 , jbyteArray buf
0750: 2c 20 6a 69 6e 74 20 6f 66 73 2c 20 6a 69 6e 74 , jint ofs, jint
0760: 20 6c 65 6e 29 20 7b 0a 09 2f 2f 20 72 65 61 64 len) {..// read
0770: 69 6e 67 20 64 61 74 61 0a 09 76 6f 69 64 2a 20 ing data..void*
0780: 6d 73 67 20 3d 20 6d 61 6c 6c 6f 63 28 6c 65 6e msg = malloc(len
0790: 29 3b 0a 09 28 2a 65 6e 76 29 2d 3e 47 65 74 42 );..(*env)->GetB
07a0: 79 74 65 41 72 72 61 79 52 65 67 69 6f 6e 28 65 yteArrayRegion(e
07b0: 6e 76 2c 20 62 75 66 2c 20 6f 66 73 2c 20 6c 65 nv, buf, ofs, le
07c0: 6e 2c 20 6d 73 67 29 3b 0a 09 2f 2f 20 63 72 65 n, msg);..// cre
07d0: 61 74 69 6e 67 20 61 6e 64 20 70 6f 70 75 6c 61 ating and popula
07e0: 74 69 6e 67 20 44 69 67 65 73 74 0a 09 44 69 67 ting Digest..Dig
07f0: 65 73 74 20 6f 62 6a 20 3d 20 6d 61 6c 6c 6f 63 est obj = malloc
0800: 28 73 69 7a 65 6f 66 28 44 69 67 65 73 74 53 74 (sizeof(DigestSt
0810: 72 75 63 74 29 29 3b 0a 09 6f 62 6a 2d 3e 68 61 ruct));..obj->ha
0820: 73 68 5f 6c 65 6e 20 20 3d 20 72 68 61 73 68 5f sh_len = rhash_
0830: 67 65 74 5f 64 69 67 65 73 74 5f 73 69 7a 65 28 get_digest_size(
0840: 68 61 73 68 5f 69 64 29 3b 0a 09 6f 62 6a 2d 3e hash_id);..obj->
0850: 68 61 73 68 5f 64 61 74 61 20 3d 20 63 61 6c 6c hash_data = call
0860: 6f 63 28 6f 62 6a 2d 3e 68 61 73 68 5f 6c 65 6e oc(obj->hash_len
0870: 2c 20 73 69 7a 65 6f 66 28 75 6e 73 69 67 6e 65 , sizeof(unsigne
0880: 64 20 63 68 61 72 29 29 3b 0a 09 72 68 61 73 68 d char));..rhash
0890: 5f 6d 73 67 28 68 61 73 68 5f 69 64 2c 20 6d 73 _msg(hash_id, ms
08a0: 67 2c 20 6c 65 6e 2c 20 6f 62 6a 2d 3e 68 61 73 g, len, obj->has
08b0: 68 5f 64 61 74 61 29 3b 0a 09 2f 2f 63 6c 65 61 h_data);..//clea
08c0: 6e 69 6e 67 0a 09 66 72 65 65 28 6d 73 67 29 3b ning..free(msg);
08d0: 0a 09 2f 2f 72 65 74 75 72 6e 69 6e 67 0a 09 72 ..//returning..r
08e0: 65 74 75 72 6e 20 54 4f 5f 4a 4c 4f 4e 47 28 6f eturn TO_JLONG(o
08f0: 62 6a 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 6c bj);.}../*. * Cl
0900: 61 73 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 5f ass: org_sf_
0910: 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a 20 rhash_Bindings.
0920: 2a 20 4d 65 74 68 6f 64 3a 20 20 20 20 72 68 61 * Method: rha
0930: 73 68 5f 70 72 69 6e 74 5f 62 79 74 65 73 0a 20 sh_print_bytes.
0940: 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 28 4a 49 * Signature: (JI
0950: 29 5b 42 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f 52 )[B. */.JNIEXPOR
0960: 54 20 6a 62 79 74 65 41 72 72 61 79 20 4a 4e 49 T jbyteArray JNI
0970: 43 41 4c 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 CALL Java_org_sf
0980: 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f _rhash_Bindings_
0990: 72 68 61 73 68 5f 31 70 72 69 6e 74 5f 31 62 79 rhash_1print_1by
09a0: 74 65 73 0a 28 4a 4e 49 45 6e 76 20 2a 65 6e 76 tes.(JNIEnv *env
09b0: 2c 20 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 6a 6c , jclass clz, jl
09c0: 6f 6e 67 20 70 74 72 2c 20 6a 69 6e 74 20 66 6c ong ptr, jint fl
09d0: 61 67 73 29 20 7b 0a 09 44 69 67 65 73 74 20 6f ags) {..Digest o
09e0: 62 6a 20 3d 20 54 4f 5f 44 49 47 45 53 54 28 70 bj = TO_DIGEST(p
09f0: 74 72 29 3b 0a 09 63 68 61 72 20 6f 75 74 70 75 tr);..char outpu
0a00: 74 5b 31 33 30 5d 3b 0a 09 69 6e 74 20 6c 65 6e t[130];..int len
0a10: 20 3d 20 72 68 61 73 68 5f 70 72 69 6e 74 5f 62 = rhash_print_b
0a20: 79 74 65 73 28 6f 75 74 70 75 74 2c 20 6f 62 6a ytes(output, obj
0a30: 2d 3e 68 61 73 68 5f 64 61 74 61 2c 20 6f 62 6a ->hash_data, obj
0a40: 2d 3e 68 61 73 68 5f 6c 65 6e 2c 20 66 6c 61 67 ->hash_len, flag
0a50: 73 29 3b 0a 09 6a 62 79 74 65 41 72 72 61 79 20 s);..jbyteArray
0a60: 61 72 72 20 3d 20 28 2a 65 6e 76 29 2d 3e 4e 65 arr = (*env)->Ne
0a70: 77 42 79 74 65 41 72 72 61 79 28 65 6e 76 2c 20 wByteArray(env,
0a80: 6c 65 6e 29 3b 0a 09 28 2a 65 6e 76 29 2d 3e 53 len);..(*env)->S
0a90: 65 74 42 79 74 65 41 72 72 61 79 52 65 67 69 6f etByteArrayRegio
0aa0: 6e 28 65 6e 76 2c 20 61 72 72 2c 20 30 2c 20 6c n(env, arr, 0, l
0ab0: 65 6e 2c 20 28 6a 62 79 74 65 2a 29 6f 75 74 70 en, (jbyte*)outp
0ac0: 75 74 29 3b 0a 09 72 65 74 75 72 6e 20 61 72 72 ut);..return arr
0ad0: 3b 0a 7d 0a 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 ;.}.../*. * Clas
0ae0: 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 5f 72 68 s: org_sf_rh
0af0: 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a 20 2a 20 ash_Bindings. *
0b00: 4d 65 74 68 6f 64 3a 20 20 20 20 72 68 61 73 68 Method: rhash
0b10: 5f 70 72 69 6e 74 5f 6d 61 67 6e 65 74 0a 20 2a _print_magnet. *
0b20: 20 53 69 67 6e 61 74 75 72 65 3a 20 28 4a 4c 6a Signature: (JLj
0b30: 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b ava/lang/String;
0b40: 49 29 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 I)Ljava/lang/Str
0b50: 69 6e 67 3b 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f ing;. */.JNIEXPO
0b60: 52 54 20 6a 73 74 72 69 6e 67 20 4a 4e 49 43 41 RT jstring JNICA
0b70: 4c 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 5f 72 LL Java_org_sf_r
0b80: 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f 72 68 hash_Bindings_rh
0b90: 61 73 68 5f 31 70 72 69 6e 74 5f 31 6d 61 67 6e ash_1print_1magn
0ba0: 65 74 0a 28 4a 4e 49 45 6e 76 20 2a 65 6e 76 2c et.(JNIEnv *env,
0bb0: 20 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 6a 6c 6f jclass clz, jlo
0bc0: 6e 67 20 63 6f 6e 74 65 78 74 2c 20 6a 73 74 72 ng context, jstr
0bd0: 69 6e 67 20 66 69 6c 65 70 61 74 68 2c 20 6a 69 ing filepath, ji
0be0: 6e 74 20 66 6c 61 67 73 29 20 7b 0a 09 63 6f 6e nt flags) {..con
0bf0: 73 74 20 63 68 61 72 2a 20 66 70 61 74 68 20 3d st char* fpath =
0c00: 20 28 66 69 6c 65 70 61 74 68 20 21 3d 20 4e 55 (filepath != NU
0c10: 4c 4c 29 20 3f 0a 09 09 09 28 2a 65 6e 76 29 2d LL) ?....(*env)-
0c20: 3e 47 65 74 53 74 72 69 6e 67 55 54 46 43 68 61 >GetStringUTFCha
0c30: 72 73 28 65 6e 76 2c 20 66 69 6c 65 70 61 74 68 rs(env, filepath
0c40: 2c 20 4e 55 4c 4c 29 20 3a 20 4e 55 4c 4c 3b 0a , NULL) : NULL;.
0c50: 09 73 69 7a 65 5f 74 20 6c 65 6e 20 3d 20 72 68 .size_t len = rh
0c60: 61 73 68 5f 70 72 69 6e 74 5f 6d 61 67 6e 65 74 ash_print_magnet
0c70: 28 4e 55 4c 4c 2c 20 66 70 61 74 68 2c 20 54 4f (NULL, fpath, TO
0c80: 5f 52 48 41 53 48 28 63 6f 6e 74 65 78 74 29 2c _RHASH(context),
0c90: 20 66 6c 61 67 73 2c 20 52 48 50 52 5f 46 49 4c flags, RHPR_FIL
0ca0: 45 53 49 5a 45 29 3b 0a 09 63 68 61 72 20 2a 62 ESIZE);..char *b
0cb0: 75 66 20 3d 20 28 63 68 61 72 2a 29 6d 61 6c 6c uf = (char*)mall
0cc0: 6f 63 28 6c 65 6e 29 3b 0a 09 72 68 61 73 68 5f oc(len);..rhash_
0cd0: 70 72 69 6e 74 5f 6d 61 67 6e 65 74 28 62 75 66 print_magnet(buf
0ce0: 2c 20 66 70 61 74 68 2c 20 54 4f 5f 52 48 41 53 , fpath, TO_RHAS
0cf0: 48 28 63 6f 6e 74 65 78 74 29 2c 20 66 6c 61 67 H(context), flag
0d00: 73 2c 20 52 48 50 52 5f 46 49 4c 45 53 49 5a 45 s, RHPR_FILESIZE
0d10: 29 3b 0a 09 69 66 20 28 66 69 6c 65 70 61 74 68 );..if (filepath
0d20: 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 28 2a != NULL) {...(*
0d30: 65 6e 76 29 2d 3e 52 65 6c 65 61 73 65 53 74 72 env)->ReleaseStr
0d40: 69 6e 67 55 54 46 43 68 61 72 73 28 65 6e 76 2c ingUTFChars(env,
0d50: 20 66 69 6c 65 70 61 74 68 2c 20 66 70 61 74 68 filepath, fpath
0d60: 29 3b 0a 09 7d 0a 09 6a 73 74 72 69 6e 67 20 73 );..}..jstring s
0d70: 74 72 20 3d 20 28 2a 65 6e 76 29 2d 3e 4e 65 77 tr = (*env)->New
0d80: 53 74 72 69 6e 67 55 54 46 28 65 6e 76 2c 20 62 StringUTF(env, b
0d90: 75 66 29 3b 0a 09 66 72 65 65 28 62 75 66 29 3b uf);..free(buf);
0da0: 0a 09 72 65 74 75 72 6e 20 73 74 72 3b 0a 7d 0a ..return str;.}.
0db0: 0a 2f 2a 0a 20 2a 20 43 6c 61 73 73 3a 20 20 20 ./*. * Class:
0dc0: 20 20 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f 42 org_sf_rhash_B
0dd0: 69 6e 64 69 6e 67 73 0a 20 2a 20 4d 65 74 68 6f indings. * Metho
0de0: 64 3a 20 20 20 20 72 68 61 73 68 5f 69 73 5f 62 d: rhash_is_b
0df0: 61 73 65 33 32 0a 20 2a 20 53 69 67 6e 61 74 75 ase32. * Signatu
0e00: 72 65 3a 20 28 49 29 5a 0a 20 2a 2f 0a 4a 4e 49 re: (I)Z. */.JNI
0e10: 45 58 50 4f 52 54 20 6a 62 6f 6f 6c 65 61 6e 20 EXPORT jboolean
0e20: 4a 4e 49 43 41 4c 4c 20 4a 61 76 61 5f 6f 72 67 JNICALL Java_org
0e30: 5f 73 66 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e _sf_rhash_Bindin
0e40: 67 73 5f 72 68 61 73 68 5f 31 69 73 5f 31 62 61 gs_rhash_1is_1ba
0e50: 73 65 33 32 0a 28 4a 4e 49 45 6e 76 20 2a 65 6e se32.(JNIEnv *en
0e60: 76 2c 20 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 6a v, jclass clz, j
0e70: 69 6e 74 20 68 61 73 68 5f 69 64 29 20 7b 0a 09 int hash_id) {..
0e80: 72 65 74 75 72 6e 20 72 68 61 73 68 5f 69 73 5f return rhash_is_
0e90: 62 61 73 65 33 32 28 68 61 73 68 5f 69 64 29 3b base32(hash_id);
0ea0: 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 73 3a .}../*. * Class:
0eb0: 20 20 20 20 20 6f 72 67 5f 73 66 5f 72 68 61 73 org_sf_rhas
0ec0: 68 5f 42 69 6e 64 69 6e 67 73 0a 20 2a 20 4d 65 h_Bindings. * Me
0ed0: 74 68 6f 64 3a 20 20 20 20 72 68 61 73 68 5f 67 thod: rhash_g
0ee0: 65 74 5f 64 69 67 65 73 74 5f 73 69 7a 65 0a 20 et_digest_size.
0ef0: 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 28 49 29 * Signature: (I)
0f00: 49 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f 52 54 20 I. */.JNIEXPORT
0f10: 6a 69 6e 74 20 4a 4e 49 43 41 4c 4c 20 4a 61 76 jint JNICALL Jav
0f20: 61 5f 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f 42 a_org_sf_rhash_B
0f30: 69 6e 64 69 6e 67 73 5f 72 68 61 73 68 5f 31 67 indings_rhash_1g
0f40: 65 74 5f 31 64 69 67 65 73 74 5f 31 73 69 7a 65 et_1digest_1size
0f50: 0a 28 4a 4e 49 45 6e 76 20 2a 65 6e 76 2c 20 6a .(JNIEnv *env, j
0f60: 63 6c 61 73 73 20 63 6c 7a 2c 20 6a 69 6e 74 20 class clz, jint
0f70: 68 61 73 68 5f 69 64 29 20 7b 0a 09 72 65 74 75 hash_id) {..retu
0f80: 72 6e 20 72 68 61 73 68 5f 67 65 74 5f 64 69 67 rn rhash_get_dig
0f90: 65 73 74 5f 73 69 7a 65 28 68 61 73 68 5f 69 64 est_size(hash_id
0fa0: 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 );.}../*. * Clas
0fb0: 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 5f 72 68 s: org_sf_rh
0fc0: 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a 20 2a 20 ash_Bindings. *
0fd0: 4d 65 74 68 6f 64 3a 20 20 20 20 72 68 61 73 68 Method: rhash
0fe0: 5f 69 6e 69 74 0a 20 2a 20 53 69 67 6e 61 74 75 _init. * Signatu
0ff0: 72 65 3a 20 28 49 29 4a 0a 20 2a 2f 0a 4a 4e 49 re: (I)J. */.JNI
1000: 45 58 50 4f 52 54 20 6a 6c 6f 6e 67 20 4a 4e 49 EXPORT jlong JNI
1010: 43 41 4c 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 CALL Java_org_sf
1020: 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f _rhash_Bindings_
1030: 72 68 61 73 68 5f 31 69 6e 69 74 0a 28 4a 4e 49 rhash_1init.(JNI
1040: 45 6e 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 73 Env *env, jclass
1050: 20 63 6c 7a 2c 20 6a 69 6e 74 20 68 61 73 68 5f clz, jint hash_
1060: 66 6c 61 67 73 29 20 7b 0a 09 72 68 61 73 68 20 flags) {..rhash
1070: 63 74 78 20 3d 20 72 68 61 73 68 5f 69 6e 69 74 ctx = rhash_init
1080: 28 68 61 73 68 5f 66 6c 61 67 73 29 3b 0a 09 72 (hash_flags);..r
1090: 68 61 73 68 5f 73 65 74 5f 61 75 74 6f 66 69 6e hash_set_autofin
10a0: 61 6c 28 63 74 78 2c 20 30 29 3b 0a 09 72 65 74 al(ctx, 0);..ret
10b0: 75 72 6e 20 54 4f 5f 4a 4c 4f 4e 47 28 63 74 78 urn TO_JLONG(ctx
10c0: 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 );.}../*. * Clas
10d0: 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 5f 72 68 s: org_sf_rh
10e0: 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a 20 2a 20 ash_Bindings. *
10f0: 4d 65 74 68 6f 64 3a 20 20 20 20 72 68 61 73 68 Method: rhash
1100: 5f 75 70 64 61 74 65 0a 20 2a 20 53 69 67 6e 61 _update. * Signa
1110: 74 75 72 65 3a 20 28 4a 5b 42 49 49 29 56 0a 20 ture: (J[BII)V.
1120: 2a 2f 0a 4a 4e 49 45 58 50 4f 52 54 20 76 6f 69 */.JNIEXPORT voi
1130: 64 20 4a 4e 49 43 41 4c 4c 20 4a 61 76 61 5f 6f d JNICALL Java_o
1140: 72 67 5f 73 66 5f 72 68 61 73 68 5f 42 69 6e 64 rg_sf_rhash_Bind
1150: 69 6e 67 73 5f 72 68 61 73 68 5f 31 75 70 64 61 ings_rhash_1upda
1160: 74 65 0a 28 4a 4e 49 45 6e 76 20 2a 65 6e 76 2c te.(JNIEnv *env,
1170: 20 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 6a 6c 6f jclass clz, jlo
1180: 6e 67 20 63 6f 6e 74 65 78 74 2c 20 6a 62 79 74 ng context, jbyt
1190: 65 41 72 72 61 79 20 64 61 74 61 2c 20 6a 69 6e eArray data, jin
11a0: 74 20 6f 66 73 2c 20 6a 69 6e 74 20 6c 65 6e 29 t ofs, jint len)
11b0: 20 7b 0a 09 76 6f 69 64 2a 20 6d 73 67 20 3d 20 {..void* msg =
11c0: 6d 61 6c 6c 6f 63 28 6c 65 6e 29 3b 0a 09 28 2a malloc(len);..(*
11d0: 65 6e 76 29 2d 3e 47 65 74 42 79 74 65 41 72 72 env)->GetByteArr
11e0: 61 79 52 65 67 69 6f 6e 28 65 6e 76 2c 20 64 61 ayRegion(env, da
11f0: 74 61 2c 20 6f 66 73 2c 20 6c 65 6e 2c 20 6d 73 ta, ofs, len, ms
1200: 67 29 3b 0a 09 72 68 61 73 68 5f 75 70 64 61 74 g);..rhash_updat
1210: 65 28 54 4f 5f 52 48 41 53 48 28 63 6f 6e 74 65 e(TO_RHASH(conte
1220: 78 74 29 2c 20 6d 73 67 2c 20 6c 65 6e 29 3b 0a xt), msg, len);.
1230: 09 66 72 65 65 28 6d 73 67 29 3b 0a 7d 0a 0a 2f .free(msg);.}../
1240: 2a 0a 20 2a 20 43 6c 61 73 73 3a 20 20 20 20 20 *. * Class:
1250: 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f 42 69 6e org_sf_rhash_Bin
1260: 64 69 6e 67 73 0a 20 2a 20 4d 65 74 68 6f 64 3a dings. * Method:
1270: 20 20 20 20 72 68 61 73 68 5f 66 69 6e 61 6c 0a rhash_final.
1280: 20 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 28 4a * Signature: (J
1290: 29 56 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f 52 54 )V. */.JNIEXPORT
12a0: 20 76 6f 69 64 20 4a 4e 49 43 41 4c 4c 20 4a 61 void JNICALL Ja
12b0: 76 61 5f 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f va_org_sf_rhash_
12c0: 42 69 6e 64 69 6e 67 73 5f 72 68 61 73 68 5f 31 Bindings_rhash_1
12d0: 66 69 6e 61 6c 0a 28 4a 4e 49 45 6e 76 20 2a 65 final.(JNIEnv *e
12e0: 6e 76 2c 20 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 nv, jclass clz,
12f0: 6a 6c 6f 6e 67 20 63 6f 6e 74 65 78 74 29 20 7b jlong context) {
1300: 0a 09 72 68 61 73 68 5f 66 69 6e 61 6c 28 54 4f ..rhash_final(TO
1310: 5f 52 48 41 53 48 28 63 6f 6e 74 65 78 74 29 2c _RHASH(context),
1320: 20 4e 55 4c 4c 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a NULL);.}../*. *
1330: 20 43 6c 61 73 73 3a 20 20 20 20 20 6f 72 67 5f Class: org_
1340: 73 66 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 sf_rhash_Binding
1350: 73 0a 20 2a 20 4d 65 74 68 6f 64 3a 20 20 20 20 s. * Method:
1360: 72 68 61 73 68 5f 72 65 73 65 74 0a 20 2a 20 53 rhash_reset. * S
1370: 69 67 6e 61 74 75 72 65 3a 20 28 4a 29 56 0a 20 ignature: (J)V.
1380: 2a 2f 0a 4a 4e 49 45 58 50 4f 52 54 20 76 6f 69 */.JNIEXPORT voi
1390: 64 20 4a 4e 49 43 41 4c 4c 20 4a 61 76 61 5f 6f d JNICALL Java_o
13a0: 72 67 5f 73 66 5f 72 68 61 73 68 5f 42 69 6e 64 rg_sf_rhash_Bind
13b0: 69 6e 67 73 5f 72 68 61 73 68 5f 31 72 65 73 65 ings_rhash_1rese
13c0: 74 0a 28 4a 4e 49 45 6e 76 20 2a 65 6e 76 2c 20 t.(JNIEnv *env,
13d0: 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 6a 6c 6f 6e jclass clz, jlon
13e0: 67 20 63 6f 6e 74 65 78 74 29 20 7b 0a 09 72 68 g context) {..rh
13f0: 61 73 68 5f 72 65 73 65 74 28 54 4f 5f 52 48 41 ash_reset(TO_RHA
1400: 53 48 28 63 6f 6e 74 65 78 74 29 29 3b 0a 7d 0a SH(context));.}.
1410: 0a 2f 2a 0a 20 2a 20 43 6c 61 73 73 3a 20 20 20 ./*. * Class:
1420: 20 20 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f 42 org_sf_rhash_B
1430: 69 6e 64 69 6e 67 73 0a 20 2a 20 4d 65 74 68 6f indings. * Metho
1440: 64 3a 20 20 20 20 72 68 61 73 68 5f 70 72 69 6e d: rhash_prin
1450: 74 0a 20 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 t. * Signature:
1460: 28 4a 49 29 4a 0a 20 2a 2f 0a 4a 4e 49 45 58 50 (JI)J. */.JNIEXP
1470: 4f 52 54 20 6a 6c 6f 6e 67 20 4a 4e 49 43 41 4c ORT jlong JNICAL
1480: 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 5f 72 68 L Java_org_sf_rh
1490: 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f 72 68 61 ash_Bindings_rha
14a0: 73 68 5f 31 70 72 69 6e 74 0a 28 4a 4e 49 45 6e sh_1print.(JNIEn
14b0: 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 73 20 63 v *env, jclass c
14c0: 6c 7a 2c 20 6a 6c 6f 6e 67 20 63 6f 6e 74 65 78 lz, jlong contex
14d0: 74 2c 20 6a 69 6e 74 20 68 61 73 68 5f 69 64 29 t, jint hash_id)
14e0: 20 7b 0a 09 44 69 67 65 73 74 20 6f 62 6a 20 3d {..Digest obj =
14f0: 20 6d 61 6c 6c 6f 63 28 73 69 7a 65 6f 66 28 44 malloc(sizeof(D
1500: 69 67 65 73 74 53 74 72 75 63 74 29 29 3b 0a 09 igestStruct));..
1510: 6f 62 6a 2d 3e 68 61 73 68 5f 6c 65 6e 20 20 3d obj->hash_len =
1520: 20 72 68 61 73 68 5f 67 65 74 5f 64 69 67 65 73 rhash_get_diges
1530: 74 5f 73 69 7a 65 28 68 61 73 68 5f 69 64 29 3b t_size(hash_id);
1540: 0a 09 6f 62 6a 2d 3e 68 61 73 68 5f 64 61 74 61 ..obj->hash_data
1550: 20 3d 20 63 61 6c 6c 6f 63 28 6f 62 6a 2d 3e 68 = calloc(obj->h
1560: 61 73 68 5f 6c 65 6e 2c 20 73 69 7a 65 6f 66 28 ash_len, sizeof(
1570: 75 6e 73 69 67 6e 65 64 20 63 68 61 72 29 29 3b unsigned char));
1580: 0a 09 72 68 61 73 68 5f 70 72 69 6e 74 28 28 63 ..rhash_print((c
1590: 68 61 72 2a 29 6f 62 6a 2d 3e 68 61 73 68 5f 64 har*)obj->hash_d
15a0: 61 74 61 2c 20 54 4f 5f 52 48 41 53 48 28 63 6f ata, TO_RHASH(co
15b0: 6e 74 65 78 74 29 2c 20 68 61 73 68 5f 69 64 2c ntext), hash_id,
15c0: 20 52 48 50 52 5f 52 41 57 29 3b 0a 09 72 65 74 RHPR_RAW);..ret
15d0: 75 72 6e 20 54 4f 5f 4a 4c 4f 4e 47 28 6f 62 6a urn TO_JLONG(obj
15e0: 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 );.}../*. * Clas
15f0: 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 5f 72 68 s: org_sf_rh
1600: 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a 20 2a 20 ash_Bindings. *
1610: 4d 65 74 68 6f 64 3a 20 20 20 20 72 68 61 73 68 Method: rhash
1620: 5f 66 72 65 65 0a 20 2a 20 53 69 67 6e 61 74 75 _free. * Signatu
1630: 72 65 3a 20 28 4a 29 56 0a 20 2a 2f 0a 4a 4e 49 re: (J)V. */.JNI
1640: 45 58 50 4f 52 54 20 76 6f 69 64 20 4a 4e 49 43 EXPORT void JNIC
1650: 41 4c 4c 20 4a 61 76 61 5f 6f 72 67 5f 73 66 5f ALL Java_org_sf_
1660: 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 5f 72 rhash_Bindings_r
1670: 68 61 73 68 5f 31 66 72 65 65 0a 28 4a 4e 49 45 hash_1free.(JNIE
1680: 6e 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 73 20 nv *env, jclass
1690: 63 6c 7a 2c 20 6a 6c 6f 6e 67 20 63 6f 6e 74 65 clz, jlong conte
16a0: 78 74 29 20 7b 0a 09 72 68 61 73 68 5f 66 72 65 xt) {..rhash_fre
16b0: 65 28 54 4f 5f 52 48 41 53 48 28 63 6f 6e 74 65 e(TO_RHASH(conte
16c0: 78 74 29 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 xt));.}../*. * C
16d0: 6c 61 73 73 3a 20 20 20 20 20 6f 72 67 5f 73 66 lass: org_sf
16e0: 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 73 0a _rhash_Bindings.
16f0: 20 2a 20 4d 65 74 68 6f 64 3a 20 20 20 20 63 6f * Method: co
1700: 6d 70 61 72 65 44 69 67 65 73 74 73 0a 20 2a 20 mpareDigests. *
1710: 53 69 67 6e 61 74 75 72 65 3a 20 28 4a 4a 29 5a Signature: (JJ)Z
1720: 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f 52 54 20 6a . */.JNIEXPORT j
1730: 62 6f 6f 6c 65 61 6e 20 4a 4e 49 43 41 4c 4c 20 boolean JNICALL
1740: 4a 61 76 61 5f 6f 72 67 5f 73 66 5f 72 68 61 73 Java_org_sf_rhas
1750: 68 5f 42 69 6e 64 69 6e 67 73 5f 63 6f 6d 70 61 h_Bindings_compa
1760: 72 65 44 69 67 65 73 74 73 0a 28 4a 4e 49 45 6e reDigests.(JNIEn
1770: 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 73 20 63 v *env, jclass c
1780: 6c 7a 2c 20 6a 6c 6f 6e 67 20 70 74 72 31 2c 20 lz, jlong ptr1,
1790: 6a 6c 6f 6e 67 20 70 74 72 32 29 20 7b 0a 09 72 jlong ptr2) {..r
17a0: 65 74 75 72 6e 20 63 6f 6d 70 61 72 65 44 69 67 eturn compareDig
17b0: 65 73 74 73 28 54 4f 5f 44 49 47 45 53 54 28 70 ests(TO_DIGEST(p
17c0: 74 72 31 29 2c 20 54 4f 5f 44 49 47 45 53 54 28 tr1), TO_DIGEST(
17d0: 70 74 72 32 29 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a ptr2));.}../*. *
17e0: 20 43 6c 61 73 73 3a 20 20 20 20 20 6f 72 67 5f Class: org_
17f0: 73 66 5f 72 68 61 73 68 5f 42 69 6e 64 69 6e 67 sf_rhash_Binding
1800: 73 0a 20 2a 20 4d 65 74 68 6f 64 3a 20 20 20 20 s. * Method:
1810: 68 61 73 68 63 6f 64 65 46 6f 72 44 69 67 65 73 hashcodeForDiges
1820: 74 0a 20 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 t. * Signature:
1830: 28 4a 29 49 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f (J)I. */.JNIEXPO
1840: 52 54 20 6a 69 6e 74 20 4a 4e 49 43 41 4c 4c 20 RT jint JNICALL
1850: 4a 61 76 61 5f 6f 72 67 5f 73 66 5f 72 68 61 73 Java_org_sf_rhas
1860: 68 5f 42 69 6e 64 69 6e 67 73 5f 68 61 73 68 63 h_Bindings_hashc
1870: 6f 64 65 46 6f 72 44 69 67 65 73 74 0a 28 4a 4e odeForDigest.(JN
1880: 49 45 6e 76 20 2a 65 6e 76 2c 20 6a 63 6c 61 73 IEnv *env, jclas
1890: 73 20 63 6c 7a 2c 20 6a 6c 6f 6e 67 20 70 74 72 s clz, jlong ptr
18a0: 29 20 7b 0a 09 72 65 74 75 72 6e 20 68 61 73 68 ) {..return hash
18b0: 63 6f 64 65 46 6f 72 44 69 67 65 73 74 28 54 4f codeForDigest(TO
18c0: 5f 44 49 47 45 53 54 28 70 74 72 29 29 3b 0a 7d _DIGEST(ptr));.}
18d0: 0a 0a 2f 2a 0a 20 2a 20 43 6c 61 73 73 3a 20 20 ../*. * Class:
18e0: 20 20 20 6f 72 67 5f 73 66 5f 72 68 61 73 68 5f org_sf_rhash_
18f0: 42 69 6e 64 69 6e 67 73 0a 20 2a 20 4d 65 74 68 Bindings. * Meth
1900: 6f 64 3a 20 20 20 20 66 72 65 65 44 69 67 65 73 od: freeDiges
1910: 74 0a 20 2a 20 53 69 67 6e 61 74 75 72 65 3a 20 t. * Signature:
1920: 28 4a 29 56 0a 20 2a 2f 0a 4a 4e 49 45 58 50 4f (J)V. */.JNIEXPO
1930: 52 54 20 76 6f 69 64 20 4a 4e 49 43 41 4c 4c 20 RT void JNICALL
1940: 4a 61 76 61 5f 6f 72 67 5f 73 66 5f 72 68 61 73 Java_org_sf_rhas
1950: 68 5f 42 69 6e 64 69 6e 67 73 5f 66 72 65 65 44 h_Bindings_freeD
1960: 69 67 65 73 74 0a 28 4a 4e 49 45 6e 76 20 2a 65 igest.(JNIEnv *e
1970: 6e 76 2c 20 6a 63 6c 61 73 73 20 63 6c 7a 2c 20 nv, jclass clz,
1980: 6a 6c 6f 6e 67 20 70 74 72 29 20 7b 0a 09 66 72 jlong ptr) {..fr
1990: 65 65 44 69 67 65 73 74 28 54 4f 5f 44 49 47 45 eeDigest(TO_DIGE
19a0: 53 54 28 70 74 72 29 29 3b 0a 7d 0a 0a ST(ptr));.}..