From a4a2117751948e6b67063768f484ebff105983a5 Mon Sep 17 00:00:00 2001 From: "ian.mcgreer%sun.com" Date: Wed, 16 Jan 2002 00:04:16 +0000 Subject: [PATCH] fix up problems in last change --- security/nss/lib/softoken/pkcs11c.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/security/nss/lib/softoken/pkcs11c.c b/security/nss/lib/softoken/pkcs11c.c index e566f57a56e8..21e37b197e26 100644 --- a/security/nss/lib/softoken/pkcs11c.c +++ b/security/nss/lib/softoken/pkcs11c.c @@ -389,7 +389,8 @@ pk11_InitGeneric(PK11Session *session,PK11SessionContext **contextPtr, /* find the key */ if (keyPtr) { CK_KEY_TYPE kt; - unsigned int size, i; + unsigned int size; + int i; key = pk11_ObjectFromHandle(hKey,session); if (key == NULL) { return CKR_KEY_HANDLE_INVALID; @@ -406,8 +407,12 @@ pk11_InitGeneric(PK11Session *session,PK11SessionContext **contextPtr, PORT_Assert(att != NULL); size = sizeof(CK_KEY_TYPE); kt = 0; - for (i=0; iattrib.pValue)[i] << i*8; + for (i=att->attrib.ulValueLen-1; i>=0; i--) { +#ifdef IS_LITTLE_ENDIAN + kt |= ((unsigned char *)att->attrib.pValue)[i] << (i*8); +#else + kt |= ((unsigned char *)att->attrib.pValue)[i] << ((size-1-i)*8); +#endif } *keyTypePtr = kt; pk11_FreeAttribute(att);