* work on new block system, encryption

+ added new exception
+ encryption now anonymous by default, will probably remove anonymous
param in future
This commit is contained in:
Kevin Froman 2018-06-20 02:40:49 -05:00
parent 10ebdddb24
commit 0a8052a9a4
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 17 additions and 1 deletions

View File

@ -700,8 +700,20 @@ class Core:
if len(symKey) < self.requirements.passwordLength: if len(symKey) < self.requirements.passwordLength:
raise onionrexceptions.SecurityError('Weak encryption key') raise onionrexceptions.SecurityError('Weak encryption key')
jsonMeta = self._crypto.symmetricEncrypt(jsonMeta, key=symKey, returnEncoded=True) jsonMeta = self._crypto.symmetricEncrypt(jsonMeta, key=symKey, returnEncoded=True)
data = self._crypto.symmetricEncrypt(data, key=symKey, returnEncoded=True)
signature = self._crypto.symmetricEncrypt(signature, key=symKey, returnEncoded=True)
signer = self._crypto.symmetricEncrypt(signer, key=symKey, returnEncoded=True)
elif encryptType == 'asym':
if self._utils.validatePubKey(asymPeer):
jsonMeta = self._crypto.pubKeyEncrypt(jsonMeta, asymPeer, encodedData=True)
data = self._crypto.pubKeyEncrypt(data, asymPeer, encodedData=True)
signature = self._crypto.pubKeyEncrypt(signature, asymPeer, encodedData=True)
else:
raise onionrexceptions.InvalidPubkey(asymPeer + ' is not a valid base32 encoded ed25519 key')
metadata['meta'] = jsonMeta metadata['meta'] = jsonMeta
metadata['sig'] = signature
metadata['signer'] = signer
powProof = onionrproofs.POW(data) powProof = onionrproofs.POW(data)
powToken = '' powToken = ''

View File

@ -110,7 +110,7 @@ class OnionrCrypto:
retData = key.sign(data).signature retData = key.sign(data).signature
return retData return retData
def pubKeyEncrypt(self, data, pubkey, anonymous=False, encodedData=False): def pubKeyEncrypt(self, data, pubkey, anonymous=True, encodedData=False):
'''Encrypt to a public key (Curve25519, taken from base32 Ed25519 pubkey)''' '''Encrypt to a public key (Curve25519, taken from base32 Ed25519 pubkey)'''
retVal = '' retVal = ''

View File

@ -26,6 +26,10 @@ class Unknown(Exception):
class Invalid(Exception): class Invalid(Exception):
pass pass
# crypto exceptions
class InvalidPubkey(Exception):
pass
# block exceptions # block exceptions
class InvalidMetadata(Exception): class InvalidMetadata(Exception):
pass pass