This commit is contained in:
Markus Ottela 2016-05-06 16:16:28 +03:00
parent 5005080cc9
commit 2e8240dcf1
12 changed files with 314 additions and 165 deletions

0
LICENSE.md Normal file → Executable file
View File

63
NH.py Normal file → Executable file
View File

@ -237,44 +237,53 @@ def print_banner():
print(((height / 2) - 1) * '\n')
# Style 1
animation = random.randint(1, 3)
# Style 1
if animation == 1:
i = 0
while i <= len(string):
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
try:
i = 0
while i <= len(string):
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
if i == len(string):
print(((width - len(string)) / 2) * ' ' + string[:i])
else:
rc = chr(random.randrange(32, 126))
print(((width - len(string)) / 2) * ' ' + string[:i] + rc)
if i == len(string):
print(((width - len(string)) / 2) * ' ' + string[:i])
else:
rc = chr(random.randrange(32, 126))
print(((width - len(string)) / 2) * ' ' + string[:i] + rc)
i += 1
time.sleep(0.03)
i += 1
time.sleep(0.03)
except KeyboardInterrupt:
os.system("clear")
return None
# Style 2
if animation == 2:
char_l = len(string) * ['']
try:
char_l = len(string) * ['']
while True:
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
st = ''
while True:
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
st = ''
for i in range(len(string)):
if char_l[i] != string[i]:
char_l[i] = chr(random.randrange(32, 126))
else:
char_l[i] = string[i]
st += char_l[i]
for i in range(len(string)):
if char_l[i] != string[i]:
char_l[i] = chr(random.randrange(32, 126))
else:
char_l[i] = string[i]
st += char_l[i]
print(((width - len(string)) / 2) * ' ' + st)
print(((width - len(string)) / 2) * ' ' + st)
time.sleep(0.004)
if st == string:
break
time.sleep(0.004)
if st == string:
break
except KeyboardInterrupt:
os.system("clear")
return None
# Style 3
if animation == 3:

106
Rx.py Normal file → Executable file
View File

