From readthedocs at readthedocs.org Sat Feb 11 10:05:59 2017 From: readthedocs at readthedocs.org (Read the Docs) Date: Sat, 11 Feb 2017 15:05:59 -0000 Subject: [Cryptography-dev] Failed: Cryptography (latest) Message-ID: <20170211150559.15871.78039@web04.servers.readthedocs.org> Build Failed for Cryptography (latest) You can find out more about this failure here: https://readthedocs.org/projects/cryptography/builds/5013987/ If you have questions, a good place to start is the FAQ: https://docs.readthedocs.org/en/latest/faq.html Keep documenting, Read the Docs -- http://readthedocs.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From readthedocs at readthedocs.org Mon Feb 13 21:01:34 2017 From: readthedocs at readthedocs.org (Read the Docs) Date: Tue, 14 Feb 2017 02:01:34 -0000 Subject: [Cryptography-dev] Failed: Cryptography (bd7cd2d4) Message-ID: <20170214020134.4275.7173@web02.servers.readthedocs.org> Build Failed for Cryptography (latest) You can find out more about this failure here: https://readthedocs.org/projects/cryptography/builds/5022902/ If you have questions, a good place to start is the FAQ: https://docs.readthedocs.org/en/latest/faq.html Keep documenting, Read the Docs -- http://readthedocs.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From readthedocs at readthedocs.org Mon Feb 13 22:28:13 2017 From: readthedocs at readthedocs.org (Read the Docs) Date: Tue, 14 Feb 2017 03:28:13 -0000 Subject: [Cryptography-dev] Failed: Cryptography (a39b20d6) Message-ID: <20170214032813.28889.2851@web04.servers.readthedocs.org> Build Failed for Cryptography (latest) You can find out more about this failure here: https://readthedocs.org/projects/cryptography/builds/5023114/ If you have questions, a good place to start is the FAQ: https://docs.readthedocs.org/en/latest/faq.html Keep documenting, Read the Docs -- http://readthedocs.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From tanhao001 at ulic.com.cn Fri Feb 17 03:00:37 2017 From: tanhao001 at ulic.com.cn (tanhao001 at ulic.com.cn) Date: Fri, 17 Feb 2017 16:00:37 +0800 Subject: [Cryptography-dev] install cryptography by source code Message-ID: <2017021716003599130024@ulic.com.cn> Hi?I'm tring to install cryptography by source code on a redhat 6.6 server myself, for I can not use the `pip install` commond in a local network. Firstly, I installed openssl-1.0.2k by source code. ``` ./config -fPIC shared --prefix=/ulic/devops/ops/softs/ssl --openssldir=/ulic/devops/ops/softs/ssl/openssl ``` Then I tried to install cryptography-1.7.2 by source code. ``` export PKG_CONFIG_PATH=/ulic/devops/ops/softs/ssl/lib/pkgconfig export LD_LIBRARY_PATH=/ulic/devops/ops/softs/ssl/lib python setup.py build python setup.py install ``` But it seemed that it does't work and it stucked here. ``` .... building '_openssl' extension gcc -pthread -fno-strict-aliasing -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/zabbix/python3.6/include/python3.6m -c build/temp.linux-x86_64-3.6/_openssl.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/_openssl.o build/temp.linux-x86_64-3.6/_openssl.c:485:25: error: openssl/cms.h: No such file or directory build/temp.linux-x86_64-3.6/_openssl.c:680: error: function definition declared ?typedef? build/temp.linux-x86_64-3.6/_openssl.c:680: warning: return type defaults to ?int? build/temp.linux-x86_64-3.6/_openssl.c: In function ?LHASH_OF?: ... ``` The cms.h file is in /ulic/devops/ops/softs/ssl/include/openssl/cms.h. And I think the setup.py can not find it correctly. Did anyone know how to deal with it. Thank you very much! -------------- next part -------------- An HTML attachment was scrubbed... URL: From bennomadic at gmail.com Sat Feb 18 06:29:18 2017 From: bennomadic at gmail.com (Ben Carrillo) Date: Sat, 18 Feb 2017 12:29:18 +0100 Subject: [Cryptography-dev] install cryptography by source code In-Reply-To: <2017021716003599130024@ulic.com.cn> References: <2017021716003599130024@ulic.com.cn> Message-ID: 2017-02-17 9:00 GMT+01:00 tanhao001 at ulic.com.cn : > > Hi?I'm tring to install cryptography by source code on a redhat 6.6 > server myself, for I can not use the `pip install` commond in a local > network. > I'm not sure I understand the problem. Is pypi blocked on your local network? Is it possible for you to download the wheels somewhere else and install them in the machine you want to use? To answer your question, maybe you need to export CFLAGS with -I/your/include/path -------------- next part -------------- An HTML attachment was scrubbed... URL: From sm5149 at yahoo.com Wed Feb 22 13:29:46 2017 From: sm5149 at yahoo.com (Salvador Munguia) Date: Wed, 22 Feb 2017 18:29:46 +0000 (UTC) Subject: [Cryptography-dev] Getting Error message when trying to decrypt a message References: <630173468.3783554.1487788186960.ref@mail.yahoo.com> Message-ID: <630173468.3783554.1487788186960@mail.yahoo.com> Original Data: gAAAAABYrP0tuwZsZ2D5v-r7O6NyGDpp3-TeiEwGRy-HCZg6eWWzfGpr0teeZ3iOeI7YQlfE-xNr1cZLRUVQj2rgNcNS6rbJ Encrypted Data: gAAAAABYrdhsLhqsuFlsPn72AvzwXAT-_wJDQIIOzl5oFyoPzSrmmDbURiPRdTDfc_FqlOpTO0zGmedlyeY8xJp1_0D-2dwOh8VUs-0ncH604Zc38LKg7eZBJgIvSAByWMzJ-HagvTIC2FzQZW7xSJbHgXaI-p6kvbOKrRcZiwLvwyZOCJ1ivyrj1kDpx06-jTLgZVD4VsWE7gHwQo2o4mj1_HtMRZevoA== Traceback (most recent call last): ? File "tmp2.py", line 49, in ??? dout = encryptMAIN(e_out,'') ? File "tmp2.py", line 31, in encryptMAIN ??? return f.decrypt(data) ? File "/usr/lib/python2.7/dist-packages/cryptography/fernet.py", line 110, in decrypt ??? raise InvalidToken cryptography.fernet.InvalidToken This is the code I am using: #!/usr/bin/python import zlib,MySQLdb,os,sys,urllib,re import os,hashlib,base64 from cryptography.fernet import Fernet from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from Crypto.Cipher import AES from pbkdf2 import PBKDF2 def encryptMAIN(data,fun): ??????? password = b"this is the password!" ??????? salt = os.urandom(16) ??????? kdf = PBKDF2HMAC( ??????? algorithm=hashes.SHA256(), ??????? length=32, ??????? salt=salt, ??????? iterations=100000, ??????? backend=default_backend() ??????? ) ??????? key = base64.urlsafe_b64encode(kdf.derive(password)) ??????? f = Fernet(key) ??????? if(fun == 'encrypt'): ??????????????? return f.encrypt(b"%s" % (data)) ??????? else: ??????????????? return f.decrypt(data) def encryptDATA(data): ??????? cipher = encryptMAIN(data,'encrypt') ??????? return cipher def decryptDATA(data): ??????? decoded = encryptMAIN(data,'') ??????? return decoded string = "gAAAAABYrP0tuwZsZ2D5v-r7O6NyGDpp3-TeiEwGRy-HCZg6eWWzfGpr0teeZ3iOeI7YQlfE-xNr1cZLRUVQj2rgNcNS6rbJ" e_out = encryptMAIN(string,'encrypt') print "Original Data: " + string print "Encrypted Data: " + e_out dout = encryptMAIN(e_out,'') print "Decrypted Data: " + d_out -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.gaynor at gmail.com Wed Feb 22 13:31:44 2017 From: alex.gaynor at gmail.com (Alex Gaynor) Date: Wed, 22 Feb 2017 13:31:44 -0500 Subject: [Cryptography-dev] Getting Error message when trying to decrypt a message In-Reply-To: <630173468.3783554.1487788186960@mail.yahoo.com> References: <630173468.3783554.1487788186960.ref@mail.yahoo.com> <630173468.3783554.1487788186960@mail.yahoo.com> Message-ID: You're generating a new salt on every invocation of encryptMAIN, which means that a different key is used when you encrypt and decrypt. On Wed, Feb 22, 2017 at 1:29 PM, Salvador Munguia via Cryptography-dev < cryptography-dev at python.org> wrote: > Original Data: > gAAAAABYrP0tuwZsZ2D5v-r7O6NyGDpp3-TeiEwGRy-HCZg6eWWzfGpr0teeZ3iOeI7YQlfE- > xNr1cZLRUVQj2rgNcNS6rbJ > > Encrypted Data: > gAAAAABYrdhsLhqsuFlsPn72AvzwXAT-_wJDQIIOzl5oFyoPzSrmmDbURiPRdTD > fc_FqlOpTO0zGmedlyeY8xJp1_0D-2dwOh8VUs-0ncH604Zc38LKg7eZBJgIvSAByWMzJ > -HagvTIC2FzQZW7xSJbHgXaI-p6kvbOKrRcZiwLvwyZOCJ1ivyrj1kD > px06-jTLgZVD4VsWE7gHwQo2o4mj1_HtMRZevoA== > > Traceback (most recent call last): > File "tmp2.py", line 49, in > dout = encryptMAIN(e_out,'') > File "tmp2.py", line 31, in encryptMAIN > return f.decrypt(data) > File "/usr/lib/python2.7/dist-packages/cryptography/fernet.py", line > 110, in decrypt > raise InvalidToken > cryptography.fernet.InvalidToken > > > This is the code I am using: > #!/usr/bin/python > > import zlib,MySQLdb,os,sys,urllib,re > import os,hashlib,base64 > from cryptography.fernet import Fernet > from cryptography.hazmat.backends import default_backend > from cryptography.hazmat.primitives import hashes > from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC > from Crypto.Cipher import AES > from pbkdf2 import PBKDF2 > > > > > > def encryptMAIN(data,fun): > password = b"this is the password!" > salt = os.urandom(16) > kdf = PBKDF2HMAC( > algorithm=hashes.SHA256(), > length=32, > salt=salt, > iterations=100000, > backend=default_backend() > ) > key = base64.urlsafe_b64encode(kdf.derive(password)) > f = Fernet(key) > if(fun == 'encrypt'): > return f.encrypt(b"%s" % (data)) > else: > return f.decrypt(data) > > def encryptDATA(data): > cipher = encryptMAIN(data,'encrypt') > return cipher > > def decryptDATA(data): > decoded = encryptMAIN(data,'') > return decoded > > string = "gAAAAABYrP0tuwZsZ2D5v-r7O6NyGDpp3-TeiEwGRy- > HCZg6eWWzfGpr0teeZ3iOeI7YQlfE-xNr1cZLRUVQj2rgNcNS6rbJ" > > e_out = encryptMAIN(string,'encrypt') > > > print "Original Data: " + string > print "Encrypted Data: " + e_out > > dout = encryptMAIN(e_out,'') > > print "Decrypted Data: " + d_out > > > > > > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev > > -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: D1B3 ADC0 E023 8CA6 -------------- next part -------------- An HTML attachment was scrubbed... URL: From sm5149 at yahoo.com Wed Feb 22 15:10:37 2017 From: sm5149 at yahoo.com (Salvador Munguia) Date: Wed, 22 Feb 2017 20:10:37 +0000 (UTC) Subject: [Cryptography-dev] Getting Error message when trying to decrypt a message In-Reply-To: References: <630173468.3783554.1487788186960.ref@mail.yahoo.com> <630173468.3783554.1487788186960@mail.yahoo.com> Message-ID: <350942634.3884979.1487794237676@mail.yahoo.com> Thank you so much! That was the problem :D!!! Sal, On Wednesday, February 22, 2017 10:32 AM, Alex Gaynor wrote: You're generating a new salt on every invocation of encryptMAIN, which means that a different key is used when you encrypt and decrypt. On Wed, Feb 22, 2017 at 1:29 PM, Salvador Munguia via Cryptography-dev wrote: Original Data: gAAAAABYrP0tuwZsZ2D5v- r7O6NyGDpp3-TeiEwGRy- HCZg6eWWzfGpr0teeZ3iOeI7YQlfE- xNr1cZLRUVQj2rgNcNS6rbJ Encrypted Data: gAAAAABYrdhsLhqsuFlsPn72AvzwXA T-_ wJDQIIOzl5oFyoPzSrmmDbURiPRdTD fc_FqlOpTO0zGmedlyeY8xJp1_0D- 2dwOh8VUs- 0ncH604Zc38LKg7eZBJgIvSAByWMzJ -HagvTIC2FzQZW7xSJbHgXaI- p6kvbOKrRcZiwLvwyZOCJ1ivyrj1kD px06-jTLgZVD4VsWE7gHwQo2o4mj1_ HtMRZevoA== Traceback (most recent call last): ? File "tmp2.py", line 49, in ??? dout = encryptMAIN(e_out,'') ? File "tmp2.py", line 31, in encryptMAIN ??? return f.decrypt(data) ? File "/usr/lib/python2.7/dist- packages/cryptography/fernet. py", line 110, in decrypt ??? raise InvalidToken cryptography.fernet. InvalidToken This is the code I am using: #!/usr/bin/python import zlib,MySQLdb,os,sys,urllib,re import os,hashlib,base64 from cryptography.fernet import Fernet from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat. primitives.kdf.pbkdf2 import PBKDF2HMAC from Crypto.Cipher import AES from pbkdf2 import PBKDF2 def encryptMAIN(data,fun): ??????? password = b"this is the password!" ??????? salt = os.urandom(16) ??????? kdf = PBKDF2HMAC( ??????? algorithm=hashes.SHA256(), ??????? length=32, ??????? salt=salt, ??????? iterations=100000, ??????? backend=default_backend() ??????? ) ??????? key = base64.urlsafe_b64encode(kdf. derive(password)) ??????? f = Fernet(key) ??????? if(fun == 'encrypt'): ??????????????? return f.encrypt(b"%s" % (data)) ??????? else: ??????????????? return f.decrypt(data) def encryptDATA(data): ??????? cipher = encryptMAIN(data,'encrypt') ??????? return cipher def decryptDATA(data): ??????? decoded = encryptMAIN(data,'') ??????? return decoded string = "gAAAAABYrP0tuwZsZ2D5v- r7O6NyGDpp3-TeiEwGRy- HCZg6eWWzfGpr0teeZ3iOeI7YQlfE- xNr1cZLRUVQj2rgNcNS6rbJ" e_out = encryptMAIN(string,'encrypt') print "Original Data: " + string print "Encrypted Data: " + e_out dout = encryptMAIN(e_out,'') print "Decrypted Data: " + d_out ______________________________ _________________ Cryptography-dev mailing list Cryptography-dev at python.org https://mail.python.org/ mailman/listinfo/cryptography- dev -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- CiceroGPG Key fingerprint:?D1B3 ADC0 E023 8CA6 _______________________________________________ Cryptography-dev mailing list Cryptography-dev at python.org https://mail.python.org/mailman/listinfo/cryptography-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: From sm5149 at yahoo.com Thu Feb 23 16:56:56 2017 From: sm5149 at yahoo.com (Salvador Munguia) Date: Thu, 23 Feb 2017 21:56:56 +0000 (UTC) Subject: [Cryptography-dev] Getting Error when updating field on DB with encoded base64 string References: <921118929.5009549.1487887016420.ref@mail.yahoo.com> Message-ID: <921118929.5009549.1487887016420@mail.yahoo.com> It works when I encrypt and decode from string in same script, but when sent to DB looks like error with base64 encoding. Error: Traceback (most recent call last): ? File "tmp2.py", line 82, in ??? main(1) ? File "tmp2.py", line 73, in main ??? string = getCode(id,'ev_details') ? File "tmp2.py", line 23, in getCode ??? result = base64.b64decode(row[0]) ? File "/usr/lib/python2.7/base64.py", line 76, in b64decode ??? raise TypeError(msg) TypeError: Incorrect padding Script: #!/usr/bin/python import zlib,MySQLdb,os,sys,urllib,re import os,hashlib,base64 from cryptography.fernet import Fernet from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from Crypto.Cipher import AES from pbkdf2 import PBKDF2 conn = MySQLdb.connect (host = "localhost", ??????????????????????? user = "root", ??????????????????????? passwd = "pass", ??????????????????????? db = "db") def getCode(id,tbl): ??????? sql = "SELECT `details` FROM %s WHERE `id` = %s;" % (tbl,id) ??????? # print sql ??????? cursor = conn.cursor () ??????? cursor.execute (sql) ??????? row = cursor.fetchone () ??????? result = base64.b64decode(row[0]) ??????? # return row[0] ??????? return result def getEncrypt(id,tbl): ??????? sql = "SELECT `encrypted` FROM %s WHERE `id` = %s;" % (tbl,id) ??????? # print sql ??????? cursor = conn.cursor () ??????? cursor.execute (sql) ??????? row = cursor.fetchone () ??????? result = base64.b64decode(row[0]) ??????? # result = row[0] ??????? return result def encryptMAIN(data,fun): ??????? password = b"This is the password!" ??????? # salt = os.urandom(16) ??????? kdf = PBKDF2HMAC( ??????? algorithm=hashes.SHA256(), ??????? length=32, ??????? salt='42$ahasdkjfha', ??????? iterations=100000, ??????? backend=default_backend() ??????? ) ??????? key = base64.urlsafe_b64encode(kdf.derive(password)) ??????? f = Fernet(key) ??????? if(fun == 'encrypt'): ??????????????? return f.encrypt(b"%s" % (data)) ??????? else: ??????????????? return f.decrypt(data) def encryptDATA(data): ??????? cipher = encryptMAIN(data,'encrypt') ??????? return cipher def decryptDATA(data): ??????? decoded = encryptMAIN(data,'') ??????? return decoded def insertBin(id,data): ??????? data = '%s' % (data) ??????? sql = "UPDATE `sec_details` set `encrypted` = '%s' WHERE `id` = %s;" % (data, id) ??????? # print sql ??????? cursor = conn.cursor () ??????? cursor.execute (sql) ??????? conn.commit() ??????? return 1 def main(id): ?? ?string = getCode(id,'ev_details') ?? ?e_out = encryptMAIN(string,'encrypt') ?? ?insertBin(id,e_out) ?? ?print "Original Data: " + string ?? ?string = getEncrypt(id,'sec_details') ?? ?print "Encrypted Data: " + string ?? ?dout = encryptMAIN(string,'') ?? ?print "Decrypted Data: " + dout main(1) -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.gaynor at gmail.com Thu Feb 23 21:39:57 2017 From: alex.gaynor at gmail.com (Alex Gaynor) Date: Thu, 23 Feb 2017 21:39:57 -0500 Subject: [Cryptography-dev] Getting Error when updating field on DB with encoded base64 string In-Reply-To: <921118929.5009549.1487887016420@mail.yahoo.com> References: <921118929.5009549.1487887016420.ref@mail.yahoo.com> <921118929.5009549.1487887016420@mail.yahoo.com> Message-ID: Hi Salvador, I haven't looked to see a bug that would cause the exception you are seeing, however the way you are created SQL strings leaves you vulnerable to SQL injection attacks if an attack can control the "id" variable. To be totally frank, I strongly recommend you familiarize yourself with SQLi and other basic application security concerns before diving into cryptography. Alex On Thu, Feb 23, 2017 at 4:56 PM, Salvador Munguia via Cryptography-dev < cryptography-dev at python.org> wrote: > It works when I encrypt and decode from string in same script, but when > sent to DB looks like error with base64 encoding. > > Error: > Traceback (most recent call last): > File "tmp2.py", line 82, in > main(1) > File "tmp2.py", line 73, in main > string = getCode(id,'ev_details') > File "tmp2.py", line 23, in getCode > result = base64.b64decode(row[0]) > File "/usr/lib/python2.7/base64.py", line 76, in b64decode > raise TypeError(msg) > TypeError: Incorrect padding > > Script: > #!/usr/bin/python > > import zlib,MySQLdb,os,sys,urllib,re > import os,hashlib,base64 > from cryptography.fernet import Fernet > from cryptography.hazmat.backends import default_backend > from cryptography.hazmat.primitives import hashes > from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC > from Crypto.Cipher import AES > from pbkdf2 import PBKDF2 > > conn = MySQLdb.connect (host = "localhost", > user = "root", > passwd = "pass", > db = "db") > > def getCode(id,tbl): > sql = "SELECT `details` FROM %s WHERE `id` = %s;" % (tbl,id) > # print sql > cursor = conn.cursor () > cursor.execute (sql) > row = cursor.fetchone () > result = base64.b64decode(row[0]) > # return row[0] > return result > > def getEncrypt(id,tbl): > sql = "SELECT `encrypted` FROM %s WHERE `id` = %s;" % (tbl,id) > # print sql > cursor = conn.cursor () > cursor.execute (sql) > row = cursor.fetchone () > result = base64.b64decode(row[0]) > # result = row[0] > return result > > def encryptMAIN(data,fun): > password = b"This is the password!" > # salt = os.urandom(16) > kdf = PBKDF2HMAC( > algorithm=hashes.SHA256(), > length=32, > salt='42$ahasdkjfha', > iterations=100000, > backend=default_backend() > ) > key = base64.urlsafe_b64encode(kdf.derive(password)) > f = Fernet(key) > if(fun == 'encrypt'): > return f.encrypt(b"%s" % (data)) > else: > return f.decrypt(data) > > def encryptDATA(data): > cipher = encryptMAIN(data,'encrypt') > return cipher > > def decryptDATA(data): > decoded = encryptMAIN(data,'') > return decoded > > def insertBin(id,data): > data = '%s' % (data) > sql = "UPDATE `sec_details` set `encrypted` = '%s' WHERE `id` = > %s;" % (data, id) > # print sql > cursor = conn.cursor () > cursor.execute (sql) > conn.commit() > return 1 > > > def main(id): > string = getCode(id,'ev_details') > e_out = encryptMAIN(string,'encrypt') > insertBin(id,e_out) > print "Original Data: " + string > string = getEncrypt(id,'sec_details') > print "Encrypted Data: " + string > dout = encryptMAIN(string,'') > print "Decrypted Data: " + dout > > main(1) > > > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev > > -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: D1B3 ADC0 E023 8CA6 -------------- next part -------------- An HTML attachment was scrubbed... URL: