aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/gnunet-chk.py.in
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/scripts/gnunet-chk.py.in')
-rwxr-xr-xcontrib/scripts/gnunet-chk.py.in23
1 files changed, 12 insertions, 11 deletions
diff --git a/contrib/scripts/gnunet-chk.py.in b/contrib/scripts/gnunet-chk.py.in
index 0fb591627..7d2cf73d3 100755
--- a/contrib/scripts/gnunet-chk.py.in
+++ b/contrib/scripts/gnunet-chk.py.in
@@ -29,9 +29,8 @@ import sys
29from Crypto.Cipher import AES 29from Crypto.Cipher import AES
30from functools import reduce 30from functools import reduce
31 31
32
33# Defaults 32# Defaults
34DBLOCK_SIZE = (32 * 1024) # Data block size 33DBLOCK_SIZE = (32 * 1024) # Data block size
35 34
36# Pick a multiple of 2 here to achive 8-byte alignment! We also 35# Pick a multiple of 2 here to achive 8-byte alignment! We also
37# probably want DBlocks to have (roughly) the same size as IBlocks. 36# probably want DBlocks to have (roughly) the same size as IBlocks.
@@ -39,7 +38,7 @@ DBLOCK_SIZE = (32 * 1024) # Data block size
39# byte = 2 * 512 bits). DO NOT CHANGE! 38# byte = 2 * 512 bits). DO NOT CHANGE!
40CHK_PER_INODE = 256 39CHK_PER_INODE = 256
41 40
42CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes 41CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes
43 42
44CHK_QUERY_SIZE = CHK_HASH_SIZE # Again a SHA-512 hash 43CHK_QUERY_SIZE = CHK_HASH_SIZE # Again a SHA-512 hash
45 44
@@ -94,11 +93,11 @@ class AESKey(object):
94 """Class for AES Keys. Contains the main key and the initialization 93 """Class for AES Keys. Contains the main key and the initialization
95 vector. """ 94 vector. """
96 95
97 key = None # The actual AES key 96 key = None # The actual AES key
98 iv = None # The initialization vector 97 iv = None # The initialization vector
99 cipher = None # The cipher object 98 cipher = None # The cipher object
100 KEY_SIZE = 32 # AES 256-bit key = 32 bytes 99 KEY_SIZE = 32 # AES 256-bit key = 32 bytes
101 IV_SIZE = AES.block_size # Initialization vector size (= AES block size) 100 IV_SIZE = AES.block_size # Initialization vector size (= AES block size)
102 101
103 def __init__(self, passphrase): 102 def __init__(self, passphrase):
104 """Creates a new AES key. 103 """Creates a new AES key.
@@ -355,13 +354,15 @@ def chkuri_from_path(path):
355 354
356def usage(): 355def usage():
357 """Prints help about using this script.""" 356 """Prints help about using this script."""
358 print(""" 357 print(
358 """
359Usage: gnunet-chk.py [options] file 359Usage: gnunet-chk.py [options] file
360Prints the Content Hash Key of given file in GNUNET-style URI. 360Prints the Content Hash Key of given file in GNUNET-style URI.
361 361
362Options: 362Options:
363 -h, --help : prints this message 363 -h, --help : prints this message
364""") 364"""
365 )
365 366
366 367
367if '__main__' == __name__: 368if '__main__' == __name__:
@@ -373,7 +374,7 @@ if '__main__' == __name__:
373 usage() 374 usage()
374 sys.exit(2) 375 sys.exit(2)
375 for option, value in opts: 376 for option, value in opts:
376 if option in("-h", "--help"): 377 if option in ("-h", "--help"):
377 usage() 378 usage()
378 sys.exit(0) 379 sys.exit(0)
379 if len(args) != 1: 380 if len(args) != 1: