|
From: Saurabh A. <tan...@gm...> - 2007-06-20 11:58:04
|
Hi
> > On 6/15/07, Saurabh Arora <tan...@gm...> wrote:
> >>On 6/14/07, Thomas Winkler <tc...@to...> wrote:
> >>>>>>how can i convert a 160 bit string nonce to TcBlobData type in
> >>>>>>jTSSWrapper library ?
> >>>
> >>>The nonce you have is a Java String?
> >>>
> >>>In case you are using jTSS Wrapper < 0.3 use the following code:
> >>>
> >>>TcBlobData blob =
> >>>TcTssStructFactory.newBlobData().initStringASCII("yourNonce");
> >>>
> >>>In case you are using jTSS Wrapper 0.3 use the following code:
> >>>
> >>>TcBlobData blob = TcBlobData.newStringASCII("yourNonce");
> >>
> >>it worked.. but now i get another error :
> >>"nonce in quote does not match expected nonce"
> >>
> >>I want to do a quote operation using my "nonce".
> >>the sample (working) quote code uses :
> >>-------
> >>TcBlobData nonce = context_.getTpm().getRandom(
> >> TcTcpaDefines.TCPA_SHA1BASED_NONCE_LEN);
> >>-------
>
> So the sample code uses a nonce of 160bit / 20byte random data.
>
> >>now when i use :
> >>---------
> >>TcBlobData nonce =
> >>TcTssStructFactory.newBlobData().initString*("516ebb86fe1dc24c6099d212ff971b61b0f5137a");
> >>---------
>
> It is still not clear what you actually want to achieve.
I simply want to use the nonce sent by another service rather than
random generated nonce.
>
> But lets consider 3 options and see what the actual content of 'nonce' is:
>
> TcBlobData nonce;
>
> nonce = TcTssStructFactory.newBlobData().initString("516ebb86fe1dc24c6099d212ff971b61b0f5137a");
> System.out.println("1:\n"+Utils.byteArrayToHexString( nonce.asByteArray()));
>
> nonce = TcTssStructFactory.newBlobData().initStringASCII("516ebb86fe1dc24c6099d212ff971b61b0f5137a");
> System.out.println("2:\n"+Utils.byteArrayToHexString( nonce.asByteArray()));
>
> byte[] barray = Utils.hexStringToByteArray("516ebb86fe1dc24c6099d212ff971b61b0f5137a");
> nonce = TcTssStructFactory.newBlobData().initByteArray(barray);
> System.out.println("3:\n"+Utils.byteArrayToHexString( nonce.asByteArray()));
>
> output:
>
> 1:
> 35 00 31 00 36 00 65 00 62 00 62 00 38 00 36 00
> 66 00 65 00 31 00 64 00 63 00 32 00 34 00 63 00
> 36 00 30 00 39 00 39 00 64 00 32 00 31 00 32 00
> 66 00 66 00 39 00 37 00 31 00 62 00 36 00 31 00
> 62 00 30 00 66 00 35 00 31 00 33 00 37 00 61 00
> 2:
> 35 31 36 65 62 62 38 36 66 65 31 64 63 32 34 63
> 36 30 39 39 64 32 31 32 66 66 39 37 31 62 36 31
> 62 30 66 35 31 33 37 61
> 3:
> 51 6e bb 86 fe 1d c2 4c 60 99 d2 12 ff 97 1b 61
> b0 f5 13 7a
>
>
> >>it gives me the error while verifying the quoteblob(in the code) :
> >>--------
> >>
> >>TcTcpaQuoteInfo quoteInfo = new TcTcpaQuoteInfo(quoteBlob.getData());
> >> if (!quoteInfo.getExternalData().getEncoded().equals(expectedNonce)) {
> >> throw new TcException(
> >> "nonce in quote does not match expected nonce");
> >> }
>
> Now look at the output of
> System.out.println(
> Utils.byteArrayToHexString( quoteInfo.getExternalData().getEncoded().asByteArray())));
>
> what actually is returned, does that match your expectation?
>
interstingly, here i get the result :
35 31 36 65 62 62 38 36 66 65 31 64 63 32 34 63 36 30 39 39 64 32 31 32 66 66 39
which is incomplete result of above number 2 output.
but when i use TcTssValidation quoteBlob (as mentioned above) instead
of TcTcpaQuoteInfo quoteInfo, i get the complete match as output No. 2
i hv two questions :
- what is the low/high level difference between TcTcpaQuoteInfo and
TcTssValidation ?
- why are both output different ?
regards
Saurabh
|