Common utilities for HAL<->TA communication

- Definition of an `AsCborValue` trait that marks a type as serializable
  to/from CBOR.  Adapted from `system/authgraph/wire/src/cbor.rs` with
  the following differences:
   - `CborError::NonEnumValue` gets an `i32` field to indicate what the
     invalid value was.
   - Add implementation of `From<TryReserveError>` for `CborError`.
   - Add implementation of `AsCborValue` for `Vec<T : AsCborValue>`.
   - Add implementation of `AsCborValue` for `bool`.
   - Add implementation of `AsCborValue` for `i64`.
- Derive macro to automatically generate implementations of the
  `AsCborValue` trait for types.  Adapted from
  `system/authgraph/derive/` with the following differences:
   - Use types from `hal_wire::` rather than assuming the relevant
     symbols are in `use`.
   - Add `AsCborValue` derivation for newtypes (`struct` with single
     anonymous field).
- Helper code (in `mem.rs`) to deal with fallible allocation. Adapted
  from `system/authgraph/core/src/lib.rs` and
  `system/keymint/wire/src/lib.rs`.

Bug: 395084113
Test: build
Flag: EXEMPT new reference implementation, device-specific
Change-Id: I30d96406a36396d2b4a85e7f3d13e5eb2616dce4
11 files changed