Protecting applications using trusted execution environments