On Tue, 2010-02-23 at 09:17 -0300, Ramon de Carvalho Valle wrote: > Fix a endianness bug while reading the public exponent attribute from > public template (for ica).
Looks OK. ACK. Note that we are already doing pointer arithmetic before #ifdefs, so another possibility would be to just do the whole pointer arithmetic inside the preprocessor conditionals. But as it is maintains a certain 'readability' and 'traceability' as well so better is to leave it as is. Another note is that I'm not even sure if we're still using ica_stdll (and I'm lazy to look in the Makefiles and RPMs). I'm still not comfortable enough to remove the whole thing, though. > Signed-off-by: Ramon de Carvalho Valle <[email protected]> > --- > usr/lib/pkcs11/ica_s390_stdll/ica_specific.c | 9 +++++++++ > usr/lib/pkcs11/ica_stdll/ica_specific.c | 9 +++++++++ > 2 files changed, 18 insertions(+), 0 deletions(-) > > diff --git a/usr/lib/pkcs11/ica_s390_stdll/ica_specific.c > b/usr/lib/pkcs11/ica_s390_stdll/ica_specific.c > index 03c2545..dc73488 100755 > --- a/usr/lib/pkcs11/ica_s390_stdll/ica_specific.c > +++ b/usr/lib/pkcs11/ica_s390_stdll/ica_specific.c > @@ -1786,7 +1786,16 @@ os_specific_rsa_keygen(TEMPLATE *publ_tmpl, TEMPLATE > *priv_tmpl) > * all fields must be right-aligned, so make > * sure we only use the rightmost part */ > ptr = publKey->exponent + publKey->key_length - publ_exp->ulValueLen; > + > +#ifndef __BYTE_ORDER > +#error "Architecture endianness is not defined." > +#endif > + > +#if __BYTE_ORDER == __LITTLE_ENDIAN > memcpy(ptr, publ_exp->pValue, publ_exp->ulValueLen); > +#else > + memcpy(ptr + (sizeof(unsigned long) - publ_exp->ulValueLen), > publ_exp->pValue, publ_exp->ulValueLen); > +#endif > > /* Build privKey: > * buffers pointed by p, q, dp, dq and qInverse in struct > diff --git a/usr/lib/pkcs11/ica_stdll/ica_specific.c > b/usr/lib/pkcs11/ica_stdll/ica_specific.c > index 2a6fdf9..0c26a57 100755 > --- a/usr/lib/pkcs11/ica_stdll/ica_specific.c > +++ b/usr/lib/pkcs11/ica_stdll/ica_specific.c > @@ -824,7 +824,16 @@ os_specific_rsa_keygen(TEMPLATE *publ_tmpl, TEMPLATE > *priv_tmpl) > > > ptr = publKey->keyRecord + keysize - publ_exp->ulValueLen; > + > +#ifndef __BYTE_ORDER > +#error "Architecture endianness is not defined." > +#endif > + > +#if __BYTE_ORDER == __LITTLE_ENDIAN > memcpy(ptr,publ_exp->pValue, publ_exp->ulValueLen); > +#else > + memcpy(ptr + (sizeof(unsigned long) - publ_exp->ulValueLen), > publ_exp->pValue, publ_exp->ulValueLen); > +#endif > > publKeySize = sizeof(ICA_KEY_RSA_MODEXPO); > privKeySize = sizeof(ICA_KEY_RSA_CRT); -- Klaus Heinrich Kiwi | [email protected] IBM LTC Security Development | http://blog.klauskiwi.com http://www.ibm.com/linux/ltc | http://www.ratliff.net/blog ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Opencryptoki-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech
