Add SHA validations to Raw operations
I this MR we add some validations to ensure that the SHA provided for Raw operations is valid.
This MR comes from https://gitlab.com/gitlab-org/gitlab-ce/issues/57901 and https://gitlab.slack.com/archives/CBNRPCRM2/p1550575264086100