8
8
"path/filepath"
9
9
"strconv"
10
10
11
- "github.com/cc-api/cc-trusted- api/common/golang/cctrusted_base "
11
+ "github.com/cc-api/evidence- api/common/golang/evidence_api "
12
12
)
13
13
14
14
const (
@@ -17,20 +17,20 @@ const (
17
17
18
18
type Device interface {
19
19
ProbeDevice () error
20
- Report (nonce , userData string , extraArgs map [string ]any ) (cctrusted_base .CcReport , error )
20
+ Report (nonce , userData string , extraArgs map [string ]any ) (evidence_api .CcReport , error )
21
21
Name () string
22
- CCType () cctrusted_base .CC_Type
23
- Version () cctrusted_base .DeviceVersion
22
+ CCType () evidence_api .CC_Type
23
+ Version () evidence_api .DeviceVersion
24
24
}
25
25
26
26
type GenericDevice struct {
27
27
Device
28
28
}
29
29
30
- func (d * GenericDevice ) Report (nonce , userData string , extraArgs map [string ]any ) (cctrusted_base .CcReport , error ) {
30
+ func (d * GenericDevice ) Report (nonce , userData string , extraArgs map [string ]any ) (evidence_api .CcReport , error ) {
31
31
var err error
32
32
if _ , err = os .Stat (TSM_PREFIX ); os .IsNotExist (err ) {
33
- return cctrusted_base .CcReport {}, errors .New ("Configfs TSM is not supported in the current environment." )
33
+ return evidence_api .CcReport {}, errors .New ("Configfs TSM is not supported in the current environment." )
34
34
}
35
35
36
36
// concatenate nonce and userData
@@ -56,22 +56,22 @@ func (d *GenericDevice) Report(nonce, userData string, extraArgs map[string]any)
56
56
57
57
tempdir , err := os .MkdirTemp (TSM_PREFIX , "report_" )
58
58
if err != nil {
59
- return cctrusted_base .CcReport {}, errors .New ("Failed to init entry in Configfs TSM." )
59
+ return evidence_api .CcReport {}, errors .New ("Failed to init entry in Configfs TSM." )
60
60
}
61
61
defer os .RemoveAll (tempdir )
62
62
63
63
if _ , err = os .Stat (filepath .Join (tempdir , "inblob" )); ! os .IsNotExist (err ) {
64
64
err = os .WriteFile (filepath .Join (tempdir , "inblob" ), reportData , 0400 )
65
65
if err != nil {
66
- return cctrusted_base .CcReport {}, errors .New ("Failed to push report data into inblob." )
66
+ return evidence_api .CcReport {}, errors .New ("Failed to push report data into inblob." )
67
67
}
68
68
}
69
69
70
70
if v , ok := extraArgs ["privilege" ]; ok {
71
71
if val , ok := v .(int ); ok {
72
72
err = os .WriteFile (filepath .Join (tempdir , "privlevel" ), []byte (strconv .Itoa (val )), 0400 )
73
73
if err != nil {
74
- return cctrusted_base .CcReport {}, errors .New ("Failed to push privilege data to privlevel file." )
74
+ return evidence_api .CcReport {}, errors .New ("Failed to push privilege data to privlevel file." )
75
75
}
76
76
}
77
77
}
@@ -81,37 +81,37 @@ func (d *GenericDevice) Report(nonce, userData string, extraArgs map[string]any)
81
81
if _ , err = os .Stat (filepath .Join (tempdir , "outblob" )); ! os .IsNotExist (err ) {
82
82
outblob , err = os .ReadFile (filepath .Join (tempdir , "outblob" ))
83
83
if err != nil {
84
- return cctrusted_base .CcReport {}, errors .New ("Failed to get outblob." )
84
+ return evidence_api .CcReport {}, errors .New ("Failed to get outblob." )
85
85
}
86
86
}
87
87
88
88
if _ , err = os .Stat (filepath .Join (tempdir , "generation" )); ! os .IsNotExist (err ) {
89
89
rawGeneration , err := os .ReadFile (filepath .Join (tempdir , "generation" ))
90
90
if err != nil {
91
- return cctrusted_base .CcReport {}, errors .New ("Failed to get generation info." )
91
+ return evidence_api .CcReport {}, errors .New ("Failed to get generation info." )
92
92
}
93
93
generation , _ = strconv .Atoi (string (rawGeneration ))
94
94
// Check if the outblob has been corrupted during file open
95
95
if generation > 1 {
96
- return cctrusted_base .CcReport {}, errors .New ("Found corrupted generation." )
96
+ return evidence_api .CcReport {}, errors .New ("Found corrupted generation." )
97
97
}
98
98
}
99
99
100
100
if _ , err = os .Stat (filepath .Join (tempdir , "provider" )); ! os .IsNotExist (err ) {
101
101
provider , err = os .ReadFile (filepath .Join (tempdir , "provider" ))
102
102
if err != nil {
103
- return cctrusted_base .CcReport {}, errors .New ("Failed to get provider info." )
103
+ return evidence_api .CcReport {}, errors .New ("Failed to get provider info." )
104
104
}
105
105
}
106
106
107
107
if _ , err = os .Stat (filepath .Join (tempdir , "auxblob" )); ! os .IsNotExist (err ) {
108
108
auxblob , err = os .ReadFile (filepath .Join (tempdir , "auxblob" ))
109
109
if err != nil {
110
- return cctrusted_base .CcReport {}, errors .New ("Failed to get auxblob info." )
110
+ return evidence_api .CcReport {}, errors .New ("Failed to get auxblob info." )
111
111
}
112
112
}
113
113
114
- return cctrusted_base .CcReport {
114
+ return evidence_api .CcReport {
115
115
Outblob : outblob ,
116
116
Provider : string (provider ),
117
117
Generation : generation ,
@@ -125,18 +125,18 @@ type EventRecorder interface {
125
125
}
126
126
127
127
type CVMContext struct {
128
- VMType cctrusted_base .CC_Type
129
- Version cctrusted_base .DeviceVersion
128
+ VMType evidence_api .CC_Type
129
+ Version evidence_api .DeviceVersion
130
130
}
131
131
132
132
type ConfidentialVM interface {
133
133
Probe () error
134
134
CVMContext () CVMContext
135
135
MaxImrIndex () int
136
- DefaultAlgorithm () cctrusted_base .TCG_ALG
136
+ DefaultAlgorithm () evidence_api .TCG_ALG
137
137
Device
138
138
EventRecorder
139
- cctrusted_base .IMARecorder
139
+ evidence_api .IMARecorder
140
140
}
141
141
142
142
type CVMInitArgs struct {
0 commit comments