Text this: Typing secure implementation of authentication protocols in environments with compromised principals.