Fix text hmac field to use the get_encrypt_sql method#700
Open
ruanpotgieter95 wants to merge 1 commit intoincuna:masterfrom
Open
Fix text hmac field to use the get_encrypt_sql method#700ruanpotgieter95 wants to merge 1 commit intoincuna:masterfrom
ruanpotgieter95 wants to merge 1 commit intoincuna:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi I started to use TextHMACField ( need the key to make it more secure ) for hashing. What I found was that the key isn't being used. When looking at the code I believe the implementation for using the key was swapped between TextDigestField and TextHMACField.
The SQL for the two above classes look like this:
As you can see the HMAC is using the PGCRYPTO extensions hmac function that takes in a key '{}'. Where digest can't.
You can see that the implementation to
get_encrypt_sqlis in the TextDigestField class and not in the TextHMACField.This makes it that the TextHMACField will never have the key used. When you want to hash a value in plain SQL to check the where clause, you will need to add '{}' as the key for it to work.
The fix is as simple as moving the
get_encrypt_sqlintoTextHMACField. I have tested this locally and it is working as expected.