Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not Deserialize Quote #37

Closed
batyrchary opened this issue Jun 13, 2019 · 1 comment
Closed

Can not Deserialize Quote #37

batyrchary opened this issue Jun 13, 2019 · 1 comment

Comments

@batyrchary
Copy link

Hello,

I am trying to Serialize Quote and send it to remote party and Deserialize it on remote party.

So currently I am just trying to Serialize and Deserialize Quote on my local machine.

This is currently what I have

QuoteResponse quote = GenerateQuote_PCR(tpm, rmessage.startPCR, rmessage.endPCR, NonceExtracted);

cout << "serialization:" << endl;
string qserialized=quote.Serialize(SerializationType::Text);
cout << "serialization done" << endl;

QuoteResponse quoteDeserialized=QuoteResponse();

cout << "deserialization:" << endl;
quoteDeserialized.Deserialize(SerializationType::Text, qserialized);
cout << "deserialization done" << endl;

I checked if quote generated by GenerateQuote_PCR function is generated correctly.

this is the line that gives me error
quoteDeserialized.Deserialize(SerializationType::Text, qserialized);

Any help will be appreciated.

Thanks
Batyr

@amarochk
Copy link
Contributor

amarochk commented Jul 8, 2019

All TPM data structures in TSS.Net support DataContractSerializer interface. For example:

            Attest quote = tpm.Quote(hSigKey, hashToSign, new SchemeRsassa(sigHashAlg),
                                     outSelection, out quoteSig);
            var ms = new MemoryStream();
            var dcs0 = new DataContractSerializer(typeof(Attest));
            dcs0.WriteObject(ms, quote);
            ms.Flush();
            byte[] serializedRepr = ms.ToArray();
            var dcs1 = new DataContractSerializer(typeof(Attest));
            var restoredQuote = (Attest)dcs1.ReadObject(new MemoryStream(serializedRepr));

Alternatively, all TPM data structures in TSS.Net have a pair of ToNet()/ToHost() methods that marshal/unmarshal a TPM object to/from a portable binary representation (see the TpmStructureBase.GetTpmRepresentation() helper for an example of ToNet() usage).

@amarochk amarochk closed this as completed Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants