From 365a96c0aa2778c5d6d9260cbd3c7df3942cb9de Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Thu, 9 Feb 2023 09:53:09 +0100 Subject: [PATCH] go/common/cbor: Remove FixSliceForSerde We are not using serde anymore and the new Rust CBOR library does not have a problem with decoding NULLs into empty containers. --- .changelog/5173.trivial.md | 0 go/common/cbor/cbor.go | 9 --------- go/runtime/host/sgx/epid.go | 5 ----- go/runtime/localstorage/localstorage.go | 3 +-- go/worker/keymanager/worker.go | 4 ++-- 5 files changed, 3 insertions(+), 18 deletions(-) create mode 100644 .changelog/5173.trivial.md diff --git a/.changelog/5173.trivial.md b/.changelog/5173.trivial.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/go/common/cbor/cbor.go b/go/common/cbor/cbor.go index 90ffdd73c7b..971047e973f 100644 --- a/go/common/cbor/cbor.go +++ b/go/common/cbor/cbor.go @@ -71,15 +71,6 @@ func init() { } } -// FixSliceForSerde will convert `nil` to `[]byte` to work around serde -// brain damage. -func FixSliceForSerde(b []byte) []byte { - if b != nil { - return b - } - return []byte{} -} - // Marshal serializes a given type into a CBOR byte vector. func Marshal(src interface{}) []byte { b, err := encMode.Marshal(src) diff --git a/go/runtime/host/sgx/epid.go b/go/runtime/host/sgx/epid.go index d04ea18dc38..e149f5b4184 100644 --- a/go/runtime/host/sgx/epid.go +++ b/go/runtime/host/sgx/epid.go @@ -55,7 +55,6 @@ func (ep *teeStateEPID) Update(ctx context.Context, sp *sgxProvisioner, conn pro if err != nil { return nil, fmt.Errorf("error while requesting SigRL: %w", err) } - sigRL = cbor.FixSliceForSerde(sigRL) quote, err := sp.aesm.GetQuote( ctx, @@ -80,10 +79,6 @@ func (ep *teeStateEPID) Update(ctx context.Context, sp *sgxProvisioner, conn pro return nil, fmt.Errorf("error while verifying attestation evidence: %w", err) } - avrBundle.Body = cbor.FixSliceForSerde(avrBundle.Body) - avrBundle.CertificateChain = cbor.FixSliceForSerde(avrBundle.CertificateChain) - avrBundle.Signature = cbor.FixSliceForSerde(avrBundle.Signature) - // Prepare quote structure. q := sgxQuote.Quote{ IAS: avrBundle, diff --git a/go/runtime/localstorage/localstorage.go b/go/runtime/localstorage/localstorage.go index 1630e2eb14b..dea8f7f5cbb 100644 --- a/go/runtime/localstorage/localstorage.go +++ b/go/runtime/localstorage/localstorage.go @@ -13,7 +13,6 @@ import ( "github.com/oasisprotocol/oasis-core/go/common" cmnBadger "github.com/oasisprotocol/oasis-core/go/common/badger" - "github.com/oasisprotocol/oasis-core/go/common/cbor" "github.com/oasisprotocol/oasis-core/go/common/logging" ) @@ -70,7 +69,7 @@ func (s *localStorage) Get(key []byte) ([]byte, error) { return nil, err } - return cbor.FixSliceForSerde(value), nil + return value, nil } func (s *localStorage) Set(key, value []byte) error { diff --git a/go/worker/keymanager/worker.go b/go/worker/keymanager/worker.go index ad4e63bb8b3..833b3cde9ae 100644 --- a/go/worker/keymanager/worker.go +++ b/go/worker/keymanager/worker.go @@ -253,8 +253,8 @@ func (w *Worker) updateStatus(status *api.Status, runtimeStatus *runtimeStatus) call := InitCall{ Method: "init", Args: InitRequest{ - Checksum: cbor.FixSliceForSerde(status.Checksum), - Policy: cbor.FixSliceForSerde(policy), + Checksum: status.Checksum, + Policy: policy, MayGenerate: w.mayGenerate, }, }