Depending on the context the failing GCM tag verification should return
different errors. Key-manager distinguishes 2 such situations:
1. Client performs GCM decryption and tag verification fails. In such case the
error returned to the client should indicate invalid parameter.
2. Client performs a cryptographic operation using a password protected key. If
password is wrong the GCM decryption of the key fails and should return an error
indication authentication failuire.
If GCM decryption requested by cliend fails with TEE_ERROR_MAC_INVALID, return
TEE_ERROR_BAD_PARAMETERS (case 1). If key decryption fails with
TEE_ERROR_MAC_INVALID (case 2) propagate it to key-manager unchanged. This way
key-manager will be able to distinguish both cases.
Change-Id: I8b5cc23281d71959fc89511e183e205deff170ad
input_data->data_size, ae_data->aad.data,
ae_data->aad.data_size, tag_data->data, tag_data->data_size,
out, &out_size);
+
+ // key-manager expects TEE_ERROR_BAD_PARAMETERS error if MAC verification fails
+ if (ret == TEE_ERROR_MAC_INVALID)
+ ret = TEE_ERROR_BAD_PARAMETERS;
}
if (TEE_SUCCESS != ret) {