Thread: [pgAdmin4] Changes required to support PyCrypto
Hi,
Please find patch to revert back the changes we have made for pycryptodom module, This will fix encrypt & decrypt functionality in python3.
--![](https://drive.google.com/a/enterprisedb.com/uc?id=0B6jGeB3BfKRMV0t4MEp0YnZCTTA&export=download)
Regards,
Attachment
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?
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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
*grumble*. Thanks, applied.
On Tue, Apr 10, 2018 at 1:52 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> 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
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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 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
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
This is the exact code we had before pycrptodom changes, Is it fresh virtual environment?
I suspect some conflicts from pycrptodom files.
--![](https://drive.google.com/a/enterprisedb.com/uc?id=0B6jGeB3BfKRMV0t4MEp0YnZCTTA&export=download)
Regards,
On Tue, Apr 10, 2018 at 9:51 PM, Dave Page <dpage@pgadmin.org> wrote:
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:ERRORrunTest (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 codeTraceback (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.passwordFile "/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 codeOn Tue, Apr 10, 2018 at 1:52 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> 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
Yeah, good call - pycryptodome was still installed.
Committed, sorry for the noise.
On Tue, Apr 10, 2018 at 6:39 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:
This is the exact code we had before pycrptodom changes, Is it fresh virtual environment?I suspect some conflicts from pycrptodom files.--Regards,On Tue, Apr 10, 2018 at 9:51 PM, Dave Page <dpage@pgadmin.org> wrote: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:ERRORrunTest (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 codeTraceback (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.passwordFile "/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-packa ges/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-packa ges/Crypto/Cipher/__init__.py" , line 55, in _create_cipher return modes[mode](factory, **kwargs)File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa ges/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-packa ges/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-packa ges/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 codeOn Tue, Apr 10, 2018 at 1:52 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> 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
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company