test_default_crypto - symmetric crypto

pull/15/head
Michael Egorov 2017-08-19 12:05:18 -07:00
parent 60c939a021
commit 55dbfdd8e0
3 changed files with 17 additions and 3 deletions

View File

@ -10,7 +10,7 @@ default_algorithm = dict(
symmetric=dict(
cipher='nacl'),
pre=dict(
cipher='bbs98',
cipher='bbs98', # BBS98 is only temporary here, for development
curve=714, # secp256k1 in OpenSSL
g=b'1:' + _bitcoin_genesis,
m=None, n=None))

View File

@ -1,4 +1,4 @@
from distutils.core import setup
from distutils.core import setup, find_packages
INSTALL_REQUIRES = [
'kademlia>=1.0',
@ -27,4 +27,4 @@ setup(name='nkms',
install_requires=INSTALL_REQUIRES,
dependency_links=LINKS,
extras_require={'testing': TESTS_REQUIRE},
packages=['nkms'])
packages=find_packages())

View File

@ -0,0 +1,14 @@
from nkms.crypto import default_algorithm
from nkms.crypto import symmetric_from_algorithm
from nkms import crypto
def test_symmetric():
Cipher = symmetric_from_algorithm(default_algorithm)
key = crypto.random(Cipher.KEY_SIZE)
cipher = Cipher(key)
data = b'Hello world' * 10
edata = cipher.encrypt(data)
assert edata != data
assert cipher.decrypt(edata) == data