Taken from apple docs for communicating with the keychain