Skip to content

Commit b3d0080

Browse files
doc: align doc.go with the current implementation
Update doc.go to align with the current implementation of AttestationResult Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
1 parent e895c1e commit b3d0080

File tree

1 file changed

+60
-49
lines changed

1 file changed

+60
-49
lines changed

doc.go

+60-49
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,67 @@ https://datatracker.ietf.org/doc/draft-ietf-rats-ar4si/
99
# Construction
1010
1111
An AttestationResult object is constructed by populating the relevant fields.
12-
The mandatory attributes are: status, timestamp and profile.
12+
The mandatory attributes are: status, issued_at, profile, submods, and verifier_id.
1313
For example, a simple AttestationResult payload with only the bare minimum
1414
claims could be created as follows:
1515
16-
myStatus := TrustTierAffirming
17-
myTimestamp := time.Now().Format(time.RFC3339)
18-
myPolicyID := `https://veraison.example/policy/1A4DF345-B512-4F3B-8461-967DE7F60ECA`
19-
myProfile := EatProfile
20-
21-
ar := AttestationResult{
22-
Status: &myStatus,
23-
Timestamp: &testTimestamp,
24-
AppraisalPolicyID: &testPolicyID,
25-
Profile: &testProfile,
26-
}
16+
myStatus := TrustTierAffirming
17+
myTimestamp := time.Now().Unix()
18+
myPolicyID := `https://veraison.example/policy/1A4DF345-B512-4F3B-8461-967DE7F60ECA`
19+
myProfile := EatProfile
20+
verifierBuild := "verifier-build"
21+
verifierDeveloper := "verifier-developer"
22+
23+
ar := AttestationResult{
24+
Profile: &myProfile,
25+
IssuedAt: &myTimestamp,
26+
Submods: map[string]*Appraisal{
27+
"submodName": {
28+
TrustVector: &TrustVector{},
29+
Status: &myStatus,
30+
AppraisalPolicyID: &myPolicyID,
31+
},
32+
},
33+
VerifierID: &VerifierIdentity{
34+
Build: &verifierBuild,
35+
Developer: &verifierDeveloper,
36+
},
37+
}
2738
2839
A richer one would normally include the Trustworthiness Vector, which provides
29-
details about the appraised attester components. In the example below, the
40+
details about the appraised attester components. In the example below, the
3041
attester has been assessed as genuine, i.e., all claims are in the "affirming"
31-
range. (See §2.3 of draft-ietf-rats-ar4si-03 for details about the allowed values
42+
range. (See §2.3 of draft-ietf-rats-ar4si-03 for details about the allowed values
3243
and their meaning.)
3344
34-
tv := TrustVector{
35-
InstanceIdentity: 2,
36-
Configuration: 2,
37-
Executables: 2,
38-
Hardware: 2,
39-
}
45+
tv := TrustVector{
46+
InstanceIdentity: 2,
47+
Configuration: 2,
48+
Executables: 2,
49+
Hardware: 2,
50+
}
4051
41-
ar.TrustVector := &tv
52+
ar.Submods["submodName"].TrustVector = &tv
4253
4354
# Signing and Serializing
4455
4556
Once the AttestationResult is populated, it can be signed (i.e., wrapped in a
4657
JWT) by invoking the Sign method:
4758
48-
myECDSAPrivateKey = `{
49-
"kty": "EC",
50-
"crv": "P-256",
51-
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
52-
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4",
53-
"d": "V8kgd2ZBRuh2dgyVINBUqpPDr7BOMGcF22CQMIUHtNM"
54-
}`
59+
myECDSAPrivateKey := `{
60+
"kty": "EC",
61+
"crv": "P-256",
62+
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
63+
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4",
64+
"d": "V8kgd2ZBRuh2dgyVINBUqpPDr7BOMGcF22CQMIUHtNM"
65+
}`
5566
56-
sigK, _ := jwk.ParseKey([]byte(myECDSAPrivateKey))
67+
sigK, _ := jwk.ParseKey([]byte(myECDSAPrivateKey))
5768
58-
buf, _ = ar.Sign(jwa.ES256, sigK)
69+
buf, _ := ar.Sign(jwa.ES256, sigK)
5970
6071
In this case, the returned buf contains a signed ES256 JWT with the JSON
61-
serialization of the AttestationResult object as its payload. This is the usual
72+
serialization of the AttestationResult object as its payload. This is the usual
6273
JWT format that can be used as-is for interchange with other applications.
6374
6475
# Parsing and Verifying
@@ -67,38 +78,38 @@ On the consumer end of the protocol, when the EAT containing the attestation
6778
result is received from a veraison verifier, the relying party needs to first
6879
parse it and verify the signature using the Verify method:
6980
70-
myECDSAPublicKey = `{
71-
"kty": "EC",
72-
"crv": "P-256",
73-
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
74-
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4"
75-
}`
81+
myECDSAPublicKey := `{
82+
"kty": "EC",
83+
"crv": "P-256",
84+
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
85+
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4"
86+
}`
7687
77-
vfyK, _ := jwk.ParseKey([]byte(myECDSAPublicKey))
88+
vfyK, _ := jwk.ParseKey([]byte(myECDSAPublicKey))
7889
79-
var ar AttestationResult
90+
var ar AttestationResult
8091
81-
err := ar.Verify(token, jwa.ES256, vfyK)
82-
if err != nil {
83-
// handle verification error
84-
}
92+
err := ar.Verify(token, jwa.ES256, vfyK)
93+
if err != nil {
94+
// handle verification error
95+
}
8596
8697
If there are no errors, the relying party can trust the attestation result and
8798
inspect the relevant fields to decide about the trustworthiness of the attested
8899
entity.
89100
90-
if *ar.Status != TrustTierAffirming {
91-
// handle troubles with appraisal
92-
}
101+
if *ar.Submods["submodName"].Status != TrustTierAffirming {
102+
// handle troubles with appraisal
103+
}
93104
94105
# Pretty printing
95106
96107
The package provides a Report method that allows pretty printing of the
97-
Trustworthiness Vector. The caller can request a short summary or a detailed
108+
Trustworthiness Vector. The caller can request a short summary or a detailed
98109
printout, as well as using colors when displaying the claims' values.
99110
100-
short, color := true, true
111+
short, color := true, true
101112
102-
fmt.Print(ar.TrustVector.Report(short, color))
113+
fmt.Print(ar.Submods["submodName"].TrustVector.Report(short, color))
103114
*/
104115
package ear

0 commit comments

Comments
 (0)