@ -75,6 +75,8 @@ print_noise_pkg = False # True displays trickle connection noise packets
disp_opsec_warning = True # False disables warning when receiving files
show_file_prompts = True # Prompt keyfile location instead of def. folders
# File settings
file_saving = False # True permanently enables file reception for all
@ -350,21 +352,38 @@ def add_rx_keyfile():
:return: None
"""
try:
root_ = Tkinter.Tk()
root_.withdraw()
rx_kf = tkFileDialog.askopenfilename(title="Select keyfile from cont"
"act's transmission media")
root_.destroy()
if show_file_prompts:
try:
root_ = Tkinter.Tk()
root_.withdraw()
rx_kf = tkFileDialog.askopenfilename(title="Select keyfile from "
"contact's transmission"
" media")
root_.destroy()
if not rx_kf:
print("\nImport aborted.\n")
if not rx_kf:
print("\nImport aborted.\n")
return None
except _tkinter.TclError:
print("\nError: No file dialog available. Manually copy key "
"to directory 'keys/' and restart Rx.py.\n")
return None
except _tkinter.TclError:
print("\nError: No file dialog available. Manually copy key "
"to directory 'keys/' and restart Rx.py.\n")
return None
else:
print('')
rx_kf = ''
while True:
rx_kf = raw_input("Specify path of new keyfile: ")
if not rx_kf:
print("\nImport aborted.\n")
return None
if not os.path.isfile(rx_kf):
print("\nError: Keyfile does not exist\n")
continue
break
file_ = rx_kf.split('/')[-1]
@ -1356,44 +1375,53 @@ def print_banner():
print(((height / 2) - 1) * '\n')
# Style 1
animation = random.randint(1, 3)
# Style 1
if animation == 1:
i = 0
while i <= len(string):
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
try:
i = 0
while i <= len(string):
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
if i == len(string):
print(((width - len(string)) / 2) * ' ' + string[:i])
else:
rc = chr(random.randrange(32, 126))
print(((width - len(string)) / 2) * ' ' + string[:i] + rc)
if i == len(string):
print(((width - len(string)) / 2) * ' ' + string[:i])
else:
rc = chr(random.randrange(32, 126))
print(((width - len(string)) / 2) * ' ' + string[:i] + rc)
i += 1
time.sleep(0.03)
i += 1
time.sleep(0.03)
except KeyboardInterrupt:
os.system("clear")
return None
# Style 2
if animation == 2:
char_l = len(string) * ['']
try:
char_l = len(string) * ['']
while True:
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
st = ''
while True:
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
st = ''
for i in range(len(string)):
if char_l[i] != string[i]:
char_l[i] = chr(random.randrange(32, 126))
else:
char_l[i] = string[i]
st += char_l[i]
for i in range(len(string)):
if char_l[i] != string[i]:
char_l[i] = chr(random.randrange(32, 126))
else:
char_l[i] = string[i]
st += char_l[i]
print(((width - len(string)) / 2) * ' ' + st)
print(((width - len(string)) / 2) * ' ' + st)
time.sleep(0.004)
if st == string:
break
time.sleep(0.004)
if st == string:
break
except KeyboardInterrupt:
os.system("clear")
return None
# Style 3
if animation == 3:

155
Tx.py Normal file → Executable file
View File

@ -46,23 +46,22 @@ from serial.serialutil import SerialException
try:
import RPi.GPIO as GPIO
except ImportError:
except ImportError: # Import Non-RPi libraries
GPIO = None
import paramiko
import Crypto.Cipher.AES
orig_new = Crypto.Cipher.AES.new
# Import crypto libraries
import Crypto.Cipher.AES
import hashlib
import nacl.encoding
import nacl.public
import nacl.secret
import nacl.utils
import paramiko
from passlib.hash import pbkdf2_sha256
from passlib.utils import ab64_decode
import simplesha3
orig_new = Crypto.Cipher.AES.new
str_version = "0.16.05"
int_version = 1605
@ -474,7 +473,7 @@ def new_psk(parameters, first_account=False):
# Create copy of key for contact
dest = '' if show_file_prompts else " to 'keys_to_contact'"
phase("Copying key for contact%s..." % dest, 61)
error = False
if show_file_prompts:
try:
root = Tkinter.Tk()
@ -486,9 +485,10 @@ def new_psk(parameters, first_account=False):
if not store_d:
raise KeyboardInterrupt
except _tkinter.TclError:
print("\nError: No file dialog available. Storing key to "
"directory 'keys_to_contact/'\n")
print("Done.\n\nError: No file dialog available. Storing "
"key to directory 'keys_to_contact/'")
store_d = "keys_to_contact/"
error = True
else:
store_d = "keys_to_contact/"
@ -498,7 +498,8 @@ def new_psk(parameters, first_account=False):
wt = threading.Thread(target=key_writer, args=(f_name, psk))
wt.start()
wt.join()
print("Done.")
if not error:
print("Done.")
# Send PSK to RxM
if not unittesting:
@ -584,7 +585,7 @@ def generate_key(key_purpose):
pretty_name = subprocess.check_output(["grep", "PRETTY_NAME",
"/etc/os-release"])
try:
if pretty_name == "Raspbian GNU/Linux" and GPIO:
if "Raspbian GNU/Linux" in pretty_name and GPIO:
if not yes(question, (24 - len(key_purpose))):
key = sha3_256(os.urandom(32))
return key
@ -595,7 +596,7 @@ def generate_key(key_purpose):
GPIO.setmode(GPIO.BCM)
GPIO.setup(gpio_port, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
phase("\nWaiting for HWRNG signal from GPIO...", 61)
phase("Waiting for HWRNG signal from GPIO...", 61)
warmup_zero = 0
warmup_one = 0
@ -633,15 +634,16 @@ def generate_key(key_purpose):
GPIO.cleanup()
ent = digits_to_bytes(vn_digits)
ent = binascii.hexlify(ent)
if len(ent) != 32:
raise CriticalError("generate_key",
"Entropy collection failed.")
ent = binascii.hexlify(ent)
else:
if not use_ssh_hwrng or not yes(question, (24 - len(key_purpose))):
phase("Loading key data from /dev/urandom...", 61)
key = sha3_256(os.urandom(32))
print("Done.")
return key
# Load entropy over SSH using hwrng-nacl.py on Raspberry Pi.
@ -723,8 +725,8 @@ def new_local_key(bootstrap=False):
s_box = nacl.secret.SecretBox(binascii.unhexlify(key_e_key))
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
ct_tag = s_box.encrypt(padded, nonce)
raw_input("\n%sBypass NH if needed and press <Enter> to send key.%s"
% ((6 * ' '), (5 * ' ')))
raw_input("\n Bypass NH if needed and press <Enter> to send "
"key. ")
packet = "TFC|N|%s|L|%s" % (int_version, base64.b64encode(ct_tag))
transmit(packet)
@ -3211,44 +3213,53 @@ def print_banner():
print(((height / 2) - 1) * '\n')
# Style 1
animation = random.randint(1, 3)
# Style 1
if animation == 1:
i = 0
while i <= len(string):
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
try:
i = 0
while i <= len(string):
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
if i == len(string):
print(((width - len(string)) / 2) * ' ' + string[:i])
else:
rc = chr(random.randrange(32, 126))
print(((width - len(string)) / 2) * ' ' + string[:i] + rc)
if i == len(string):
print(((width - len(string)) / 2) * ' ' + string[:i])
else:
rc = chr(random.randrange(32, 126))
print(((width - len(string)) / 2) * ' ' + string[:i] + rc)
i += 1
time.sleep(0.03)
i += 1
time.sleep(0.03)
except KeyboardInterrupt:
os.system("clear")
return None
# Style 2
if animation == 2:
char_l = len(string) * ['']
try:
char_l = len(string) * ['']
while True:
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
st = ''
while True:
sys.stdout.write("\x1b[1A" + ' ')
sys.stdout.flush()
st = ''
for i in range(len(string)):
if char_l[i] != string[i]:
char_l[i] = chr(random.randrange(32, 126))
else:
char_l[i] = string[i]
st += char_l[i]
for i in range(len(string)):
if char_l[i] != string[i]:
char_l[i] = chr(random.randrange(32, 126))
else:
char_l[i] = string[i]
st += char_l[i]
print(((width - len(string)) / 2) * ' ' + st)
print(((width - len(string)) / 2) * ' ' + st)
time.sleep(0.004)
if st == string:
break
time.sleep(0.004)
if st == string:
break
except KeyboardInterrupt:
os.system("clear")
return None
# Style 3
if animation == 3:
@ -3527,14 +3538,12 @@ def search_serial_interfaces():
graceful_exit("Error: No USB-serial adapter was not found.")
else:
os_name = subprocess.check_output(["grep", "PRETTY_NAME",
"/etc/os-release"])
rpi_distros = ["Raspbian GNU/Linux"]
pretty_name = subprocess.check_output(["grep", "PRETTY_NAME",
"/etc/os-release"])
rpi_in_use = False
for distro in rpi_distros:
if distro in os_name:
rpi_in_use = True
if "Raspbian GNU/Linux" in pretty_name:
rpi_in_use = True
integrated_if = "ttyAMA0" if rpi_in_use else "ttyS0"
@ -3548,7 +3557,7 @@ def search_serial_interfaces():
else:
graceful_exit("Error: /dev/%s was not found." % integrated_if)
return serial_iface
return serial_iface
###############################################################################
@ -3613,35 +3622,35 @@ def trickle_delay(start):
f_duration = (final_time - start) / 1000.0
ct_filler = trickle_c_delay - f_duration
if ct_filler < 0:
raise CriticalError("trickle_delay",
"Function execute time exceeded trickle_c_delay.\n"
"Increase the value from settings and restart.\n")
if ct_filler < 0: # Soft warning only: RPi's initial lag won't raise error
print("\nWarning! Trickle delay exceeded. If this warning\n"
"repeats, increase trickle_c_delay from settings.\n")
time.sleep(ct_filler)
t_after_ct_sleep = get_ms() - start
else:
time.sleep(ct_filler)
t_after_ct_sleep = get_ms() - start
t_r_delay = random.SystemRandom().uniform(0, trickle_r_delay)
time.sleep(t_r_delay)
l_t_delay = 0
if lt_random_delay:
l_t_delay = random.SystemRandom().uniform(0, lt_max_delay)
time.sleep(l_t_delay)
if print_ct_stats:
print("Time after constant time delay %sms (setting=%sms)" %
(t_after_ct_sleep, trickle_c_delay * 1000))
print("(Packet process time: %sms, CT delay length: %sms)" %
(f_duration * 1000, ct_filler * 1000))
print("Trickle random delay: %sms\n" % (t_r_delay * 1000))
t_r_delay = random.SystemRandom().uniform(0, trickle_r_delay)
time.sleep(t_r_delay)
l_t_delay = 0
if lt_random_delay:
print("Random lt_delay: %sms" % l_t_delay * 1000)
l_t_delay = random.SystemRandom().uniform(0, lt_max_delay)
time.sleep(l_t_delay)
return None
if print_ct_stats:
print("Time after constant time delay %sms (setting=%sms)" %
(t_after_ct_sleep, trickle_c_delay * 1000))
print("(Packet process time: %sms, CT delay length: %sms)" %
(f_duration * 1000, ct_filler * 1000))
print("Trickle random delay: %sms\n" % (t_r_delay * 1000))
if lt_random_delay:
print("Random lt_delay: %sms" % l_t_delay * 1000)
return None
def sender_process():

0
dd.py Normal file → Executable file
View File

0
hwrng-nacl.py Normal file → Executable file
View File

0
readme.md Normal file → Executable file
View File

88
setup.py Normal file → Executable file
View File

@ -23,7 +23,7 @@ import subprocess
import time
repository = "https://cs.helsinki.fi/u/oottela/tfc-nacl/"
repository = "https://raw.githubusercontent.com/maqp/tfc-nacl/master/"
str_version = "0.16.05"
@ -116,13 +116,14 @@ be2623c41873e8e8a512a77f93edb301f64377331714b71116f7c30ea4fe6e2a pyc.zip
402c44cd30284a6acf80fdb4de56de44b879049f4d0342e28c84ef60223113bc paramiko.zip
249db300d1fe395ac1c31d08e91a3a31b473214b5da06002503e01229e44ae03 dd.py
45f2c3b9790a0b831609b0cd0b28517c7d0fc5412d8cae3af4f01a99bed554e3 hwrng-nacl.py
fbbd1dac1c4bd63b7f3ede0f65881a8e28cf5a4212dc45b65c7cda35195353cd NH.py
f55a2b8c84e81400a9c2ef1183deb791f6e8f48280853451fefd20e42e4d338b Rx.py
e777f8034a924e8df184e5cde54a5a48f0356aa506f255d4dcbdbd3c849c4d1a setup.py
d00ec5e0b776699e00682631a7f858dd852f809eec1fbd9ac5f19349fb03e9ce NH.py
d722061bb76a7a1a2e1b34c564046b70ac8125f1ba7ccabb740a3c6bb8af44b2 Rx.py
6c3586d1cbd8f0a388a40c326faf4da2799dc3a88e235addb0efc819156fa211 test_nh.py
1200902f4569373597dc66f555c0a8fce087fcfd1392f2ea5367a0ace1858cb1 test_rx.py
3faf6d2a9ad83e314809605bc1d41bce58565fbe6bc346e5de225832ab610ddc test_tx.py
6817de77dbf1c2c22dda6951c1c662899cca6e5ca34823bdf4e7a61fb46d5d38 Tx.py
35fc1c0c08d0c3048d9ce42df82dfbd64caece4334ecd7687943846a7c94a19a test_rx.py
18e56bb13946acd0b649b26448d603d1bc8ebe12755974393ff2fce96617eb39 test_tx.py
8d8d483c49a10e547b2b2d4e675d4803e1facf9d96b41d15133a10ebfed2d3a2 Tx.py
""")
@ -370,6 +371,9 @@ def get_tx():
"Downloading test_tx.py (TxM)")
check_file_hash("test_tx.py")
fix_ownership("Tx.py")
fix_ownership("test_tx.py")
def get_rx():
cmd("wget %sRx.py" % repository, "Downloading Rx.py (RxM)")
@ -379,6 +383,9 @@ def get_rx():
"Downloading test_rx.py (RxM)")
check_file_hash("test_rx.py")
fix_ownership("Rx.py")
fix_ownership("test_rx.py")
def get_nh():
cmd("wget %sNH.py" % repository, "Downloading NH.py (NH)")
@ -388,16 +395,23 @@ def get_nh():
"Downloading test_nh.py (NH)")
check_file_hash("test_nh.py")
fix_ownership("NH.py")
fix_ownership("test_nh.py")
def get_hwrng():
cmd("wget %shwrng-nacl.py" % repository, "Downloading hwrng-nacl.py")
check_file_hash("hwrng-nacl.py")
fix_ownership("hwrng-nacl.py")
def get_dd():
cmd("wget %sdd.py" % repository, "Downloading dd.py (NH)")
check_file_hash("dd.py")
fix_ownership("dd.py")
###############################################################################
# EDIT TFC PROGRAMS #
@ -666,7 +680,7 @@ Select a device-OS configuration (tested distros are listed):
Lubuntu 15.04
Linux Mint 17.3 Rosa
8. Tails 2.2.1
8. Tails 2.3
Local Testing (insecure)
9. Ubuntu 16.04 LTS
@ -720,6 +734,22 @@ def disable_network_interfaces():
cmd("sudo ifconfig %s down" % i, "Disabling %s network interface" % i)
def fix_ownership(path):
"""
Change the owner of the file to SUDO_UID.
:return: None
"""
uid = os.environ.get('SUDO_UID')
gid = os.environ.get('SUDO_GID')
if uid is not None:
os.chown(path, int(uid), int(gid))
return None
###############################################################################
# INSTALL ROUTINES #
###############################################################################
@ -732,6 +762,12 @@ def raspbian_txm():
"\nExiting.\n")
exit()
kill = False
if kill_ifaces:
if yes("Disable networking from this "
"device after downloads complete?"):
kill = True
update_repositories()
install_python_setuptools()
@ -749,9 +785,11 @@ def raspbian_txm():
cmd("mkdir tfc-nacl")
root_dir = os.getcwd()
os.chdir("tfc-nacl/")
fix_ownership('.')
get_tx()
disable_network_interfaces()
if kill:
disable_network_interfaces()
os.chdir(root_dir)
passlib_install()
@ -779,6 +817,12 @@ def ubuntu_txm():
"\nExiting.\n")
exit()
kill = False
if kill_ifaces:
if yes("Disable networking from this "
"device after downloads complete?"):
kill = True
update_repositories()
install_python_setuptools()
@ -799,10 +843,11 @@ def ubuntu_txm():
cmd("mkdir tfc-nacl")
root_dir = os.getcwd()
os.chdir("tfc-nacl/")
fix_ownership('.')
get_tx()
disable_network_interfaces()
if kill:
disable_network_interfaces()
os.chdir(root_dir)
passlib_install()
@ -854,6 +899,12 @@ def raspbian_rxm():
"\nExiting.\n")
exit()
kill = False
if kill_ifaces:
if yes("Disable networking from this "
"device after downloads complete?"):
kill = True
update_repositories()
install_python_setuptools()
@ -871,9 +922,11 @@ def raspbian_rxm():
cmd("mkdir tfc-nacl")
root_dir = os.getcwd()
os.chdir("tfc-nacl/")
fix_ownership('.')
get_rx()
disable_network_interfaces()
if kill:
disable_network_interfaces()
os.chdir(root_dir)
passlib_install()
@ -903,6 +956,12 @@ def ubuntu_rxm():
"\nExiting.\n")
exit()
kill = False
if kill_ifaces:
if yes("Disable networking from this "
"device after downloads complete?"):
kill = True
update_repositories()
install_python_setuptools()
@ -920,9 +979,11 @@ def ubuntu_rxm():
cmd("mkdir tfc-nacl")
root_dir = os.getcwd()
os.chdir("tfc-nacl/")
fix_ownership('.')
get_rx()
disable_network_interfaces()
if kill:
disable_network_interfaces()
os.chdir(root_dir)
passlib_install()
@ -1059,6 +1120,7 @@ def local_testing():
subprocess.Popen("mkdir tfc-nacl", shell=True).wait()
os.chdir("tfc-nacl/")
fix_ownership('.')
get_tx()
get_rx()

