I have a table in BigQuery, in which 1 column ssn is encrypted using .
I am doing encryption from Nifi using vault and the algorithm used is AES256, such that the encryption key in the format “sdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLAsdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLAsdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLAsdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLA=” .
The encrypted column is in the the format “blablaBLABlaBLaBlA+xUErvXADaYg=”.
Then encrypted column is stored in a BigQuery table.
I am looking for a way to decrypt this column from the BigQuery console using the same key.
Tried the solution mentioned here and here and customized the query to be:
SELECT AEAD.DECRYPT_STRING(KEYS.ADD_KEY_FROM_RAW_BYTES(b'', 'AES_CBC_PKCS', b'sdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLAsdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLAsdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLAsdfdfsASgfdsHsaDSFSjsdasfsfblaBlaBLA='), CAST(ssn AS BYTES), '') AS plaintext FROM `vf-grp-maml-dev-lab-01.Test_Dataset.test_table`;
Then i got the below error in the BQ console:
Failed to add a key from raw bytes: Unsupported key size: 404 bytes; expected 16, 24, or 32 bytes.; error in KEYS.ADD_KEY_FROM_RAW_BYTES expression
Can you please guide me how to properly formulate the query to decrypt the ssn column.