Here is the relevant quote from v 2.11:

> 8.1 Structure packing
> Cryptoki structures are packed to occupy as little space as is possible.
> In particular, on the Win32 and Win16 platforms, Cryptoki structures
> should be packed with 1-byte alignment.  In a UNIX environment, it may
> or may not be necessary (or even possible) to alter the byte-alignment of
> structures.

I agree that we could benefit from stronger wording regarding the alignment.
I interpreted the paragraph above as "do pack(1) if the CPU/compiler allows
this", which means that Linux x86 should be identical to Win32.

I think that it is too late so change Linux padding to pack(1), but is it
worth to mandate the padding for 64 bit platform to be 4 for PKCS11
structures?


----- Original Message ----- 
From: "Robert Relyea" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 20, 2004 11:22 AM
Subject: Re: PKCS11 field alignment on non-Win32 platforms


> Sigh,
>
> The PKCS #11 spec is pretty vague. There is some words about always going
for the tightest packing possible. The current spec says to use packing (1)
for Win32 and Win16, and default packing for Unix. Since Linux is Unix, it
will probably have different packing than a windows binary. The entire
section on binary compatibility and PKCS #11 is defined in section 8. This
section is a very good discussion about the issues and the tools PKCS #11
gives to deal with them. Igeneral if the spec is quiet about a particular
platform, then usually mozilla sets the default binary compatibility
standard for the platform. Unfortunately, often, not a lot of thought goes
into these issues for each platform, and mozilla depends a lot on decisions
make in NSPR for binary compatibility.
>
> bob
>
>
> Andrey Jivsov wrote on Tue, 20 Apr 04, 1:04 AM:
> > Hello,
> >
> > I observed a difference in field alignment between Windows and Linux
> > version of PKCS11 library from one HW token vendor.
> >
> > On Linux CK_FUNCTION_LIST was using 4 byte field alignment, while on
> > Windows it was 1.
> >
> > File pkcs11.h, part of PKCS11 standard, states that
> >
> > *                         [...] the packing convention
> > * for PKCS #11 structures should be set.  The PKCS #11
> > * convention on packing is that structures should be 1-byte
> > * aligned.
> >
> > I find that few other vendors have 4 byte padding on Linux and they are
> > quick to point out that this works with Mozilla.
> >
> > By looking at pkcs11p.h and pkcs11u.h it appears that Mozilla uses
> > default padding for !defined(_WIN32).
> >
> > Could someone clarify what PKCS11 structure padding Mozilla uses on 32
> > and 64 bit platforms?
> >
> > Thank you.
> >
> > _______________________________________________
> > mozilla-crypto mailing list
> > [EMAIL PROTECTED]
> > http://mail.mozilla.org/listinfo/mozilla-crypto
> _______________________________________________
> mozilla-crypto mailing list
> [EMAIL PROTECTED]
> http://mail.mozilla.org/listinfo/mozilla-crypto
>

_______________________________________________
mozilla-crypto mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-crypto

Reply via email to