0
unittests/test_nh.py Normal file → Executable file
View File

20
unittests/test_rx.py Normal file → Executable file
View File

@ -409,14 +409,15 @@ class TestAddRxKeyfile(unittest.TestCase):
def test_1_no_path(self):
# Setup
original_aofn = tkFileDialog.askopenfilename
tkFileDialog.askopenfilename = lambda title: ''
Rx.show_file_prompts = False
orig_rawinput = __builtins__.raw_input
__builtins__.raw_input = lambda x: ''
# Test
self.assertIsNone(add_rx_keyfile())
# Teardown
tkFileDialog.askopenfilename = original_aofn
__builtins__.raw_input = orig_rawinput
def test_2_valid_path(self):
@ -429,6 +430,10 @@ class TestAddRxKeyfile(unittest.TestCase):
fname = "rx.bob@jabber.org.e - Give this file to alice@jabber.org"
open("test_dir/%s" % fname, 'w+').write('\n'.join(test_set))
orig_rawinput = __builtins__.raw_input
__builtins__.raw_input = lambda x: 'test_dir/%s' % fname
Rx.show_file_prompts = False
Rx.file_saving = False
Rx.log_messages = True
@ -444,9 +449,6 @@ class TestAddRxKeyfile(unittest.TestCase):
Rx.acco_store_l["rx.bob@jabber.org"] = False
Rx.acco_store_l["me.bob@jabber.org"] = False
original_aofn = tkFileDialog.askopenfilename
tkFileDialog.askopenfilename = lambda title: 'test_dir/%s' % fname
# Test
self.assertIsNone(add_rx_keyfile())
self.assertFalse(os.path.isfile("test_dir/%s" % fname))
@ -468,7 +470,7 @@ class TestAddRxKeyfile(unittest.TestCase):
self.assertTrue(Rx.acco_store_l["rx.bob@jabber.org"])
# Teardown
tkFileDialog.askopenfilename = original_aofn
__builtins__.raw_input = orig_rawinput
shutil.rmtree("test_dir")
shutil.rmtree("keys")
@ -2140,7 +2142,7 @@ class TestMessagePacket(unittest.TestCase):
"k8daJs1+gBDcGOZIdIRrwnmTyk5v3QxeKcOjyDcOBTn5MFSGt2Q/WcRPcw"
"ph0cbJzaAVyQj1expHHnlksxJ7ac1MSEIvx5ykR/6TMMPzGqMtrNH0DpAQ"
"E00JmCyYoaZ1+LF8SmEQTI2i0NaTdKPpXa/wVDhvCbhQVIK9Fh0W7Tbo7|"
"400|me.alice@jabber.org")
"100|me.alice@jabber.org")
self.assertIsNone(message_packet(packet))
@ -2338,7 +2340,7 @@ class TestCommandPacket(unittest.TestCase):
"k8daJs1+gBDcGOZIdIRrwnmTyk5v3QxeKcOjyDcOBTn5MFSGt2Q/WcRPcw"
"ph0cbJzaAVyQj1expHHnlksxJ7ac1MSEIvx5ykR/6TMMPzGqMtrNH0DpAQ"
"E00JmCyYoaZ1+LF8SmEQTI2i0NaTdKPpXa/wVDhvCbhQVIK9Fh0W7Tbo7|"
"400")
"100")
self.assertIsNone(command_packet(packet))

