work on peer encryption

master
Kevin Froman 2018-02-07 03:04:58 -06:00
parent 6ca70afb78
commit 4948712904
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
6 changed files with 33 additions and 8 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ onionr/*.pyc
onionr/*.log
onionr/data/hs/hostname
onionr/data/*
onionr/gnupg/*

View File

@ -23,7 +23,7 @@ from multiprocessing import Process
import configparser, sys, random, threading, hmac, hashlib, base64, time, math, gnupg, os, logger
from core import Core
import onionrutils
import onionrutils, onionrcrypto
class API:
'''
Main HTTP API (Flask)
@ -56,6 +56,7 @@ class API:
self.debug = debug
self._privateDelayTime = 3
self._core = Core()
self._crypto = onionrcrypto.OnionrCrypto(self._core)
self._utils = onionrutils.OnionrUtils(self._core)
app = flask.Flask(__name__)
bindPort = int(self.config['CLIENT']['PORT'])
@ -131,7 +132,9 @@ class API:
pass
elif action == 'ping':
resp = Response("pong!")
elif action == 'setHMAC':
elif action == 'getHMAC':
resp = Response(self._crypto.generateHMAC())
elif action == 'getSymmetric':
pass
elif action == 'getDBHash':
resp = Response(self._utils.getBlockDBHash())

View File

@ -18,11 +18,11 @@
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
from Crypto.Cipher import AES
from Crypto import Random
#from Crypto.Cipher import AES
#from Crypto import Random
import netcontroller
import onionrutils
import onionrutils, onionrcrypto
if sys.version_info < (3, 6):
try:
@ -41,7 +41,9 @@ class Core:
self.ownPGPID = ''
self.blockDB = 'data/blocks.db'
self.blockDataLocation = 'data/blocks/'
self.gpgHome = './data/pgp/'
self._utils = onionrutils.OnionrUtils(self)
self._crypto = onionrcrypto.OnionrCrypto(self)
if not os.path.exists('data/'):
os.mkdir('data/')
@ -59,7 +61,7 @@ class Core:
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)
key = gpg.gen_key(input_data)
logger.info("Generating PGP key, this will take some time..")

View File

@ -17,10 +17,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import nacl
import nacl, gnupg
class OnionrCrypto:
def __init__(self):
def __init__(self, coreInstance):
self._core = coreInstance
return
def symmetricPeerEncrypt(self, data, key):
@ -31,3 +32,8 @@ class OnionrCrypto:
def rsaEncrypt(self, peer, data):
return
def verifyPGP(self, peer, signature):
'''Verify PGP signed data'''
gpg = gnupg.GPG(homedir=self._core.gpgHome)

View File

@ -154,6 +154,17 @@ class OnionrUtils:
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):
'''
Validate if a user ID is a valid tor or i2p hidden service

View File

@ -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.
**Onionr API and functionality is subject to non-backwards compatible change during development**
## Disclaimer
The Tor Project, I2P developers, and anyone else do not own, create, or endorse this project, and are not otherwise involved.