rsaref and byte packing

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

rsaref and byte packing

Ludovic Rousseau
Hello,

I used the new libp11 using the new rsaref files and discovered that
my program now crashes :-(

After searching a bit I discovered that libp11/rsaref/cryptoki.h contains:
#pragma pack(push, cryptoki, 1)
[...]
#pragma pack(pop, cryptoki)

This is a major change.

Before, the structure CK_FUNCTION_LIST contained the version on 4 bytes:
2 bytes for CK_VERSION and 2 bytes for padding/alignment.
Now the structure is packed and the 2 padding bytes are removed and
then all the function pointers that comes after are now wrong because
libp11 uses a packed version but OpenSC (and others) uses an unpacked
version.

I think that on a non Windows platform we should NOT use the packed
version (that is what is used now for all the PKCS#11 lib I know). If
you think different please tell us/me.

I will patch cryptoki.h so it does not break running code for now but
the discussion is open.

Bye,

--
  Dr. Ludovic Rousseau
 For private mail use [hidden email] and not "big brother" Google
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: rsaref and byte packing [u]

Andreas Jellinghaus-2
I admit I had no idea what that pragma does.
If it breaks unix, then get rid of it :)
also we might revert to the rsaref/ files
in opensc, as those are the same except for
cryptoki.h and that one works on windows only.

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: rsaref and byte packing

Nils Larsch
In reply to this post by Ludovic Rousseau
Ludovic Rousseau wrote:

> Hello,
>
> I used the new libp11 using the new rsaref files and discovered that
> my program now crashes :-(
>
> After searching a bit I discovered that libp11/rsaref/cryptoki.h contains:
> #pragma pack(push, cryptoki, 1)
> [...]
> #pragma pack(pop, cryptoki)
>
> This is a major change.
>
> Before, the structure CK_FUNCTION_LIST contained the version on 4 bytes:
> 2 bytes for CK_VERSION and 2 bytes for padding/alignment.
> Now the structure is packed and the 2 padding bytes are removed and
> then all the function pointers that comes after are now wrong because
> libp11 uses a packed version but OpenSC (and others) uses an unpacked
> version.
>
> I think that on a non Windows platform we should NOT use the packed
> version (that is what is used now for all the PKCS#11 lib I know). If
> you think different please tell us/me.
>
> I will patch cryptoki.h so it does not break running code for now but
> the discussion is open.

hmm, the cryptoki.h header file from rsa looks very windows specific and
I guess everything but perhaps the CK_PTR and NULL_PTR definitions
should be removed for unix like systems (and I see no reason why
this pragma might be useful here anyway).

Nils

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: rsaref and byte packing [u]

Ludovic Rousseau
In reply to this post by Andreas Jellinghaus-2
On 29/08/05, Andreas Jellinghaus [c] <[hidden email]> wrote:
> I admit I had no idea what that pragma does.

http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/pragm_22.asp

> If it breaks unix, then get rid of it :)

Already done :-)

> also we might revert to the rsaref/ files
> in opensc, as those are the same except for
> cryptoki.h and that one works on windows only.

I have no problem with the rsaref header files as they are now. They
document PKCS#11 v2.20 and AFAIK OpenSC implements v2.11 but the
differences are just some new #define and structures in pkcs11t.h for
v2.20.

Bye,

--
  Dr. Ludovic Rousseau
 For private mail use [hidden email] and not "big brother" Google
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel