Remote attestation (RA) is a primitive that allows the authentication of software components on untrusted systems by relying on a root of trust. Network protocols can use the primitive to establish trust in remote software components they communicate with. As such, RA can be regarded as a firstclass security primitive like (a)symmetric encryption, message authentication, etc. However, current formal models of RA do not allow analysing protocols that use the primitive without tying them to specific platforms, low-level languages, memory protection models, or implementation details.In this paper, we propose and demonstrate a new model, called π RA , that supports RA at a high level of abstraction by treating it as a cryptographic primitive in a variant of the applied πcalculus. To demonstrate the use of π RA , we use it to formalise and analyse the security of MAGE, an SGX-based framework that allows mutual attestation of multiple enclaves. The protocol is formalised in the form of a compiler that implements actorbased communication primitives in a source language (π Actor ) in terms of remote attestation primitives in π RA . Our security analysis uncovers a caveat in the security of MAGE that was left unmentioned in the original paper.