From dstromberglists at gmail.com Mon Aug 2 12:39:08 2021 From: dstromberglists at gmail.com (Dan Stromberg) Date: Mon, 2 Aug 2021 09:39:08 -0700 Subject: [Cryptography-dev] Three openssl(1) commands Message-ID: Hi people. We have some Python (CPython) code that uses openssl(1) via a subprocess at present. I'm coming to believe this isn't terribly secure though, so I looked for an openssl wrapper for CPython. What I found was PyOpenSSL, which recommends using pyca/cryptography instead for almost everything. So I'm looking into what it would take to rewrite those three openssl(1) commands using pyca/cryptography. I'm intending to send those three openssl(1) commands to this list, inquiring about how to rewrite them to use pyca/cryptography - one command per message. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From dstromberglists at gmail.com Mon Aug 2 12:46:12 2021 From: dstromberglists at gmail.com (Dan Stromberg) Date: Mon, 2 Aug 2021 09:46:12 -0700 Subject: [Cryptography-dev] openssl command one that needs a pyca/cryptography rewrite Message-ID: So the first command looks like this: ['openssl', 'rsa', '-passin', 'pass:{0}'.format(record.password)] It's just accepting the following on stdin, formatted like: -----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY----- ...and outputting something that'll later be passed to ssh-keygen -i -f -mPKCS8. Is there a pyca/cryptography equivalent? Thanks! PS: I should've mentioned previously: I'm a bit of a cryptography newb. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dstromberglists at gmail.com Mon Aug 2 12:49:07 2021 From: dstromberglists at gmail.com (Dan Stromberg) Date: Mon, 2 Aug 2021 09:49:07 -0700 Subject: [Cryptography-dev] openssl command two that needs a pyca/cryptography rewrite Message-ID: The second command looks like: ['openssl', 'genrsa', '-aes128', '-passout', 'stdin', '2048'] I believe this is generating a public key, that will later be used by ssh. This one probably isn't much of a problem, but it might be better to go all pyca/cryptography (one dependency) rather than openssl(1) and pyca/cryptography (two dependencies). Any suggestions? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From dstromberglists at gmail.com Mon Aug 2 12:51:13 2021 From: dstromberglists at gmail.com (Dan Stromberg) Date: Mon, 2 Aug 2021 09:51:13 -0700 Subject: [Cryptography-dev] openssl command three that a pyca/cryptography rewrite Message-ID: The third command looks like: ["openssl", "rsa", "-passin", "pass:{0}".format(newpassword), "-pubout"] I think here we're obtaining a new public key. Any suggestions as to how this could be rewritten to use pyca/cryptography? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.l.kehrer at gmail.com Mon Aug 2 18:10:01 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Mon, 2 Aug 2021 18:10:01 -0400 Subject: [Cryptography-dev] openssl command one that needs a pyca/cryptography rewrite In-Reply-To: References: Message-ID: Hi Dan, This mailing list doesn't have a great deal of active members who help with questions like this in general, but I'll try to help out. For this one you're just reading a password protected private key and outputting a (still not PKCS8) private key without a password. The standard load_pem_private_key method (and public_bytes for serialization) will do this. -Paul On Mon, Aug 2, 2021 at 12:46 PM Dan Stromberg wrote: > > > So the first command looks like this: > ['openssl', 'rsa', '-passin', 'pass:{0}'.format(record.password)] > > It's just accepting the following on stdin, formatted like: > -----BEGIN RSA PRIVATE KEY----- > ... > -----END RSA PRIVATE KEY----- > > ...and outputting something that'll later be passed to ssh-keygen -i -f -mPKCS8. > > Is there a pyca/cryptography equivalent? > > Thanks! > > PS: I should've mentioned previously: I'm a bit of a cryptography newb. > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev From paul.l.kehrer at gmail.com Mon Aug 2 18:11:45 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Mon, 2 Aug 2021 18:11:45 -0400 Subject: [Cryptography-dev] openssl command one that needs a pyca/cryptography rewrite In-Reply-To: References: Message-ID: Apologies, I meant private_bytes here, not public_bytes. On Mon, Aug 2, 2021 at 6:10 PM Paul Kehrer wrote: > > Hi Dan, > > This mailing list doesn't have a great deal of active members who help > with questions like this in general, but I'll try to help out. > > For this one you're just reading a password protected private key and > outputting a (still not PKCS8) private key without a password. The > standard load_pem_private_key method (and public_bytes for > serialization) will do this. > > -Paul > > On Mon, Aug 2, 2021 at 12:46 PM Dan Stromberg wrote: > > > > > > So the first command looks like this: > > ['openssl', 'rsa', '-passin', 'pass:{0}'.format(record.password)] > > > > It's just accepting the following on stdin, formatted like: > > -----BEGIN RSA PRIVATE KEY----- > > ... > > -----END RSA PRIVATE KEY----- > > > > ...and outputting something that'll later be passed to ssh-keygen -i -f -mPKCS8. > > > > Is there a pyca/cryptography equivalent? > > > > Thanks! > > > > PS: I should've mentioned previously: I'm a bit of a cryptography newb. > > > > _______________________________________________ > > Cryptography-dev mailing list > > Cryptography-dev at python.org > > https://mail.python.org/mailman/listinfo/cryptography-dev From paul.l.kehrer at gmail.com Mon Aug 2 18:12:17 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Mon, 2 Aug 2021 18:12:17 -0400 Subject: [Cryptography-dev] openssl command two that needs a pyca/cryptography rewrite In-Reply-To: References: Message-ID: This just generates a 2048-bit traditional OpenSSL RSA private key and encrypts it under the password provided to stdin. You can use our standard generation APIs and serialize the private key to encrypted form with private_bytes. -Paul On Mon, Aug 2, 2021 at 12:49 PM Dan Stromberg wrote: > > > The second command looks like: > ['openssl', 'genrsa', '-aes128', '-passout', 'stdin', '2048'] > > I believe this is generating a public key, that will later be used by ssh. > > This one probably isn't much of a problem, but it might be better to go all pyca/cryptography (one dependency) rather than openssl(1) and pyca/cryptography (two dependencies). > > Any suggestions? > > Thanks! > > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev From paul.l.kehrer at gmail.com Mon Aug 2 18:12:59 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Mon, 2 Aug 2021 18:12:59 -0400 Subject: [Cryptography-dev] openssl command three that a pyca/cryptography rewrite In-Reply-To: References: Message-ID: Once you've loaded the key you can get a public key via public_key() and then serialize it with public_bytes. -Paul On Mon, Aug 2, 2021 at 12:51 PM Dan Stromberg wrote: > > > The third command looks like: > ["openssl", "rsa", "-passin", "pass:{0}".format(newpassword), "-pubout"] > > I think here we're obtaining a new public key. > > Any suggestions as to how this could be rewritten to use pyca/cryptography? > > Thanks! > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev From jim.rowan at intel.com Mon Aug 2 10:24:21 2021 From: jim.rowan at intel.com (Rowan, Jim) Date: Mon, 2 Aug 2021 14:24:21 +0000 Subject: [Cryptography-dev] SM4 support Message-ID: I have a few questions about SM4 support? 1. Is there a planned release date for a release that includes SM4? 2. Is GCM support for SM4 planned? I don't see it listed in _register_default_ciphers(). * https://github.com/Infineon/cryptography/blob/sm4/src/cryptography/hazmat/backends/openssl/backend.py Thanks, Jim Rowan FPGA System Validation Architect, PE DPG | Custom Logic Engineering | CPSE | Platform Validation Engineering -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.gaynor at gmail.com Mon Aug 2 20:36:34 2021 From: alex.gaynor at gmail.com (Alex Gaynor) Date: Mon, 2 Aug 2021 20:36:34 -0400 Subject: [Cryptography-dev] SM4 support In-Reply-To: References: Message-ID: We do not have a planned release date for our next release. Probably towards the end of the month though, maybe early next month. Alex On Mon, Aug 2, 2021 at 8:34 PM Rowan, Jim wrote: > > I have a few questions about SM4 support? > > Is there a planned release date for a release that includes SM4? > Is GCM support for SM4 planned? I don?t see it listed in _register_default_ciphers(). > > https://github.com/Infineon/cryptography/blob/sm4/src/cryptography/hazmat/backends/openssl/backend.py > > > > Thanks, > > > > Jim Rowan > > FPGA System Validation Architect, PE > > DPG | Custom Logic Engineering | CPSE | Platform Validation Engineering > > > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev -- All that is necessary for evil to succeed is for good people to do nothing. From paul.l.kehrer at gmail.com Mon Aug 2 21:26:14 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Mon, 2 Aug 2021 21:26:14 -0400 Subject: [Cryptography-dev] SM4 support In-Reply-To: References: Message-ID: <25B40753-4681-4973-8736-13C731F40A8D@gmail.com> SM4 GCM support would be dependent on test vectors and OpenSSL support. If the latter supports it then landing a set of test vectors and adding support in our backend and tests is (probably) the only obstacle. -Paul > On Aug 2, 2021, at 8:34 PM, Rowan, Jim wrote: > > ? > I have a few questions about SM4 support? > Is there a planned release date for a release that includes SM4? > Is GCM support for SM4 planned? I don?t see it listed in _register_default_ciphers(). > https://github.com/Infineon/cryptography/blob/sm4/src/cryptography/hazmat/backends/openssl/backend.py > > Thanks, > > Jim Rowan > FPGA System Validation Architect, PE > DPG | Custom Logic Engineering | CPSE | Platform Validation Engineering > > _______________________________________________ > 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 sanojthampi at gmail.com Wed Aug 4 09:37:38 2021 From: sanojthampi at gmail.com (sinuthampi) Date: Wed, 4 Aug 2021 19:07:38 +0530 Subject: [Cryptography-dev] custom oids. Message-ID: Hi all is it possible to use custom OIDs for signing algorithms in pyca? , i have uploaded a sample certificate which is using a custom private oid and this oid is mapped with ed25519ph. how is this possible using pyca, is there any other ca which is supporting this custom method? [image: image.png] -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 38768 bytes Desc: not available URL: From paul.l.kehrer at gmail.com Wed Aug 4 21:09:12 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Wed, 4 Aug 2021 21:09:12 -0400 Subject: [Cryptography-dev] custom oids. Message-ID: <1002A4E4-C6E3-4A76-A2A7-C784425C8A54@gmail.com> ? ? As I already mentioned in the pyopenssl issue you filed, neither pyopenssl or cryptography support this in their x509 signing, no. Callers who need this will need to implement their own asn1 serialization and just use cryptography to obtain a signature. -Paul > On Aug 4, 2021, at 9:00 PM, sinuthampi wrote: > ? > Hi all > > > is it possible to use custom OIDs for signing algorithms in pyca? , i have uploaded a sample certificate which is using a custom private oid and this oid is mapped with ed25519ph. how is this possible using pyca, is there any other ca which is supporting this custom method? > > > > > > > > > _______________________________________________ > 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 k.jackiewicz at samsung.com Thu Aug 5 03:35:58 2021 From: k.jackiewicz at samsung.com (=?ks_c_5601-1987?B?S3J6eXN6dG9mIEphY2tpZXdpY3ovU2VjdXJpdHkgKFBMVA==?= =?ks_c_5601-1987?B?KSAvU1JQT0wvRW5naW5lZXIvu++8usD8wNo=?=) Date: Thu, 5 Aug 2021 09:35:58 +0200 Subject: [Cryptography-dev] KBKDFCMAC review References: Message-ID: <010901d789cc$8c3c3a50$a4b4aef0$@samsung.com> Hi, My PR https://github.com/pyca/cryptography/pull/6181 has finally passed all the checks. Is there anything else I should do initiate the review? Thanks in advance Krzysiek From paul.l.kehrer at gmail.com Thu Aug 5 08:45:58 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Thu, 5 Aug 2021 08:45:58 -0400 Subject: [Cryptography-dev] KBKDFCMAC review In-Reply-To: <010901d789cc$8c3c3a50$a4b4aef0$@samsung.com> References: <010901d789cc$8c3c3a50$a4b4aef0$@samsung.com> Message-ID: We'll review it as soon as we have bandwidth, thanks for the contribution. What's your use case for KBKDFCMAC by the way? -Paul On Thu, Aug 5, 2021 at 3:36 AM Krzysztof Jackiewicz/Security (PLT) /SRPOL/Engineer/???? wrote: > > Hi, > > My PR https://github.com/pyca/cryptography/pull/6181 has finally passed all > the checks. Is there anything else I should do initiate the review? > > Thanks in advance > > Krzysiek > > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev From k.jackiewicz at samsung.com Thu Aug 5 09:16:31 2021 From: k.jackiewicz at samsung.com (=?UTF-8?Q?Krzysztof_Jackiewicz/Security_=28P?= =?UTF-8?Q?LT=29_/SRPOL/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?=) Date: Thu, 5 Aug 2021 15:16:31 +0200 Subject: [Cryptography-dev] KBKDFCMAC review In-Reply-To: References: <010901d789cc$8c3c3a50$a4b4aef0$@samsung.com> Message-ID: <002601d789fc$1efeadd0$5cfc0970$@samsung.com> Thanks for the info. I can only tell that I use it to integrate with a closed system with limited crypto that only supports KBKDFCMAC. Krzysiek -----Original Message----- From: Cryptography-dev On Behalf Of Paul Kehrer Sent: Thursday, August 5, 2021 2:46 PM To: cryptography-dev at python.org Subject: Re: [Cryptography-dev] KBKDFCMAC review We'll review it as soon as we have bandwidth, thanks for the contribution. What's your use case for KBKDFCMAC by the way? -Paul On Thu, Aug 5, 2021 at 3:36 AM Krzysztof Jackiewicz/Security (PLT) /SRPOL/Engineer/???? wrote: > > Hi, > > My PR > https://protect2.fireeye.com/v1/url?k=2398fd4c-7c03c44e-23997603-0cc47a312ab0-201701d7e207433a&q=1&e=34969df5-3e2d-4f09-a4ff-0c2ddf5670f9&u=https%3A%2F%2Fgithub.com%2Fpyca%2Fcryptography%2Fpull%2F6181 has finally passed all the checks. Is there anything else I should do initiate the review? > > Thanks in advance > > Krzysiek > > > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev _______________________________________________ Cryptography-dev mailing list Cryptography-dev at python.org https://mail.python.org/mailman/listinfo/cryptography-dev From gjiao3-c at my.cityu.edu.hk Mon Aug 9 23:23:00 2021 From: gjiao3-c at my.cityu.edu.hk (JIAO Guangren) Date: Tue, 10 Aug 2021 03:23:00 +0000 Subject: [Cryptography-dev] A question about the ValueError "Encryption/decryption failed" Message-ID: Hello. I am a student from the City University of Hong Kong. I want to realize a project about oblivious transfer. I have a problem that I used public_key_1 to encrypt a message and I want to use three private key to decrypt the ciphertext. Of course, private_key_1 could decrypt the ciphertext correctly. The private_key_2 and private_key_3 could not decrypt the ciphertext and return the ValueError "Encryption/decryption failed". But what I need is if the private key could not decrypt the ciphertext, it ought to return a random array not an error. How could I achieve my aim using the package Cryptography of Python? I would be deeply grateful if you could solve my problem. Thank you for your help! Best Wishes! -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.l.kehrer at gmail.com Wed Aug 11 17:24:44 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Wed, 11 Aug 2021 17:24:44 -0400 Subject: [Cryptography-dev] A question about the ValueError "Encryption/decryption failed" In-Reply-To: References: Message-ID: This is not currently possible with cryptography's public API. Such an approach is one potential way to solve https://github.com/pyca/cryptography/issues/6167 though. -Paul On Tue, Aug 10, 2021 at 7:34 PM JIAO Guangren wrote: > > Hello. > I am a student from the City University of Hong Kong. I want to realize a project about oblivious transfer. I have a problem that I used public_key_1 to encrypt a message and I want to use three private key to decrypt the ciphertext. Of course, private_key_1 could decrypt the ciphertext correctly. The private_key_2 and private_key_3 could not decrypt the ciphertext and return the ValueError "Encryption/decryption failed". But what I need is if the private key could not decrypt the ciphertext, it ought to return a random array not an error. How could I achieve my aim using the package Cryptography of Python? I would be deeply grateful if you could solve my problem. Thank you for your help! > > Best Wishes! > _______________________________________________ > Cryptography-dev mailing list > Cryptography-dev at python.org > https://mail.python.org/mailman/listinfo/cryptography-dev From paul.l.kehrer at gmail.com Tue Aug 24 14:39:40 2021 From: paul.l.kehrer at gmail.com (Paul Kehrer) Date: Tue, 24 Aug 2021 14:39:40 -0400 Subject: [Cryptography-dev] PyCA cryptography 3.4.8 released Message-ID: PyCA cryptography 3.4.8 has been released to PyPI. cryptography includes both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, asymmetric algorithms, message digests, X509, key derivation functions, and much more. We support Python 3.6+, and PyPy3. Changelog (https://cryptography.io/en/latest/changelog.html#v3-4-8): * Updated Windows, macOS, and manylinux wheels to be compiled with OpenSSL 1.1.1l. -Paul Kehrer (reaperhulk)