'Update an existing credential.'

def update_credential(self, credential_id, credential):

    self._validate_credential_update(credential_id, credential)
    if ('blob' in credential):
        credential_copy = self._encrypt_credential(credential)
    else:
        credential_copy = credential.copy()
        existing_credential = self.get_credential(credential_id)
        existing_blob = existing_credential['blob']
    ref = self.driver.update_credential(credential_id, credential_copy)
    ref.pop('key_hash', None)
    ref.pop('encrypted_blob', None)
    if credential.get('blob'):
        ref['blob'] = credential['blob']
    else:
        ref['blob'] = existing_blob
    return ref