33
unittests/test_tx.py Normal file → Executable file
View File

@ -498,11 +498,17 @@ class TestNewPSK(unittest.TestCase):
Tx.unittesting = True
Tx.txm_side_logging = True
Tx.use_ssh_hwrng = False
Tx.acco_store_l["bob@jabber.org"] = False
Tx.recipient_acco = "bob@jabber.org"
Tx.recipient_nick = "Robert"
origin_raw_input = __builtins__.raw_input
__builtins__.raw_input = lambda x: "alice@jabber.org"
original_genkey = Tx.generate_key
Tx.generate_key = lambda x: 64 * 'a'
create_contact_db(["local", "bob"])
create_test_keys(["local", "bob"])
@ -548,6 +554,7 @@ class TestNewPSK(unittest.TestCase):
os.remove(".tx_contacts")
os.remove("unitt_txm_out")
__builtins__.raw_input = origin_raw_input
Tx.generate_key = original_genkey
Tx.acco_store_l["bob@jabber.org"] = False
Tx.local_testing = False
Tx.show_file_prompts = True
@ -562,11 +569,17 @@ class TestNewPSK(unittest.TestCase):
Tx.unittesting = True
Tx.use_ssh_hwrng = False
Tx.txm_side_logging = False
Tx.acco_store_l["bob@jabber.org"] = True
Tx.recipient_acco = "bob@jabber.org"
Tx.recipient_nick = "Robert"
origin_raw_input = __builtins__.raw_input
__builtins__.raw_input = lambda x: "alice@jabber.org"
original_genkey = Tx.generate_key
Tx.generate_key = lambda x: 64 * 'a'
create_contact_db(["local"])
create_test_keys(["local"])
@ -612,6 +625,7 @@ class TestNewPSK(unittest.TestCase):
os.remove(".tx_contacts")
os.remove("unitt_txm_out")
__builtins__.raw_input = origin_raw_input
Tx.generate_key = original_genkey
Tx.acco_store_l["bob@jabber.org"] = False
Tx.local_testing = False
Tx.show_file_prompts = True
@ -647,10 +661,15 @@ class TestGenerateKey(unittest.TestCase):
# Setup
Tx.use_ssh_hwrng = False
original_yes = Tx.yes
Tx.yes = lambda x, y: False
# Test
self.assertTrue(ut_validate_key(generate_key("test")))
# Teardown
Tx.yes = original_yes
class TestNewLocalKey(unittest.TestCase):
@ -672,6 +691,9 @@ class TestNewLocalKey(unittest.TestCase):
origin_raw_input = __builtins__.raw_input
__builtins__.raw_input = lambda x: ''
original_genkey = Tx.generate_key
Tx.generate_key = lambda x: 64 * 'a'
# Test command returns None
self.assertIsNone(new_local_key())
@ -699,6 +721,7 @@ class TestNewLocalKey(unittest.TestCase):
os.remove("unitt_txm_out")
Tx.local_testing = False
Tx.unittesting = False
Tx.generate_key = original_genkey
__builtins__.raw_input = origin_raw_input
@ -919,6 +942,10 @@ class TestStartKeyExchange(unittest.TestCase):
"7ecd61cdb590266b59fa7610b901e6c132e3"
original_yes = Tx.yes
Tx.yes = lambda x, y: True
original_genkey = Tx.generate_key
Tx.generate_key = lambda x: 64 * 'a'
Tx.recipient_acco = "bob@jabber.org"
Tx.unittesting = True
create_test_keys(["bob", "local"])
@ -949,6 +976,7 @@ class TestStartKeyExchange(unittest.TestCase):
# Teardown
__builtins__.raw_input = origin_raw_input
Tx.generate_key = original_genkey
Tx.yes = original_yes
os.remove("unitt_txm_out")
os.remove(".tx_contacts")
@ -2967,9 +2995,10 @@ class TestHeads(unittest.TestCase):
class TestGetMS(unittest.TestCase):
def test_1_output(self):
def test_1_output_type(self):
self.assertTrue(isinstance(get_ms(), (int, long)))
self.assertTrue(isinstance(get_ms(), int))
def test_2_output_len(self):
self.assertEqual(len(str(get_ms())), 13)

