@@ -127,6 +127,8 @@ private void GenerateKey(string algorithm)
127127 Template template = new Template ( ) ;
128128 byte [ ] blob_buffer = new byte [ Device . MAX_KEYBLOB_BYTES ] ;
129129
130+ Console . WriteLine ( "Generating {0} key" , algorithm ) ;
131+
130132 if ( algorithm == "RSA" )
131133 {
132134 rc = template . GetKeyTemplate_RSA ( ( ulong ) (
@@ -158,6 +160,7 @@ private void GenerateKey(string algorithm)
158160 rc = blob . GetKeyBlobAsBuffer ( blob_buffer ) ;
159161 if ( rc > 0 )
160162 {
163+ Console . WriteLine ( "Key Blob Size: {0} bytes" , rc ) ;
161164 Array . Resize ( ref blob_buffer , rc ) ;
162165 if ( algorithm == "RSA" )
163166 {
@@ -190,6 +193,8 @@ private void LoadGeneratedKey(string algorithm)
190193 KeyBlob blob = new KeyBlob ( ) ;
191194 byte [ ] blob_buffer ;
192195
196+ Console . WriteLine ( "Loading {0} key" , algorithm ) ;
197+
193198 if ( algorithm == "RSA" )
194199 {
195200 blob_buffer = generatedRSA ;
@@ -213,6 +218,28 @@ private void LoadGeneratedKey(string algorithm)
213218 rc = blob . SetKeyAuthPassword ( "ThisIsMyKeyAuth" ) ;
214219 Assert . AreEqual ( ( int ) Status . TPM_RC_SUCCESS , rc ) ;
215220
221+ /* Use key to make sure authentication works */
222+ if ( algorithm == "RSA" ) {
223+ const int RsaKeySz = 256 ;
224+ const int HashDigestSz = 32 ;
225+ byte [ ] sig = new byte [ RsaKeySz ] ;
226+ byte [ ] digest = new byte [ HashDigestSz ] ;
227+
228+ /* Perform RSA sign / verify - PKCSv1.5 (SSA) padding */
229+ for ( int i = 0 ; i < digest . Length ; i ++ ) {
230+ digest [ i ] = 0x11 ;
231+ }
232+ rc = device . SignHashScheme ( blob , digest , sig ,
233+ TPM2_Alg . RSASSA , TPM2_Alg . SHA256 ) ;
234+ Assert . AreEqual ( RsaKeySz , rc ) ;
235+
236+ rc = device . VerifyHashScheme ( blob , sig , digest ,
237+ TPM2_Alg . RSASSA , TPM2_Alg . SHA256 ) ;
238+ Assert . AreEqual ( ( int ) Status . TPM_RC_SUCCESS , rc ) ;
239+
240+ Console . WriteLine ( "RSA Sign/Verify Success" ) ;
241+ }
242+
216243 rc = device . UnloadHandle ( blob ) ;
217244 Assert . AreEqual ( ( int ) Status . TPM_RC_SUCCESS , rc ) ;
218245 }
0 commit comments