0.16.10
This commit is contained in:
parent
2f3b942864
commit
194251010c
|
@ -0,0 +1,21 @@
|
|||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
47322690ab1817b2770db17c8f830a5d4c5bfb86f712730176320435ddd46c41 setup.py
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAEBAgAGBQJX4vxlAAoJEGXa0OZTMFFOMckP/2KdIN46LCrkKr8fQFZt8bSx
|
||||
e6eUwSDKXTLcnKizAqzz3KNefYSPWVlzK3Ii4jXpAmlunKVF7vmGOPqi6wkvRWQE
|
||||
u+Sgt/7uYfRDOfZhTtFFMpzVzLz7Bn4VlyX4X+jCPKKNkXIquFz3SqrjvWL87Pqp
|
||||
NQ9/yGiu/vVHvXlcfcwgSbMyffinL0VAfopLOT//XXxLPGm7uPRF9/kW+mYq1D3X
|
||||
0FyxyS44YGo6IZ2dvCQ8HkcMtxCbppq6C7jeAETZKUrmJZxQHfRRhrLRe1W4ldQr
|
||||
+t12XRJiNVUC74APgcDHvyXONqBgjNHMB+0jZjOI4usXue8L1oKk/3cQ/cZc4o7B
|
||||
1b+hz+TL2m1V+vTIOtBenu6rNmnk593OGv9zxP1LPV7rEXKGedAWY+++9B8yPZ4p
|
||||
N/kTEZWuW56SKe24x6am/x98EcJu3dje7gdqOH2oThahTQJNo1VhO5oz0Kt4VATB
|
||||
soO64f61jxqsWhbdj8uqD9fUx2hz0p7uE1BXZHWm8MS+6qWWFPtM+gso3cxtQ4E8
|
||||
44pp8K4cls7tSl56i+ZSZc2KN71nYBy7RXgZMMobcc1Wg7QiWYVXMptM7F9czkKj
|
||||
KmT5N9bn6gcAXAkGJYtqqydzrdTbaaLIeo1XVjKFbrw/dZ2jk8Dm4N7TxaK8IuHG
|
||||
lRbVMpdOVfjymyMyAzad
|
||||
=EMRx
|
||||
-----END PGP SIGNATURE-----
|
|
@ -0,0 +1,101 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# TFC 0.16.10 || hwrng.py
|
||||
|
||||
"""
|
||||
Copyright (C) 2013-2016 Markus Ottela
|
||||
|
||||
This file is part of TFC.
|
||||
|
||||
TFC is free software: you can redistribute it and/or modify it under the terms
|
||||
of the GNU General Public License as published by the Free Software Foundation,
|
||||
either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
TFC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TFC. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import binascii
|
||||
import time
|
||||
import sys
|
||||
|
||||
try:
|
||||
import RPi.GPIO as GPIO
|
||||
except ImportError:
|
||||
GPIO = None
|
||||
pass
|
||||
|
||||
|
||||
###############################################################################
|
||||
# CONFIGURATION #
|
||||
###############################################################################
|
||||
|
||||
sample_delay = 0.1 # Delay in seconds between samples
|
||||
|
||||
gpio_port = 4 # RPi's GPIO pin (Broadcom layout) to collect entropy from
|
||||
|
||||
|
||||
###############################################################################
|
||||
# MAIN #
|
||||
###############################################################################
|
||||
|
||||
def main():
|
||||
"""
|
||||
Load 256 or 512 bits of entropy from HWRNG.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(gpio_port, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
|
||||
ent_size = int(sys.argv[1])
|
||||
|
||||
if ent_size not in [256, 512, 768]:
|
||||
print('S')
|
||||
exit()
|
||||
|
||||
init0 = 0
|
||||
init1 = 0
|
||||
vnd = ''
|
||||
|
||||
while init0 < 1500 or init1 < 1500:
|
||||
time.sleep(0.001)
|
||||
|
||||
if GPIO.input(gpio_port) == 1:
|
||||
init1 += 1
|
||||
else:
|
||||
init0 += 1
|
||||
|
||||
while len(vnd) != ent_size:
|
||||
|
||||
# Perform Von Neumann whitening during sampling
|
||||
first_bit = GPIO.input(gpio_port)
|
||||
time.sleep(sample_delay)
|
||||
|
||||
second_bit = GPIO.input(gpio_port)
|
||||
time.sleep(sample_delay)
|
||||
|
||||
if first_bit == second_bit:
|
||||
continue
|
||||
else:
|
||||
vnd += str(first_bit)
|
||||
sys.stdout.flush()
|
||||
sys.stdout.write("N\n")
|
||||
|
||||
# Convert bits to byte string
|
||||
ent = ''.join(chr(int(vnd[i:i + 8], 2)) for i in range(0, len(vnd), 8))
|
||||
|
||||
if len(ent) != ent_size / 8:
|
||||
print('L')
|
||||
|
||||
GPIO.cleanup()
|
||||
print(binascii.hexlify(ent))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue