1

I try to encrypt columns with pgcrypto using pgp_sym_encrypt/pgp_sym_decrypt in PostgreSQL. While creating indexes for certain columns, I use reverse encryption for speeding up the search of selection by exact match or using (i)like.

I have a problem with the key. Index doesn't have an encryption or hiding key in source.

I tried to hash the key via function but its code can be seen so that it is clear how the table has been encrypted.

Can you tell me how to hide the key in the process of making the index with the help of method of reverse encrypting?

Thanks in advance.

function of hashing key

index

  • If you are storing the unencrypted data in the database (in the indexes), then what is the point of encrypting it in the first place? What are you trying to accomplish? – jjanes Jul 03 '20 at 13:31
  • Data in the index is internal to PostgreSQL, and it's not accessible to the outside world. You can introspect your index definitions (using pg_indexes table or pg_get_indexdef function), but you can't look up what's actually stored in those. Well, you technically can find the file(s) in which the index data is stored (use pg_class.relfilenode and checking for files in base/ subdirectory), and decode the binary data of their b-trees (or whatever your indexes use) – Alexandr Kolomoets Jul 04 '20 at 14:56

0 Answers0