revert last change, and move conversion of attribute value to host long up to where the long variable actually appears.
git-svn-id: svn://10.0.0.236/trunk@112190 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b09f4e3c33
commit
58cb3db0bc
@ -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; i<size; i+=8) {
|
||||
kt |= ((unsigned char *)att->attrib.pValue)[i] << i*8;
|
||||
}
|
||||
*keyTypePtr = kt;
|
||||
pk11_FreeAttribute(att);
|
||||
*keyPtr = key;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user