fido-device-onboard / go-fdo

A FIDO Device Onboard library with minimal dependencies
Apache License 2.0
15 stars 5 forks source link

Fix for CBOR encoding of embedded/nested struct fields on arm32 #9

Closed shivakumargurija closed 1 month ago

shivakumargurija commented 1 month ago

Fix for Defect https://github.com/fido-device-onboard/go-fdo/issues/6

Marshalling and unmarshalling of CBOR data works as expected for arm32-v5 platform. Saving blob.DeviceCredential to file and reading works as expected with this fix.

Added a test case in cbor_test.go to demonstrate the defect. It marshals & unmarshals only last field of the embedded struct correctly.

Test output on arm32:

> GOARCH=arm GOARM=5 go test -c -o test.arm32 ./cbor
> qemu-arm ./test.arm32
PASS

Test output on x86:

> go test -c -o test ./cbor
> ./test
PASS
shivakumargurija commented 1 month ago

Please refer to the failing test case in cbor_test.go

> GOARCH=arm GOARM=5 go test -c -o test.arm32 ./cbor
> qemu-arm ./test.arm32
--- FAIL: TestEmbeddedStruct (0.00s)
    cbor_test.go:2142: Unexpected B value in embedded struct. Expected: , Received:test
    cbor_test.go:2147: Unexpected C value in embedded struct. Expected: [], Received:[12 13 14 15]
FAIL
> go test -c -o test ./cbor
> ./test
PASS
ben-krieger commented 1 month ago

Replaced by #15 (since I can't push to your branch). I made you commit author @shivakumargurija. Thank you for the amazing find!