Debian Codegraph @

README.md

raw
1 Go-Attestation
2 ==============
3
4 [![GoDoc](https://godoc.org/github.com/google/go-attestation/attest?status.svg)](https://godoc.org/github.com/google/go-attestation/attest)
5
6 Go-Attestation abstracts remote attestation operations across a variety of platforms
7 and TPMs, enabling remote validation of machine identity and state. This project
8 attempts to provide high level primitives for both client and server logic.
9
10 Talks on this project:
11
12 * _"Making Device Identity Trustworthy"_ - Open Source Summit Europe - October 2019 - ([Slides](https://static.sched.com/hosted_files/osseu19/ec/Device%20Identity.pdf))
13 * _"Using TPMs to Cryptographically Verify Devices at Scale"_ - Open Source Summit North America - September 2019 - ([Video](https://www.youtube.com/watch?v=EmEymlA5Q5Q) 39min)
14 * _"Making Remote Attestation Useful on Linux"_ - Linux Security Summit - September 2019 - ([Video](https://www.youtube.com/watch?v=TKva_h66Ptc) 26min)
15
16 ## Status
17
18 Go-Attestation is has reached initial maturity. It supports the initial design
19 goals and is actively used at Google. It is still under development, and API
20 changes may occur at any time. One caveat is that support for Windows is still
21 relatively immature compared to support for Linux.
22
23 Please note that this is not an official Google product.
24
25 TPM 1.2 support is best effort, meaning we will accept fixes for TPM 1.2, but
26 testing is not covered by CI.
27
28 ## Installation
29
30 The go-attestation package is installable using go get: `go get github.com/google/go-attestation/attest`
31
32 ## Example: device identity
33
34 TPMs can be used to identify a device remotely and provision unique per-device
35 hardware-bound keys.
36
37 TPMs are provisioned with a set of Endorsement Keys (EKs) by the manufacturer.
38 These optionally include a certificate signed by the manufacturer and act as a
39 TPM's identity. For privacy reasons the EK can't be used to sign or encrypt data
40 directly, and is instead used to attest to the presence of a signing key, an
41 Attestation Key (AK), on the same TPM. (Newer versions of the spec may allow the
42 EK to sign directly.)
43
44 During attestation, a TPM generates an AK and proves to a certificate authority
45 that the AK is on the same TPM as a EK. If the certificate authority trusts the
46 EK, it can transitively trust the AK, for example by issuing a certificate for
47 the AK.
48
49 To perform attestation, the client generates an AK and sends the EK and AK
50 parameters to the server:
51
52 ```go
53 // Client generates an AK and sends it to the server
54
55 config := &attest.OpenConfig{}
56 tpm, err := attest.OpenTPM(config)
57 if err != nil {
58 // handle error
59 }
60
61 eks, err := tpm.EKs()
62 if err != nil {
63 // handle error
64 }
65 ek := eks[0]
66
67 akConfig := &attest.AKConfig{}
68 ak, err := tpm.NewAK(akConfig)
69 if err != nil {
70 // handle error
71 }
72 attestParams := ak.AttestationParameters()
73
74 akBytes, err := ak.Marshal()
75 if err != nil {
76 // handle error
77 }
78
79 if err := os.WriteFile("encrypted_aik.json", akBytes, 0600); err != nil {
80 // handle error
81 }
82
83 // send TPM version, EK, and attestParams to the server
84 ```
85
86 The server uses the EK and AK parameters to generate a challenge encrypted to
87 the EK, returning the challenge to the client. During this phase, the server
88 determines if it trusts the EK, either by chaining its certificate to a known
89 manufacturer and/or querying an inventory system.
90
91 ```go
92 // Server validates EK and/or EK certificate
93
94 params := attest.ActivationParameters{
95 TPMVersion: tpmVersion,
96 EK: ek.Public,
97 AK: attestParams,
98 }
99 secret, encryptedCredentials, err := params.Generate()
100 if err != nil {
101 // handle error
102 }
103
104 // return encrypted credentials to client
105 ```
106
107 The client proves possession of the AK by decrypting the challenge and
108 returning the same secret to the server.
109
110 ```go
111 // Client decrypts the credential
112
113 akBytes, err := os.ReadFile("encrypted_aik.json")
114 if err != nil {
115 // handle error
116 }
117 ak, err := tpm.LoadAK(akBytes)
118 if err != nil {
119 // handle error
120 }
121 secret, err := ak.ActivateCredential(tpm, encryptedCredentials)
122 if err != nil {
123 // handle error
124 }
125
126 // return secret to server
127 ```
128
129 At this point, the server records the AK and EK association and allows the client
130 to use its AK as a credential (e.g. by issuing it a client certificate).