Scott Moynes wrote: > Hello, > > I am developing an application that uses a patched version of openssl > which has engine support for musclecard. Attached is a simple patch for > libmusclecard-1.3.3 that I needed in order to successfully execute a > sequence of crypto operations with a smart card. The issue it attempts > to resolve is that the cached context is not invalidated after the > context is released. This causes MSCListTokens under at least the > following sequence: > - MSCListTokens is called > - MSCEstablishConnection is called > - RSA encryption or decryption > - MSCReleaseConnection is called > - MSCListTokens is called and fails > > I am not sure if this is an appropriate fix or if there is some other > method of achieving it, but it works for me.
I believe the problem is the following: Usually the context should only released, if the library is unloaded. But SCardReleaseContext is called in the Release function, that means not only the connection to the card is closed, but also the connection to the resource manager of the system. So, the value of the handle localHContext is also invalid, because it is a value, which context was destroyed. So an error occurs. Set localHContext to 0 is not necessary, because the context should be cached, so the solution, which would fit better the idea of caching, is to remove the whole SCardReleaseContext branch, the disconnection is enough. I think, I have not such problem. Karsten > > Any feedback is appreciated. > > Cheers, > scott. > > > > ------------------------------------------------------------------------ > > diff -pur libmusclecard-1.3.3/src/musclecard.c > libmusclecard-1.3.3-cbn/src/musclecard.c > --- libmusclecard-1.3.3/src/musclecard.c 2006-03-21 14:22:06.000000000 > -0500 > +++ libmusclecard-1.3.3-cbn/src/musclecard.c 2006-06-14 15:18:58.000000000 > -0400 > @@ -607,6 +607,9 @@ MSC_RV MSCReleaseConnection(MSCLPTokenCo > rv = SCardReleaseContext(pConnection->hContext); > if (pcscToMSC(rv) != MSC_SUCCESS) > return pcscToMSC(rv); > + > + if (pConnection->hContext == localHContext) > + localHContext = 0; > } > > pConnection->tokenLibHandle = 0; > > > ------------------------------------------------------------------------ > > _______________________________________________ > Muscle mailing list > [email protected] > http://lists.drizzle.com/mailman/listinfo/muscle _______________________________________________ Muscle mailing list [email protected] http://lists.drizzle.com/mailman/listinfo/muscle
