| OLD | NEW |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 /* | 4 /* |
| 5 * Internal PKCS #11 functions. Should only be called by pkcs11.c | 5 * Internal PKCS #11 functions. Should only be called by pkcs11.c |
| 6 */ | 6 */ |
| 7 #include "pkcs11.h" | 7 #include "pkcs11.h" |
| 8 #include "pkcs11i.h" | 8 #include "pkcs11i.h" |
| 9 #include "lowkeyi.h" | 9 #include "lowkeyi.h" |
| 10 #include "secasn1.h" | 10 #include "secasn1.h" |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 /* | 1169 /* |
| 1170 * delete an object from a slot and session queue | 1170 * delete an object from a slot and session queue |
| 1171 */ | 1171 */ |
| 1172 CK_RV | 1172 CK_RV |
| 1173 sftk_DeleteObject(SFTKSession *session, SFTKObject *object) | 1173 sftk_DeleteObject(SFTKSession *session, SFTKObject *object) |
| 1174 { | 1174 { |
| 1175 SFTKSlot *slot = sftk_SlotFromSession(session); | 1175 SFTKSlot *slot = sftk_SlotFromSession(session); |
| 1176 SFTKSessionObject *so = sftk_narrowToSessionObject(object); | 1176 SFTKSessionObject *so = sftk_narrowToSessionObject(object); |
| 1177 SFTKTokenObject *to = sftk_narrowToTokenObject(object); | |
| 1178 CK_RV crv = CKR_OK; | 1177 CK_RV crv = CKR_OK; |
| 1179 PRUint32 index = sftk_hash(object->handle, slot->sessObjHashSize); | 1178 PRUint32 index = sftk_hash(object->handle, slot->sessObjHashSize); |
| 1180 | 1179 |
| 1181 /* Handle Token case */ | 1180 /* Handle Token case */ |
| 1182 if (so && so->session) { | 1181 if (so && so->session) { |
| 1183 SFTKSession *session = so->session; | 1182 SFTKSession *session = so->session; |
| 1184 PZ_Lock(session->objectLock); | 1183 PZ_Lock(session->objectLock); |
| 1185 sftkqueue_delete(&so->sessionList,0,session->objects,0); | 1184 sftkqueue_delete(&so->sessionList,0,session->objects,0); |
| 1186 PZ_Unlock(session->objectLock); | 1185 PZ_Unlock(session->objectLock); |
| 1187 PZ_Lock(slot->objectLock); | 1186 PZ_Lock(slot->objectLock); |
| 1188 sftkqueue_delete2(object, object->handle, index, slot->sessObjHashTable)
; | 1187 sftkqueue_delete2(object, object->handle, index, slot->sessObjHashTable)
; |
| 1189 PZ_Unlock(slot->objectLock); | 1188 PZ_Unlock(slot->objectLock); |
| 1190 sftkqueue_clear_deleted_element(object); | 1189 sftkqueue_clear_deleted_element(object); |
| 1191 sftk_FreeObject(object); /* free the reference owned by the queue */ | 1190 sftk_FreeObject(object); /* free the reference owned by the queue */ |
| 1192 } else { | 1191 } else { |
| 1193 SFTKDBHandle *handle = sftk_getDBForTokenObject(slot, object->handle); | 1192 SFTKDBHandle *handle = sftk_getDBForTokenObject(slot, object->handle); |
| 1194 | 1193 #ifdef DEBUG |
| 1194 SFTKTokenObject *to = sftk_narrowToTokenObject(object); |
| 1195 PORT_Assert(to); | 1195 PORT_Assert(to); |
| 1196 #endif |
| 1196 crv = sftkdb_DestroyObject(handle, object->handle); | 1197 crv = sftkdb_DestroyObject(handle, object->handle); |
| 1197 sftk_freeDB(handle); | 1198 sftk_freeDB(handle); |
| 1198 } | 1199 } |
| 1199 return crv; | 1200 return crv; |
| 1200 } | 1201 } |
| 1201 | 1202 |
| 1202 /* | 1203 /* |
| 1203 * Token objects don't explicitly store their attributes, so we need to know | 1204 * Token objects don't explicitly store their attributes, so we need to know |
| 1204 * what attributes make up a particular token object before we can copy it. | 1205 * what attributes make up a particular token object before we can copy it. |
| 1205 * below are the tables by object type. | 1206 * below are the tables by object type. |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 objClassTemplate.ulValueLen = sizeof(*objClass); | 1893 objClassTemplate.ulValueLen = sizeof(*objClass); |
| 1893 crv = sftkdb_GetAttributeValue(dbHandle, handle, &objClassTemplate, 1); | 1894 crv = sftkdb_GetAttributeValue(dbHandle, handle, &objClassTemplate, 1); |
| 1894 sftk_freeDB(dbHandle); | 1895 sftk_freeDB(dbHandle); |
| 1895 return crv; | 1896 return crv; |
| 1896 } | 1897 } |
| 1897 | 1898 |
| 1898 SFTKObject * | 1899 SFTKObject * |
| 1899 sftk_NewTokenObject(SFTKSlot *slot, SECItem *dbKey, CK_OBJECT_HANDLE handle) | 1900 sftk_NewTokenObject(SFTKSlot *slot, SECItem *dbKey, CK_OBJECT_HANDLE handle) |
| 1900 { | 1901 { |
| 1901 SFTKObject *object = NULL; | 1902 SFTKObject *object = NULL; |
| 1902 SFTKTokenObject *tokObject = NULL; | |
| 1903 PRBool hasLocks = PR_FALSE; | 1903 PRBool hasLocks = PR_FALSE; |
| 1904 CK_RV crv; | 1904 CK_RV crv; |
| 1905 | 1905 |
| 1906 object = sftk_GetObjectFromList(&hasLocks, PR_FALSE, &tokenObjectList, 0, | 1906 object = sftk_GetObjectFromList(&hasLocks, PR_FALSE, &tokenObjectList, 0, |
| 1907 PR_FALSE); | 1907 PR_FALSE); |
| 1908 if (object == NULL) { | 1908 if (object == NULL) { |
| 1909 return NULL; | 1909 return NULL; |
| 1910 } | 1910 } |
| 1911 tokObject = (SFTKTokenObject *) object; | |
| 1912 | 1911 |
| 1913 object->handle = handle; | 1912 object->handle = handle; |
| 1914 /* every object must have a class, if we can't get it, the object | 1913 /* every object must have a class, if we can't get it, the object |
| 1915 * doesn't exist */ | 1914 * doesn't exist */ |
| 1916 crv = handleToClass(slot, handle, &object->objclass); | 1915 crv = handleToClass(slot, handle, &object->objclass); |
| 1917 if (crv != CKR_OK) { | 1916 if (crv != CKR_OK) { |
| 1918 goto loser; | 1917 goto loser; |
| 1919 } | 1918 } |
| 1920 object->slot = slot; | 1919 object->slot = slot; |
| 1921 object->objectInfo = NULL; | 1920 object->objectInfo = NULL; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 { | 1969 { |
| 1971 return !sftk_isToken(obj->handle) ? (SFTKSessionObject *)obj : NULL; | 1970 return !sftk_isToken(obj->handle) ? (SFTKSessionObject *)obj : NULL; |
| 1972 } | 1971 } |
| 1973 | 1972 |
| 1974 SFTKTokenObject * | 1973 SFTKTokenObject * |
| 1975 sftk_narrowToTokenObject(SFTKObject *obj) | 1974 sftk_narrowToTokenObject(SFTKObject *obj) |
| 1976 { | 1975 { |
| 1977 return sftk_isToken(obj->handle) ? (SFTKTokenObject *)obj : NULL; | 1976 return sftk_isToken(obj->handle) ? (SFTKTokenObject *)obj : NULL; |
| 1978 } | 1977 } |
| 1979 | 1978 |
| OLD | NEW |