Replace CryptRsa with CryptTor
This commit is contained in:
parent
39864330d5
commit
a0ae8897d7
2 changed files with 11 additions and 9 deletions
|
@ -4,7 +4,7 @@ import pytest
|
|||
import mock
|
||||
|
||||
from File import FileServer
|
||||
from Crypt import CryptRsa
|
||||
from Crypt import CryptTor
|
||||
from Config import config
|
||||
|
||||
@pytest.mark.usefixtures("resetSettings")
|
||||
|
@ -34,17 +34,17 @@ class TestTor:
|
|||
address = tor_manager.addOnion()
|
||||
|
||||
# Sign
|
||||
sign = CryptRsa.sign(b"hello", tor_manager.getPrivatekey(address))
|
||||
sign = CryptTor.sign(b"hello", tor_manager.getPrivatekey(address))
|
||||
assert len(sign) == 128
|
||||
|
||||
# Verify
|
||||
publickey = CryptRsa.privatekeyToPublickey(tor_manager.getPrivatekey(address))
|
||||
publickey = CryptTor.privatekeyToPublickey(tor_manager.getPrivatekey(address))
|
||||
assert len(publickey) == 140
|
||||
assert CryptRsa.verify(b"hello", publickey, sign)
|
||||
assert not CryptRsa.verify(b"not hello", publickey, sign)
|
||||
assert CryptTor.verify(b"hello", publickey, sign)
|
||||
assert not CryptTor.verify(b"not hello", publickey, sign)
|
||||
|
||||
# Pub to address
|
||||
assert CryptRsa.publickeyToOnion(publickey) == address
|
||||
assert CryptTor.publickeyToOnion(publickey) == address
|
||||
|
||||
# Delete
|
||||
tor_manager.delOnion(address)
|
||||
|
|
|
@ -12,8 +12,10 @@ import atexit
|
|||
import gevent
|
||||
|
||||
from Config import config
|
||||
from Crypt import CryptEd25519
|
||||
from Crypt import CryptRsa
|
||||
|
||||
from lib import Ed25519
|
||||
from Crypt import CryptTor
|
||||
|
||||
from Site import SiteManager
|
||||
import socks
|
||||
from gevent.lock import RLock
|
||||
|
@ -272,7 +274,7 @@ class TorManager(object):
|
|||
return self.privatekeys[address]
|
||||
|
||||
def getPublickey(self, address):
|
||||
return CryptRsa.privatekeyToPublickey(self.privatekeys[address])
|
||||
return CryptTor.privatekeyToPublickey(self.privatekeys[address])
|
||||
|
||||
def getOnion(self, site_address):
|
||||
if not self.enabled:
|
||||
|
|
Loading…
Reference in a new issue