diff --git a/mozilla/security/nss/lib/softoken/pkcs11c.c b/mozilla/security/nss/lib/softoken/pkcs11c.c index 110fc9e697a..e566f57a56e 100644 --- a/mozilla/security/nss/lib/softoken/pkcs11c.c +++ b/mozilla/security/nss/lib/softoken/pkcs11c.c @@ -388,6 +388,8 @@ pk11_InitGeneric(PK11Session *session,PK11SessionContext **contextPtr, /* find the key */ if (keyPtr) { + CK_KEY_TYPE kt; + unsigned int size, i; key = pk11_ObjectFromHandle(hKey,session); if (key == NULL) { return CKR_KEY_HANDLE_INVALID; @@ -402,7 +404,12 @@ pk11_InitGeneric(PK11Session *session,PK11SessionContext **contextPtr, /* get the key type */ att = pk11_FindAttribute(key,CKA_KEY_TYPE); PORT_Assert(att != NULL); - *keyTypePtr = *(CK_KEY_TYPE *)att->attrib.pValue; + size = sizeof(CK_KEY_TYPE); + kt = 0; + for (i=0; iattrib.pValue)[i] << i*8; + } + *keyTypePtr = kt; pk11_FreeAttribute(att); *keyPtr = key; } diff --git a/mozilla/security/nss/lib/softoken/pkcs11u.c b/mozilla/security/nss/lib/softoken/pkcs11u.c index 9374c79429c..127d910d713 100644 --- a/mozilla/security/nss/lib/softoken/pkcs11u.c +++ b/mozilla/security/nss/lib/softoken/pkcs11u.c @@ -669,31 +669,8 @@ pk11_FindSecretKeyAttribute(PK11TokenObject *object, CK_ATTRIBUTE_TYPE type) } switch (type) { case CKA_KEY_TYPE: - { - SECItem ktItem, *coeff; - unsigned char ktBuf[4]; - int k; - coeff = &key->u.rsa.coefficient; - if (coeff->len < 4) { - /* The coefficient has been decoded from an entry in the - * key db. The decoder removes leading zeros, but PKCS#11 - * expects an attribute 4 bytes long it can convert to a - * CK_ULONG. In order for big-endian platforms to work, the - * leading zeros must be prepended again. - */ - ktItem.len = 4; - ktItem.data = ktBuf; - for (k=0; k<4; k++) { - if (k < coeff->len) { - ktBuf[3-k] = coeff->data[k]; - } else { - ktBuf[3-k] = 0; - } - } - coeff = &ktItem; - } - return pk11_NewTokenAttribute(type, coeff->data, coeff->len, PR_FALSE); - } + return pk11_NewTokenAttribute(type,key->u.rsa.coefficient.data, + key->u.rsa.coefficient.len, PR_FALSE); case CKA_VALUE: return pk11_NewTokenAttribute(type,key->u.rsa.privateExponent.data, key->u.rsa.privateExponent.len, PR_FALSE);