Skip to content

Commit

Permalink
go/common/cbor: Remove FixSliceForSerde
Browse files Browse the repository at this point in the history
We are not using serde anymore and the new Rust CBOR library does not
have a problem with decoding NULLs into empty containers.
  • Loading branch information
kostko committed Feb 9, 2023
1 parent 0c8e1fa commit 365a96c
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 18 deletions.
Empty file added .changelog/5173.trivial.md
Empty file.
9 changes: 0 additions & 9 deletions go/common/cbor/cbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions go/runtime/host/sgx/epid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions go/runtime/localstorage/localstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions go/worker/keymanager/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand Down

0 comments on commit 365a96c

Please sign in to comment.