aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/Makefile.am4
-rwxr-xr-xcontrib/gnunet-chk.py.in (renamed from contrib/gnunet-chk.py)21
2 files changed, 15 insertions, 10 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 577924fab..1db5b3091 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -20,7 +20,8 @@ noinst_SCRIPTS = \
20 terminate.py \ 20 terminate.py \
21 pydiffer.py \ 21 pydiffer.py \
22 gnunet_pyexpect.py \ 22 gnunet_pyexpect.py \
23 gnunet_janitor.py 23 gnunet_janitor.py \
24 gnunet-chk.py
24 25
25dist_pkgdata_DATA = \ 26dist_pkgdata_DATA = \
26 gns-bcd.html \ 27 gns-bcd.html \
@@ -50,6 +51,7 @@ EXTRA_DIST = \
50 terminate.py.in \ 51 terminate.py.in \
51 gnunet_pyexpect.py.in \ 52 gnunet_pyexpect.py.in \
52 gnunet_janitor.py.in \ 53 gnunet_janitor.py.in \
54 gnunet-chk.py.in \
53 pydiffer.py.in \ 55 pydiffer.py.in \
54 gnunet-gns-import.sh \ 56 gnunet-gns-import.sh \
55 openvpn-tap32/tapw32/tap0901.sys \ 57 openvpn-tap32/tapw32/tap0901.sys \
diff --git a/contrib/gnunet-chk.py b/contrib/gnunet-chk.py.in
index dba694c34..f20153a8a 100755
--- a/contrib/gnunet-chk.py
+++ b/contrib/gnunet-chk.py.in
@@ -1,6 +1,6 @@
1#!/usr/bin/python 1#!@PYTHON@
2# This file is part of GNUnet. 2# This file is part of GNUnet.
3# (C) 2013 Christian Grothoff (and other contributing authors) 3# (C) 2013, 2018 Christian Grothoff (and other contributing authors)
4# 4#
5# GNUnet is free software; you can redistribute it and/or modify 5# GNUnet is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published 6# it under the terms of the GNU General Public License as published
@@ -27,6 +27,7 @@ import os
27import getopt 27import getopt
28import sys 28import sys
29from Crypto.Cipher import AES 29from Crypto.Cipher import AES
30from functools import reduce
30 31
31 32
32# Defaults 33# Defaults
@@ -76,7 +77,7 @@ def encode_data_to_string(data):
76 wpos += 1 77 wpos += 1
77 vbit -= 5 78 vbit -= 5
78 assert (0 == vbit) 79 assert (0 == vbit)
79 return out; 80 return out
80 81
81 82
82def sha512_hash(data): 83def sha512_hash(data):
@@ -105,7 +106,7 @@ class AESKey:
105 passphrase: string containing the passphrase to get the AES key and 106 passphrase: string containing the passphrase to get the AES key and
106 initialization vector 107 initialization vector
107 """ 108 """
108 passphrase = bytearray(passphrase); 109 passphrase = bytearray(passphrase)
109 self.key = bytearray(self.KEY_SIZE) 110 self.key = bytearray(self.KEY_SIZE)
110 self.iv = bytearray(self.IV_SIZE) 111 self.iv = bytearray(self.IV_SIZE)
111 if (len(passphrase) > self.KEY_SIZE): 112 if (len(passphrase) > self.KEY_SIZE):
@@ -191,6 +192,8 @@ class Chk:
191 def setSize(self, size): 192 def setSize(self, size):
192 self.fsize = size 193 self.fsize = size
193 194
195 # 2to3-3.5 suggests to change the code below to:
196 # if isinstance (self.fsize, int):
194 def uri(self): 197 def uri(self):
195 sizestr = repr(self.fsize) 198 sizestr = repr(self.fsize)
196 if isinstance(self.fsize, long): 199 if isinstance(self.fsize, long):
@@ -284,7 +287,7 @@ def compute_rootchk(readin, size):
284 readin: the stream where to read data from 287 readin: the stream where to read data from
285 size: the size of data to be read 288 size: the size of data to be read
286 """ 289 """
287 depth = compute_depth_(size); 290 depth = compute_depth_(size)
288 current_depth = 0 291 current_depth = 0
289 chks = [None] * (depth * CHK_PER_INODE) # list buffer 292 chks = [None] * (depth * CHK_PER_INODE) # list buffer
290 read_offset = 0 293 read_offset = 0
@@ -294,13 +297,13 @@ def compute_rootchk(readin, size):
294 off = CHK_PER_INODE * (depth - 1) 297 off = CHK_PER_INODE * (depth - 1)
295 assert (chks[off] is not None) 298 assert (chks[off] is not None)
296 logging.debug("Encoding done, reading CHK `" + chks[off].query + \ 299 logging.debug("Encoding done, reading CHK `" + chks[off].query + \
297 "' from " + repr(off) + "\n") 300 "' from " + repr(off) + "\n")
298 uri_chk = chks[off] 301 uri_chk = chks[off]
299 assert (size == read_offset) 302 assert (size == read_offset)
300 uri_chk.setSize(size) 303 uri_chk.setSize(size)
301 return uri_chk 304 return uri_chk
302 if (0 == current_depth): 305 if (0 == current_depth):
303 pt_size = min(DBLOCK_SIZE, size - read_offset); 306 pt_size = min(DBLOCK_SIZE, size - read_offset)
304 try: 307 try:
305 pt_block = readin.read(pt_size) 308 pt_block = readin.read(pt_size)
306 except IOError: 309 except IOError:
@@ -366,7 +369,7 @@ Options:
366if '__main__' == __name__: 369if '__main__' == __name__:
367 try: 370 try:
368 opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) 371 opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
369 except getopt.GetoptError, err: 372 except getopt.GetoptError as err:
370 print(err) 373 print(err)
371 print("Exception occured") 374 print("Exception occured")
372 usage() 375 usage()
@@ -379,4 +382,4 @@ if '__main__' == __name__:
379 print("Incorrect number of arguments passed") 382 print("Incorrect number of arguments passed")
380 usage() 383 usage()
381 sys.exit(1) 384 sys.exit(1)
382 print chkuri_from_path(args[0]) 385 print(chkuri_from_path(args[0]))