diff options
Diffstat (limited to 'contrib/scripts/gnunet-chk.py.in')
-rwxr-xr-x | contrib/scripts/gnunet-chk.py.in | 23 |
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 | |||
29 | from Crypto.Cipher import AES | 29 | from Crypto.Cipher import AES |
30 | from functools import reduce | 30 | from functools import reduce |
31 | 31 | ||
32 | |||
33 | # Defaults | 32 | # Defaults |
34 | DBLOCK_SIZE = (32 * 1024) # Data block size | 33 | DBLOCK_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! |
40 | CHK_PER_INODE = 256 | 39 | CHK_PER_INODE = 256 |
41 | 40 | ||
42 | CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes | 41 | CHK_HASH_SIZE = 64 # SHA-512 hash = 512 bits = 64 bytes |
43 | 42 | ||
44 | CHK_QUERY_SIZE = CHK_HASH_SIZE # Again a SHA-512 hash | 43 | CHK_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 | ||
356 | def usage(): | 355 | def usage(): |
357 | """Prints help about using this script.""" | 356 | """Prints help about using this script.""" |
358 | print(""" | 357 | print( |
358 | """ | ||
359 | Usage: gnunet-chk.py [options] file | 359 | Usage: gnunet-chk.py [options] file |
360 | Prints the Content Hash Key of given file in GNUNET-style URI. | 360 | Prints the Content Hash Key of given file in GNUNET-style URI. |
361 | 361 | ||
362 | Options: | 362 | Options: |
363 | -h, --help : prints this message | 363 | -h, --help : prints this message |
364 | """) | 364 | """ |
365 | ) | ||
365 | 366 | ||
366 | 367 | ||
367 | if '__main__' == __name__: | 368 | if '__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: |