Re: [pgAdmin4] Changes required to support PyCrypto - Mailing list pgadmin-hackers

From Dave Page
Subject Re: [pgAdmin4] Changes required to support PyCrypto
Date
Msg-id CA+OCxoxZxc_+2VykyDwQgPzTqjnz168G31UBcpfX7MqgwTkMig@mail.gmail.com
Whole thread Raw
In response to Re: [pgAdmin4] Changes required to support PyCrypto  (Dave Page <dpage@pgadmin.org>)
Responses Re: [pgAdmin4] Changes required to support PyCrypto
List pgadmin-hackers


On Tue, Apr 10, 2018 at 4:51 PM, Dave Page <dpage@pgadmin.org> wrote:
*grumble*. Thanks, applied.

And reverted. When I went back to 2.7, it got very upset:

ERROR
runTest (pgadmin.browser.server_groups.servers.databases.schemas.tables.tests.test_table_put.TableUpdateTestCase)
Create partitions of existing range partitioned table ... 2018-04-10 17:10:57,703: ERROR pgadmin: Object type <type 'unicode'> cannot be passed to C code
Traceback (most recent call last):
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/__init__.py", line 962, in connect
    if password is not None else server.password
  File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/crypto.py", line 31, in encrypt
    cipher = AES.new(pad(key), AES.MODE_CFB, iv)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/Crypto/Cipher/AES.py", line 200, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/Crypto/Cipher/__init__.py", line 55, in _create_cipher
    return modes[mode](factory, **kwargs)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/Crypto/Cipher/_mode_cfb.py", line 230, in _create_cfb_cipher
    cipher_state = factory._create_base_cipher(kwargs)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/Crypto/Cipher/AES.py", line 100, in _create_base_cipher
    result = start_operation(c_uint8_ptr(key),
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/Crypto/Util/_raw_api.py", line 151, in c_uint8_ptr
    raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <type 'unicode'> cannot be passed to C code

 

On Tue, Apr 10, 2018 at 1:52 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:
On Tue, Apr 10, 2018 at 5:27 PM, Dave Page <dpage@pgadmin.org> wrote:


On Tue, Apr 10, 2018 at 12:49 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:
Hi,

Please find patch to revert back the changes we have made for pycryptodom module, This will fix encrypt & decrypt functionality in python3.

Wait, what? Are you telling me that encrypt/decrypt is broken under Python 3 in the builds I've just pushed? 
​Only if user's password contains non-ascii characters and running on Python3.​
 

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company




--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Revert "Fix non-ASCII passworddecryption/encryption
Next
From: Khushboo Vashi
Date:
Subject: Re: pgAdmin 3.0 builds