-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for password protected public key encryption private keys #89
Comments
PGPPublicKey fields use public key encryption (PUBLIC_PGP_KEY / PRIVATE_PGP_KEY) and PGPSymmetricKey fields use symmetric key encryption (PGCRYPTO_KEY). If you want to use symmetric key encryption (PGCRYPTO_KEY), you would need to use TextPGPSymmetricKeyField instead of TextPGPPublicKeyField. You can find the chart of supported fields here: https://github.com/incuna/django-pgcrypto-fields#django-model-field-equivalents We do not currently support public key encryption with a passphrase. We will welcome a PR. Please be sure to include tests. |
@klall If you want to make a PR, the documentation for pgp_public_decrypt() in PGCRYPTO is here: https://www.postgresql.org/docs/9.5/pgcrypto.html You'd have to figure out how to add in the |
Hi, is this still open? |
Yes, PR are welcome.
…On Tue, Aug 4, 2020, 12:29 PM Abder ***@***.***> wrote:
Hi, is this still open?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#89 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVZRZAYFZUHB4Q73LSGAJ3R7BHRFANCNFSM4GLAODBQ>
.
|
I've attempted to solve this in #364. Any comments/suggestions there would be welcome. |
To add support for password-protected private keys for public key encryption in django-pgcrypto-fields, you can modify the PGPPublicKeyFieldMixin class to accept an additional parameter for the passphrase. Here's an example implementation:
In this implementation, the PGPPublicKeyFieldMixin class inherits from the PGPMixin class, which handles the encryption and decryption of the PGP key. The init method is modified to accept an additional passphrase argument, which is stored in the instance variable self.passphrase. The to_python method deserializes the value from the database and decrypts the PGP key using the passphrase, if one was provided. The get_prep_value method serializes the value to the database and encrypts the PGP key using the passphrase, if one was provided. With this implementation, you can use the PGPPublicKeyField in the same way as before, with added support for password-protected private keys. To add support for password protected public key encryption private keys, you can follow these steps:
By making these changes, the PGPPublicKeyFieldMixin class would now support password protected public key encryption private keys. Make sure to test the functionality thoroughly to ensure proper operation. |
@some1ataplace Thanks for the in depth comment. PRs are welcome however setting a passphrase on the field (which is configuration) is less than optimal. |
The setting PGCRYPTO_KEY is used in PGPSymmetricKeyFieldMixin (
django-pgcrypto-fields/pgcrypto/mixins.py
Line 143 in 429b9a8
but not PGPPublicKeyFieldMixin
django-pgcrypto-fields/pgcrypto/mixins.py
Line 128 in 429b9a8
I was unable to use a public/private key with a passphrase with a TextPGPPublicKeyField. I regenerated a public/private key without a passphrase it worked fine.
Does PGPPublicKeyFieldMixin need to be updated to support PGCRYPTO_KEY?
Thanks
The text was updated successfully, but these errors were encountered: