## 6 Purpose-Based Encryption
### Experimental Results
#### 6.4.2 The Lifecycle of PII under Test  
In the following section, we test the lifecycle of PII. We show that the shopping service and the delivery service can only decrypt a portion of PII to complete a purchase order and to deliver a parcel, respectively, but nothing more. _(1) Encryption:_ Table 1 shows some examples of user identities under test. In our example, the user is willing to disclose his \"date of birth\" (DOB) for purchasing a product (e.g., confirm that a user is an adult). However, for delivering a parcel, he does not need to disclose his birthday. Furthermore, he only discloses his \"addresses\" in a \"current\" transaction and limited within 14 days after \"delivery\". In contrast to his \"addresses\", his \"last name\" has a longer lifetime (e.g., 30 days) and can be used for contacting purpose without having a \"current\" transaction (e.g., a marketing service may use his last name to \"contact\" him later on for advertising a new product). Figure 14: Test environment. _(2) Authentication_: Figure 15a shows an authentication response from the home IdP to the shopping service. In the SAML response, the home IdP issues the encrypted TAT (lines 19 to 21) and several attribute statements about the user (lines 12 to 18). These user attributes are in ciphertext format, so the shopping service cannot read them (yet). Figure 15b shows the TAT in plaintext after the services decrypt it. The TAT is a Based64-encoded format that contains some cryptographic key attributes about the current access time (lines 3 to 6), which is the current date that the user authenticates to his home IdP (see the implementation for more details). Also, the TAT has the key attributes issued for the visitor IdP of \"salesforce\" with the domain \"eu\" (lines 7 and 8). _(3) Purpose authorisation request_: To implement the purpose authorisation request, we have extended the protocol \"SAML 2.0 Profile for OAuth 2.0\" [71]. Briefly, the shopping service authenticates to the visitor IdP and submits the SAML response in a POST request. After receiving the request, \"OAuth Handler\" checks the expiration time of the SAML session. If the session is still valid, it issues a PAT containing two key attributes \"current\" and \"purchase\". It means the shopping service is authorised for processing PII to \"purchase\" a product in the \"current\" transaction. _(4) Decryption_: In Figure 16a, the shopping service can decrypt PII for the \"purchase\" purpose (e.g., last name and birthday) but cannot decrypt the \"addresses\". In Figure 16b, the delivery service also performs the purpose authorisation request and receives a PAT containing the key attributes \"delivery\", \"contact\", and \"current\". With the given keys, the delivery service can decrypt user \"addresses\" for shipping the product, but cannot see the user birthday. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Attribute** & **Attribute Value** & **Purpose** & **PPurpose** & **Domain** & **Country Name** & **Lifetime (days)** \\ \hline Last name & Tri & current, contact & purchase, delivery & salesforce, amazon & eu & 30 \\ DOB & 01.01.1980 & current & purchase, government & salesforce, amazon & eu & 30 \\ Addresses & Berlin & contact & delivery & salesforce & eu & 14 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Sample user data. Figure 15: (a) SAML response with encrypted time access token; (b) Time access token. _(5) Expired authentication:_ When the shopping service submits an expired SAML session, the PAT does not contain the key attribute \"current\". Thus, the shopping service cannot decrypt the \"dob\". It means after the shopping service completed the current transaction, it cannot reuse the SAML to access the \"dob\" (even though it was authorised to access the \"dob\" before). _(6) Expired ciphertext:_ When the user authenticates to the home IdP after 15 days, the home IdP issues a TAT with a new access time. Recall that the \"addresses\" is encrypted with the disclosure policy limited to 14 days.