removed PGP
This commit is contained in:
parent
b15c0b7e00
commit
895b1919fd
8 changed files with 36 additions and 155 deletions
|
@ -20,7 +20,7 @@
|
|||
import flask
|
||||
from flask import request, Response, abort
|
||||
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, os, logger
|
||||
|
||||
from core import Core
|
||||
import onionrutils, onionrcrypto
|
||||
|
@ -140,8 +140,6 @@ class API:
|
|||
resp = Response(self._utils.getBlockDBHash())
|
||||
elif action == 'getBlockHashes':
|
||||
resp = Response(self._core.getBlockList())
|
||||
elif action == 'getPGP':
|
||||
resp = Response(self._utils.exportMyPubkey())
|
||||
# setData should be something the communicator initiates, not this api
|
||||
elif action == 'getData':
|
||||
resp = self._core.getData(data)
|
||||
|
|
|
@ -40,13 +40,6 @@ class OnionrCommunicate:
|
|||
|
||||
self.peerData = {} # Session data for peers (recent reachability, speed, etc)
|
||||
|
||||
# get our own PGP fingerprint
|
||||
fingerprintFile = 'data/own-fingerprint.txt'
|
||||
if not os.path.exists(fingerprintFile):
|
||||
self._core.generateMainPGP(torID)
|
||||
with open(fingerprintFile,'r') as f:
|
||||
self.pgpOwnFingerprint = f.read()
|
||||
logger.info('My PGP fingerprint is ' + logger.colors.underline + self.pgpOwnFingerprint + logger.colors.reset + logger.colors.fg.green + '.')
|
||||
if os.path.exists(self._core.queueDB):
|
||||
self._core.clearDaemonQueue()
|
||||
while True:
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
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 sqlite3, os, sys, time, math, gnupg, base64, tarfile, getpass, simplecrypt, hashlib, nacl, logger
|
||||
import sqlite3, os, sys, time, math, base64, tarfile, getpass, simplecrypt, hashlib, nacl, logger
|
||||
#from Crypto.Cipher import AES
|
||||
#from Crypto import Random
|
||||
import netcontroller
|
||||
|
@ -38,10 +38,8 @@ class Core:
|
|||
'''
|
||||
self.queueDB = 'data/queue.db'
|
||||
self.peerDB = 'data/peers.db'
|
||||
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)
|
||||
|
||||
|
@ -55,28 +53,6 @@ class Core:
|
|||
|
||||
return
|
||||
|
||||
def generateMainPGP(self, myID):
|
||||
'''
|
||||
Generate the main PGP key for our client. Should not be done often.
|
||||
|
||||
Uses own PGP home folder in the data/ directory
|
||||
'''
|
||||
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..")
|
||||
while key.status != "key created":
|
||||
time.sleep(0.5)
|
||||
print(key.status)
|
||||
|
||||
logger.info("Finished generating PGP key")
|
||||
# Write the key
|
||||
myFingerpintFile = open('data/own-fingerprint.txt', 'w')
|
||||
myFingerpintFile.write(key.fingerprint)
|
||||
myFingerpintFile.close()
|
||||
|
||||
return
|
||||
|
||||
def addPeer(self, peerID, name=''):
|
||||
'''
|
||||
Add a peer by their ID, with an optional name, to the peer database
|
||||
|
@ -104,8 +80,7 @@ class Core:
|
|||
c.execute('''CREATE TABLE peers(
|
||||
ID text not null,
|
||||
name text,
|
||||
pgpKey text,
|
||||
hmacKey text,
|
||||
pubkey text,
|
||||
blockDBHash text,
|
||||
forwardKey text,
|
||||
dateSeen not null,
|
||||
|
@ -335,7 +310,6 @@ class Core:
|
|||
|
||||
id text 0
|
||||
name text, 1
|
||||
pgpKey text, 2
|
||||
hmacKey text, 3
|
||||
blockDBHash text, 4
|
||||
forwardKey text, 5
|
||||
|
@ -346,7 +320,7 @@ class Core:
|
|||
conn = sqlite3.connect(self.peerDB)
|
||||
c = conn.cursor()
|
||||
command = (peer,)
|
||||
infoNumbers = {'id': 0, 'name': 1, 'pgpKey': 2, 'hmacKey': 3, 'blockDBHash': 4, 'forwardKey': 5, 'dateSeen': 6, 'bytesStored': 7, 'trust': 8}
|
||||
infoNumbers = {'id': 0, 'name': 1, 'hmacKey': 3, 'blockDBHash': 4, 'forwardKey': 5, 'dateSeen': 6, 'bytesStored': 7, 'trust': 8}
|
||||
info = infoNumbers[info]
|
||||
iterCount = 0
|
||||
retVal = ''
|
||||
|
@ -369,7 +343,7 @@ class Core:
|
|||
c = conn.cursor()
|
||||
command = (data, peer)
|
||||
# TODO: validate key on whitelist
|
||||
if key not in ('id', 'text', 'name', 'pgpKey', 'hmacKey', 'blockDBHash', 'forwardKey', 'dateSeen', 'bytesStored', 'trust'):
|
||||
if key not in ('id', 'name', 'pubkey', 'blockDBHash', 'forwardKey', 'dateSeen', 'bytesStored', 'trust'):
|
||||
raise Exception("Got invalid database key when setting peer info")
|
||||
c.execute('UPDATE peers SET ' + key + ' = ? WHERE id=?', command)
|
||||
conn.commit()
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
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, gnupg
|
||||
import nacl
|
||||
|
||||
class OnionrCrypto:
|
||||
def __init__(self, coreInstance):
|
||||
|
@ -29,15 +29,9 @@ class OnionrCrypto:
|
|||
|
||||
def symmetricPeerDecrypt(self, data, key):
|
||||
return
|
||||
|
||||
def rsaEncrypt(self, peer, data):
|
||||
return
|
||||
|
||||
def verifyPGP(self, peer, signature):
|
||||
'''Verify PGP signed data'''
|
||||
gpg = gnupg.GPG(homedir=self._core.gpgHome)
|
||||
|
||||
def generateSymmetric():
|
||||
return
|
||||
|
||||
def generateHMAC():
|
||||
return
|
|
@ -18,7 +18,7 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
# Misc functions that do not fit in the main api, but are useful
|
||||
import getpass, sys, requests, configparser, os, socket, gnupg, hashlib, logger, sqlite3
|
||||
import getpass, sys, requests, configparser, os, socket, hashlib, logger, sqlite3
|
||||
if sys.version_info < (3, 6):
|
||||
try:
|
||||
import sha3
|
||||
|
@ -93,19 +93,6 @@ class OnionrUtils:
|
|||
else:
|
||||
return True
|
||||
|
||||
def exportMyPubkey(self):
|
||||
'''
|
||||
Export our PGP key if it exists
|
||||
'''
|
||||
if not os.path.exists(self.fingerprintFile):
|
||||
raise Exception("No fingerprint found, cannot export our PGP key.")
|
||||
gpg = gnupg.GPG(homedir='./data/pgp/')
|
||||
with open(self.fingerprintFile,'r') as f:
|
||||
fingerprint = f.read()
|
||||
ascii_armored_public_keys = gpg.export_keys(fingerprint)
|
||||
|
||||
return ascii_armored_public_keys
|
||||
|
||||
def getBlockDBHash(self):
|
||||
'''
|
||||
Return a sha3_256 hash of the blocks DB
|
||||
|
@ -153,17 +140,6 @@ class OnionrUtils:
|
|||
retVal = False
|
||||
|
||||
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):
|
||||
'''
|
||||
|
|
|
@ -85,33 +85,6 @@ class OnionrTests(unittest.TestCase):
|
|||
else:
|
||||
self.assertTrue(False)
|
||||
|
||||
def testPGPGen(self):
|
||||
logger.debug('--------------------------')
|
||||
logger.info('Running PGP key generation test...')
|
||||
if os.path.exists('data/pgp/'):
|
||||
self.assertTrue(True)
|
||||
else:
|
||||
import core, netcontroller
|
||||
myCore = core.Core()
|
||||
net = netcontroller.NetController(1337)
|
||||
net.startTor()
|
||||
torID = open('data/hs/hostname').read()
|
||||
myCore.generateMainPGP(torID)
|
||||
if os.path.exists('data/pgp/'):
|
||||
self.assertTrue(True)
|
||||
|
||||
def testHMACGen(self):
|
||||
logger.debug('--------------------------')
|
||||
logger.info('Running HMAC generation test...')
|
||||
# Test if hmac key generation is working
|
||||
import core
|
||||
myCore = core.Core()
|
||||
key = myCore.generateHMAC()
|
||||
if len(key) > 10:
|
||||
self.assertTrue(True)
|
||||
else:
|
||||
self.assertTrue(False)
|
||||
|
||||
def testQueue(self):
|
||||
logger.debug('--------------------------')
|
||||
logger.info('Running daemon queue test...')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue