From: Saurabh A. <tan...@gm...> - 2007-06-13 03:06:00
|
Hi how can i convert a 160 bit string nonce to TcBlobData type in jTSSWrapper library ? i hv tried : initString* functions, and get the "nullpointer exception" error. regards Saurabh |
From: Martin P. <Mar...@ia...> - 2007-06-13 08:01:09
Attachments:
smime.p7s
|
Saurabh Arora wrote: > how can i convert a 160 bit string nonce to TcBlobData type in > jTSSWrapper library ? > > i hv tried : > initString* functions, and get the "nullpointer exception" error. Looking at the Javadoc: http://trustedjava.sourceforge.net/jtss/javadoc_tsp/iaik/tc/tss/api/structs/common/TcBlobData.html There is only one method starting with "initString*", that is "initStringASCII". As guessable from the name, it expects a String containing only ASCII chars. If you want to pass in a 160bit nonce binary blob the "newByteArray" method may be your choice? HTH -- Martin Pirker IAIK, TU Graz |
From: Saurabh A. <tan...@gm...> - 2007-06-13 08:23:31
|
hi martin On 6/13/07, Martin Pirker <Mar...@ia...> wrote: > Saurabh Arora wrote: > > how can i convert a 160 bit string nonce to TcBlobData type in > > jTSSWrapper library ? > > > > i hv tried : > > initString* functions, and get the "nullpointer exception" error. > > Looking at the Javadoc: > http://trustedjava.sourceforge.net/jtss/javadoc_tsp/iaik/tc/tss/api/structs/common/TcBlobData.html > > There is only one method starting with "initString*", that is "initStringASCII". > As guessable from the name, it expects a String containing only ASCII chars. > > If you want to pass in a 160bit nonce binary blob the "newByteArray" method > may be your choice? > > i shud have mentioned.. i am using jTSSWrapper 0.2.5 and in this version there are many initString* functions. for few reasons i cannot port to 0.3 anytime soon. and hence my problem remains same. ne solution ? regards Saurabh |
From: Thomas W. <tc...@to...> - 2007-06-14 05:43:47
|
Hi, > > > 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"); Nontice: The main difference between 0.3. and older versions here is that the StructFactory was replaced by factory methods. hth, -- Thomas Winkler e-mail: tc...@to... |
From: Saurabh A. <tan...@gm...> - 2007-06-14 15:45:47
|
Hi On 6/14/07, Thomas Winkler <tc...@to...> wrote: > Hi, > > > > > 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); ------- now when i use : --------- TcBlobData nonce = TcTssStructFactory.newBlobData().initString*("516ebb86fe1dc24c6099d212ff971b61b0f5137a"); --------- 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"); } -------- ne pointers what is going wrong here ? regards Saurabh |
From: Saurabh A. <tan...@gm...> - 2007-06-18 08:37:15
|
I wish this group was more active in co-operation. On 6/15/07, Saurabh Arora <tan...@gm...> wrote: > Hi > > On 6/14/07, Thomas Winkler <tc...@to...> wrote: > > Hi, > > > > > > > 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); > ------- > > now when i use : > --------- > TcBlobData nonce = > TcTssStructFactory.newBlobData().initString*("516ebb86fe1dc24c6099d212ff971b61b0f5137a"); > --------- > > 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"); > } > > -------- > > > ne pointers what is going wrong here ? > > regards > Saurabh > |
From: Martin P. <Mar...@ia...> - 2007-06-18 13:15:38
Attachments:
smime.p7s
|
Hi... Saurabh Arora wrote: > I wish this group was more active in co-operation. Considering the number of downloads, yes, this list is surprisingly quiet. But this may be because open source allows anyone to just "dive" into the source and figure out why something is not working as expected. No external dependencies, isn't that great? > 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. 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? HTH -- Martin Pirker IAIK, TU Graz |
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 |