From 76624bf30a035d9d183e356a3cff369b85bb8d52 Mon Sep 17 00:00:00 2001 From: Xiaocheng Dong Date: Mon, 29 Jul 2024 02:43:46 -0400 Subject: [PATCH] Rename dependency cc-trusted-api to evidence-api Signed-off-by: Xiaocheng Dong --- container/cima-example/Dockerfile | 8 +-- container/cima-perf/Dockerfile | 8 +-- sdk/golang/README.md | 14 +++--- sdk/golang/cima/client.go | 4 +- sdk/golang/cima/sdk.go | 62 ++++++++++++------------ sdk/golang/example/go-sdk-example.go | 6 +-- sdk/golang/example/go.mod | 17 +------ sdk/golang/example/go.sum | 33 ------------- sdk/python3/README.md | 2 +- sdk/python3/cima/sdk.py | 18 +++---- sdk/python3/requirements.txt | 2 +- sdk/rust/README.MD | 38 +++++++-------- sdk/rust/cima/Cargo.toml | 6 +-- sdk/rust/cima/src/client.rs | 4 +- sdk/rust/cima/src/sdk.rs | 22 ++++----- sdk/rust/example/Cargo.toml | 2 +- sdk/rust/example/src/rust-sdk-example.rs | 32 ++++++------ service/cima-server/Cargo.toml | 2 +- service/cima-server/README.md | 2 +- service/cima-server/src/agent.rs | 2 +- service/cima-server/src/container.rs | 2 +- service/cima-server/src/main.rs | 2 +- service/cima-server/src/measurement.rs | 2 +- 23 files changed, 121 insertions(+), 169 deletions(-) delete mode 100644 sdk/golang/example/go.sum diff --git a/container/cima-example/Dockerfile b/container/cima-example/Dockerfile index 14d2b28..31186f0 100644 --- a/container/cima-example/Dockerfile +++ b/container/cima-example/Dockerfile @@ -4,8 +4,8 @@ FROM python:3.12.3-alpine3.19 AS python-builder RUN apk update && apk add git RUN python3 -m pip install --upgrade build -RUN git clone https://github.com/cc-api/cc-trusted-api && \ - cd cc-trusted-api/common/python && \ +RUN git clone https://github.com/cc-api/evidence-api && \ + cd evidence-api/common/python && \ python3 -m build COPY sdk/python3 cima-sdk @@ -37,14 +37,14 @@ RUN chown $USER:$GROUP /run/cima COPY test ./ COPY sdk/python3/example/py_sdk_example.py ./ -COPY --from=python-builder cc-trusted-api/common/python/dist/cctrusted_base*.whl ./ +COPY --from=python-builder evidence-api/common/python/dist/evidence_api*.whl ./ COPY --from=python-builder cima-sdk/dist/cima*.whl ./ COPY --from=golang-builder /go/cima-sdk/example/go-sdk-example ./ COPY --from=rust-builder cima-sdk/example/target/release/rust-sdk-example ./ RUN apk update && apk add bash vim tar wget libexpat=2.6.2-r0 -RUN pip install ./cctrusted_base*.whl ./cima*.whl pytest && rm -f *.whl +RUN pip install ./evidence_api*.whl ./cima*.whl pytest && rm -f *.whl USER ${USER} ENTRYPOINT ["tail", "-f", "/dev/null"] diff --git a/container/cima-perf/Dockerfile b/container/cima-perf/Dockerfile index bdeb2ae..4b995b9 100644 --- a/container/cima-perf/Dockerfile +++ b/container/cima-perf/Dockerfile @@ -2,8 +2,8 @@ FROM python:alpine AS python-builder RUN apk update && apk add git RUN python3 -m pip install --upgrade build -RUN git clone https://github.com/cc-api/cc-trusted-api && \ - cd cc-trusted-api/common/python && \ +RUN git clone https://github.com/cc-api/evidence-api && \ + cd evidence-api/common/python && \ python3 -m build COPY sdk/python3 cima-sdk @@ -16,11 +16,11 @@ FROM python:alpine WORKDIR /run/cima COPY container/cima-perf/cima_perf.py ./ -COPY --from=python-builder cc-trusted-api/common/python/dist/cctrusted_base*.whl ./ +COPY --from=python-builder evidence-api/common/python/dist/evidence_api*.whl ./ COPY --from=python-builder cima-sdk/dist/cima*.whl ./ RUN apk update && apk add bash vim RUN python3 -m pip install pytest -RUN pip install ./cctrusted_base*.whl ./cima*.whl && rm -f *.whl +RUN pip install ./evidence_api*.whl ./cima*.whl && rm -f *.whl ENTRYPOINT ["tail", "-f", "/dev/null"] diff --git a/sdk/golang/README.md b/sdk/golang/README.md index 83bd597..4e52fa2 100644 --- a/sdk/golang/README.md +++ b/sdk/golang/README.md @@ -53,7 +53,7 @@ import ( "fmt" "os" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" + "github.com/cc-api/evidence-api/common/golang/evidence_api" "github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima" ) @@ -74,7 +74,7 @@ func testGetCCReport() { } fmt.Println("Dump the attestation report fetched.") - report.Dump(cctrusted_base.QuoteDumpFormat(cctrusted_base.QuoteDumpFormatRaw)) + report.Dump(evidence_api.QuoteDumpFormat(evidence_api.QuoteDumpFormatRaw)) } ``` @@ -96,7 +96,7 @@ import( "os" "fmt" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" + "github.com/cc-api/evidence-api/common/golang/evidence_api" "github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima" ) @@ -105,7 +105,7 @@ func testGetCCMeasurement() { // set the imr index to 0 imr_index := 0 - alg := cctrusted_base.TPM_ALG_SHA384 + alg := evidence_api.TPM_ALG_SHA384 measurement, err := sdk.GetCCMeasurement(imr_index, alg) if err != nil { @@ -135,7 +135,7 @@ import( "os" "fmt" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" + "github.com/cc-api/evidence-api/common/golang/evidence_api" "github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima" ) @@ -168,7 +168,7 @@ import( "os" "fmt" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" + "github.com/cc-api/evidence-api/common/golang/evidence_api" "github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima" ) @@ -215,4 +215,4 @@ If you encounter any bugs or have suggestions, please file an issue in the Issue [source_code]: https://github.com/cc-api/container-integrity-measurement-agent/tree/main/sdk/golang [cima_golang]: https://pkg.go.dev/github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima -[api_doc]: https://github.com/cc-api/cc-trusted-api?tab=readme-ov-file#3-apis +[api_doc]: https://github.com/cc-api/evidence-api?tab=readme-ov-file#3-apis diff --git a/sdk/golang/cima/client.go b/sdk/golang/cima/client.go index 13c2315..b893a86 100644 --- a/sdk/golang/cima/client.go +++ b/sdk/golang/cima/client.go @@ -13,8 +13,8 @@ import ( "strings" "time" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" pb "github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima/proto" + "github.com/cc-api/evidence-api/common/golang/evidence_api" "google.golang.org/grpc" ) @@ -129,7 +129,7 @@ func (cc *Client) GetMeasurementCountFromServer() (pb.GetMeasurementCountRespons return *response, nil } -func (cc *Client) GetCCMeasurementFromServer(index int, alg cctrusted_base.TCG_ALG) (pb.GetCcMeasurementResponse, error) { +func (cc *Client) GetCCMeasurementFromServer(index int, alg evidence_api.TCG_ALG) (pb.GetCcMeasurementResponse, error) { ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() diff --git a/sdk/golang/cima/sdk.go b/sdk/golang/cima/sdk.go index 5d2ae07..344fbf7 100644 --- a/sdk/golang/cima/sdk.go +++ b/sdk/golang/cima/sdk.go @@ -9,17 +9,17 @@ import ( "errors" "log" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base/tdx" + "github.com/cc-api/evidence-api/common/golang/evidence_api" + "github.com/cc-api/evidence-api/common/golang/evidence_api/tdx" ) -var _ cctrusted_base.CCTrustedAPI = (*SDK)(nil) +var _ evidence_api.EvidenceAPI = (*SDK)(nil) type SDK struct { } -// GetCCReport implements CCTrustedAPI -func (s *SDK) GetCCReport(nonce string, userData string, _ any) (cctrusted_base.Report, error) { +// GetCCReport implements EvidenceAPI +func (s *SDK) GetCCReport(nonce string, userData string, _ any) (evidence_api.Report, error) { client, err := NewClient() if err != nil { log.Fatalf("[GetCCReport] failed to connect to client with error %v", err) @@ -31,8 +31,8 @@ func (s *SDK) GetCCReport(nonce string, userData string, _ any) (cctrusted_base. return nil, err } - switch cctrusted_base.CC_Type(result.CcType) { - case cctrusted_base.TYPE_CC_TDX: + switch evidence_api.CC_Type(result.CcType) { + case evidence_api.TYPE_CC_TDX: report, err := tdx.NewTdxReportFromBytes(result.CcReport) if err != nil { return nil, err @@ -43,27 +43,27 @@ func (s *SDK) GetCCReport(nonce string, userData string, _ any) (cctrusted_base. return nil, errors.New("[GetCCReport] get CC report failed") } -// DumpCCReport implements cctrusted_base.CCTrustedAPI. +// DumpCCReport implements evidence_api.EvidenceAPI. func (s *SDK) DumpCCReport(reportBytes []byte) error { return nil } -// GetCCMeasurement implements cctrusted_base.CCTrustedAPI. -func (s *SDK) GetCCMeasurement(index int, alg cctrusted_base.TCG_ALG) (cctrusted_base.TcgDigest, error) { +// GetCCMeasurement implements evidence_api.EvidenceAPI. +func (s *SDK) GetCCMeasurement(index int, alg evidence_api.TCG_ALG) (evidence_api.TcgDigest, error) { client, err := NewClient() if err != nil { log.Fatalf("[GetCCMeasurement] failed to connect to client with error %v", err) - return cctrusted_base.TcgDigest{}, err + return evidence_api.TcgDigest{}, err } result, err := client.GetCCMeasurementFromServer(index, alg) if err != nil { - return cctrusted_base.TcgDigest{}, err + return evidence_api.TcgDigest{}, err } - return cctrusted_base.TcgDigest{AlgID: cctrusted_base.TCG_ALG(result.Measurement.AlgoId), Hash: result.Measurement.Hash}, nil + return evidence_api.TcgDigest{AlgID: evidence_api.TCG_ALG(result.Measurement.AlgoId), Hash: result.Measurement.Hash}, nil } -// GetMeasurementCount implements cctrusted_base.CCTrustedAPI. +// GetMeasurementCount implements evidence_api.EvidenceAPI. func (s *SDK) GetMeasurementCount() (int, error) { client, err := NewClient() if err != nil { @@ -78,28 +78,28 @@ func (s *SDK) GetMeasurementCount() (int, error) { return int(result.Count), nil } -// ReplayCCEventLog implements cctrusted_base.CCTrustedAPI. -func (s *SDK) ReplayCCEventLog(formatedEventLogs []cctrusted_base.FormatedTcgEvent) map[int]map[cctrusted_base.TCG_ALG][]byte { - return cctrusted_base.ReplayFormatedEventLog(formatedEventLogs) +// ReplayCCEventLog implements evidence_api.EvidenceAPI. +func (s *SDK) ReplayCCEventLog(formatedEventLogs []evidence_api.FormatedTcgEvent) map[int]map[evidence_api.TCG_ALG][]byte { + return evidence_api.ReplayFormatedEventLog(formatedEventLogs) } -// GetDefaultAlgorithm implements cctrusted_base.CCTrustedAPI. -func (s *SDK) GetDefaultAlgorithm() (cctrusted_base.TCG_ALG, error) { +// GetDefaultAlgorithm implements evidence_api.EvidenceAPI. +func (s *SDK) GetDefaultAlgorithm() (evidence_api.TCG_ALG, error) { client, err := NewClient() if err != nil { log.Fatalf("[GetDefaultAlgorithm] failed to connect to client with error %v", err) - return cctrusted_base.TPM_ALG_ERROR, err + return evidence_api.TPM_ALG_ERROR, err } result, err := client.GetDefaultAlgorithmFromServer() if err != nil { - return cctrusted_base.TPM_ALG_ERROR, err + return evidence_api.TPM_ALG_ERROR, err } - return cctrusted_base.TCG_ALG(result.AlgoId), nil + return evidence_api.TCG_ALG(result.AlgoId), nil } -// GetCCEventlog implements CCTrustedAPI. -func (s *SDK) GetCCEventLog(params ...int32) ([]cctrusted_base.FormatedTcgEvent, error) { +// GetCCEventlog implements EvidenceAPI. +func (s *SDK) GetCCEventLog(params ...int32) ([]evidence_api.FormatedTcgEvent, error) { if len(params) > 2 { log.Fatalf("Invalid params specified for [GetCCEventlog].") return nil, errors.New("Invalid params.") @@ -116,19 +116,19 @@ func (s *SDK) GetCCEventLog(params ...int32) ([]cctrusted_base.FormatedTcgEvent, return nil, err } - formatted_log_list := make([]cctrusted_base.FormatedTcgEvent, len(result)) + formatted_log_list := make([]evidence_api.FormatedTcgEvent, len(result)) for idx, log := range result { - digests := make([]cctrusted_base.TcgDigest, len(log.Digests)) + digests := make([]evidence_api.TcgDigest, len(log.Digests)) for idx, digest := range log.Digests { - formattedData := cctrusted_base.TcgDigest{AlgID: cctrusted_base.TCG_ALG(digest.AlgoId), Hash: digest.Hash} + formattedData := evidence_api.TcgDigest{AlgID: evidence_api.TCG_ALG(digest.AlgoId), Hash: digest.Hash} digests[idx] = formattedData } - logParser := cctrusted_base.TcgEventLogParser{RecNum: int(log.RecNum), ImrIndex: int(log.ImrIndex), EventType: cctrusted_base.TcgEventType(log.EventType), Digests: digests, EventSize: int(log.EventSize), Event: log.Event, ExtraInfo: log.ExtraInfo} - if cctrusted_base.TcgEventType(log.EventType) != cctrusted_base.IMA_MEASUREMENT_EVENT { - formattedLog := logParser.Format(cctrusted_base.TCG_PCCLIENT_FORMAT) + logParser := evidence_api.TcgEventLogParser{RecNum: int(log.RecNum), ImrIndex: int(log.ImrIndex), EventType: evidence_api.TcgEventType(log.EventType), Digests: digests, EventSize: int(log.EventSize), Event: log.Event, ExtraInfo: log.ExtraInfo} + if evidence_api.TcgEventType(log.EventType) != evidence_api.IMA_MEASUREMENT_EVENT { + formattedLog := logParser.Format(evidence_api.TCG_PCCLIENT_FORMAT) formatted_log_list[idx] = formattedLog } else { - formattedLog := logParser.Format(cctrusted_base.TCG_PCCLIENT_FORMAT) + formattedLog := logParser.Format(evidence_api.TCG_PCCLIENT_FORMAT) formatted_log_list[idx] = formattedLog } } diff --git a/sdk/golang/example/go-sdk-example.go b/sdk/golang/example/go-sdk-example.go index 92acf88..407bc2b 100644 --- a/sdk/golang/example/go-sdk-example.go +++ b/sdk/golang/example/go-sdk-example.go @@ -8,8 +8,8 @@ import ( "math/rand" "os" - "github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base" "github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima" + "github.com/cc-api/evidence-api/common/golang/evidence_api" ) // func to test GetCCReport() @@ -30,7 +30,7 @@ func testGetCCReport(sdk cima.SDK, logger *log.Logger) { } logger.Println("Dump the attestation report fetched.") - report.Dump(cctrusted_base.QuoteDumpFormat(cctrusted_base.QuoteDumpFormatRaw)) + report.Dump(evidence_api.QuoteDumpFormat(evidence_api.QuoteDumpFormatRaw)) logger.Println("----------------------------------------------------------------------------------") } @@ -39,7 +39,7 @@ func testGetCCMeasurement(sdk cima.SDK, logger *log.Logger) { logger.Println("Call [GetCCMeasurement] to fetch measurement for specific IMR[0]...") imr_index := 0 - alg := cctrusted_base.TPM_ALG_SHA384 + alg := evidence_api.TPM_ALG_SHA384 measurement, err := sdk.GetCCMeasurement(imr_index, alg) if err != nil { diff --git a/sdk/golang/example/go.mod b/sdk/golang/example/go.mod index aeff8e3..5adeec7 100644 --- a/sdk/golang/example/go.mod +++ b/sdk/golang/example/go.mod @@ -1,18 +1,3 @@ module example.com/sdk -go 1.22.1 - -require ( - github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base v0.0.0-20240401053915-fe5bfeadd509 - github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima v0.0.0-20240401063131-998a393b583a -) - -require ( - github.com/golang/protobuf v1.5.3 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/grpc v1.62.1 // indirect - google.golang.org/protobuf v1.33.0 // indirect -) +go 1.20 diff --git a/sdk/golang/example/go.sum b/sdk/golang/example/go.sum deleted file mode 100644 index a80b7bb..0000000 --- a/sdk/golang/example/go.sum +++ /dev/null @@ -1,33 +0,0 @@ -github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base v0.0.0-20240401053915-fe5bfeadd509 h1:Odnr+9Sponu6x5rANn7kAvdF288lcOa/0QQzlhKkfKQ= -github.com/cc-api/cc-trusted-api/common/golang/cctrusted_base v0.0.0-20240401053915-fe5bfeadd509/go.mod h1:0rggJ3Z7AxSCbOfi2PBO98sAftWWsI39V7v/aG9xPmQ= -github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima v0.0.0-20240401063131-998a393b583a h1:1Z+zoOsY6ma58Vn9RgNidXP/tENPIz9LCM//3Hv19Io= -github.com/cc-api/container-integrity-measurement-agent/sdk/golang/cima v0.0.0-20240401063131-998a393b583a/go.mod h1:PtDzCV0SF6ZI4ofmi07gsjFL6kPpxxZMkt+Uab6kqBM= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/python3/README.md b/sdk/python3/README.md index 8d1b813..447fc3c 100644 --- a/sdk/python3/README.md +++ b/sdk/python3/README.md @@ -159,4 +159,4 @@ If you encounter any bugs or have suggestions, please file an issue in the Issue [source_code]: https://github.com/cc-api/container-integrity-measurement-agent/tree/main/sdk/python3 [cima_pypi]: https://pypi.org/project/cima/ -[api_doc]: https://github.com/cc-api/cc-trusted-api?tab=readme-ov-file#3-apis +[api_doc]: https://github.com/cc-api/evidence-api?tab=readme-ov-file#3-apis diff --git a/sdk/python3/cima/sdk.py b/sdk/python3/cima/sdk.py index d56f5df..1371639 100644 --- a/sdk/python3/cima/sdk.py +++ b/sdk/python3/cima/sdk.py @@ -10,13 +10,13 @@ from typing import Optional import grpc -from cctrusted_base.api import CCTrustedApi -from cctrusted_base.ccreport import CcReport -from cctrusted_base.tcg import TcgAlgorithmRegistry -from cctrusted_base.tcg import TcgDigest -from cctrusted_base.tcg import TcgImrEvent -from cctrusted_base.tcg import TcgPcClientImrEvent -from cctrusted_base.tdx.quote import TdxQuote +from evidence_api.api import EvidenceApi +from evidence_api.ccreport import CcReport +from evidence_api.tcg import TcgAlgorithmRegistry +from evidence_api.tcg import TcgDigest +from evidence_api.tcg import TcgImrEvent +from evidence_api.tcg import TcgPcClientImrEvent +from evidence_api.tdx.quote import TdxQuote # pylint: disable=E1101 from cima import cima_server_pb2 from cima import cima_server_pb2_grpc @@ -26,7 +26,7 @@ # Default gRPC timeout TIMEOUT = 60 -class CimaSdk(CCTrustedApi): +class CimaSdk(EvidenceApi): """CIMA SDK class This class is a client to connect to CIMA Server and do gRPC call getting the @@ -193,7 +193,7 @@ def get_cc_report( LOG.error("CIMA service response is not correct.") return None - if resp.cc_type == CCTrustedApi.TYPE_CC_TDX: + if resp.cc_type == EvidenceApi.TYPE_CC_TDX: return TdxQuote(resp.cc_report) LOG.error("The SDK does not support %s yet", resp.cc_type) diff --git a/sdk/python3/requirements.txt b/sdk/python3/requirements.txt index aa2d607..9447f28 100644 --- a/sdk/python3/requirements.txt +++ b/sdk/python3/requirements.txt @@ -1,4 +1,4 @@ -cctrusted_base +evidence_api grpcio-tools grpcio protobuf diff --git a/sdk/rust/README.MD b/sdk/rust/README.MD index 34f1e1f..7594278 100644 --- a/sdk/rust/README.MD +++ b/sdk/rust/README.MD @@ -44,10 +44,10 @@ Here are the example usages of the SDK: * Fetch report with a `nonce` and `user_data` ```rust -use cctrusted_base::api::*; -use cctrusted_base::api_data::*; -use cctrusted_base::cc_type::TeeType; -use cctrusted_base::tdx::quote::TdxQuote; +use evidence_api::api::*; +use evidence_api::api_data::*; +use evidence_api::cc_type::TeeType; +use evidence_api::tdx::quote::TdxQuote; use cima::sdk::API; use log::*; use rand::Rng; @@ -62,7 +62,7 @@ fn get_cc_report() { let data = base64::encode(rand::thread_rng().gen::<[u8; 32]>()); // retrieve cc report with API "get_cc_report" - info!("call cc trusted API [get_cc_report] to retrieve cc report with nonce and data!"); + info!("call evidence API [get_cc_report] to retrieve cc report with nonce and data!"); let report = match API::get_cc_report(Some(nonce), Some(data), ExtraArgs {}) { Ok(q) => q, Err(e) => { @@ -74,7 +74,7 @@ fn get_cc_report() { info!("length of the cc report: {}", report.cc_report.len()); // dump the cc report with API "dump_cc_report" - //info!("call cc trusted API [dump_cc_report] to dump cc report!"); + //info!("call evidence API [dump_cc_report] to dump cc report!"); //API::dump_cc_report(&report.cc_report); // parse the cc report with API "parse_cc_report" @@ -98,7 +98,7 @@ fn get_cc_report() { } // retrieve cc report with API "get_cc_report" - info!("call cc trusted API [get_cc_report] to retrieve cc report with no nonce and data!"); + info!("call evidence API [get_cc_report] to retrieve cc report with no nonce and data!"); let report1 = match API::get_cc_report(None, None, ExtraArgs {}) { Ok(q) => q, Err(e) => { @@ -145,15 +145,15 @@ Here are the example usages for measurement SDK: * Fetch TEE measurement of the current pod(Fetch measurements of all IMR index) ```rust -use cctrusted_base::api::*; -use cctrusted_base::api_data::*; -use cctrusted_base::tcg::TcgAlgorithmRegistry; +use evidence_api::api::*; +use evidence_api::api_data::*; +use evidence_api::tcg::TcgAlgorithmRegistry; use cima::sdk::API; use log::*; fn get_cc_measurement() { // get default algorithm with API "get_default_algorithm" - info!("call cc trusted API [get_default_algorithm] to get supported algorithm!"); + info!("call evidence API [get_default_algorithm] to get supported algorithm!"); let defalt_algo = match API::get_default_algorithm() { Ok(algorithm) => { info!("supported algorithm: {}", algorithm.algo_id_str); @@ -166,7 +166,7 @@ fn get_cc_measurement() { }; // get number of measurement registers - info!("call cc trusted API [get_measurement_count] to get number of measurement registers!"); + info!("call evidence API [get_measurement_count] to get number of measurement registers!"); let _count = match API::get_measurement_count() { Ok(count) => { info!("measurement registers count: {}", count); @@ -179,7 +179,7 @@ fn get_cc_measurement() { }; // retrive and show measurement registers - info!("call cc trusted API [get_cc_measurement] to get measurement register content!"); + info!("call evidence API [get_cc_measurement] to get measurement register content!"); for index in [0, 1, 3] { let tcg_digest = match API::get_cc_measurement(index, defalt_algo.algo_id) { Ok(tcg_digest) => tcg_digest, @@ -210,14 +210,14 @@ Here are the example usages of the SDK: * Fetch event log of platform and check the information inside, then replay event logs ```rust -use cctrusted_base::api::*; -use cctrusted_base::api_data::*; +use evidence_api::api::*; +use evidence_api::api_data::*; use cima::sdk::API; use log::*; fn get_cc_eventlog() { // retrieve cc eventlog with API "get_cc_eventlog" - info!("call cc trusted API [get_cc_eventlog] to get container related eventlog without count!"); + info!("call evidence API [get_cc_eventlog] to get container related eventlog without count!"); let eventlogs1 = match API::get_cc_eventlog(Some(0), None) { Ok(q) => q, Err(e) => { @@ -229,7 +229,7 @@ fn get_cc_eventlog() { info!("container event log count: {}", eventlogs1.len()); // retrieve cc eventlog with API "get_cc_eventlog" - info!("call cc trusted API [get_cc_eventlog] to get container related eventlog with count number!"); + info!("call evidence API [get_cc_eventlog] to get container related eventlog with count number!"); let eventlogs = match API::get_cc_eventlog(Some(0), Some(101)) { Ok(q) => q, Err(e) => { @@ -244,7 +244,7 @@ fn get_cc_eventlog() { } // replay cc eventlog with API "replay_cc_eventlog" - info!("call cc trusted API [replay_cc_eventlog] to replay container related eventlog!"); + info!("call evidence API [replay_cc_eventlog] to replay container related eventlog!"); let replay_results = match API::replay_cc_eventlog(eventlogs) { Ok(q) => q, Err(e) => { @@ -284,4 +284,4 @@ If you encounter any bugs or have suggestions, please file an issue in the Issue [source_code]: https://github.com/cc-api/container-integrity-measurement-agent/tree/main/sdk/rust -[api_doc]: https://github.com/cc-api/cc-trusted-api?tab=readme-ov-file#3-apis +[api_doc]: https://github.com/cc-api/evidence-api?tab=readme-ov-file#3-apis diff --git a/sdk/rust/cima/Cargo.toml b/sdk/rust/cima/Cargo.toml index e3f9a14..07f5505 100644 --- a/sdk/rust/cima/Cargo.toml +++ b/sdk/rust/cima/Cargo.toml @@ -3,8 +3,8 @@ name = "cima" version = "0.1.0" edition = "2021" authors = ["Chen Hairong "] -repository = "https://github.com/cc-api/cc-trusted-api" -description = "CC Trusted API CIMA SDK" +repository = "https://github.com/cc-api/evidence-api" +description = "Evidence API CIMA SDK" license = "Apache-2.0" [lib] @@ -12,7 +12,7 @@ name = "cima" path = "src/lib.rs" [dependencies] -cctrusted_base = { git="https://github.com/cc-api/cc-trusted-api" } +evidence_api = { git="https://github.com/cc-api/evidence-api" } anyhow = "1.0" log = "0.4.20" tonic = "0.11" diff --git a/sdk/rust/cima/src/client.rs b/sdk/rust/cima/src/client.rs index 9c3cfea..417614c 100644 --- a/sdk/rust/cima/src/client.rs +++ b/sdk/rust/cima/src/client.rs @@ -4,8 +4,8 @@ use crate::client::cima_server_pb::{ GetDefaultAlgorithmResponse, GetMeasurementCountRequest, GetMeasurementCountResponse, }; use anyhow::anyhow; -use cctrusted_base::api_data::ExtraArgs; -use cctrusted_base::cc_type::TeeType; +use evidence_api::api_data::ExtraArgs; +use evidence_api::cc_type::TeeType; use core::result::Result::Ok; use hashbrown::HashMap; use std::fs::read_to_string; diff --git a/sdk/rust/cima/src/sdk.rs b/sdk/rust/cima/src/sdk.rs index f43e521..ecb6e22 100644 --- a/sdk/rust/cima/src/sdk.rs +++ b/sdk/rust/cima/src/sdk.rs @@ -1,17 +1,17 @@ use crate::client::CimaServiceClient; use anyhow::*; -use cctrusted_base::api::CCTrustedApi; -use cctrusted_base::api_data::{Algorithm, CcReport, ExtraArgs}; -use cctrusted_base::binary_blob::dump_data; -use cctrusted_base::tcg::*; +use evidence_api::api::EvidenceApi; +use evidence_api::api_data::{Algorithm, CcReport, ExtraArgs}; +use evidence_api::binary_blob::dump_data; +use evidence_api::tcg::*; use core::result::Result::Ok; const UDS_PATH: &str = "/run/cima/uds/cima-server.sock"; pub struct API {} -impl CCTrustedApi for API { - // CCTrustedApi trait function: get cc report from CIMA server +impl EvidenceApi for API { + // EvidenceApi trait function: get cc report from CIMA server fn get_cc_report( nonce: Option, data: Option, @@ -36,12 +36,12 @@ impl CCTrustedApi for API { }) } - // CCTrustedApi trait function: dump report of in hex and char format + // EvidenceApi trait function: dump report of in hex and char format fn dump_cc_report(report: &Vec) { dump_data(report) } - // CCTrustedApi trait function: get max number of IMRs + // EvidenceApi trait function: get max number of IMRs fn get_measurement_count() -> Result { let mut cima_service_client = CimaServiceClient { cima_uds_path: UDS_PATH.to_string(), @@ -60,7 +60,7 @@ impl CCTrustedApi for API { Ok(response.count.try_into().unwrap()) } - // CCTrustedApi trait function: get measurements + // EvidenceApi trait function: get measurements fn get_cc_measurement(index: u8, algo_id: u16) -> Result { let mut cima_service_client = CimaServiceClient { cima_uds_path: UDS_PATH.to_string(), @@ -87,7 +87,7 @@ impl CCTrustedApi for API { }) } - // CCTrustedApi trait function: get eventlogs + // EvidenceApi trait function: get eventlogs fn get_cc_eventlog( start: Option, count: Option, @@ -135,7 +135,7 @@ impl CCTrustedApi for API { Ok(event_logs) } - // CCTrustedApi trait function: get default algorithm + // EvidenceApi trait function: get default algorithm fn get_default_algorithm() -> Result { let mut cima_service_client = CimaServiceClient { cima_uds_path: UDS_PATH.to_string(), diff --git a/sdk/rust/example/Cargo.toml b/sdk/rust/example/Cargo.toml index fd0a3e6..48b4732 100644 --- a/sdk/rust/example/Cargo.toml +++ b/sdk/rust/example/Cargo.toml @@ -10,7 +10,7 @@ path = "src/rust-sdk-example.rs" [dependencies] cima = { path = "../cima" } -cctrusted_base = { git="https://github.com/cc-api/cc-trusted-api" } +evidence_api = { git="https://github.com/cc-api/evidence-api" } anyhow = "1.0" log = "0.4.20" env_logger = "0.10.1" diff --git a/sdk/rust/example/src/rust-sdk-example.rs b/sdk/rust/example/src/rust-sdk-example.rs index 681efd8..f9cf747 100644 --- a/sdk/rust/example/src/rust-sdk-example.rs +++ b/sdk/rust/example/src/rust-sdk-example.rs @@ -1,9 +1,9 @@ -use cctrusted_base::api::*; -use cctrusted_base::api_data::*; -use cctrusted_base::cc_type::TeeType; -use cctrusted_base::tcg::EventLogEntry; -use cctrusted_base::tcg::TcgAlgorithmRegistry; -use cctrusted_base::tdx::quote::TdxQuote; +use evidence_api::api::*; +use evidence_api::api_data::*; +use evidence_api::cc_type::TeeType; +use evidence_api::tcg::EventLogEntry; +use evidence_api::tcg::TcgAlgorithmRegistry; +use evidence_api::tdx::quote::TdxQuote; use cima::sdk::API; use log::*; use rand::Rng; @@ -18,7 +18,7 @@ fn get_cc_report() { let data = base64::encode(rand::thread_rng().gen::<[u8; 32]>()); // retrieve cc report with API "get_cc_report" - info!("call cc trusted API [get_cc_report] to retrieve cc report with nonce and data!"); + info!("call evidence API [get_cc_report] to retrieve cc report with nonce and data!"); let report = match API::get_cc_report(Some(nonce), Some(data), ExtraArgs {}) { Ok(q) => q, Err(e) => { @@ -30,7 +30,7 @@ fn get_cc_report() { info!("length of the cc report: {}", report.cc_report.len()); // dump the cc report with API "dump_cc_report" - //info!("call cc trusted API [dump_cc_report] to dump cc report!"); + //info!("call evidence API [dump_cc_report] to dump cc report!"); //API::dump_cc_report(&report.cc_report); // parse the cc report with API "parse_cc_report" @@ -54,7 +54,7 @@ fn get_cc_report() { } // retrieve cc report with API "get_cc_report" - info!("call cc trusted API [get_cc_report] to retrieve cc report with no nonce and data!"); + info!("call evidence API [get_cc_report] to retrieve cc report with no nonce and data!"); let report1 = match API::get_cc_report(None, None, ExtraArgs {}) { Ok(q) => q, Err(e) => { @@ -88,7 +88,7 @@ fn get_cc_report() { fn get_cc_measurement() { // get default algorithm with API "get_default_algorithm" - info!("call cc trusted API [get_default_algorithm] to get supported algorithm!"); + info!("call evidence API [get_default_algorithm] to get supported algorithm!"); let defalt_algo = match API::get_default_algorithm() { Ok(algorithm) => { info!("supported algorithm: {}", algorithm.algo_id_str); @@ -101,7 +101,7 @@ fn get_cc_measurement() { }; // get number of measurement registers - info!("call cc trusted API [get_measurement_count] to get number of measurement registers!"); + info!("call evidence API [get_measurement_count] to get number of measurement registers!"); let _count = match API::get_measurement_count() { Ok(count) => { info!("measurement registers count: {}", count); @@ -114,7 +114,7 @@ fn get_cc_measurement() { }; // retrive and show measurement registers - info!("call cc trusted API [get_cc_measurement] to get measurement register content!"); + info!("call evidence API [get_cc_measurement] to get measurement register content!"); for index in [0, 1, 3] { let tcg_digest = match API::get_cc_measurement(index, defalt_algo.algo_id) { Ok(tcg_digest) => tcg_digest, @@ -134,7 +134,7 @@ fn get_cc_measurement() { fn get_cc_eventlog() { // retrieve cc eventlog with API "get_cc_eventlog" - info!("call cc trusted API [get_cc_eventlog] to get container related eventlog without count!"); + info!("call evidence API [get_cc_eventlog] to get container related eventlog without count!"); let eventlogs1 = match API::get_cc_eventlog(Some(0), None) { Ok(q) => q, Err(e) => { @@ -146,7 +146,7 @@ fn get_cc_eventlog() { info!("container event log count: {}", eventlogs1.len()); // retrieve cc eventlog with API "get_cc_eventlog" - info!("call cc trusted API [get_cc_eventlog] to get container related eventlog with count number!"); + info!("call evidence API [get_cc_eventlog] to get container related eventlog with count number!"); let eventlogs = match API::get_cc_eventlog(Some(0), Some(101)) { Ok(q) => q, Err(e) => { @@ -161,7 +161,7 @@ fn get_cc_eventlog() { // } // retrieve cc eventlog in batch - info!("call cc trusted API [get_cc_eventlog] to get container related eventlog in 10 batches!"); + info!("call evidence API [get_cc_eventlog] to get container related eventlog in 10 batches!"); let mut eventlogs2: Vec = Vec::new(); let mut start = 0; let batch_size = (eventlogs1.len() / 10) as u32; @@ -187,7 +187,7 @@ fn get_cc_eventlog() { info!("event log count: {}", eventlogs2.len()); // replay cc eventlog with API "replay_cc_eventlog" - info!("call cc trusted API [replay_cc_eventlog] to replay container related eventlog!"); + info!("call evidence API [replay_cc_eventlog] to replay container related eventlog!"); let replay_results = match API::replay_cc_eventlog(eventlogs) { Ok(q) => q, Err(e) => { diff --git a/service/cima-server/Cargo.toml b/service/cima-server/Cargo.toml index 7e72642..efcc8f7 100644 --- a/service/cima-server/Cargo.toml +++ b/service/cima-server/Cargo.toml @@ -22,7 +22,7 @@ tonic-reflection = "0.9.2" tonic-health = "0.9.2" lazy_static = "1.4.0" cctrusted_vm = { git="https://github.com/cc-api/cc-trusted-vmsdk.git", branch = "main" } -cctrusted_base = { git="https://github.com/cc-api/cc-trusted-api.git", branch = "main" } +evidence_api = { git="https://github.com/cc-api/evidence-api.git", branch = "main" } env_logger = "0.10.1" regex = "1.10.3" serde = { version = "1.0", features = ["derive"] } diff --git a/service/cima-server/README.md b/service/cima-server/README.md index 71e6ab3..f85f4d6 100644 --- a/service/cima-server/README.md +++ b/service/cima-server/README.md @@ -1,6 +1,6 @@ # CIMA Service -This service will provide CC event log/CC measurement/CC report by [CC Trusted API](https://github.com/cc-api/cc-trusted-api) for remote attestation service to verify the integrity and confidentiality of the trusted computing environment and required software environment. +This service will provide CC event log/CC measurement/CC report by [Evidence API](https://github.com/cc-api/evidence-api) for remote attestation service to verify the integrity and confidentiality of the trusted computing environment and required software environment. ## Start Service diff --git a/service/cima-server/src/agent.rs b/service/cima-server/src/agent.rs index db29493..571d792 100644 --- a/service/cima-server/src/agent.rs +++ b/service/cima-server/src/agent.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, Error}; -use cctrusted_base::{api::CCTrustedApi, api_data::ExtraArgs, tcg}; +use evidence_api::{api::EvidenceApi, api_data::ExtraArgs, tcg}; use cctrusted_vm::sdk::API; use log::info; use std::cmp::Ordering; diff --git a/service/cima-server/src/container.rs b/service/cima-server/src/container.rs index 1aef018..fbe885c 100644 --- a/service/cima-server/src/container.rs +++ b/service/cima-server/src/container.rs @@ -1,6 +1,6 @@ use crate::cima_pb::{TcgDigest, TcgEventlog}; use anyhow::{anyhow, Error}; -use cctrusted_base::tcg; +use evidence_api::tcg; use openssl::hash::{Hasher, MessageDigest}; use regex::Regex; diff --git a/service/cima-server/src/main.rs b/service/cima-server/src/main.rs index 3995695..336a594 100644 --- a/service/cima-server/src/main.rs +++ b/service/cima-server/src/main.rs @@ -80,7 +80,7 @@ async fn main() -> Result<(), Box> { mod cima_server_test { use super::*; use crate::agent::IMR; - use cctrusted_base::{cc_type::TeeType, tcg}; + use evidence_api::{cc_type::TeeType, tcg}; use cima_pb::{ cima_client::CimaClient, GetCcEventlogRequest, GetCcMeasurementRequest, GetCcReportRequest, }; diff --git a/service/cima-server/src/measurement.rs b/service/cima-server/src/measurement.rs index e24d091..b17818b 100644 --- a/service/cima-server/src/measurement.rs +++ b/service/cima-server/src/measurement.rs @@ -1,5 +1,5 @@ use anyhow::Error; -use cctrusted_base::tcg; +use evidence_api::tcg; use openssl::hash::Hasher; use regex::Regex; use std::collections::HashMap;