Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 611594 - dev-python/flask-restful: support dev-python/pycryptodome
Summary: dev-python/flask-restful: support dev-python/pycryptodome
Status: IN_PROGRESS
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: pycryptodome-tracker
  Show dependency tree
 
Reported: 2017-03-03 23:15 UTC by Michał Górny
Modified: 2018-11-18 23:45 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-03-03 23:15:44 UTC
See tracker.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-03-27 15:26:36 UTC
Looks like it has some str/bytes problems with Python 3.


======================================================================
ERROR: test_encrypt_decrypt (tests.test_crypto.CryptoTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/tests/test_crypto.py", line 10, in test_encrypt_decrypt
    self.assertEqual(decrypt(encrypt(message, key, seed), key, seed), message)
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/flask_restful/utils/crypto.py", line 31, in encrypt
    return b64encode(create_cipher(key, seed).encrypt(pad(plaintext_data)))
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/flask_restful/utils/crypto.py", line 26, in create_cipher
    return AES.new(key, AES.MODE_CBC, seed)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/AES.py", line 264, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/__init__.py", line 130, in _create_cipher
    return modes[mode](factory, **kwargs)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/_mode_cbc.py", line 232, in _create_cbc_cipher
    cipher_state = factory._create_base_cipher(kwargs)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/AES.py", line 131, in _create_base_cipher
    expect_byte_string(key)
  File "/usr/lib64/python3.4/site-packages/Crypto/Util/_raw_api.py", line 175, in expect_byte_string
    raise TypeError("Only byte strings can be passed to C code")
TypeError: Only byte strings can be passed to C code

======================================================================
ERROR: test_bookmark_paging (tests.test_paging.PagingTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/tests/test_paging.py", line 19, in test_bookmark_paging
    result, filter, approx_result_size = retrieve_next_page(key, seed, filter, fetch_data)
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/flask_restful/paging.py", line 26, in retrieve_next_page
    filter['pager_info'] = encrypt(new_bookmark, key, seed)
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/flask_restful/utils/crypto.py", line 31, in encrypt
    return b64encode(create_cipher(key, seed).encrypt(pad(plaintext_data)))
  File "/tmp/portage/dev-python/flask-restful-0.3.5-r1/work/flask-restful-0.3.5/flask_restful/utils/crypto.py", line 26, in create_cipher
    return AES.new(key, AES.MODE_CBC, seed)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/AES.py", line 264, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/__init__.py", line 130, in _create_cipher
    return modes[mode](factory, **kwargs)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/_mode_cbc.py", line 232, in _create_cbc_cipher
    cipher_state = factory._create_base_cipher(kwargs)
  File "/usr/lib64/python3.4/site-packages/Crypto/Cipher/AES.py", line 131, in _create_base_cipher
    expect_byte_string(key)
  File "/usr/lib64/python3.4/site-packages/Crypto/Util/_raw_api.py", line 175, in expect_byte_string
    raise TypeError("Only byte strings can be passed to C code")
TypeError: Only byte strings can be passed to C code
Comment 2 Daniel Robbins 2017-12-23 00:45:04 UTC
Flask-restful only has a tiny bit of pycrypto code, and it is compatible with pycryptodome. So it should be sufficient just to update deps in the ebuild to get flask-restful working with pycryptodome. Also note that flask-restful will use crypto if available but also runs OK without pycrypto(dome) installed.
Comment 3 Virgil Dupras gentoo-dev 2018-11-18 23:45:07 UTC
pycrypto dependency has been dropped upstream[1] but there isn't a release for it yet. We can either wait for a release or, if in a hurry, apply the patch in 3.6.

[1]: https://github.com/flask-restful/flask-restful/pull/743