@@ -147,21 +147,18 @@ impl Attestation {
147147 }
148148 }
149149
150- pub fn to_cbor ( & self ) -> Result < Vec < u8 > > {
150+ pub fn to_msgpack ( & self ) -> Result < Vec < u8 > > {
151151 let mut normalized = self . clone ( ) ;
152152 normalized. version = ATTESTATION_VERSION ;
153- let mut bytes = Vec :: new ( ) ;
154- ciborium:: into_writer ( & normalized, & mut bytes)
155- . context ( "Failed to encode attestation as CBOR" ) ?;
156- Ok ( bytes)
153+ rmp_serde:: to_vec_named ( & normalized) . context ( "failed to encode attestation as msgpack" )
157154 }
158155
159- pub fn from_cbor ( bytes : & [ u8 ] ) -> Result < Self > {
156+ pub fn from_msgpack ( bytes : & [ u8 ] ) -> Result < Self > {
160157 let value: Self =
161- ciborium :: from_reader ( bytes) . context ( "Failed to decode attestation from CBOR " ) ?;
158+ rmp_serde :: from_slice ( bytes) . context ( "failed to decode attestation from msgpack " ) ?;
162159 if value. version != ATTESTATION_VERSION {
163160 bail ! (
164- "Unsupported attestation version: expected {}, got {}" ,
161+ "unsupported attestation version: expected {}, got {}" ,
165162 ATTESTATION_VERSION ,
166163 value. version
167164 ) ;
@@ -199,7 +196,7 @@ mod tests {
199196 use super :: * ;
200197
201198 #[ test]
202- fn cbor_roundtrip_preserves_attestation ( ) {
199+ fn msgpack_roundtrip_preserves_attestation ( ) {
203200 let attestation = Attestation :: new (
204201 PlatformEvidence :: Tdx {
205202 quote : vec ! [ 1u8 , 2 , 3 ] ,
@@ -222,9 +219,9 @@ mod tests {
222219 } ,
223220 ) ;
224221
225- let encoded = attestation. to_cbor ( ) . expect ( "encode cbor " ) ;
226- assert ! ( matches!( encoded. first( ) , Some ( 0xa0 ..=0xbf ) ) ) ;
227- let decoded = Attestation :: from_cbor ( & encoded) . expect ( "decode cbor " ) ;
222+ let encoded = attestation. to_msgpack ( ) . expect ( "encode msgpack " ) ;
223+ assert ! ( matches!( encoded. first( ) , Some ( 0x80 ..=0x8f ) ) ) ;
224+ let decoded = Attestation :: from_msgpack ( & encoded) . expect ( "decode msgpack " ) ;
228225 assert_eq ! ( decoded. version, ATTESTATION_VERSION ) ;
229226 match decoded. platform {
230227 PlatformEvidence :: Tdx { quote, event_log } => {
0 commit comments