work on peer encryption
parent
6ca70afb78
commit
4948712904
|
@ -6,3 +6,4 @@ onionr/*.pyc
|
||||||
onionr/*.log
|
onionr/*.log
|
||||||
onionr/data/hs/hostname
|
onionr/data/hs/hostname
|
||||||
onionr/data/*
|
onionr/data/*
|
||||||
|
onionr/gnupg/*
|
||||||
|
|
|
@ -23,7 +23,7 @@ from multiprocessing import Process
|
||||||
import configparser, sys, random, threading, hmac, hashlib, base64, time, math, gnupg, os, logger
|
import configparser, sys, random, threading, hmac, hashlib, base64, time, math, gnupg, os, logger
|
||||||
|
|
||||||
from core import Core
|
from core import Core
|
||||||
import onionrutils
|
import onionrutils, onionrcrypto
|
||||||
class API:
|
class API:
|
||||||
'''
|
'''
|
||||||
Main HTTP API (Flask)
|
Main HTTP API (Flask)
|
||||||
|
@ -56,6 +56,7 @@ class API:
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self._privateDelayTime = 3
|
self._privateDelayTime = 3
|
||||||
self._core = Core()
|
self._core = Core()
|
||||||
|
self._crypto = onionrcrypto.OnionrCrypto(self._core)
|
||||||
self._utils = onionrutils.OnionrUtils(self._core)
|
self._utils = onionrutils.OnionrUtils(self._core)
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
bindPort = int(self.config['CLIENT']['PORT'])
|
bindPort = int(self.config['CLIENT']['PORT'])
|
||||||
|
@ -131,7 +132,9 @@ class API:
|
||||||
pass
|
pass
|
||||||
elif action == 'ping':
|
elif action == 'ping':
|
||||||
resp = Response("pong!")
|
resp = Response("pong!")
|
||||||
elif action == 'setHMAC':
|
elif action == 'getHMAC':
|
||||||
|
resp = Response(self._crypto.generateHMAC())
|
||||||
|
elif action == 'getSymmetric':
|
||||||
pass
|
pass
|
||||||
elif action == 'getDBHash':
|
elif action == 'getDBHash':
|
||||||
resp = Response(self._utils.getBlockDBHash())
|
resp = Response(self._utils.getBlockDBHash())
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import sqlite3, os, sys, time, math, gnupg, base64, tarfile, getpass, simplecrypt, hashlib, nacl, logger
|
import sqlite3, os, sys, time, math, gnupg, base64, tarfile, getpass, simplecrypt, hashlib, nacl, logger
|
||||||
from Crypto.Cipher import AES
|
#from Crypto.Cipher import AES
|
||||||
from Crypto import Random
|
#from Crypto import Random
|
||||||
import netcontroller
|
import netcontroller
|
||||||
|
|
||||||
import onionrutils
|
import onionrutils, onionrcrypto
|
||||||
|
|
||||||
if sys.version_info < (3, 6):
|
if sys.version_info < (3, 6):
|
||||||
try:
|
try:
|
||||||
|
@ -41,7 +41,9 @@ class Core:
|
||||||
self.ownPGPID = ''
|
self.ownPGPID = ''
|
||||||
self.blockDB = 'data/blocks.db'
|
self.blockDB = 'data/blocks.db'
|
||||||
self.blockDataLocation = 'data/blocks/'
|
self.blockDataLocation = 'data/blocks/'
|
||||||
|
self.gpgHome = './data/pgp/'
|
||||||
self._utils = onionrutils.OnionrUtils(self)
|
self._utils = onionrutils.OnionrUtils(self)
|
||||||
|
self._crypto = onionrcrypto.OnionrCrypto(self)
|
||||||
|
|
||||||
if not os.path.exists('data/'):
|
if not os.path.exists('data/'):
|
||||||
os.mkdir('data/')
|
os.mkdir('data/')
|
||||||
|
@ -59,7 +61,7 @@ class Core:
|
||||||
|
|
||||||
Uses own PGP home folder in the data/ directory
|
Uses own PGP home folder in the data/ directory
|
||||||
'''
|
'''
|
||||||
gpg = gnupg.GPG(homedir='./data/pgp/')
|
gpg = gnupg.GPG(homedir=self.gpgHome)
|
||||||
input_data = gpg.gen_key_input(key_type="RSA", key_length=1024, name_real=myID, name_email='anon@onionr', testing=True)
|
input_data = gpg.gen_key_input(key_type="RSA", key_length=1024, name_real=myID, name_email='anon@onionr', testing=True)
|
||||||
key = gpg.gen_key(input_data)
|
key = gpg.gen_key(input_data)
|
||||||
logger.info("Generating PGP key, this will take some time..")
|
logger.info("Generating PGP key, this will take some time..")
|
||||||
|
|
|
@ -17,10 +17,11 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import nacl
|
import nacl, gnupg
|
||||||
|
|
||||||
class OnionrCrypto:
|
class OnionrCrypto:
|
||||||
def __init__(self):
|
def __init__(self, coreInstance):
|
||||||
|
self._core = coreInstance
|
||||||
return
|
return
|
||||||
|
|
||||||
def symmetricPeerEncrypt(self, data, key):
|
def symmetricPeerEncrypt(self, data, key):
|
||||||
|
@ -31,3 +32,8 @@ class OnionrCrypto:
|
||||||
|
|
||||||
def rsaEncrypt(self, peer, data):
|
def rsaEncrypt(self, peer, data):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def verifyPGP(self, peer, signature):
|
||||||
|
'''Verify PGP signed data'''
|
||||||
|
gpg = gnupg.GPG(homedir=self._core.gpgHome)
|
||||||
|
|
|
@ -154,6 +154,17 @@ class OnionrUtils:
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
def getPeerPGPFingerprint(self, peer):
|
||||||
|
'''
|
||||||
|
Get peer's PGP fingerprint
|
||||||
|
'''
|
||||||
|
retData = ''
|
||||||
|
gpg = gnupg.GPG(homedir=self._core.gpgHome)
|
||||||
|
for i in gpg.list_keys():
|
||||||
|
if peer in i['uids'][0]:
|
||||||
|
retData = i['fingerprint']
|
||||||
|
return retData
|
||||||
|
|
||||||
def validateID(self, id):
|
def validateID(self, id):
|
||||||
'''
|
'''
|
||||||
Validate if a user ID is a valid tor or i2p hidden service
|
Validate if a user ID is a valid tor or i2p hidden service
|
||||||
|
|
|
@ -13,6 +13,8 @@ Major work in progress.
|
||||||
|
|
||||||
This software is in heavy development. If for some reason you want to get involved, get in touch first.
|
This software is in heavy development. If for some reason you want to get involved, get in touch first.
|
||||||
|
|
||||||
|
**Onionr API and functionality is subject to non-backwards compatible change during development**
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
The Tor Project, I2P developers, and anyone else do not own, create, or endorse this project, and are not otherwise involved.
|
The Tor Project, I2P developers, and anyone else do not own, create, or endorse this project, and are not otherwise involved.
|
||||||
|
|
Loading…
Reference in New Issue