14
updatelog Normal file → Executable file
View File

@ -7,11 +7,14 @@ Removed from x import y to avoid conflicts in namespace etc.
Refactored code here and there.
Added unittests. test_tx.py and test_rx.py now evaluate XSalsa20-Poly1305
implementation in PyNaCl using official test vectors by djb.
Added more unittests. test_tx.py and test_rx.py now evaluate XSalsa20-Poly1305
implementation in PyNaCl using official test vectors by djb. Unittests can now
be run from RPi over SSH.
Improved LUI here and there.
Banner can now be skipped with keyboard interrupt
-------------------------------------------------------------------------------
Tx.py
-------------------------------------------------------------------------------
@ -31,6 +34,11 @@ Reversed PSK and ECDHE key choice answer to more intuitive order.
Fixed issues when sending dotfiles.
Changed trickle delay's time's constant delay time exceeding from critical
error to soft warning. Raspberry Pi tends to send first packet with greater
delay. User will now be prompted to increase trickle_c_delay if the problem
persists.
-------------------------------------------------------------------------------
Rx.py
-------------------------------------------------------------------------------
@ -56,6 +64,8 @@ apt-packets. It then downloads and verifies crypto libraries and TFC.
Finally, the installer runs 'sudo ifconfig down' on every interface excluding
'lo', listed by 'ifconfig -a', before extracting and building libraries.
Fixed issues with file permissions when running installer as superuser.
-------------------------------------------------------------------------------
hwrng-nacl.py
-------------------------------------------------------------------------------