I'm trying to use KEYS.KEYSET_CHAIN to obtain the a key from the KMS but I haven't figured out how to generate the first_level_keyset correctly. I'm getting the following message:
AEAD.ENCRYPT failed: Keyset deserialization failed: Error reading keyset data: Could not parse the input stream as a Keyset-proto.
I'm following the doc:
My code:
DECLARE KMS_RESOURCE_NAME STRING;
DECLARE FIRST_LEVEL_KEYSET BYTES;
SET KMS_RESOURCE_NAME = 'gcp-kms://projects/XXX/locations/XXX/keyRings/XXX-key-ring/cryptoKeys/XXX-key';
SET FIRST_LEVEL_KEYSET = FROM_HEX("0a240... <suppressed>");
select AEAD.ENCRYPT(KEYS.KEYSET_CHAIN(KMS_RESOURCE_NAME, FIRST_LEVEL_KEYSET), b'string to encrypt', b'customer_id');
